-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update our description etc. #13255
Open
xbankingorg
wants to merge
5
commits into
DefiLlama:main
Choose a base branch
from
xbankingorg:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
update our description etc. #13255
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
83aceb1
true tvl xbanking on solana chain
xbankingorg 2aba77d
Merge pull request #13 from xbankingorg/true-tvl-xbanking-on-solana-c…
xbankingorg 7e11240
tvl calculator of xbanking chains
xbankingorg 9f42c0d
Merge branch 'DefiLlama:main' into main
xbankingorg 78bc96b
Merge pull request #15 from xbankingorg/tvl-calculator-of-xbanking-ch…
xbankingorg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,45 @@ | ||
const sdk = require("@defillama/sdk"); | ||
const abi = require("./abi.json"); | ||
const contracts = require("./contracts.json"); | ||
const { pool2 } = require("../helper/pool2"); | ||
const vaults = [ | ||
contracts.ftmVault, | ||
contracts.ethVault, | ||
contracts.avaxVault, | ||
contracts.tombVault, | ||
] | ||
const utils = require('../helper/utils'); | ||
let _response; | ||
|
||
const tokens = [ | ||
contracts.FTM, | ||
contracts.WETH, | ||
contracts.AVAX, | ||
contracts.TOMB, | ||
] | ||
function fetchChain(chainId, staking) { | ||
return async () => { | ||
if (!_response) { | ||
_response = utils.fetchURL('https://api.xbanking.org/v2/platform/tvl'); | ||
} | ||
const response = await _response; | ||
let tvl = 0; | ||
|
||
async function tvl(api) { | ||
const _tokens = [...tokens] | ||
const owners = [...vaults, ...vaults] | ||
vaults.forEach(v => _tokens.push(contracts.Collateral)) | ||
return api.sumTokens({ tokensAndOwners2: [_tokens, owners] }) | ||
} | ||
|
||
async function borrowed(api) { | ||
const vaults0 = vaults.slice(0, 2); | ||
const vaults1 = vaults.slice(2); | ||
const tokens0 = tokens.slice(0, 2); | ||
const tokens1 = tokens.slice(2); | ||
const balances = await api.multiCall({ abi: abi.see_s1ftm_circ, calls: vaults0 }) | ||
const balances1 = await api.multiCall({ abi: abi.see_s1tomb_circ, calls: vaults1 }) | ||
api.addTokens(tokens0, balances) | ||
api.addTokens(tokens1, balances1) | ||
const chainName = Object.keys(response).find(key => key.toLowerCase() === chainId.toLowerCase()); | ||
|
||
if (chainName) { | ||
tvl = Number(response[chainName]); | ||
} | ||
|
||
const chainApi = new sdk.ChainApi({ chain: api.chain, block: api.block }) | ||
chainApi.sumTokens({ tokensAndOwners2: [tokens, vaults] }) | ||
Object.entries(chainApi.getBalances()).forEach(([token, balance]) => { | ||
api.add(token, balance * -1, { skipChain: true }) | ||
}) | ||
return api.getBalances() | ||
if (tvl === 0) { | ||
throw new Error(`chain ${chainId} tvl is 0`); | ||
} | ||
return tvl; | ||
}; | ||
} | ||
|
||
const chains = { | ||
ethereum: 'ethereum', | ||
avax: 'avax', | ||
arbitrum: 'arbitrum', | ||
binance: 'binance', | ||
solana: 'solana', | ||
bitcoin: 'bitcoin', | ||
ton: 'ton', | ||
aptos: 'aptos', | ||
sui: 'sui' | ||
}; | ||
|
||
module.exports = { | ||
fantom: { | ||
tvl, | ||
borrowed, | ||
pool2: pool2( | ||
[contracts.pool2, contracts.pool2], | ||
[contracts.daiPool2, contracts.ftmPool2], | ||
) | ||
} | ||
} | ||
timetravel: false, | ||
misrepresentedTokens: true, | ||
doublecounted: true, | ||
...Object.fromEntries(Object.entries(chains).map(chain => [chain[0], { | ||
tvl: fetchChain(chain[1], false), | ||
staking: fetchChain(chain[1], true), | ||
}])) | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we cant use this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so u need new code to just change our token chain and new links and smart contract in the start of topic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we cant fetch a tvl number from your api endpoint. please rewrite the adapter to use on chain data