Skip to content

Commit

Permalink
Merge branch 'DefiLlama:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
daedboi authored Aug 17, 2024
2 parents a3a96ff + 24dd550 commit ffc4981
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 7 deletions.
32 changes: 25 additions & 7 deletions projects/ayin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,26 @@ const alephium = require('../helper/chain/alephium')
const Addresses = {
alphAyinPool: '25ywM8iGxKpZWuGA5z6DXKGcZCXtPBmnbQyJEsjvjjWTy',
alphUsdtPool: '2A5R8KZQ3rhKYrW7bAS4JTjY9FCFLJg6HjQpqSFZBqACX',
alphUsdcPool: '283R192Z8n6PhXSpSciyvCsLEiiEVFkSE6MbRBA4KSaAj',
alphWethPool: 'yXMFxdoKcE86W9NAyajc8Z3T3k2f5FGiHqHtuA69DYT1',
ayinUsdtPool: '21NEBCk8nj5JBKpS7eN8kX6xGJoLHNqTS3WBFnZ7q8L9m',
alphWbtcPool: '28XY326TxvSekaAwiWDLFg2QBRfacSga8dyNJCYGUYNbq',
alphApadPool: 'vFpZ1DF93x1xGHoXM8rsDBFjpcoSsCi5ZEuA5NG5UJGX',
alphChengPool: '25b5aNfdrNRjJ7ugPTkxThT51L1NSvf8igQyDHKZhweiK',
alphAnsdPool: 'uM4QJwHqFoTF2Pou8TqwhaDiHYLk4SHG65uaQG8r7KkT',
alphAlphagaPool: '23cXw23ZjRqKc7i185ZoH8vh9KT4XTumVRWpVLUecgLMd',
ayinUsdtPool: '21NEBCk8nj5JBKpS7eN8kX6xGJoLHNqTS3WBFnZ7q8L9m',
ayinUsdcPool: '2961aauvprhETv6TXGQRc3zZY4FbLnqKon2a4wK6ABH9q',
ayinApadPool: '247rZysrruj8pj2GnFyK2bqB2nU4JsUj7k2idksAp4XMy',
usdtUsdcPool: '27C75V9K5o9CkkGTMDQZ3x2eP82xnacraEqTYXA35Xuw5',
usdt: 'zSRgc7goAYUgYsEBYdAzogyyeKv3ne3uvWb3VDtxnaEK',
weth: 'vP6XSUyjmgWCB2B9tD5Rqun56WJqDdExWnfwZVEqzhQb',
ayin: 'vT49PY8ksoUL6NcXiZ1t2wAmC7tTPRfFfER8n3UCLvXy',
wbtc: 'xUTp3RXGJ1fJpCGqsAY6GgyfRQ3WQ1MdcYR1SiwndAbR',
usdc: '22Nb9JajRpAh9A2fWNgoKt867PA6zNyi541rtoraDfKXV'
usdc: '22Nb9JajRpAh9A2fWNgoKt867PA6zNyi541rtoraDfKXV',
apad: '27HxXZJBTPjhHXwoF1Ue8sLMcSxYdxefoN2U6d8TKmZsm',
cheng: '27DP28mGQzSrHGZgnRvYQH1VAWYZVVLUjGALazLrtrRJF',
ansd: '2AhEaQiUYtAF6g1vtRQHsPR7xTkMY1PRr3k7QkXuisynF',
alphaga: '26Mirs33zojnVMRkqVDJtMZvVZcbAFVyxGojGw7UtWp2K'
}

const XAyinAddress = 'zst5zMzizEeFYFis6DNSknY5GCYTpM85D3yXeRLe2ug3'
Expand All @@ -21,7 +32,10 @@ const TokenIds = {
weth: alephium.contractIdFromAddress(Addresses.weth),
ayin: alephium.contractIdFromAddress(Addresses.ayin),
wbtc: alephium.contractIdFromAddress(Addresses.wbtc),
usdc: alephium.contractIdFromAddress(Addresses.usdc)
usdc: alephium.contractIdFromAddress(Addresses.usdc),
apad: alephium.contractIdFromAddress(Addresses.apad),
cheng: alephium.contractIdFromAddress(Addresses.cheng),
ansd: alephium.contractIdFromAddress(Addresses.ansd)
}

