mirror of
https://github.com/alexgo-io/DefiLlama-Adapters.git
synced 2026-05-12 11:21:24 +08:00
Merge branch 'main' into feat/project-lisa
This commit is contained in:
@@ -310,6 +310,11 @@ module.exports = {
|
||||
pendleAddress: "0x5cb12D56F5346a016DBBA8CA90635d82e6D1bcEa",
|
||||
};
|
||||
|
||||
const pTEzETHDEC30 = {
|
||||
vault: "0xebdaDFC590393938b601a9738C3107460838e880",
|
||||
pendleAddress: "0xf7906F274c174A52d444175729E3fa98f9bde285",
|
||||
};
|
||||
|
||||
const tokensAndOwners2 = [
|
||||
pTweETH,
|
||||
pTezETH,
|
||||
@@ -320,6 +325,7 @@ module.exports = {
|
||||
bptzrsETH1x,
|
||||
bptzUSDe1x,
|
||||
bptrswETH1x,
|
||||
pTEzETHDEC30,
|
||||
].map((i) => [i.pendleAddress, i.vault]);
|
||||
tokensAndOwners.push(...tokensAndOwners2);
|
||||
await api.sumTokens({ tokensAndOwners });
|
||||
@@ -345,6 +351,11 @@ module.exports = {
|
||||
pendleAddress: "0xad853EB4fB3Fe4a66CdFCD7b75922a0494955292",
|
||||
};
|
||||
|
||||
const bsolvBTC1X = {
|
||||
vault: "0x43D10bfB9f1625827Ee8EE7A461eDE28340bdBb5",
|
||||
tokenAddress: "0x3647c54c4c2C65bC7a2D63c0Da2809B399DBBDC0",
|
||||
};
|
||||
|
||||
await api.sumTokens({
|
||||
tokensAndOwners: [
|
||||
[ADDRESSES.arbitrum.USDC, lendingArb.usdc_e],
|
||||
@@ -354,6 +365,7 @@ module.exports = {
|
||||
[ADDRESSES.arbitrum.ARB, lendingArb.arb],
|
||||
[ADDRESSES.arbitrum.USDC_CIRCLE, lendingArb.usdc],
|
||||
[bptUSDe1x.pendleAddress, bptUSDe1x.vault],
|
||||
[bsolvBTC1X.tokenAddress, bsolvBTC1X.vault],
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
27
projects/bitlen/index.js
Normal file
27
projects/bitlen/index.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const { sumTokens2 } = require("../helper/unwrapLPs");
|
||||
|
||||
const WBTC_POOL = '0x6996c446b1bfb8cc2ef7a4bc32979de613bcefe1';
|
||||
const USDT_POOL = '0xad9b8b6c60ca112ab10670d87d53e6ff86ec3c2a';
|
||||
const USDC_POOL = '0x779bddc3cBc62617093CB1E27436C78DA015508E'
|
||||
|
||||
const config = {
|
||||
bsquared: {
|
||||
pools: [WBTC_POOL, USDT_POOL, USDC_POOL,]
|
||||
}
|
||||
}
|
||||
|
||||
Object.keys(config).forEach(chain => {
|
||||
const { pools } = config[chain]
|
||||
module.exports[chain] = {
|
||||
tvl: async (api) => {
|
||||
const tokens = await api.multiCall({ abi: 'address:underlyingToken', calls: pools })
|
||||
return sumTokens2({ api, tokensAndOwners2: [tokens, pools] })
|
||||
},
|
||||
borrowed: async (api) => {
|
||||
const tokens = await api.multiCall({ abi: 'address:underlyingToken', calls: pools })
|
||||
let debts = await api.multiCall({ abi: "uint256:totalDebt", calls: pools })
|
||||
api.add(tokens, debts)
|
||||
return sumTokens2({ api, })
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -1,9 +1,10 @@
|
||||
const { sumTokens2 } = require("../helper/chain/cardano");
|
||||
|
||||
const LENDING_SCRIPT = "addr1z878lgw0676mfkusf0f2h9wl3w5q2zu0klrlcamv6g2werc0pqnxu0fg7wvwgjtgzvg6lg6avzczmwf84aclygrvlkhqfmh5zc";
|
||||
const AMM_SCRIPT = "addr1zyl8u7cw93g99g2e68cq3k27ad7rd8p6yy3yg9vesgahrus0pqnxu0fg7wvwgjtgzvg6lg6avzczmwf84aclygrvlkhq2a0paj";
|
||||
|
||||
async function tvl() {
|
||||
return sumTokens2({ scripts: [LENDING_SCRIPT] })
|
||||
return sumTokens2({ scripts: [LENDING_SCRIPT, AMM_SCRIPT] })
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
const ADDRESSES = require('../helper/coreAssets.json')
|
||||
async function tvl(_, _1, _2, { api }) {
|
||||
const stakedMetis = await api.call({
|
||||
abi: 'erc20:balanceOf',
|
||||
target: ADDRESSES.metis.Metis,
|
||||
params: ['0x810Ef8Aa1326FB1c5Ce57cD79d549CF9B2cC32aF']
|
||||
abi: 'erc20:totalSupply',
|
||||
target: '0x97a2de3A09F4A4229369ee82c7F76be1a5564661',
|
||||
});
|
||||
|
||||
api.add(ADDRESSES.metis.Metis, stakedMetis);
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
|
||||
|
||||
const { ApiPromise, WsProvider } = require("@polkadot/api")
|
||||
const { Wallet } = require("@acala-network/sdk/wallet")
|
||||
const { FixedPointNumber, forceToCurrencyName } = require("@acala-network/sdk-core");
|
||||
const { options } = require("@acala-network/api")
|
||||
const sdk = require('@defillama/sdk')
|
||||
const { getCoreAssets } = require("../tokenMapping")
|
||||
|
||||
|
||||
const api = {}
|
||||
|
||||
@@ -56,23 +53,13 @@ const providers = {
|
||||
async function getAPI(chain) {
|
||||
if (!api[chain]) {
|
||||
const provider = new WsProvider(providers[chain]);
|
||||
api[chain] = ApiPromise.create(options({ provider }))
|
||||
api[chain] = ApiPromise.create({ provider })
|
||||
}
|
||||
|
||||
await api[chain].isReady
|
||||
return api[chain]
|
||||
}
|
||||
|
||||
async function getWallet(chain) {
|
||||
const api = await getAPI(chain)
|
||||
const wallet = new Wallet(api, {
|
||||
supportAUSD: true,
|
||||
})
|
||||
|
||||
await wallet.isReady
|
||||
return wallet
|
||||
}
|
||||
|
||||
const fixMapping = {
|
||||
parallel: {
|
||||
101: { geckoId: 'polkadot', decimals: 10, },
|
||||
@@ -199,58 +186,19 @@ async function getTokenPrices({ api, chain = '' }) {
|
||||
}
|
||||
}
|
||||
|
||||
const geckoMappings = {
|
||||
acala: {
|
||||
token: {
|
||||
ACA: 'acala',
|
||||
DOT: 'polkadot',
|
||||
// AUSD: 'acala-dollar',
|
||||
// LDOT: 'liquid-staking-dot', // coingecko delisted it
|
||||
},
|
||||
liquidCrowdloan: {
|
||||
// 13: 'liquid-crowdloan-dot', // coingecko delisted it
|
||||
}
|
||||
},
|
||||
karura: {
|
||||
token: {
|
||||
KSM: 'kusama',
|
||||
LKSM: 'liquid-ksm',
|
||||
KAR: 'karura',
|
||||
BNC: 'bifrost-native-coin',
|
||||
KINT: 'kintsugi',
|
||||
KBTC: 'kintsugi-btc',
|
||||
},
|
||||
liquidCrowdloan: {
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
async function addTokenBalance({ balances, amount, chain, tokenArg, api, wallet, }) {
|
||||
if (!api) api = await getAPI(chain)
|
||||
if (!wallet) wallet = await getWallet(chain)
|
||||
const geckoMapping = geckoMappings[chain]
|
||||
const tokenJson = tokenArg.toJSON()
|
||||
const token = await wallet.getToken(forceToCurrencyName(tokenArg));
|
||||
amount = FixedPointNumber.fromInner(amount.toString(), token.decimals)
|
||||
|
||||
if (tokenJson.token && geckoMapping.token[tokenJson.token])
|
||||
return sdk.util.sumSingleBalance(balances, geckoMapping.token[tokenJson.token], amount.toNumber())
|
||||
|
||||
if (tokenJson.liquidCrowdloan && geckoMapping.liquidCrowdloan[tokenJson.liquidCrowdloan])
|
||||
return sdk.util.sumSingleBalance(balances, geckoMapping.liquidCrowdloan[tokenJson.liquidCrowdloan], amount.toNumber())
|
||||
|
||||
if (chain === 'acala' && tokenJson.foreignAsset === 3) return;
|
||||
|
||||
const price = await wallet.getPrice(token)
|
||||
if (price) {
|
||||
sdk.log('Adding token value in USD (in millions), amount: ', forceToCurrencyName(tokenArg), amount.times(price).toNumber() / 1e6, amount.toNumber()/1e6,)
|
||||
sdk.util.sumSingleBalance(balances, 'tether', amount.times(price).toNumber())
|
||||
const coreAssets = getCoreAssets(chain)
|
||||
const getTokenName = tokenJson => {
|
||||
tokenJson = tokenJson.toJSON()
|
||||
if (tokenJson.token && coreAssets.includes(tokenJson.token.toLowerCase())) return tokenJson.token
|
||||
return chain + ':' + JSON.stringify(tokenJson).replace(/(\{|\}|\s|")/g, '')
|
||||
}
|
||||
sdk.util.sumSingleBalance(balances, getTokenName(tokenArg), amount)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getAPI,
|
||||
getWallet,
|
||||
getTokenPrices,
|
||||
addTokenBalance,
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
const { FixedPointNumber, forceToCurrencyName } = require("@acala-network/sdk-core");
|
||||
const { getAPI, getWallet } = require('./api')
|
||||
|
||||
async function dexStaking(chain){
|
||||
const api = await getAPI(chain)
|
||||
const wallet = await getWallet(chain)
|
||||
const data = await api.query.rewards.poolInfos.entries();
|
||||
let total = FixedPointNumber.ZERO;
|
||||
const filterData = data.filter(([token]) => {
|
||||
return token.toHuman()[0].Dex
|
||||
});
|
||||
|
||||
for (let i = 0; i < filterData.length; i++) {
|
||||
const [token, amount] = filterData[i];
|
||||
|
||||
const lpToken = await wallet.getToken(forceToCurrencyName(token.args[0].asDex));
|
||||
const totalShares = FixedPointNumber.fromInner(amount.totalShares.toString(), lpToken.decimals);
|
||||
const price = await wallet.getPrice(lpToken.name);
|
||||
|
||||
total = total.add(totalShares.times(price));
|
||||
}
|
||||
|
||||
return {
|
||||
tether: total.toNumber()
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
dexStaking
|
||||
}
|
||||
@@ -1,21 +1,31 @@
|
||||
|
||||
const { getAPI, addTokenBalance } = require('./api')
|
||||
const { getAPI, } = require('./api')
|
||||
const { transformDexBalances } = require('../portedTokens')
|
||||
const { getCoreAssets } = require('../tokenMapping')
|
||||
|
||||
|
||||
async function dex(chain) {
|
||||
const api = await getAPI(chain)
|
||||
const data = await api.query.dex.liquidityPool.entries();
|
||||
const balances = {}
|
||||
|
||||
const promises = []
|
||||
const coreAssets = getCoreAssets(chain)
|
||||
const dexData = []
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const [token, amount] = data[i];
|
||||
promises.push(addTokenBalance({ balances, chain, amount: amount[0], tokenArg: token.args[0][0], }))
|
||||
promises.push(addTokenBalance({ balances, chain, amount: amount[1], tokenArg: token.args[0][1], }))
|
||||
const getTokenName = tokenJson => {
|
||||
tokenJson = tokenJson.toJSON()
|
||||
if (tokenJson.token && coreAssets.includes(tokenJson.token.toLowerCase())) return tokenJson.token
|
||||
return chain + ':' + JSON.stringify(tokenJson).replace(/(\{|\}|\s|")/g, '')
|
||||
}
|
||||
data.forEach(([token, amount]) => {
|
||||
dexData.push({
|
||||
token0: getTokenName(token.args[0][0]),
|
||||
token0Bal: +amount[0],
|
||||
token1: getTokenName(token.args[0][1]),
|
||||
token1Bal: +amount[1],
|
||||
})
|
||||
})
|
||||
|
||||
await Promise.all(promises)
|
||||
return balances
|
||||
return transformDexBalances({ chain, data: dexData })
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
const { getWallet } = require('./api')
|
||||
const { getAPI } = require('./api')
|
||||
|
||||
|
||||
async function staking(chain) {
|
||||
const wallet = await getWallet(chain)
|
||||
const supply = await wallet.getIssuance('lc://13')
|
||||
const api = await getAPI(chain)
|
||||
const data = await api.query.tokens.totalIssuance( { LiquidCrowdLoan: '13' } )
|
||||
|
||||
return {
|
||||
polkadot: supply.toNumber()
|
||||
polkadot: data/1e10
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
const { transformBalances } = require('../portedTokens');
|
||||
const { getAPI, addTokenBalance } = require('./api')
|
||||
|
||||
async function lending(chain){
|
||||
@@ -8,10 +9,10 @@ async function lending(chain){
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const [_token, amount] = data[i];
|
||||
await addTokenBalance({ balances, chain, tokenArg: _token.args[0], amount: amount.collateral })
|
||||
addTokenBalance({ balances, chain, tokenArg: _token.args[0], amount: amount.collateral })
|
||||
}
|
||||
|
||||
return balances
|
||||
return transformBalances(chain, balances)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,33 +1,29 @@
|
||||
const { FixedPointNumber } = require("@acala-network/sdk-core")
|
||||
const { getAPI, getWallet } = require('./api')
|
||||
const { getAPI, } = require('./api')
|
||||
|
||||
|
||||
const getTotalStaking = async (api, token) => {
|
||||
const getTotalStaking = async (api) => {
|
||||
const toBond = await api.query.homa.toBondPool();
|
||||
const stakingLedgers = await api.query.homa.stakingLedgers.entries();
|
||||
let totalInSubAccount = FixedPointNumber.ZERO;
|
||||
let totalInSubAccount = 0;
|
||||
|
||||
stakingLedgers.map(item => {
|
||||
const ledge = item[1].unwrapOrDefault();
|
||||
totalInSubAccount = totalInSubAccount.add(FixedPointNumber.fromInner(ledge.bonded.unwrap().toString(), token.decimals));
|
||||
totalInSubAccount += +ledge.bonded.unwrap()
|
||||
})
|
||||
|
||||
const total = FixedPointNumber.fromInner(toBond.toString(), token.decimals).add(totalInSubAccount);
|
||||
|
||||
return total;
|
||||
return +toBond + +totalInSubAccount
|
||||
}
|
||||
|
||||
async function staking(chain) {
|
||||
const api = await getAPI(chain)
|
||||
const wallet = await getWallet(chain)
|
||||
const getStakingCurrencyId = api.consts.prices.getStakingCurrencyId;
|
||||
const stakingToken = await wallet.getToken(getStakingCurrencyId);
|
||||
const price = await wallet.getPrice(stakingToken);
|
||||
|
||||
const total = await getTotalStaking(api, stakingToken)
|
||||
|
||||
const total = await getTotalStaking(api)
|
||||
if (chain === 'acala')
|
||||
return {
|
||||
polkadot: +total / 1e10,
|
||||
}
|
||||
return {
|
||||
tether: total.times(price).toNumber(),
|
||||
kusama: +total / 1e12,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -142,6 +142,20 @@ const fixBalancesTokens = {
|
||||
[ADDRESSES.null]: { coingeckoId: "ethereum", decimals: 18, },
|
||||
[ADDRESSES.zora.USDzC]: { coingeckoId: "usd-coin", decimals: 6, },
|
||||
},
|
||||
acala: {
|
||||
ACA: { coingeckoId: "acala", decimals: 12 },
|
||||
LDOT: { coingeckoId: "liquid-staking-dot", decimals: 10 },
|
||||
DOT: { coingeckoId: "polkadot", decimals: 10 },
|
||||
},
|
||||
karura: {
|
||||
KSM: { coingeckoId: "kusama", decimals: 12 },
|
||||
LKSM: { coingeckoId: "liquid-ksm", decimals: 12 },
|
||||
KAR: { coingeckoId: "karura", decimals: 12 },
|
||||
BNC: { coingeckoId: "bifrost-native-coin", decimals: 12 },
|
||||
PHA: { coingeckoId: "pha", decimals: 12 },
|
||||
KINT: { coingeckoId: "kintsugi", decimals: 12 },
|
||||
KBTC: { coingeckoId: "kintsugi-btc", decimals: 8 },
|
||||
}
|
||||
}
|
||||
|
||||
ibcChains.forEach(chain => fixBalancesTokens[chain] = { ...ibcMappings, ...(fixBalancesTokens[chain] || {}) })
|
||||
|
||||
@@ -110,8 +110,8 @@ function isLP(symbol, token, chain) {
|
||||
|
||||
const isLPRes = LP_SYMBOLS.includes(symbol) || /(UNI-V2|vAMM|sAMM)/.test(symbol) || symbol.split(/\W+/).includes('LP')
|
||||
|
||||
if (isLPRes && !['UNI-V2', 'Cake-LP'].includes(symbol))
|
||||
sdk.log(chain, symbol, token)
|
||||
// if (isLPRes && !['UNI-V2', 'Cake-LP'].includes(symbol))
|
||||
// sdk.log(chain, symbol, token)
|
||||
|
||||
return isLPRes
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@ async function tvl() {
|
||||
const reserve = await call({ reserveAddr, abi: 'get-reserve' });
|
||||
const pending = await call({ registryAddr, abi: 'get-mint-requests-pending-amount'});
|
||||
return {
|
||||
blockstack: (reserve.value + pending) / 1e6
|
||||
blockstack: (reserve.value + pending.value) / 1e6
|
||||
}
|
||||
}
|
||||
@@ -3,16 +3,36 @@ const { getLogs } = require('../helper/cache/getLogs')
|
||||
// const graphUri = "https://api.studio.thegraph.com/query/42478/blast_mainnet/version/latest";
|
||||
|
||||
const config = {
|
||||
blast: { factory: '0x5B0b4b97edb7377888E2c37268c46E28f5BD81d0', fromBlock: 202321, },
|
||||
blast: [
|
||||
{factory: '0x5B0b4b97edb7377888E2c37268c46E28f5BD81d0', fromBlock: 202321,},
|
||||
{factory: '0xbd9215e002E4344c8333fc0bf4F5ECEd62BF9B85', fromBlock: 2525118,}
|
||||
],
|
||||
}
|
||||
|
||||
Object.keys(config).forEach(chain => {
|
||||
const { factory, fromBlock, } = config[chain]
|
||||
const [v1, v2] = config[chain]
|
||||
module.exports[chain] = {
|
||||
tvl: async (api) => {
|
||||
const logs = await getLogs({ api, target: factory, eventAbi: 'event PoolCreated (address indexed token0, address indexed token1, uint24 indexed fee, int24 tickSpacing, address pool, address tradePool)', onlyArgs: true, fromBlock, })
|
||||
const ownerTokens = logs.map(i => [[[i.token0, i.token1], i.pool], [[i.token0, i.token1], i.tradePool]]).flat()
|
||||
return api.sumTokens({ ownerTokens })
|
||||
tvl: async (_, _b, _cb, {api,}) => {
|
||||
const v1_logs = await getLogs({
|
||||
api,
|
||||
target: v1.factory,
|
||||
eventAbi: 'event PoolCreated (address indexed token0, address indexed token1, uint24 indexed fee, int24 tickSpacing, address pool, address tradePool)',
|
||||
onlyArgs: true,
|
||||
fromBlock: v1.fromBlock,
|
||||
})
|
||||
const v1_ownerTokens = v1_logs.map(i => [[[i.token0, i.token1], i.pool], [[i.token0, i.token1], i.tradePool]]).flat()
|
||||
|
||||
const v2_logs = await getLogs({
|
||||
api,
|
||||
target: v2.factory,
|
||||
eventAbi: 'event PoolCreated (address indexed token0, address indexed token1, uint24 indexed fee, int24 tickSpacing, address pool, address tradePool)',
|
||||
onlyArgs: true,
|
||||
fromBlock: v2.fromBlock,
|
||||
})
|
||||
const v2_ownerTokens = v2_logs.map(i => [[[i.token0, i.token1], i.pool], [[i.token0, i.token1], i.tradePool]]).flat();
|
||||
|
||||
const all_ownerTokens = v1_ownerTokens.concat(v2_ownerTokens);
|
||||
return api.sumTokens({ownerTokens: all_ownerTokens})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
const { getAPI } = require('../helper/acala/api')
|
||||
const { forceToCurrencyId } = require("@acala-network/sdk-core");
|
||||
const sdk = require('@defillama/sdk')
|
||||
|
||||
module.exports = {
|
||||
@@ -18,19 +17,18 @@ module.exports = {
|
||||
const usdcBalance = usdcRes / 1e6
|
||||
|
||||
return {
|
||||
kusama: (await balanceOf(api, account, 'KSM')) / 1e12,
|
||||
'liquid-ksm': (await balanceOf(api, account, 'LKSM')) / 1e12,
|
||||
kusama: (await balanceOf(api, account, { Token: 'KSM' })) / 1e12,
|
||||
'liquid-ksm': (await balanceOf(api, account, { Token: 'LKSM'})) / 1e12,
|
||||
// 'acala-dollar': (await balanceOf(api, account_3USD, 'KUSD')) / 1e12,
|
||||
// 'usd-coin': (await balanceOf(api, account_3USD, 'erc20://0x1f3a10587a20114ea25ba1b388ee2dd4a337ce27')) / 1e6,
|
||||
'usd-coin': usdcBalance,
|
||||
tether: (await balanceOf(api, account_3USD, 'fa://7')) / 1e6,
|
||||
tether: (await balanceOf(api, account_3USD, { ForeignAsset: '7'})) / 1e6,
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
async function balanceOf(api, account, token) {
|
||||
const currencyId = await forceToCurrencyId(api, token)
|
||||
const tokenRes = await api.query.tokens.accounts(account, currencyId)
|
||||
const tokenRes = await api.query.tokens.accounts(account, token)
|
||||
return +tokenRes.toHuman().free.replace(/,/g, '')
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
const { getAPI } = require('../helper/acala/api')
|
||||
const { forceToCurrencyId } = require("@acala-network/sdk-core");
|
||||
|
||||
module.exports = {
|
||||
acala: {
|
||||
@@ -8,15 +7,14 @@ module.exports = {
|
||||
const api = await getAPI(chain)
|
||||
const account = '23M5ttkp2zdM8qa6LFak4BySWZDsAVByjepAfr7kt929S1U9'
|
||||
return {
|
||||
polkadot: (await balanceOf(api, account, 'DOT')) / 1e10,
|
||||
'liquid-staking-dot': (await balanceOf(api, account, 'LDOT')) / 1e10,
|
||||
polkadot: (await balanceOf(api, account, { Token: 'DOT'})) / 1e10,
|
||||
'liquid-staking-dot': (await balanceOf(api, account,{ Token: 'LDOT'})) / 1e10,
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
async function balanceOf(api, account, token) {
|
||||
const currencyId = await forceToCurrencyId(api, token)
|
||||
const tokenRes = await api.query.tokens.accounts(account, currencyId)
|
||||
const tokenRes = await api.query.tokens.accounts(account, token)
|
||||
return +tokenRes.toHuman().free.replace(/,/g, '')
|
||||
}
|
||||
|
||||
23
projects/teahouse-v3/abi.js
Normal file
23
projects/teahouse-v3/abi.js
Normal file
@@ -0,0 +1,23 @@
|
||||
module.exports = {
|
||||
assetToken1: "function assetToken1() view returns (address)",
|
||||
estimatedValueIntoken1: "function estimatedValueInToken1() view returns (uint256 value1)",
|
||||
getAssets: "function getAssets() view returns (address[])",
|
||||
getAssetsBalance: "function getAssetsBalance() view returns (uint256[])",
|
||||
assetType: "function assetType(address) external returns (uint8)",
|
||||
underlyingAsset: "function UNDERLYING_ASSET_ADDRESS() returns (address)",
|
||||
asset_token0: {
|
||||
type: "function",
|
||||
state_mutability: "view",
|
||||
name: "asset_token0",
|
||||
inputs: [],
|
||||
outputs: [{ name: "address", type: "felt" }],
|
||||
customType: "address",
|
||||
},
|
||||
estimated_value_in_token0: {
|
||||
type: "function",
|
||||
state_mutability: "view",
|
||||
name: "estimated_value_in_token0",
|
||||
inputs: [],
|
||||
outputs: [{ name: "value", type: "Uint256" }],
|
||||
},
|
||||
};
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"decimals": "function decimals() view returns (uint8)",
|
||||
"assetToken1": "function assetToken1() view returns (address)",
|
||||
"estimatedValueIntoken1": "function estimatedValueInToken1() view returns (uint256 value1)",
|
||||
"assets": "function assets(uint256) view returns (address)",
|
||||
"calculateTotalValue": "function calculateTotalValue() view returns (uint256)"
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
const abi = require("./abi.json");
|
||||
const abi = require("./abi.js")
|
||||
const starknet = require("../helper/chain/starknet");
|
||||
const { getConfig } = require("../helper/cache");
|
||||
|
||||
// teahouse public api for vault
|
||||
@@ -7,34 +8,44 @@ const teahouseVaultAPI = "https://vault-content-api.teahouse.finance/vaults";
|
||||
// get vault contract addresses from teahouse api
|
||||
async function getVaultContractsAddress(chain) {
|
||||
let pairVault = [];
|
||||
let portVault = []
|
||||
let portVault = [];
|
||||
let starknetPairVault = [];
|
||||
const { vaults } = await getConfig("teahouse/v3", teahouseVaultAPI);
|
||||
vaults.forEach((element) => {
|
||||
// permissionless vaults
|
||||
if (element.isDeFi == true && element.isActive == true) {
|
||||
if (element.chain === chain) {
|
||||
const type = element.type.toLowerCase();
|
||||
if (type === 'v3pair') {
|
||||
pairVault.push(element.share.address);
|
||||
} else if (type === 'v3port') {
|
||||
portVault.push(element.share.address);
|
||||
// starknet
|
||||
if (chain === 'starknet') {
|
||||
starknetPairVault.push(element.share.address);
|
||||
} else {
|
||||
// evm
|
||||
const type = element.type.toLowerCase();
|
||||
if (type === "v3pair") {
|
||||
pairVault.push(element.share.address);
|
||||
} else if (type === "v3port") {
|
||||
portVault.push(element.share.address);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
pair: pairVault,
|
||||
port: portVault
|
||||
port: portVault,
|
||||
starknetPair: starknetPairVault,
|
||||
};
|
||||
}
|
||||
|
||||
const chains = ["ethereum", "optimism", "arbitrum", 'polygon', 'boba', 'mantle'];
|
||||
const chains = ["optimism", "arbitrum", "polygon", "bsc", "mantle", "boba", "linea", "scroll", "starknet"];
|
||||
|
||||
chains.forEach((chain) => {
|
||||
module.exports[chain] = {
|
||||
tvl: async (api) => {
|
||||
const vaults = await getVaultContractsAddress(chain);
|
||||
|
||||
// EVM pair vault
|
||||
let tokens = await api.multiCall({
|
||||
abi: abi.assetToken1,
|
||||
calls: vaults.pair,
|
||||
@@ -45,15 +56,49 @@ chains.forEach((chain) => {
|
||||
});
|
||||
api.addTokens(tokens, bals);
|
||||
|
||||
tokens = await api.multiCall({ abi: "address[]:getAssets", calls: vaults.port })
|
||||
const allTokens = [...new Set(tokens.flat())]
|
||||
const symbols = await api.multiCall({ abi: 'string:symbol', calls: allTokens })
|
||||
const sMap = Object.fromEntries(allTokens.map((address, i) => [address, symbols[i]]))
|
||||
const ownerTokens = vaults.port.map((v, i) => {
|
||||
const tokenList = tokens[i].filter(t => !sMap[t].startsWith('TEA-'))
|
||||
return [tokenList, v]
|
||||
})
|
||||
return api.sumTokens({ ownerTokens})
|
||||
// EVM portfolio vault
|
||||
tokens = await api.multiCall({ abi: abi.getAssets, calls: vaults.port });
|
||||
bals = await api.multiCall({ abi: abi.getAssetsBalance, calls: vaults.port });
|
||||
let assetTypes = await Promise.all(tokens.map(
|
||||
async (tokenArr, index) =>
|
||||
await api.multiCall({
|
||||
abi: abi.assetType,
|
||||
calls: tokenArr.map(token => ({ target: vaults.port[index], params: [token] })),
|
||||
})
|
||||
));
|
||||
tokens = tokens.flat();
|
||||
bals = bals.flat();
|
||||
assetTypes = assetTypes.flat();
|
||||
|
||||
// assetType: 3-TeaVault, 4-AaveAToken, convert type 4 to underlying asset and then exclude type 3 balances
|
||||
let aTokenIndice = [];
|
||||
let excludeIndice = [];
|
||||
assetTypes.forEach((type, index) => {
|
||||
if (type === '4') {
|
||||
aTokenIndice.push(index);
|
||||
} else if (type === '3') {
|
||||
excludeIndice.push(index);
|
||||
}
|
||||
});
|
||||
|
||||
const underlyings = await api.multiCall({ abi: abi.underlyingAsset, calls: aTokenIndice.map((index) => tokens[index]) });
|
||||
aTokenIndice.forEach((value, index) => (tokens[value] = underlyings[index]));
|
||||
tokens = tokens.filter((_, index) => !excludeIndice.includes(index));
|
||||
bals = bals.filter((_, index) => !excludeIndice.includes(index));
|
||||
api.addTokens(tokens, bals);
|
||||
|
||||
// Starknet pair vault
|
||||
tokens = await starknet.multiCall({
|
||||
abi: abi.asset_token0,
|
||||
calls: vaults.starknetPair,
|
||||
});
|
||||
bals = await starknet.multiCall({
|
||||
abi: abi.estimated_value_in_token0,
|
||||
calls: vaults.starknetPair,
|
||||
});
|
||||
api.addTokens(tokens, bals);
|
||||
|
||||
return api.getBalances();
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
@@ -36,6 +36,9 @@ const indexBTC_BiWeekly_B = "0xB1105529305f166531b7d857B1d6f28000278aff"
|
||||
const PTeETH_27JUN24 = '0xc69Ad9baB1dEE23F4605a82b3354F8E40d1E5966'
|
||||
const aPTeETH_27JUN24 = '0xE6A9465B9DA25Ddacc55AF5F2a111Db4E80Ba20D'
|
||||
const aWETH = '0xE41645Db7C6813993eEA1cBA83912cE07d8a6d29'
|
||||
const PTUSDe_25JUL24 = '0xa0021EF8970104c2d008F38D92f115ad56a9B8e1'
|
||||
const aPTUSDe_25JUL24 = '0xCe51Ca8D61dAb1f84bD95329218b87E95054aB22'
|
||||
const aUSDC = '0xFB3CbdA3145Fac86040bE8501e0750cd1ddDA0Af'
|
||||
|
||||
// Avalanche Vaults
|
||||
const avaxCallVault = '0xd06Bd68d58eD40CC2031238A3993b99172ea37cA'
|
||||
@@ -93,6 +96,13 @@ const arbC_LLV = '0x721Bba1556649e9c70E2dF1EAFC04270376025f7'
|
||||
const arbP_LLV = '0x57eD79afD32c616E4631231636F4597188d20C5e'
|
||||
const ethC_LLV = '0x078F98Be8A1bb1bD64799B8F05Aca08f5850A69D'
|
||||
const ethP_LLV = '0xE84CB9daF67644734051c7f6e978968f04F6751e'
|
||||
// Boosted assets (Selling options backed by yielding assets) (locked in Aave V2 Fork)
|
||||
const PTezETH_27JUN24 = '0x8EA5040d423410f1fdc363379Af88e1DB5eA1C34'
|
||||
const aPTezETH_27JUN24 = '0x2F741a91dCe2a1e1Ed24c88F93A0f3530f1CBf2C'
|
||||
const PTrsETH_27JUN24 = '0xAFD22F824D51Fb7EeD4778d303d4388AC644b026'
|
||||
const aPTrsETH_27JUN24 = '0x121b956D11EaeCFD3f0CdF259D6faFFEbEDD0bC9'
|
||||
const PTweETH_27JUN24 = '0x1c27Ad8a19Ba026ADaBD615F6Bc77158130cfBE4'
|
||||
const aPTweETH_27JUN24 = '0x1B38B4586003E64c6c87F4acaF4f15415C2034EB'
|
||||
|
||||
// Polygon zkEVM vaults
|
||||
const stMaticCallVault = '0x7bF3c7C23501EA3E09B237D6F8AdcB7Ea3CeF41C'
|
||||
@@ -192,6 +202,9 @@ const config = {
|
||||
|
||||
[PTeETH_27JUN24, aPTeETH_27JUN24,],
|
||||
[weth, aWETH,],
|
||||
[PTUSDe_25JUL24, aPTUSDe_25JUL24,],
|
||||
[usdc, aUSDC,],
|
||||
|
||||
]
|
||||
},
|
||||
avax: {
|
||||
@@ -208,6 +221,10 @@ const config = {
|
||||
[usdc_arb, ethPutVaultArb,],
|
||||
[arb, aArb,],
|
||||
[usdc_arb, aUsdc,],
|
||||
|
||||
[PTezETH_27JUN24, aPTezETH_27JUN24,],
|
||||
[PTrsETH_27JUN24, aPTrsETH_27JUN24,],
|
||||
[PTweETH_27JUN24, aPTweETH_27JUN24,],
|
||||
],
|
||||
LLVOwners: [
|
||||
[univ3nft_arb, arbC_LLV,],
|
||||
|
||||
@@ -9,4 +9,12 @@ module.exports = {
|
||||
tvl: gmxExports({ vault: '0xBC918775C20959332c503d51a9251C2405d9cF88' }),
|
||||
staking: staking(zkStaking, zkZKE),
|
||||
},
|
||||
metis: {
|
||||
tvl: gmxExports({ vault: '0x79C365bA484CBa73F3e9cB04186ddCc0DEBFB00c' }),
|
||||
//staking: staking("0xb3Bcb2839b7fb103b1a117dBb451829078acAD59", "0xdf020cBd1897133978C7FcDF04B07E69d8934Efc"),
|
||||
},
|
||||
telos: {
|
||||
tvl: gmxExports({ vault: '0x17D3FdF3b017C96782dE322A286c03106C75C62E' }),
|
||||
//staking: staking(zkStaking, "0xdf020cBd1897133978C7FcDF04B07E69d8934Efc"),
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user