-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
11 additions
and
33 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,43 +1,21 @@ | ||
const sdk = require("@defillama/sdk"); | ||
const { queryContract } = require('../helper/chain/cosmos') | ||
|
||
const chains = { | ||
cosmos: { | ||
chainId: "cosmoshub-4", | ||
denom: "uatom", | ||
const config = { | ||
neutron: [{ | ||
coinGeckoId: "cosmos", | ||
dropContract: "neutron16m3hjh7l04kap086jgwthduma0r5l0wh8kc6kaqk92ge9n5aqvys9q6lxr" | ||
}, | ||
contract: "neutron16m3hjh7l04kap086jgwthduma0r5l0wh8kc6kaqk92ge9n5aqvys9q6lxr" | ||
}], | ||
}; | ||
|
||
function makeTvlFn(chain) { | ||
return async () => { | ||
const balances = {}; | ||
const data = await queryContract({ | ||
contract: chain.dropContract, | ||
chain: "neutron", | ||
data: { | ||
"total_bonded": {} | ||
} | ||
}); | ||
const assetBalance = parseInt(data, 10) / 1e6; | ||
const amount = assetBalance; | ||
|
||
sdk.util.sumSingleBalance( | ||
balances, | ||
chain.coinGeckoId, | ||
amount | ||
); | ||
|
||
return balances; | ||
}; | ||
async function tvl(api) { | ||
for (const { coinGeckoId, contract, decimals = 6 } of config[api.chain]) { | ||
const bonded = await queryContract({ contract, chain: api.chain, data: { "total_bonded": {} } }) | ||
api.addCGToken(coinGeckoId, bonded / 10 ** decimals) | ||
} | ||
} | ||
|
||
module.exports = { | ||
timetravel: false, | ||
methodology: "Sum of all the tokens that are liquid staked on DROP", | ||
}; | ||
|
||
for (const chainName of Object.keys(chains)) { | ||
module.exports[chainName] = { tvl: makeTvlFn(chains[chainName]) }; | ||
} | ||
neutron: { tvl } | ||
} |