Skip to content

Commit

Permalink
Merge branch 'main' of github.com:buchaoqun/DefiLlama-Adapters
Browse files Browse the repository at this point in the history
* 'main' of github.com:buchaoqun/DefiLlama-Adapters:
  fix usdx
  add shape chain and swan swap Dex (DefiLlama#11880)
  Update: Additional ZTX Staking Pool (DefiLlama#11877)
  Add gnosis uniswap (DefiLlama#11879)
  add base chain (DefiLlama#11884)
  symbiosis adds bsquared chain support (DefiLlama#11885)
  update script
  add usdx.money USDX (DefiLlama#11776)
  stkd lps
  find bitcoin duplicates
  Add WBTC tokens to CrossCurve TVL (DefiLlama#11878)
  Update raindex adapter (DefiLlama#11874)
  Update index.js
  Refactor: fetch BOB Gateway owners from chain (DefiLlama#11867)
  track alienbase treasury DefiLlama#11868
  Add SuiBridge Adapter (DefiLlama#11869)
  add ascentyield (DefiLlama#11873)
  FWX DEX add chain base (DefiLlama#11871)
  Add solv-btc-lst bbn owner  address (DefiLlama#11872)
  • Loading branch information
buchaoqun committed Oct 12, 2024
2 parents 7a884b9 + 5aedb52 commit c4c219a
Show file tree
Hide file tree
Showing 23 changed files with 301 additions and 48 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"entities": "cd utils;npm i; cd ..; node utils/testInteractive entities",
"useTokenLabels": "node utils/scripts/useTokenLabels.js",
"biggest-files": "find ./projects -name '*.js' -not -path './projects/helper/*' -not -path './projects/curve/*' -not -path './projects/sigmao/*' -exec du -sh {} \\; | sort -rh | head -n 100",
"check-bitcoin-duplicates": "node utils/scripts/checkBTCDups.js",
"postinstall": "echo 'run \"npm update @defillama/sdk\" if you want lastest sdk changes' "
},
"author": "",
Expand Down
38 changes: 38 additions & 0 deletions projects/ascentyield/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const ADDRESSES = require('../helper/coreAssets.json')
const { sumTokens2 } = require("../helper/solana");
const { post } = require('../helper/http');
const { sumTokensExport } = require("../helper/unwrapLPs")


const hyperliquidSubAccount = "0x75b2e5c67d2116bcf1b77c5e6444fc18bc5d38a4" // for trading at hyperliquid
const jlpholder = "9nAgg9wAnuiPv57dXkmCwoGhhbTHS1RRzvYLjnRGZtXp" // for keeping JLP and USDC(buy JLP)
const arbiusdcholder = "0xa6Ff9a77D6bD8B0a759055Cd8885e23228bc10Ec" // USDC on arbi(will bridge to solana)
const hyperliquidMainAccount = "0x7151609Fdc7E0Cac89FB9720F0957AF9d552f8f9" // will transfer USDC to sub account


module.exports = {
methodology: "Aggregate trading account margins in HyperLiquid and JLP, USDC on the solana network.",
solana: {
tvl: async (api) => {
return sumTokens2({
owner: jlpholder
});
},
},
hyperliquid: {
tvl: async (api) => {
let data = await post('https://api.hyperliquid.xyz/info', {
type: "clearinghouseState",
user: hyperliquidSubAccount
})
data = parseInt(data.marginSummary.accountValue)
api.addCGToken('usd-coin', data)
}
},
arbitrum: {
tvl: sumTokensExport({
owners: [arbiusdcholder, hyperliquidMainAccount],
tokens: [ADDRESSES.arbitrum.USDC_CIRCLE,]
})
},
};
7 changes: 7 additions & 0 deletions projects/avalon-finance-cedefi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ const getMetrics = async (api, borrowed) => {
// @note: no more count collateral on Ethereum, count collateral on Bitcoin instead
// const balanceOfCollateral = marketData.collateral;
const balanceOfDebt = marketData.debt;
if (!borrowed) {
const supply= await api.call({ abi: 'erc20:totalSupply', target: '0x3119a1AD5B63A000aB9CA3F2470611eB997B93B9'})
api.add('0x3119a1AD5B63A000aB9CA3F2470611eB997B93B9', supply)

}

if (borrowed)
api.add(usdtAddress, balanceOfDebt);
Expand All @@ -47,3 +52,5 @@ module.exports = {
]),
},
}

delete module.exports.bitcoin
47 changes: 29 additions & 18 deletions projects/bob-gateway/index.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
const ADDRESSES = require('../helper/coreAssets.json')
const { sumTokens2 } = require("../helper/unwrapLPs");

const factories = {
v1: "0x1831d29376eb94bba3ca855af7984db923768b27",
v2: "0x37f330e667208633e1da1cf601d01f0ef8484306",
v3: "0xAE6770a207E86FaE3b191564FA55ce7Bfee0Dde9",
};

const abis = {
v1: {
allOnramps: "function allOnramps() view returns (address[])",
},
v2: {
allGateways: "function allGateways() view returns (address[])",
},
v3: {
allGateways: "function allGateways() view returns (address[])",
},
};

module.exports = {
bob: {
tvl: (api) =>
sumTokens2({
tvl: async (api) => {
const gateways = (await api.batchCall([
{ abi: abis.v1.allOnramps, target: factories.v1 },
{ abi: abis.v2.allGateways, target: factories.v2 },
{ abi: abis.v3.allGateways, target: factories.v3 }
])).flat();

return sumTokens2({
api,
chain: "bob",
tokens: [
ADDRESSES.bob.WBTC,
ADDRESSES.bob.TBTC,
],
owners: [
// taken from onramp factory (allOnramps): https://explorer.gobob.xyz/address/0x1831d29376eb94bba3ca855af7984db923768b27?tab=read_contract
"0x587e6E2b280C70ec811a371671D3CBE9D7b9F691",
"0xA1884124a52331Bc2fa66e2b0EFa15856C6830c6",
"0x2e0A1Fa2f61985c475B869559cF2Cf733d4DB282",
"0xCA94d277d04e8e6ce960F7492b2df62e2215d562",
"0x9BBBc8F4e4258cC9Ec79164DDB7ef72954f381E2",
"0x47340424457463Fa77B59FDAdea31cA886a241FD",
// V2 gateways taken from gateway registry (allGateways): https://explorer.gobob.xyz/address/0x37f330e667208633e1da1cf601d01f0ef8484306?tab=read_contract
"0x1578c26085b45A559D6B4D4cCfc1DD9e5c66F7B6",
"0x2a7b7Db980B2228D5FfC47711D09d13F8F90961e",
// V3 gateways taken from gateway registry (allGateways): https://explorer.gobob.xyz/address/0xAE6770a207E86FaE3b191564FA55ce7Bfee0Dde9?tab=read_contract
"0xcc2c1d45A3ECeEdec364a6B9e537AE97Fa20bEa7",
"0x32768E87f7E929616f43B02F83c0F155A942Bc6B",
],
}),
owners: gateways,
});
},
}
};

8 changes: 8 additions & 0 deletions projects/crosscurve/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
"0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490", // 3Crv
"0xc4AD29ba4B3c580e6D59105FFf484999997675Ff", // crv3crypto
"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", // WETH
"0xb7ecb2aa52aa64a717180e030241bc75cd946726", // tBTC/WBTC
],
}),
},
Expand All @@ -31,6 +32,7 @@ module.exports = {
"0x73aF1150F265419Ef8a5DB41908B700C32D49135", // crvUSDT
"0x7f90122BF0700F9E7e1F688fe926940E8839F353", // 2CRV
"0x82af49447d8a07e3bd95bd0d56f35241523fbab1", // WETH
"0x186cf879186986a20aadfb7ead50e3c20cb26cec", // 2BTC-ng
],
}),
},
Expand All @@ -46,6 +48,7 @@ module.exports = {
"0xe7a24ef0c5e95ffb0f6684b813a78f2a3ad7d171", // aave
"0xa70af99bff6b168327f9d1480e29173e757c7904", // crvUSDT
"0xdad97f7713ae9437fa9249920ec8507e5fbb23d3", // crv3crypto
"0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6", // WBTC
],
}),
},
Expand All @@ -60,6 +63,7 @@ module.exports = {
"0xc4ec3ab41182e70ca45a764ffc5c45b9a82ccc97", // crvUSDC
"0xA5E0E46462970C9Ee8C2ECadcde254c483748Ec4", // b3pool
"0xae87e5fa20f335ce14aa3b9e0616308d9ac7d4ce", // crvUSDT
"0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c", // BTCB
],
}),
},
Expand All @@ -75,6 +79,7 @@ module.exports = {
"0x1337bedc9d22ecbe766df105c9623922a27963ec", // 3pool
"0xd1b30ba128573fcd7d141c8a987961b40e047bb6", // crvUSDT
"0x4200000000000000000000000000000000000006", // WETH
"0x1dc5c0f8668a9f54ed922171d578011850ca0341", // 2BTC
],
}),
},
Expand All @@ -88,6 +93,7 @@ module.exports = {
ADDRESSES.avax.DAI, // DAI
"0x1337BedC9D22ecbe766dF105c9623922A27963EC", // av3crv
"0x1daB6560494B04473A0BE3E7D83CF3Fdf3a51828", // crv3crypto
"0x152b9d0FdC40C096757F570A51E494bd4b943E50", // BTC.b
],
}),
},
Expand All @@ -97,6 +103,7 @@ module.exports = {
tokens: [
"0xf6C5F01C7F3148891ad0e19DF78743D31E390D1f", // 4pool
"0x4200000000000000000000000000000000000006", // WETH
"0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf", // cbBTC
],
}),
},
Expand Down Expand Up @@ -129,6 +136,7 @@ module.exports = {
owner: "0xac8f44ceca92b2a4b30360e5bd3043850a0ffcbe",
tokens: [
"0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f", // WETH
"0x3aab2285ddcddad8edf438c1bab47e1a9d05a9b4", // WBTC
],
}),
},
Expand Down
1 change: 1 addition & 0 deletions projects/fwx-dex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { transformDexBalances } = require('../helper/portedTokens')

