forked from DefiLlama/DefiLlama-Adapters
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
get available tokens in protocol from currencyController contract (De…
- Loading branch information
Showing
1 changed file
with
27 additions
and
15 deletions.
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,18 +1,30 @@ | ||
const config = { | ||
ethereum: { FIL: '0x6a7b717ae5ed65f85ba25403d5063d368239828e'}, | ||
arbitrum: {}, | ||
avax: { FIL: '0xf3bcb00146d1123dd19974de758f83d01e26d3f1'}, | ||
polygon_zkevm: { vault: '0x0896AC8B9e2DC3545392ff65061E5a8a3eD68824' }, | ||
} | ||
ethereum: {}, | ||
arbitrum: {}, | ||
avax: {}, | ||
polygon_zkevm: { | ||
tokenVault: '0x0896AC8B9e2DC3545392ff65061E5a8a3eD68824', | ||
currencyController: '0x9E1254292195F241FA2DF1aA51af23796627A74B', | ||
}, | ||
}; | ||
|
||
Object.keys(config).forEach(chain => { | ||
const { vault = '0xB74749b2213916b1dA3b869E41c7c57f1db69393', FIL } = config[chain] | ||
module.exports[chain] = { | ||
tvl: async (_, _b, _cb, { api, }) => { | ||
const bytes = await api.call({ abi: 'function getCollateralCurrencies() view returns (bytes32[])', target: vault }) | ||
const tokens = await api.multiCall({ abi: 'function getTokenAddress(bytes32) view returns (address)', calls: bytes, target: vault }) | ||
if (FIL) tokens.push(FIL) | ||
return api.sumTokens({ owner: vault, tokens, }) | ||
} | ||
} | ||
}) | ||
const { | ||
tokenVault = '0xB74749b2213916b1dA3b869E41c7c57f1db69393', | ||
currencyController = '0x7dca6b6BF30cd28ADe83e86e21e82e3F852bF2DC', | ||
} = config[chain]; | ||
module.exports[chain] = { | ||
tvl: async (_, _b, _cb, { api }) => { | ||
const bytes = await api.call({ | ||
abi: 'function getCurrencies() view returns (bytes32[])', | ||
target: currencyController, | ||
}); | ||
const tokens = await api.multiCall({ | ||
abi: 'function getTokenAddress(bytes32) view returns (address)', | ||
calls: bytes, | ||
target: tokenVault, | ||
}); | ||
return api.sumTokens({ owner: tokenVault, tokens }); | ||
}, | ||
}; | ||
}); |