async function ayinTvlForXAyin() {
Expand All @@ -37,12 +51,12 @@ async function ayinTvlForXAyin() {

async function tvl() {
const alphTvls = await Promise.all([
Addresses.alphAyinPool, Addresses.alphUsdtPool, Addresses.alphWethPool
Addresses.alphAyinPool, Addresses.alphUsdtPool, Addresses.alphUsdcPool, Addresses.alphWethPool, Addresses.alphApadPool, Addresses.alphChengPool, Addresses.alphAnsdPool, Addresses.alphAlphagaPool
].map(poolAddress => alephium.getAlphBalance(poolAddress)))
const alphTvl = alphTvls.reduce((tvl, res) => tvl + Number(res.balance), 0)
const tokensTvls = await Promise.all([
Addresses.alphAyinPool, Addresses.alphUsdtPool, Addresses.alphWethPool, Addresses.ayinUsdtPool,
Addresses.alphWbtcPool, Addresses.usdtUsdcPool
Addresses.ayinUsdcPool,Addresses.alphWbtcPool, Addresses.usdtUsdcPool,Addresses.alphApadPool, Addresses.alphChengPool, Addresses.ayinApadPool, Addresses.alphAnsdPool, Addresses.alphAlphagaPool
].map(poolAddress => alephium.getTokensBalance(poolAddress)))
const tokensTvl = tokensTvls.reduce((res, tokenTvls) => {
tokenTvls.forEach(tokenTvl => {
Expand All @@ -51,14 +65,18 @@ async function tvl() {
}
});
return res
}, { [TokenIds.ayin]: 0, [TokenIds.usdt]: 0, [TokenIds.weth]: 0, [TokenIds.wbtc]: 0, [TokenIds.usdc]: 0 })
}, { [TokenIds.ayin]: 0, [TokenIds.usdt]: 0, [TokenIds.weth]: 0, [TokenIds.wbtc]: 0, [TokenIds.usdc]: 0, [TokenIds.apad]: 0, [TokenIds.cheng]: 0, [TokenIds.ansd]: 0, [TokenIds.ansd]: 0, [TokenIds.alphaga]: 0 })
return {
alephium: alphTvl / 1e18,
ayin: tokensTvl[TokenIds.ayin] / 1e18,
weth: tokensTvl[TokenIds.weth] / 1e18,
tether: tokensTvl[TokenIds.usdt] / 1e6,
usdc: tokensTvl[TokenIds.usdc] / 1e6,
bitcoin: tokensTvl[TokenIds.wbtc] / 1e8
bitcoin: tokensTvl[TokenIds.wbtc] / 1e8,
alphpad: tokensTvl[TokenIds.apad] / 1e18,
gigacheng: tokensTvl[TokenIds.cheng] / 1e6,
alephiumdomains: tokensTvl[TokenIds.ansd] / 1e18,
alphaga: tokensTvl[TokenIds.alphaga] / 1e18
}
}

Expand Down
6 changes: 6 additions & 0 deletions projects/capyfi/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { compoundExports2, methodology } = require('../helper/compound')

module.exports = {
methodology,
lac: compoundExports2({ comptroller: '0x123Abe3A273FDBCeC7fc0EBedc05AaeF4eE63060', cether: '0x465ebfceb3953e2922b686f2b4006173664d16ce' })
}
51 changes: 51 additions & 0 deletions projects/defi-money/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const { sumTokens2 } = require("../helper/unwrapLPs")

const config = {
optimism: {
controller: "0x1337F001E280420EcCe9E7B934Fa07D67fdb62CD",
MONEY: "0x7e803F4edd6528caFBf5C5d03Cc106b04379C24b",
stakeLPs: [
// "0x7e803F4edd6528caFBf5C5d03Cc106b04379C24b", // MONEY - already included in tvl
"0xE8f00491afa68B4A653C77e5f92DBA0F8df3a185", // crvUSD/MONEY
"0xa398a48C2738fd6c79F5654823Fb93456B0fDaF6", // USDT/MONEY
"0x36afCD1083eE9186A2b984E10d75C1E14b99B75e", // USDC/MONEY
"0xcf38a66DeD7825cfEF66046c256Aa0EDbd41BEf5", // DAI/MONEY
"0x73C3eC2b8e00929824a529e60fb6ed8aF193c7cc", // FRAX/MONEY
],
},
arbitrum: {
controller: "0x1337F001E280420EcCe9E7B934Fa07D67fdb62CD",
MONEY: "0xEbE54BEE7A397919C53850bA68E126b0A6b295ed",
stakeLPs: [
// "0xEbE54BEE7A397919C53850bA68E126b0A6b295ed", // MONEY - already included in tvl
"0xF2852d7e810d3EC7094bFE1D7DDCa5044c259c25", // crvUSD/MONEY
"0x6e59b326984fC132F16a977cd20E38641A9043De", // USDT/MONEY
"0xdE718A791226c93B53C77D60E5D4693C05a31422", // USDC/MONEY
"0xE3763d545707F435e21eeBbe75070495c806B744", // DAI/MONEY
"0x07aDF588508b923B8eA0389d27b61b9CB8a197Cb", // FRAX/MONEY
],
},
}

