Skip to content

Commit

Permalink
Update Desyn strategy Pools (DefiLlama#12136)
Browse files Browse the repository at this point in the history
Co-authored-by: g1nt0ki <[email protected]>
  • Loading branch information
2 people authored and twothirtyfive committed Dec 11, 2024
1 parent eb9ddef commit 8816a0d
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 124 deletions.
12 changes: 12 additions & 0 deletions projects/desyn-basisTrading/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { getTvlFunction, chains } = require("../desyn-farm/helper");

module.exports = {
doublecounted: true,
methodology: 'Combines on-chain airdrops with stable returns from basis trading on Binance.',
}

chains.forEach(chain => {
module.exports[chain] = {
tvl: getTvlFunction('StrategyType3', true)
}
})
59 changes: 59 additions & 0 deletions projects/desyn-farm/helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const { getConfig } = require('../helper/cache')

const chains = ["ethereum", "arbitrum", "btr", "mode", "zklink", "core", "ailayer", "linea", "merlin", "scroll"];

const abi = {
getBalance: "function getBalance(address) view returns (uint256)"
}

async function getInfoListPool(strategy_type, chain) {
const data = await getConfig('desyn/' + strategy_type, `https://api.desyn.io/etf/defillama/get_pool_list?strategy_type=${strategy_type}`)
return data.data.config[chain]?.safePools
}

// This is aSTETH,
// before the design of the semi-closed soETH,
// the contract in order to limit the closure of the time,
// the user can still deposit,
// so he was given a maximum value of the balance,
// which will become negative after adding any number, blocking the user to put in
const leverageStaking = '0x1982b2F5814301d4e9a8b0201555376e62F82428'


function getTvlFunction(strategy_type, isDoubleCounted) {
return async (api) => {
const pools = await getInfoListPool(strategy_type, api.chain)
if (!pools?.length) return;
const tokens = await api.multiCall({ abi: 'address[]:getCurrentTokens', calls: pools })
const calls = []
const tokensAndOwners = []
const allTokens = []
let i = 0

for (const pool of pools) {
for (const token of tokens[i]) {
if (!isDoubleCounted) {
tokensAndOwners.push([token, pool])
} else {
calls.push({ target: pool, params: token })
allTokens.push(token)
}
}
i++
}

if (!isDoubleCounted) return api.sumTokens({ tokensAndOwners })

const allBals = await api.multiCall({ abi: abi.getBalance, calls })
api.add(allTokens, allBals)

if (strategy_type === 'StrategyType2')
api.removeTokenBalance(leverageStaking)
}
}


module.exports = {
getTvlFunction,
chains
}
46 changes: 9 additions & 37 deletions projects/desyn-farm/index.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,16 @@
const { getLogs } = require('../helper/cache/getLogs')
const { getTvlFunction, chains } = require("./helper");

module.exports = {
doublecounted: true,
methodology: 'On-chain restaking',
hallmarks: [
[1719734400, "Launched on Merlin Chain"],
[1718092800, "DeSyn KelpDAO Restaking Fund Launched"],
[1713340800, "Restaking Fund Series Launched"]
],
methodology: 'Focused on airdrops from DeSyn and new chains.',
}

const config = {
merlin: { factory: '0x790b4ee7998A93702f29e56f8b615eF35BE5af43', fromBlock: 11260440},
}

const abi = {
getBalance: "function getBalance(address) view returns (uint256)"
}

Object.keys(config).forEach(chain => {
const {factory, fromBlock, } = config[chain]
chains.forEach(chain => {
module.exports[chain] = {
tvl: async (api) => {
const logs = await getLogs({
api,
target: factory,
eventAbi: 'event LOG_NEW_POOL (address indexed caller, address indexed pool)',
onlyArgs: true,
fromBlock,
})

const pools = logs.map(i=>i.pool)
const tokens = await api.multiCall({ abi: 'address[]:getCurrentTokens', calls: pools})
const calls = []
const allTokens = []
let i = 0
for (const pool of pools) {
for (const token of tokens[i]) {
calls.push({ target: pool, params: token })
allTokens.push(token)
}
i++
}
const allBals = await api.multiCall({ abi: abi.getBalance, calls })
api.add(allTokens, allBals)
}
tvl: getTvlFunction('StrategyType1', false)
}
})
48 changes: 0 additions & 48 deletions projects/desyn-farm1/index.js

This file was deleted.

12 changes: 12 additions & 0 deletions projects/desyn-yieldAggregator/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { getTvlFunction, chains } = require("../desyn-farm/helper");

module.exports = {
doublecounted: true,
methodology: 'Engages with DeFi protocols like Lending, DEX, and Restaking, offering both airdrops and structured yield options.',
}

chains.forEach(chain => {
module.exports[chain] = {
tvl: getTvlFunction('StrategyType2', true)
}
})
39 changes: 0 additions & 39 deletions projects/desyn/index.js

This file was deleted.

0 comments on commit 8816a0d

Please sign in to comment.