Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
0xIvan committed Aug 15, 2024
2 parents b6a7b73 + 4ba7d7b commit a4b0501
Show file tree
Hide file tree
Showing 244 changed files with 3,975 additions and 4,364 deletions.
1,894 changes: 1,009 additions & 885 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions projects/Astra/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { getUniTVL } = require('../helper/unknownTokens')

const FACTORY = "0x2b6852CeDEF193ece9814Ee99BE4A4Df7F463557" // This factory is on AirDAO Mainnet (Chain Id: 16718)

const dexTVL = getUniTVL({ factory: FACTORY, useDefaultCoreAssets: true, fetchBalances: true, })

module.exports = {
misrepresentedTokens: true,
methodology: `Uses factory(${FACTORY}) address to find and price Liquidity Pool pairs.`,
airdao: {
tvl: dexTVL
}
};
2 changes: 1 addition & 1 deletion projects/aark/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ async function tvl(api) {
return api.sumTokens({ owner: VAULT_CONTRACT_ADDRESS, tokens: [
ADDRESSES.arbitrum.WETH,
ADDRESSES.arbitrum.USDC,
'0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F', //FRAX
ADDRESSES.arbitrum.FRAX, //FRAX
ADDRESSES.arbitrum.USDC_CIRCLE,
ADDRESSES.arbitrum.WSTETH,
ADDRESSES.arbitrum.DAI,
Expand Down
13 changes: 13 additions & 0 deletions projects/aevo-xyz/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,17 @@ module.exports = {
]
})
},
base: {
tvl: sumTokensExport({
owners: [
'0x6ee3907D1B9423584195979812379143B327fb48', // Native USDC
'0xA8bD0eCb10a83CC6E14FC5381f384DD3C0779e8B', // WETH
],
tokens: [
ADDRESSES.base.USDC,
ADDRESSES.base.USDbC,
ADDRESSES.base.WETH,
]
})
}
}
8 changes: 4 additions & 4 deletions projects/airpuff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,22 @@ module.exports = {
tvl: async (api) => {
const KUSDC = {
vault: "0x4c18E80b801AA24066D8B1C6E65ee245497Cb741",
token: "0xa415021bC5c4C3b5B989116DC35Ae95D9C962c8D",
token: ADDRESSES.karak.USDC,
};

const KWETH = {
vault: "0x9a9631F7BEcE5C6E0aBA1f73f0e5796c534dc4db",
token: "0x4200000000000000000000000000000000000006",
token: ADDRESSES.optimism.WETH_1,
};

const wethLending = {
vault: "0xd6034F9147CF7528e857403Dea93bc45743295eb",
token: "0x4200000000000000000000000000000000000006",
token: ADDRESSES.optimism.WETH_1,
};

const usdcLending = {
vault: "0x475820E4bCE0E3d233Ad7f6A8c9DD1f66974c5d6",
token: "0xa415021bC5c4C3b5B989116DC35Ae95D9C962c8D",
token: ADDRESSES.karak.USDC,
};

const KarakUSDCBal = await api.call({ target: KUSDC.vault, abi: contractAbis.getTotalSupply });
Expand Down
20 changes: 7 additions & 13 deletions projects/akronswap/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
const { getUniTVL } = require('../helper/unknownTokens');


const tvl = getUniTVL({ factory: '0xAf39606bec181887951Ab6912Ac7EA216Bd6E4B4', useDefaultCoreAssets: true, fetchBalances: true, })

module.exports = {
misrepresentedTokens: true,
ethereum:{
tvl: getUniTVL({ factory: '0x6624Ac5F9abFA36174511607860e81C8dB9e84E9', useDefaultCoreAssets: true, fetchBalances: true, }),
},
arbitrum:{
tvl: getUniTVL({ factory: '0x40Cbdf84475f8Dd7C9a9c665eDE551EeaaF21F8d', useDefaultCoreAssets: true, fetchBalances: true, }),
},
base:{
tvl: getUniTVL({ factory: '0xD2156Bb9ed200FE88705443BfFcA788BA8b205f6', useDefaultCoreAssets: true, fetchBalances: true, }),
},
bsc:{
tvl: getUniTVL({ factory: '0x40Cbdf84475f8Dd7C9a9c665eDE551EeaaF21F8d', useDefaultCoreAssets: true, fetchBalances: true, }),
},
ethereum: { tvl, },
arbitrum: { tvl, },
base: { tvl, },
bsc: { tvl, },
}
2 changes: 1 addition & 1 deletion projects/alcor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async function eos() {
// Alcor
// https://wax.alcor.exchange
async function wax() {
const accounts = ["swap.alcor", "alcordexmain"];
const accounts = ["swap.alcor", "alcordexmain", "liquid.alcor"];
const tokens = [
["eosio.token", "WAX", "wax"],
["alien.worlds", "TLM", "alien-worlds"],
Expand Down
110 changes: 110 additions & 0 deletions projects/alexlab/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
const { call } = require('../helper/chain/stacks-api')
const { getCache, setCache } = require('../helper/cache')
const { sleep } = require('../helper/utils')
const sdk = require('@defillama/sdk')

const factory = 'SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.amm-pool-v2-01'

async function tvl(api) {
// https://docs.alexgo.io/developers/smart-contracts


// get simple weight pool data
const simpleWeightAMM = 'SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.simple-weight-pool-alex'
let { value: swPools } = await call({ target: simpleWeightAMM, abi: 'get-pools' })
swPools = swPools.map(i => i.value)
for (const { value: pool } of swPools) {
const inputArgs = ['token-x', 'token-y'].map(key => pool[key])
const { value: poolData } = await call({ target: simpleWeightAMM, abi: 'get-pool-details', inputArgs })
api.add(pool['token-x'].value, poolData['balance-x'].value)
api.add(pool['token-y'].value, poolData['balance-y'].value)
await sleep(2100)
}



// get fixed weight pool data
const fixedWeightAMM = 'SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.fixed-weight-pool-v1-01'
let { value: fwPools } = await call({ target: fixedWeightAMM, abi: 'get-pools' })
fwPools = fwPools.map(i => i.value)
for (const { value: pool } of fwPools) {
const inputArgs = ['token-x', 'token-y', 'weight-x', 'weight-y'].map(key => pool[key])
const { value: poolData } = await call({ target: fixedWeightAMM, abi: 'get-pool-details', inputArgs })
api.add(pool['token-x'].value, poolData['balance-x'].value)
api.add(pool['token-y'].value, poolData['balance-y'].value)
await sleep(2100)
}



// update cache for amm v2 pools & token metadata
const cache = await getCache('alex/ammv2', 'stacks')
if (!cache.pairData) cache.pairData = []
if (!cache.tokenMetadata) cache.tokenMetadata = {}
const currentPairCount = cache.pairData.length
let hasMorePairs = true
let i = currentPairCount + 1
do {
try {
const pairData = await call({ target: factory, abi: 'get-pool-details-by-id', inputArgs: [{ type: 'number', value: i }] })
if (!pairData.value?.factor) hasMorePairs = false
else
cache.pairData.push(pairData.value)
i++
await sleep(2100)
} catch (e) {
sdk.log('error fetching pair data', e)
hasMorePairs = false
}
} while (hasMorePairs)
let cacheNeedsUpdate = cache.pairData.length > currentPairCount
const tokenSet = new Set(cache.pairData.flatMap(pair => [pair['token-x'], pair['token-y']]).map(token => token.value)
.filter(token => !cache.tokenMetadata[token])
)
const tokensMissingMetadata = Array.from(tokenSet)
if (tokensMissingMetadata.length > 0) {
cacheNeedsUpdate = true
for (const token of tokensMissingMetadata) {
try {
const decimals = await call({ target: token, abi: 'get-decimals' })
const symbol = await call({ target: token, abi: 'get-symbol' })
let baseToken = {}
let baseDecimals = {}
let baseSymbol = {}
try {
baseDecimals = await call({ target: token, abi: 'get-base-decimals' })
baseToken = await call({ target: token, abi: 'get-base-token' })
if (typeof baseToken === 'string') baseToken = { value: baseToken }
if (baseToken.value) {
baseSymbol = await call({ target: baseToken.value, abi: 'get-symbol' })
}
} catch (e) {
// sdk.log('error fetching base token metadata', e)
}
cache.tokenMetadata[token] = { decimals: decimals.value, symbol: symbol.value, baseToken: baseToken.value, baseDecimals: baseDecimals.value, baseSymbol: baseSymbol.value }
await sleep(2100)
} catch (e) {
sdk.log('error fetching token metadata', e)
}
}
}

api.log('pair count', cache.pairData.length)
if (cacheNeedsUpdate)
await setCache('alex/ammv2', 'stacks', cache)



// add amm v2 tvl
for (const pair of cache.pairData) {
const { value: bals } = await call({ target: factory, abi: 'get-balances', inputArgs: [pair['token-x'], pair['token-y'], pair.factor] })
api.add(pair['token-x'].value, bals['balance-x'].value)
api.add(pair['token-y'].value, bals['balance-y'].value)
await sleep(600)
}
return api.getBalances()
}

module.exports = {
stacks: { tvl }
}
35 changes: 5 additions & 30 deletions projects/alexlab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,16 @@ const { get } = require('../helper/http')
// https://stacks-node-api.blockstack.org/extended/v1/address/SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.alex-vault/balances
const ALEX_API = "https://api.alexlab.co/v1";

async function fetch() {
const url = `${ALEX_API}/pool_token_stats`;
const alexStatsResponse = await get(url)

const valueLockedMap = {};
let totalValueLocked = 0;
for (const pool of alexStatsResponse) {
let poolValue = 0;
const poolToken = pool.pool_token;

if (poolToken == "age000-governance-token") {
poolValue = pool.price * pool.reserved_balance;
} else {
poolValue = pool.price * pool.total_supply;
}
totalValueLocked += poolValue;
valueLockedMap[poolToken] = poolValue;
}

return { tether: totalValueLocked };
}

async function staking() {
const url = `${ALEX_API}/stats/tvl`;
const alexResponse = await get(url)
return { tether: alexResponse.reserve_pool_value };
}
const { getExports } = require('../helper/heroku-api')

// node test.js projects/alexlab/index.js
module.exports = {
misrepresentedTokens: true,
timetravel: false,
stacks: {
tvl: fetch,
staking,
},
methodology: "Alex Lab TVL is sum of tokens locked in ALEX platform.",
};
...getExports("alexlab", ['stacks']),
}

module.exports.stacks.staking = staking
26 changes: 26 additions & 0 deletions projects/alienworlds/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { get_account_tvl } = require("../helper/chain/eos");

const accounts = ["nftmt.worlds", "stake.worlds", "lore.worlds", "arena.worlds", "boost.worlds"]

// AlienWorlds
// https://alienworlds.io/
async function wax() {
const tokens = [
["eosio.token", "WAX", "wax"],
];
return await get_account_tvl(accounts, tokens, "wax");
}
async function staking() {
const tokens = [
["alien.worlds", "TLM", "alien-worlds"],
];
return await get_account_tvl(accounts, tokens, "wax");
}

module.exports = {
methodology: `AlienWorlds TVL is achieved by querying token balances from Staking, Voting & Gaming smart contract(s).`,
wax: {
tvl: wax,
staking,
},
}
29 changes: 29 additions & 0 deletions projects/alphaX-protocol/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const ADDRESSES = require('../helper/coreAssets.json');
const { sumTokensExport } = require('../helper/unwrapLPs');

const tokens = [
ADDRESSES.ethereum.USDT,
];

const walletAddresses = {
ethereum: ['0xA61a6E696B7C566DA42B80dA27d96e7104bcec99'],
arbitrum: ['0x552E7A55802f3350C707a243E402aa50Eda9D286']

};

const tokenAddress = {
ethereum: [ADDRESSES.ethereum.USDT],
arbitrum: [ADDRESSES.arbitrum.USDT],


}

module.exports = {
ethereum: {
tvl: sumTokensExport({ owners: walletAddresses.ethereum, tokens: tokenAddress.ethereum }),
},
arbitrum: {
tvl: sumTokensExport({ owners: walletAddresses.arbitrum, tokens: tokenAddress.arbitrum }),
},

};
Loading

0 comments on commit a4b0501

Please sign in to comment.