const tvl = async (api) => {
const { controller, } = config[api.chain]
const colls = await api.call({ target: controller, abi: 'address[]:get_all_collaterals' })
const amms = await api.multiCall({ abi: 'function get_amm(address) view returns (address)', calls: colls, target: controller })
return sumTokens2({ api, tokensAndOwners2: [colls, amms]})
}

const pool2 = async (api) => {
const { stakeLPs = [], } = config[api.chain]
const tokens = await api.multiCall({ abi: 'address:STAKE_TOKEN', calls: stakeLPs })
return sumTokens2({ api, tokensAndOwners2: [tokens, stakeLPs]})
}

module.exports = {
methodology: "TVL corresponds to the collateral deposited in the markets",
}

Object.keys(config).forEach((chain) => {
module.exports[chain] = {
tvl, pool2,
}
})
6 changes: 6 additions & 0 deletions projects/helper/tokenMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ const fixBalancesTokens = {
cronos_zkevm: {
'0xc1bf55ee54e16229d9b369a5502bfe5fc9f20b6d': { coingeckoId: 'crypto-com-chain', decimals: 18 },
},
lac: {
[ADDRESSES.null]: { coingeckoId: "la-coin", decimals: 18 },
'0x2911a1AB18546cb501628Be8625C7503a2A7DB54': { coingeckoId: "la-coin", decimals: 18 },
'0x42c8c9c0f0a98720dacdaeac0c319cb272b00d7e': { coingeckoId: "ethereum", decimals: 18 },
'0xf54b8cb8eeee3823a55dddf5540ceaddf9724626': { coingeckoId: "wrapped-bitcoin", decimals: 8 },
}
}

ibcChains.forEach(chain => fixBalancesTokens[chain] = { ...ibcMappings, ...(fixBalancesTokens[chain] || {}) })
Expand Down
33 changes: 33 additions & 0 deletions projects/lulo/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const sdk = require('@defillama/sdk')

const endpoint = 'http://api.flexlend.fi/stats'
const startTimestamp = 1704067200 // 2024-01-01

async function tvl(options) {
const balances = {}
const request = {
method: 'GET',
headers: {
accept: 'application/json',
'x-lulo-api-key': String(process.env.LULO_API_KEY || ''),
},
}

const response = await fetch(`${endpoint}?timestamp=${options.timestamp}`, request)

const { data } = await response.json()

data.map(d => {
sdk.util.sumSingleBalance(balances, d.mintAddress, d.tokens, 'solana')
})
return balances
}

module.exports = {
doublecounted: true,
timetravel: true,
start: startTimestamp,
methodology:
'Volume is calculated by summing the total USD value of deposited funds in Lulo across all tokens',
solana: { tvl },
}
30 changes: 30 additions & 0 deletions projects/waxdao/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const { get_account_tvl } = require("../helper/chain/eos");

const staking_accounts = ["waxdaofarmer", "farms.waxdao", "tf.waxdao"];

const tokens = [
["eosio.token", "WAX", "wax"],
["wuffi", "WUF", "wuffi"],
["alien.worlds", "TLM", "alien-worlds"],
];


// WaxDAO
// https://waxdao.io
async function wax() {
const accounts = ["waxdaolocker", "waxdaomarket", "waxdaobacker", "waxdaoescrow", "waxdaosynths"];

return await get_account_tvl(accounts, tokens, "wax");
}

async function staking() {
return await get_account_tvl(staking_accounts, tokens, "wax");
}

module.exports = {
methodology: `WaxDAO TVL is achieved by querying token balances from vesting, farming, and market contract(s)`,
wax: {
tvl: wax,
staking
},
}

0 comments on commit ffc4981

Please sign in to comment.