Skip to content

Commit a2a7c3d

Browse files
Merge branch 'main' into main
2 parents 523af58 + 21841ec commit a2a7c3d

File tree

231 files changed

+3592
-3379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

231 files changed

+3592
-3379
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Also, don't hesitate to send a message on [our discord](https://discord.defillam
99
1010
1. PLEASE PLEASE **enable "Allow edits by maintainers" while putting up the PR.**
1111
2. Once your adapter has been merged, it takes time to show on the UI. No need to notify us on Discord.
12-
3. TVL must be computed from blockchain data (reason: https://github.com/DefiLlama/DefiLlama-Adapters/discussions/432), if you have trouble with creating a the adapter, please hop onto our discord, we are happy to assist you.
12+
3. TVL must be computed from blockchain data (reason: https://github.com/DefiLlama/DefiLlama-Adapters/discussions/432), if you have trouble with creating the adapter, please hop onto our discord, we are happy to assist you.
1313
4. **For updating listing info** It is a different repo, you can find your listing in this file: https://github.com/DefiLlama/defillama-server/blob/master/defi/src/protocols/data2.ts, you can edit it there and put up a PR
1414
5. Do not edit/push `package-lock.json` file as part of your changes, we use lockfileVersion 2, and most use v1 and using that messes up our CI
1515
6. No need to go to our discord and announce that you've created a PR, we monitor all PRs and will review it asap
@@ -20,7 +20,7 @@ Please send answers to questions there https://github.com/DefiLlama/DefiLlama-Ad
2020

2121
## Work in progress
2222

23-
This is a work in progress. DefiLlama aims to be transparent, accurate and open source.
23+
This is a work in progress. DefiLlama aims to be transparent, accurate, and open source.
2424

2525
If you have any suggestions, want to contribute or want to chat, please join [our discord](https://discord.defillama.com/) and drop a message.
2626

@@ -44,4 +44,4 @@ POLYGON_RPC="..."
4444
The name of each rpc is `{CHAIN-NAME}_RPC`, and the name we use for each chain can be found [here](https://unpkg.com/@defillama/sdk@latest/build/providers.json). If you run into issues with a chain make sure to update the sdk with `npm update @defillama/sdk`.
4545

4646
## Adapter rules
47-
- Never add extra npm packages, if you need a chain-level package for your chain, ask us and we'll consider it, but we can't accept any npm package that is project-specific
47+
- Never add extra npm packages, if you need a chain-level package for your chain, ask us, and we'll consider it, but we can't accept any npm package that is project-specific

funding.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"opRetro": {
3+
"projectId": "0xae07bfec2c3c90937679f8c8c5c32e80407c09903aa03d1b5e5a075e67592b86"
4+
}
5+
}

package-lock.json

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/LiquidOps/index.js

Lines changed: 75 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,99 @@
11
const { post } = require("../helper/http.js")
2+
const methodologies = require('../helper/methodologies');
23

34

45
const endpoint = 'https://cu.ao-testnet.xyz'
56
const controllerId = 'SmmMv0rJwfIDVM3RvY2-P729JFYwhdGSeGo2deynbfY'
67
const tickerTransformations = {
78
'qAR': 'arweave',
89
'wUSDC': 'usd-coin',
9-
};
10-
10+
};
1111

12-
async function tvl() {
1312

14-
const supportedTokensRes = await DryRun(controllerId, "Get-Tokens")
15-
const supportedTokens = JSON.parse(supportedTokensRes.Messages[0].Data)
16-
const balancesPromises = supportedTokens.map(async balanceObject => {
17-
const infoRes = await DryRun(balanceObject.oToken, "Info");
18-
const tagsObject = Object.fromEntries(
19-
infoRes.Messages[0].Tags.map((tag) => [tag.name, tag.value])
20-
);
21-
const ticker = tickerTransformations[balanceObject.ticker] || balanceObject.ticker;
22-
return { [`coingecko:${ticker}`]: scaleBalance(tagsObject['Cash'], tagsObject['Denomination']) };
23-
});
24-
25-
const balancesArray = await Promise.all(balancesPromises);
26-
27-
const combinedBalances = Object.assign({}, ...balancesArray);
13+
// Access AO on chain data via the node endpoint
14+
async function DryRun(target, action) {
15+
const response = await post(`${endpoint}/dry-run?process-id=${target}`, {
16+
Id: "1234", Target: target, Owner: "1234", Anchor: "0", Data: "1234",
17+
Tags: [
18+
["Target", target],
19+
["Action", action],
20+
["Data-Protocol", "ao"],
21+
["Type", "Message"],
22+
["Variant", "ao.TN.1"]
23+
].map(([name, value]) => ({ name, value }))
24+
});
25+
return response
26+
}
2827

29-
return combinedBalances
3028

31-
}
29+
function scaleBalance(amount, denomination) {
30+
if (amount === "0") return 0;
31+
const denominationVal = parseInt(denomination);
32+
const len = amount.length;
3233

34+
if (denominationVal >= len) {
35+
return parseFloat("0." + "0".repeat(denominationVal - len) + amount.replace(/0+$/, ""));
36+
}
3337

38+
const integerPart = amount.substr(0, len - denominationVal);
39+
const fractionalPart = amount.substr(len - denominationVal).replace(/0+$/, "");
3440

35-
// Access AO on chain data via the node endpoint
36-
async function DryRun(target, action) {
37-
const response = await post(`${endpoint}/dry-run?process-id=${target}`, {
38-
Id: "1234", Target: target, Owner: "1234", Anchor: "0", Data: "1234",
39-
Tags: [
40-
["Target", target],
41-
["Action", action],
42-
["Data-Protocol", "ao"],
43-
["Type", "Message"],
44-
["Variant", "ao.TN.1"]
45-
].map(([name, value]) => ({ name, value }))
46-
});
47-
return response
41+
if (fractionalPart === "") return parseInt(integerPart);
42+
43+
return parseFloat(integerPart + "." + fractionalPart);
4844
}
4945

50-
function scaleBalance(amount, denomination) {
51-
const scaledDivider = BigInt(10) ** BigInt(denomination)
52-
const balance = BigInt(amount) / scaledDivider
53-
return Number(balance)
46+
47+
async function getTokenInfos() {
48+
const supportedTokensRes = await DryRun(controllerId, "Get-Tokens")
49+
const supportedTokens = JSON.parse(supportedTokensRes.Messages[0].Data)
50+
const tokenInfo = await Promise.all(
51+
supportedTokens.map(async (balanceObject) => {
52+
const infoRes = await DryRun(balanceObject.oToken, "Info");
53+
const tagsObject = Object.fromEntries(
54+
infoRes.Messages[0].Tags.map((tag) => [tag.name, tag.value])
55+
);
56+
const ticker = tickerTransformations[balanceObject.ticker] || balanceObject.ticker;
57+
58+
return {
59+
ticker: `coingecko:${ticker}`,
60+
cash: scaleBalance(tagsObject['Cash'], tagsObject['Denomination']),
61+
totalBorrows: scaleBalance(tagsObject['Total-Borrows'], tagsObject['Denomination'])
62+
};
63+
})
64+
);
65+
66+
return tokenInfo;
67+
}
68+
69+
70+
async function tvl() {
71+
const tokensInfo = await getTokenInfos();
72+
const combinedBalances = {};
73+
74+
tokensInfo.forEach(token => {
75+
combinedBalances[token.ticker] = token.cash;
76+
});
77+
78+
return combinedBalances;
5479
}
5580

5681

82+
async function borrowed() {
83+
const tokensInfo = await getTokenInfos();
84+
const combinedBalances = {};
85+
86+
tokensInfo.forEach(token => {
87+
combinedBalances[token.ticker] = token.totalBorrows;
88+
});
89+
90+
return combinedBalances;
91+
}
92+
5793

5894
module.exports = {
59-
methodology: "TVL is calculated by getting all supported token pools on LiquidOps, then the lent token balances from the pools and adding up all token USD values provided by CoinGecko.",
60-
ao: { tvl },
95+
methodology: methodologies.lendingMarket,
96+
ao: { tvl, borrowed },
6197
};
62-
98+
// node test.js projects/LiquidOps/index.js
6399

projects/MantraProtocol/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const ADDRESSES = require('../helper/coreAssets.json')
12
const { sumTokens2 } = require('../helper/unwrapLPs')
23

34
const MANTRA_CONTRACT_PER_CHAIN = {

projects/MultiSwap/index.js

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11

2-
const sdk = require('@defillama/sdk')
3-
const { createIncrementArray } = require('../helper/utils')
4-
const { sumTokens2 } = require('../helper/unwrapLPs')
52
const token0ABI = 'address:token0'
63
const token1ABI = 'address:token1'
74

@@ -25,41 +22,16 @@ const config = {
2522
},
2623
}
2724

28-
module.exports = {}
29-
3025
Object.keys(config).forEach(chain => {
3126
const { positionManager } = config[chain]
3227
module.exports[chain] = {
33-
tvl: async function tvl(_, _b, { [chain]: block }) {
34-
35-
const { output: poolCount } = await sdk.api.abi.call({
36-
target: positionManager,
37-
abi: abis.poolsCount,
38-
chain, block,
39-
})
40-
const calls = createIncrementArray(poolCount).map(i => ({ params: i }))
41-
let { output: poolAddreses } = await sdk.api.abi.multiCall({
42-
target: positionManager,
43-
abi: abis.poolsAddresses,
44-
calls,
45-
chain, block,
46-
})
47-
48-
poolAddreses = poolAddreses.map(i => ({ target: i.output }))
49-
const { output: token0s } = await sdk.api.abi.multiCall({
50-
abi: token0ABI,
51-
calls: poolAddreses,
52-
chain, block,
53-
})
54-
const { output: token1s } = await sdk.api.abi.multiCall({
55-
abi: token1ABI,
56-
calls: poolAddreses,
57-
chain, block,
58-
})
59-
const toa = []
60-
token0s.forEach(({ input: { target }, output }) => toa.push([output, target]))
61-
token1s.forEach(({ input: { target }, output }) => toa.push([output, target]))
62-
return sumTokens2({ chain, block, tokensAndOwners: toa })
28+
tvl: async function tvl(api) {
29+
const pools = await api.fetchList({ lengthAbi: abis.poolsCount, itemAbi: abis.poolsAddresses, target: positionManager})
30+
const token0s = await api.multiCall({ abi: token0ABI, calls: pools})
31+
const token1s = await api.multiCall({ abi: token1ABI, calls: pools})
32+
const ownerTokens = []
33+
pools.forEach((pool, i) => ownerTokens.push([[token0s[i], token1s[i]], pool]))
34+
return api.sumTokens({ ownerTokens })
6335
}
6436
}
6537
})

projects/SuperHedge/index.js

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,56 @@
11
const ADDRESSES = require('../helper/coreAssets.json')
2-
const SH_VAULT_1_CURRENCY = ADDRESSES.ethereum.USDe; // USDe Ethereum
3-
const SH_VAULT_1_PT = '0x8A47b431A7D947c6a3ED6E42d501803615a97EAa'; // Pendle pt token
4-
const SH_VAULT_1 = '0xDF59153DA47dc7c39505261D423BAf14c48D23A6'; // SHProduct Vault
52

6-
const SH_VAULT_2_CURRENCY = '0x7c1156e515aa1a2e851674120074968c905aaf37'; // lvlUSD Ethereum
7-
const SH_VAULT_2_PT = '0x9bca74f805ab0a22ddd0886db0942199a0feba71'; // Pendle pt token
8-
const SH_VAULT_2 = '0xca287B0E1F4d498D3e9C637E611eb37AAA553B2a'; // SHProduct Vault 2
3+
// Vault configs
4+
const vaults = [
5+
// BTC Bullish Call-Spread eUSDe
6+
{
7+
currency: '0x90d2af7d622ca3141efa4d8f1f24d86e5974cc8f',
8+
pt: '0x50d2c7992b802eef16c04feadab310f31866a545',
9+
vault: '0x2324bb9F7d651E0169B9df9194937759E08Acfa9'
10+
},
11+
// BTC Bullish Call-Spread lvlUSD
12+
{
13+
currency: '0x7c1156e515aa1a2e851674120074968c905aaf37',
14+
pt: '0x9bca74f805ab0a22ddd0886db0942199a0feba71',
15+
vault: '0x93c318E595F58E4Ffc8779E35E574832D8d9a5Dc'
16+
},
17+
// BTC Bearish Put eUSDe
18+
{
19+
currency: '0x90d2af7d622ca3141efa4d8f1f24d86e5974cc8f',
20+
pt: '0x50d2c7992b802eef16c04feadab310f31866a545',
21+
vault: '0x9021d933D1Ef4c31550201C8A9522Ab15b3e6d65'
22+
},
23+
// BTC Bearish Put lvlUSD
24+
{
25+
currency: '0x7c1156e515aa1a2e851674120074968c905aaf37',
26+
pt: '0x9bca74f805ab0a22ddd0886db0942199a0feba71',
27+
vault: '0x1fEcD2E54648476bD6AeA2f5B8BBD5155166816e'
28+
}
29+
]
930

1031
async function tvl(api) {
11-
12-
const currencyBalance1 = await api.call({
13-
abi: 'erc20:balanceOf',
14-
target: SH_VAULT_1_CURRENCY,
15-
params: [SH_VAULT_1],
16-
});
17-
api.add(SH_VAULT_1_CURRENCY, currencyBalance1)
18-
19-
const ptBalance1 = await api.call({
20-
abi: 'erc20:balanceOf',
21-
target: SH_VAULT_1_PT,
22-
params: [SH_VAULT_1],
23-
});
24-
api.add(SH_VAULT_1_PT, ptBalance1)
25-
26-
const currencyBalance2 = await api.call({
27-
abi: 'erc20:balanceOf',
28-
target: SH_VAULT_2_CURRENCY,
29-
params: [SH_VAULT_2],
30-
});
31-
api.add(SH_VAULT_2_CURRENCY, currencyBalance2)
32-
33-
const ptBalance2 = await api.call({
34-
abi: 'erc20:balanceOf',
35-
target: SH_VAULT_2_PT,
36-
params: [SH_VAULT_2],
37-
});
38-
api.add(SH_VAULT_2_PT, ptBalance2)
32+
// Process all vaults in a loop
33+
for (const { currency, pt, vault } of vaults) {
34+
// Get currency balance
35+
const currencyBalance = await api.call({
36+
abi: 'erc20:balanceOf',
37+
target: currency,
38+
params: [vault],
39+
});
40+
api.add(currency, currencyBalance);
41+
42+
// Get PT token balance
43+
const ptBalance = await api.call({
44+
abi: 'erc20:balanceOf',
45+
target: pt,
46+
params: [vault],
47+
});
48+
api.add(pt, ptBalance);
49+
}
3950
}
4051

4152
module.exports = {
42-
methodology: 'counts the number of stablecoins and pt tokens in the SuperHedge Vault contracts.',
53+
methodology: 'Counts the number of stablecoins and PT tokens in the SuperHedge Vault contracts.',
4354
ethereum: {
4455
tvl,
4556
}

projects/TradeOgre/index.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const { cexExports } = require('../helper/cex')
2+
3+
const config = {
4+
avax: {
5+
owners: [
6+
'0x4648451b5f87ff8f0f7d622bd40574bb97e25980'
7+
]
8+
},
9+
bsc: {
10+
owners: [
11+
'0x4648451b5f87ff8f0f7d622bd40574bb97e25980'
12+
]
13+
},
14+
ethereum: {
15+
owners: [
16+
'0x4648451b5f87ff8f0f7d622bd40574bb97e25980'
17+
],
18+
},
19+
polygon: {
20+
owners: [
21+
'0x4648451b5f87ff8f0f7d622bd40574bb97e25980'
22+
]
23+
},
24+
ripple: {
25+
owners: [
26+
'rhsZa1NR9GqA7NtQjDe5HtYWZxPAZ4oGrE'
27+
]
28+
},
29+
tron: {
30+
owners: [
31+
'TBQc1xRWp2G6iUQTD51Lczrk7zbjTRoGRE'
32+
]
33+
},
34+
}
35+
36+
module.exports = cexExports(config)
37+
module.exports.methodology = 'All reserves information can be found on block explorers.'

projects/VeryLongSwap/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ module.exports = uniV3Export({
55
astrzk: { factory: factory, fromBlock: 156301, },
66
});
77

8+
module.exports.deadFrom = '2025-03-31' // Astar ZK is shutting down on March 31, 2025: https://docs.astar.network/docs/learn/zkEVM

projects/aave-v3/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const CONFIG = {
1919
bsc: ['0x23dF2a19384231aFD114b036C14b6b03324D79BC'],
2020
era: ['0x5F2A704cE47B373c908fE8A29514249469b52b99'],
2121
linea: ['0x2D97F8FA96886Fd923c065F5457F9DDd494e3877'],
22-
sonic: ['0x306c124fFba5f2Bc0BcAf40D249cf19D492440b9']
22+
sonic: ['0x306c124fFba5f2Bc0BcAf40D249cf19D492440b9'],
23+
celo: ['0x33b7d355613110b4E842f5f7057Ccd36fb4cee28']
2324
};
2425

2526
const fetchReserveData = async (api, poolDatas, isBorrowed) => {

0 commit comments

Comments
 (0)