Skip to content

Commit d356afd

Browse files
Update Desyn strategy Pools (DefiLlama#12136)
Co-authored-by: g1nt0ki <[email protected]>
1 parent fb6927e commit d356afd

File tree

6 files changed

+92
-124
lines changed

6 files changed

+92
-124
lines changed

projects/desyn-basisTrading/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const { getTvlFunction, chains } = require("../desyn-farm/helper");
2+
3+
module.exports = {
4+
doublecounted: true,
5+
methodology: 'Combines on-chain airdrops with stable returns from basis trading on Binance.',
6+
}
7+
8+
chains.forEach(chain => {
9+
module.exports[chain] = {
10+
tvl: getTvlFunction('StrategyType3', true)
11+
}
12+
})

projects/desyn-farm/helper.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
const { getConfig } = require('../helper/cache')
2+
3+
const chains = ["ethereum", "arbitrum", "btr", "mode", "zklink", "core", "ailayer", "linea", "merlin", "scroll"];
4+
5+
const abi = {
6+
getBalance: "function getBalance(address) view returns (uint256)"
7+
}
8+
9+
async function getInfoListPool(strategy_type, chain) {
10+
const data = await getConfig('desyn/' + strategy_type, `https://api.desyn.io/etf/defillama/get_pool_list?strategy_type=${strategy_type}`)
11+
return data.data.config[chain]?.safePools
12+
}
13+
14+
// This is aSTETH,
15+
// before the design of the semi-closed soETH,
16+
// the contract in order to limit the closure of the time,
17+
// the user can still deposit,
18+
// so he was given a maximum value of the balance,
19+
// which will become negative after adding any number, blocking the user to put in
20+
const leverageStaking = '0x1982b2F5814301d4e9a8b0201555376e62F82428'
21+
22+
23+
function getTvlFunction(strategy_type, isDoubleCounted) {
24+
return async (api) => {
25+
const pools = await getInfoListPool(strategy_type, api.chain)
26+
if (!pools?.length) return;
27+
const tokens = await api.multiCall({ abi: 'address[]:getCurrentTokens', calls: pools })
28+
const calls = []
29+
const tokensAndOwners = []
30+
const allTokens = []
31+
let i = 0
32+
33+
for (const pool of pools) {
34+
for (const token of tokens[i]) {
35+
if (!isDoubleCounted) {
36+
tokensAndOwners.push([token, pool])
37+
} else {
38+
calls.push({ target: pool, params: token })
39+
allTokens.push(token)
40+
}
41+
}
42+
i++
43+
}
44+
45+
if (!isDoubleCounted) return api.sumTokens({ tokensAndOwners })
46+
47+
const allBals = await api.multiCall({ abi: abi.getBalance, calls })
48+
api.add(allTokens, allBals)
49+
50+
if (strategy_type === 'StrategyType2')
51+
api.removeTokenBalance(leverageStaking)
52+
}
53+
}
54+
55+
56+
module.exports = {
57+
getTvlFunction,
58+
chains
59+
}

projects/desyn-farm/index.js

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,16 @@
1-
const { getLogs } = require('../helper/cache/getLogs')
1+
const { getTvlFunction, chains } = require("./helper");
22

33
module.exports = {
4-
doublecounted: true,
5-
methodology: 'On-chain restaking',
4+
hallmarks: [
5+
[1719734400, "Launched on Merlin Chain"],
6+
[1718092800, "DeSyn KelpDAO Restaking Fund Launched"],
7+
[1713340800, "Restaking Fund Series Launched"]
8+
],
9+
methodology: 'Focused on airdrops from DeSyn and new chains.',
610
}
711

8-
const config = {
9-
merlin: { factory: '0x790b4ee7998A93702f29e56f8b615eF35BE5af43', fromBlock: 11260440},
10-
}
11-
12-
const abi = {
13-
getBalance: "function getBalance(address) view returns (uint256)"
14-
}
15-
16-
Object.keys(config).forEach(chain => {
17-
const {factory, fromBlock, } = config[chain]
12+
chains.forEach(chain => {
1813
module.exports[chain] = {
19-
tvl: async (api) => {
20-
const logs = await getLogs({
21-
api,
22-
target: factory,
23-
eventAbi: 'event LOG_NEW_POOL (address indexed caller, address indexed pool)',
24-
onlyArgs: true,
25-
fromBlock,
26-
})
27-
28-
const pools = logs.map(i=>i.pool)
29-
const tokens = await api.multiCall({ abi: 'address[]:getCurrentTokens', calls: pools})
30-
const calls = []
31-
const allTokens = []
32-
let i = 0
33-
for (const pool of pools) {
34-
for (const token of tokens[i]) {
35-
calls.push({ target: pool, params: token })
36-
allTokens.push(token)
37-
}
38-
i++
39-
}
40-
const allBals = await api.multiCall({ abi: abi.getBalance, calls })
41-
api.add(allTokens, allBals)
42-
}
14+
tvl: getTvlFunction('StrategyType1', false)
4315
}
4416
})

projects/desyn-farm1/index.js

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const { getTvlFunction, chains } = require("../desyn-farm/helper");
2+
3+
module.exports = {
4+
doublecounted: true,
5+
methodology: 'Engages with DeFi protocols like Lending, DEX, and Restaking, offering both airdrops and structured yield options.',
6+
}
7+
8+
chains.forEach(chain => {
9+
module.exports[chain] = {
10+
tvl: getTvlFunction('StrategyType2', true)
11+
}
12+
})

projects/desyn/index.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)