const config = {
avax: { factory: '0x2131Bdb0E0B451BC1C5A53F2cBC80B16D43634Fa', fromBlock: 46372045 },
base: { factory: '0x3512DA8F30D9AE6528e8e0787663C14Fe263Fbea', fromBlock: 15001568 },
}

module.exports = {
Expand Down
1 change: 1 addition & 0 deletions projects/helper/chains.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"scroll",
"secret",
"sei",
"shape",
"shibarium",
"shiden",
"shimmer_evm",
Expand Down
2 changes: 2 additions & 0 deletions projects/helper/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const DEFAULTS = {
ETN_RPC: "https://rpc.ankr.com/electroneum",
MATCHAIN_RPC: "https://rpc.matchscan.io,https://rpc.matchain.io",
MATCHAIN_RPC_MULTICALL: "0xDa91510Bd8c50bfa54FC2BE2dD6dAbE03eA8496c",
SHAPE_RPC:'https://mainnet.shape.network',
SHAPE_RPC_MULTICALL: "0xcA11bde05977b3631167028862bE2a173976CA11",
}

const ENV_KEYS = [
Expand Down
5 changes: 5 additions & 0 deletions projects/helper/tokenMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ const fixBalancesTokens = {
ozone: {
// '0x83048f0bf34feed8ced419455a4320a735a92e9d': { coingeckoId: "ozonechain", decimals: 18 }, // was mapped to wrong chain
},
shape: {
'0x4200000000000000000000000000000000000006': { coingeckoId: 'ethereum', decimals: 18 },
'0x48A9B22b80F566E88f0f1DcC90Ea15A8A3bAE8a4': { coingeckoId: 'ethereum', decimals: 18 },
},
hela: {
'0xf5b85320a772b436cb8105441a3db9ba29437b4a': { coingeckoId: "usd-coin", decimals: 6 },
'0xd3442073fa7ccf8a7c39d95dc125cd59497aa078': { coingeckoId: "tether", decimals: 6 },
Expand All @@ -51,6 +55,7 @@ const fixBalancesTokens = {
base: {
[ADDRESSES.base.rETH]: { coingeckoId: 'rocket-pool-eth', decimals: 18 },
'0x0a27e060c0406f8ab7b64e3bee036a37e5a62853': { coingeckoId: 'zai-stablecoin', decimals: 18 },
'0xc26c9099bd3789107888c35bb41178079b282561': { coingeckoId: 'solv-protocol-solvbtc-bbn', decimals: 18},
},
op_bnb: {
[ADDRESSES.defiverse.USDC]: { coingeckoId: 'binance-bitcoin', decimals: 18 },
Expand Down
4 changes: 3 additions & 1 deletion projects/impermax/impermaxHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ function impermaxHelper(exportsObj, config, blacklistedPools) {

async function getUVTokens(rawPools, underlyings, uSymbols, api) {
var impermaxSymbol;
var stableImpermaxSymbol;
switch (api.chain) {
case 'ethereum':
impermaxSymbol = 'UNI-V2'
Expand All @@ -110,7 +111,8 @@ function impermaxHelper(exportsObj, config, blacklistedPools) {
case 'optimism':
default:
impermaxSymbol = 'STKD-UNI-V2'
return underlyings.filter((_, i) => uSymbols[i] === impermaxSymbol)
stableImpermaxSymbol = 'STKD-STBL'
return underlyings.filter((_, i) => uSymbols[i] === impermaxSymbol || uSymbols[i] === stableImpermaxSymbol)
}
}

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

module.exports = uniTvlExport('shape', '0x74Eac16615ed3b5A8Df2d00d72C72780beDED02A')
2 changes: 1 addition & 1 deletion projects/pell/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { sumTokens2 } = require('../helper/unwrapLPs')
const { getConfig } = require('../helper/cache')

const chains = ['ethereum', 'arbitrum', 'merlin', 'bouncebit', 'btr', 'bsc', 'bsquared', 'core', 'bevm', 'mantle', 'scroll', 'bob', 'ailayer']
const chains = ['ethereum', 'arbitrum', 'merlin', 'bouncebit', 'btr', 'bsc', 'base', 'bsquared', 'core', 'bevm', 'mantle', 'scroll', 'bob', 'ailayer']

chains.forEach(chain => {
module.exports[chain] = {
Expand Down
4 changes: 2 additions & 2 deletions projects/pstake-btc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const sdk = require("@defillama/sdk");
const owner = ["bc1qajcp935tuvqakut95f0sc9qm09hxjj6egexl9d", "bc1pzq0ve6e7j6jt4ckx8uzdjyddrfda9ew8dxvrjmkxmfnj9yz68zeqgqh9cl", "bc1pjp9pg0d6wcejlg576st4s8d424zx443mdumdhvjcxx5ehnfk4xcqyru7ay", "bc1px92pntcj0wd5076nnymp787a7qczsaauuefgntxngdwvkd584xgsaagem2", "bc1pxhkczd3jq9nq50p2xll99edhxlx5dj6ztgw5pgtzszjtlvg7tl4s8ttf04"];

module.exports = {
methodology: `Total amount of BTC in ${owner}. Restaked on babylon`,
methodology: `Total amount of BTC in ${owner.join(", ")}. Restaked on babylon`,
bitcoin: {
tvl: sdk.util.sumChainTvls([sumTokensExport({ owner })]),
},
};
};
92 changes: 68 additions & 24 deletions projects/raindex/index.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,88 @@
const { cachedGraphQuery } = require("../helper/cache")
const { sumTokens2 } = require("../helper/unwrapLPs")

const orderbooks = {
arbitrum: {
address: "0x550878091b2b1506069f61ae59e3a5484bca9166",
sg: "https://api.goldsky.com/api/public/project_clv14x04y9kzi01saerx7bxpg/subgraphs/ob4-arbitrum/0.1/gn",
v3: [
{ address: "0x90caf23ea7e507bb722647b0674e50d8d6468234", start: 1710573200 },
],
v4: [
{ address: "0x550878091b2b1506069f61ae59e3a5484bca9166", start: 1727110056 },
]
},
base: {
address: "0xd2938e7c9fe3597f78832ce780feb61945c377d7",
sg: "https://api.goldsky.com/api/public/project_clv14x04y9kzi01saerx7bxpg/subgraphs/ob4-base/0.7/gn",
v3: [
{ address: "0x2aee87d75cd000583daec7a28db103b1c0c18b76", start: 1710593051 },
],
v4: [
{ address: "0xd2938e7c9fe3597f78832ce780feb61945c377d7", start: 1724856007 },
{ address: "0xa2f56f8f74b7d04d61f281be6576b6155581dcba", start: 1719934425 },
{ address: "0x32aCbdF51abe567C91b7a5cd5E52024a5Ca56844", start: 1724451937 },
{ address: "0x80DE00e3cA96AE0569426A1bb1Ae22CD4181dE6F", start: 1724168357 },
{ address: "0x7A44459893F99b9d9a92d488eb5d16E4090f0545", start: 1723404441 },
],
},
bsc: {
address: "0xd2938e7c9fe3597f78832ce780feb61945c377d7",
sg: "https://api.goldsky.com/api/public/project_clv14x04y9kzi01saerx7bxpg/subgraphs/ob4-bsc/0.1/gn",
v3: [
{ address: "0xb1d6d10561d4e1792a7c6b336b0529e4bfb5ea8f", start: 1710592564 },
],
v4: [
{ address: "0xd2938e7c9fe3597f78832ce780feb61945c377d7", start: 1727110200 },
]
},
ethereum: {
v3: [
{ address: "0xf1224a483ad7f1e9aa46a8ce41229f32d7549a74", start: 1707183011 },
],
v4: []
},
flare: {
address: "0xcee8cd002f151a536394e564b84076c41bbbcd4d",
sg: "https://api.goldsky.com/api/public/project_clv14x04y9kzi01saerx7bxpg/subgraphs/ob4-flare/0.2/gn",
v3: [
{ address: "0xb06202aA3Fe7d85171fB7aA5f17011d17E63f382", start: 1712406628 },
],
v4: [
{ address: "0xcee8cd002f151a536394e564b84076c41bbbcd4d", start: 1725430973 },
{ address: "0xaa3b14Af0e29E3854E4148f43321C4410db002bC", start: 1724097373 },
{ address: "0xA2Ac77b982A9c0999472c1De378A81d7363d926F", start: 1724079109 },
{ address: "0x582d9e838FE6cD9F8147C66A8f56A3FBE513a6A2", start: 1720717267 },
]
},
linea: {
address: "0x22410e2a46261a1b1e3899a072f303022801c764",
sg: "https://api.goldsky.com/api/public/project_clv14x04y9kzi01saerx7bxpg/subgraphs/ob4-linea/0.1/gn",
v3: [],
v4: [
{ address: "0x22410e2a46261a1b1e3899a072f303022801c764", start: 1727718941 },
{ address: "0xF97DE1c2d864d90851aDBcbEe0A38260440B8D90", start: 1722282647 },
]
},
// matchain: {
// v3: [],
// v4: [
// { address: "0x40312EDAB8Fe65091354172ad79e9459f21094E2", start: 1725285390 },
// ]
// },
polygon: {
address: "0x7d2f700b1f6fd75734824ea4578960747bdf269a",
sg: "https://api.goldsky.com/api/public/project_clv14x04y9kzi01saerx7bxpg/subgraphs/ob4-polygon/0.4/gn",
v3: [
{ address: "0xde5abe2837bc042397d80e37fb7b2c850a8d5a6c", start: 1705929922 },
{ address: "0x34200e026fbac0c902a0ff18e77a49265ca6ac99", start: 1691086795 },
{ address: "0xd3edafeb9eaa454ce26e60a66ccda73939c343a4", start: 1698953082 },
{ address: "0xc95a5f8efe14d7a20bd2e5bafec4e71f8ce0b9a6", start: 1710528345 },
{ address: "0x95c9bf235435b660aa69f519904c3f175aab393d", start: 1698859456 },
{ address: "0xdcdee0e7a58bba7e305db3abc42f4887ce8ef729", start: 1701659318 },
{ address: "0x16d518706d666c549da7bd31110623b09ef23abb", start: 1702067640 },
],
v4: [
{ address: "0x7d2f700b1f6fd75734824ea4578960747bdf269a", start: 1726792922 },
{ address: "0x2f209e5b67a33b8fe96e28f24628df6da301c8eb", start: 1721758591 },
{ address: "0xb8CD71e3b4339c8B718D982358cB32Ed272e4174", start: 1723733415 },
{ address: "0x001B302095D66b777C04cd4d64b86CCe16de55A1", start: 1723728017 },
{ address: "0xAfD94467d2eC43D9aD39f835BA758b61b2f41A0E", start: 1721746069 },
]
},
}

const query = `query MyQuery($lastId: ID) {
erc20S(where: {id_gt: $lastId} first: 1000) { id }
}`

async function tvl(api) {
const { address, sg } = orderbooks[api.chain]

const cacheKey = `raindex/${api.chain}`
const res = await cachedGraphQuery(cacheKey, sg, query, { fetchById: true, })

const tokens = res.map(t => t.id)
return api.sumTokens({ tokens, owner: address })
const { v3 = [], v4 = [] } = orderbooks[api.chain]
const owners = v3.concat(v4).map(orderbook => orderbook.address)
return sumTokens2({ api, owners, fetchCoValentTokens: true, permitFailure: true })
}

module.exports = {
Expand Down
Loading

0 comments on commit c4c219a

Please sign in to comment.