-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
30 additions
and
21 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,38 +1,47 @@ | ||
const { queryV1Beta1 } = require('../helper/chain/cosmos') | ||
const { getDenomBalance } = require('../helper/chain/cosmos') | ||
const { queryV1Beta1, getBalance2 } = require('../helper/chain/cosmos') | ||
const { transformDexBalances } = require('../helper/portedTokens') | ||
|
||
const poolURI = 'liquidity/v1beta1/pools' | ||
const chain = 'bostrom' | ||
const poolURI = 'liquidity/v1beta1/pools' | ||
const blacklistedTokens = ['ibc/4B322204B4F59D770680FE4D7A565DDC3F37BFF035474B717476C66A4F83DD72'] // DSM giving invalid values for some reason, incorrect decimals? | ||
|
||
async function tvl() { | ||
async function tvl(api) { | ||
let paginationKey | ||
const data = [] | ||
let data = [] | ||
|
||
do { | ||
const { pools, pagination } = await queryV1Beta1({ chain, url: poolURI, paginationKey }) | ||
paginationKey = pagination.next_key; | ||
const { pools, pagination } = await queryV1Beta1({ chain, url: poolURI }) | ||
paginationKey = pagination.next_key | ||
for (const pool of pools) { | ||
const base_coin_amount = await getDenomBalance({ denom: pool.reserve_coin_denoms[0], owner: pool.reserve_account_address, chain }) | ||
const quote_coin_amount = await getDenomBalance({ denom: pool.reserve_coin_denoms[1], owner: pool.reserve_account_address, chain }) | ||
data.push({ | ||
token0: pool.reserve_coin_denoms[0], | ||
token1: pool.reserve_coin_denoms[1], | ||
token0Bal: base_coin_amount, | ||
token1Bal: quote_coin_amount, | ||
}) | ||
const tokens = pool.reserve_coin_denoms | ||
const owner = pool.reserve_account_address | ||
const balances = await getBalance2({ tokens, owner, chain, blacklistedTokens }) | ||
|
||
const keys = Object.keys(balances); | ||
const values = Object.values(balances); | ||
|
||
if (keys.length === 2 && values.length === 2) { | ||
const [token0, token1] = keys; | ||
const [token0Bal, token1Bal] = values; | ||
|
||
if (token0 && token1 && token0Bal && token1Bal) { | ||
data.push({ | ||
token0, | ||
token0Bal, | ||
token1, | ||
token1Bal, | ||
}); | ||
} | ||
} | ||
} | ||
} while (paginationKey) | ||
return transformDexBalances({ chain, data, blacklistedTokens: [ | ||
'ibc/4B322204B4F59D770680FE4D7A565DDC3F37BFF035474B717476C66A4F83DD72', // DSM giving invalid values for some reason, incorrect decimals? | ||
] }) | ||
|
||
return transformDexBalances({ chain, api, data }) | ||
} | ||
|
||
module.exports = { | ||
timetravel: false, | ||
misrepresentedTokens: true, | ||
methodology: "Counts the liquidity on all pools. ", | ||
bostrom: { | ||
tvl | ||
} | ||
bostrom: { tvl } | ||
} |