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:
  Add SolanaHub Staked SOL (hubSOL)  (DefiLlama#12221)
  Add newly supported Rumpel assets (Primarly YTs) (DefiLlama#12223)
  AeraFinance - added new arbitrum Aera Vault Factory (DefiLlama#12224)
  track royco
  add commonwealth tvl (DefiLlama#12219)
  feat: add new base vault (w/morpho) on bakerfi (DefiLlama#12220)
  add ezETH and uniBTC vaults
  Add SKALE IMA Bridge (Native) to SKALE TVL (DefiLlama#12214)
  Add additional reserve managers and tokens (DefiLlama#12215)
  Magma v3 (DefiLlama#12216)
  Fix  pumpbtc adapter(addresses of other chains not read properly) (DefiLlama#12217)
  Add STAB Protocol adapter (DefiLlama#12218)
  🥕 added Carrot tvl adapter (DefiLlama#12205)
  Fix: Velvet v3 (DefiLlama#12213)
  add wallet
  add wallets
  [WIP] -Fix: Maker (DefiLlama#12211)
  Update Desyn strategy Pools (DefiLlama#12136)
  feat: udpate pumpbtc adapter logic (DefiLlama#12147)
  • Loading branch information
buchaoqun committed Nov 11, 2024
2 parents 50957d4 + f29014b commit 142090e
Show file tree
Hide file tree
Showing 27 changed files with 549 additions and 512 deletions.
4 changes: 4 additions & 0 deletions projects/aera/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ const config = {
{
address: "0xaF2762E1F75DeCdb8d240576e7A2CEc1A365cD46",
fromBlock: 203397910
},
{
address: '0x49b428ea1cd536e7d103e9729ea14400785e30ec',
fromBlock: 245595750
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion projects/bakerfi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const config = {
vaults: ["0x4c6d58749126FEBb1D28E8B8FdE97DC3107996d3"]
},
base: {
vaults: ["0x37327c99bBc522e677a97d01021dB20227faF60A"]
vaults: ["0x37327c99bBc522e677a97d01021dB20227faF60A", "0x892022FE1431fdE03836725BBD0f0380e21E2095"]
},
ethereum: {
vaults: ["0x01280b3683fE20Dc9cCF4D9526418F252871E4F7"]
Expand Down
50 changes: 50 additions & 0 deletions projects/carrot/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const { PublicKey } = require('@solana/web3.js');
const { Program } = require("@project-serum/anchor");
const { getConnection, getProvider, getTokenSupplies } = require('../helper/solana')

async function tvl(api) {

const connection = getConnection()
const programId = 'CarrotwivhMpDnm27EHmRLeQ683Z1PufuqEmBZvD282s'
const testVaultExclusion = '2AV35oWyAuSN5wmuy26VD5JirjVpXkfkv5ZMCQ2LtpuV' // our test vault should not be included in TVL

// Use this method to track TVL via the token...
// const CRT_MINT = 'CRTx1JouZhzSU6XytsE42UQraoGqiHgxabocVfARTy2s';
// await getTokenSupplies(CRT_MINT, {api})

// Use this method to track TVL via onchain state of each Vault by adding the balance at each strategy.
const programAccounts = await connection.getProgramAccounts(new PublicKey(programId), {
filters: [{
memcmp: {
offset: 8,
bytes: 'CarrotLYPhQzYL4fEsTUvEzw5QDaMGSZUENHSkh7qzQa' // carrot keeper
},
},]
});

const provider = getProvider();
const idl = await Program.fetchIdl(programId, provider)
const program = new Program(idl, programId, provider)

programAccounts.forEach(({ account, pubkey }, i) => {
if(pubkey.toBase58() !== testVaultExclusion) {
const { assets, strategies } = program.coder.accounts.decode(
"Vault",
account.data
);
const assetMap = {}
assets.forEach(({assetId, mint }) => assetMap[assetId] = mint.toString())

strategies.forEach(i => {
api.add(assetMap[i.assetId], i.balance.toString())
})
}
})
}

module.exports = {
doublecounted: true,
timetravel: false,
methodology: 'TVL calculated by calling the onchain state of the CRT Vault accounts, and tallying the balance of each strategy.',
solana: { tvl },
}
26 changes: 26 additions & 0 deletions projects/commonwealth/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { staking } = require('../helper/staking');

const TREASURY = [
'0xdE70B8BC5215BdF03f839BB8cD0F639D4E3E2881',
'0xA205fD6A798A9Ba8b107A00b8A6a5Af742d6aCb5',
'0x990eCdf73704f9114Ee28710D171132b5Cfdc6f0',
'0xa653879692D4D0e6b6E0847ceDd58eAD2F1CC136'
]


const CONTRACTS = [
'0xf4aa59f5192856f41ae19caab4929ccd3a265e70', // staked
'0x7519461fbd96abb539c770d57f38c2e91f8262aa',
'0xd7e31990883250e53314b15ee555345f04d011e8',
'0x87412c03979cc19c60071f5f98313a7cbe9f6d65', // rewards

];

const WLTH = '0x99b2B1A2aDB02B38222ADcD057783D7e5D1FCC7D';

module.exports = {
base: {
tvl: () => ({}),
staking: staking(CONTRACTS, WLTH)
}
};
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.

6 changes: 3 additions & 3 deletions projects/helper/bitcoin-book/fetchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ module.exports = {
return Object.values(await getConfig('solv-protocol/solv-btc-lst', API_URL)).flat();
},
pumpBTC: async () => {
const API_URL = 'https://dashboard.pumpbtc.xyz/api/dashboard/btc/addresses'
return getConfig('pumpbtc', undefined, {
const API_URL = 'https://dashboard.pumpbtc.xyz/api/dashboard/asset/tokenowners'
return getConfig('pumpbtc/v2', undefined, {
fetcher: async () => {
const { data } = await axios.get(API_URL)
return data.data || []
return data.data.bitcoin.owners
}
})
},
Expand Down
8 changes: 7 additions & 1 deletion projects/helper/tokenMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,13 @@ const fixBalancesTokens = {
'0x93919784C523f39CACaa98Ee0a9d96c3F32b593e': { coingeckoId: 'universal-btc', decimals: 18 },
'0xC75D7767F2EdFbc6a5b18Fc1fA5d51ffB57c2B37': { coingeckoId: 'pumpbtc', decimals: 18 },
'0xCAbAE6f6Ea1ecaB08Ad02fE02ce9A44F09aebfA2': { coingeckoId: 'wrapped-bitcoin', decimals: 8 },
}
},
bsc: {
'0x6B2a01A5f79dEb4c2f3c0eDa7b01DF456FbD726a': { coingeckoId: 'universal-btc', decimals: 8 },
},
arbitrum: {
'0x6B2a01A5f79dEb4c2f3c0eDa7b01DF456FbD726a': { coingeckoId: 'universal-btc', decimals: 8 },
},
}

ibcChains.forEach(chain => fixBalancesTokens[chain] = { ...ibcMappings, ...(fixBalancesTokens[chain] || {}) })
Expand Down
Loading

0 comments on commit 142090e

Please sign in to comment.