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.
Add Joltify RWA Adapter (DefiLlama#10606)
* add Joltify RWA adapter * update rwa adapter
- Loading branch information
1 parent
a07f606
commit bf4d857
Showing
1 changed file
with
37 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const { queryV1Beta1 } = require('../helper/chain/cosmos'); | ||
const chain = 'joltify' | ||
|
||
const tvl = async (api) => { | ||
const [pools] = await Promise.all([ | ||
queryV1Beta1({ chain, url: `spv/list_pools` }), | ||
]); | ||
|
||
pools.pools_info.forEach(async pool => { | ||
api.add(pool.usable_amount.denom, pool.usable_amount.amount); | ||
}); | ||
} | ||
|
||
const borrowed = async (api) => { | ||
const [pools] = await Promise.all([ | ||
queryV1Beta1({ chain, url: `spv/list_pools` }), | ||
]); | ||
|
||
const [price_info] = await Promise.all([ | ||
queryV1Beta1({ chain, url: `third_party/pricefeed/v1beta1/prices` }), | ||
]); | ||
|
||
pools.pools_info.forEach(async pool => { | ||
const [market, borrowed_denom] = pool.borrowed_amount.denom.split('-'); | ||
const market_id = `${market}:usd`; | ||
const price = price_info.prices.find(price => price.market_id === market_id)?.price; | ||
api.add(borrowed_denom, pool.borrowed_amount.amount * price); | ||
}); | ||
} | ||
|
||
module.exports = { | ||
timetravel: false, | ||
joltify: { | ||
tvl, | ||
borrowed | ||
} | ||
} |