Skip to content

Commit 6fe0587

Browse files
authored
Add support for solidly veNfts (DefiLlama#9138)
* add support to unwrap solidly veNfts * update inverse treasury with veNFTs * refacto tangible with unwrapSolidlyVeNft util
1 parent a6e3115 commit 6fe0587

File tree

5 files changed

+70
-31
lines changed

5 files changed

+70
-31
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"tokensOfOwner": "function tokensOfOwner(address) view returns (uint256[])",
3+
"ownerToNFTokenIdList": "function ownerToNFTokenIdList(address, uint256) view returns (uint256)",
4+
"tokenOfOwnerByIndex": "function tokenOfOwnerByIndex(address _owner, uint256 _tokenIndex) view returns (uint256)",
5+
"locked": "function locked(uint256 _tokenId) view returns (tuple(int128 amount, uint256 end, bool isPermanent))",
6+
"lockedSimple": "function locked(uint256 _tokenId) view returns (tuple(int128 amount, uint256 end))"
7+
}

projects/helper/unwrapLPs.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ const { requery } = require('./requery')
88
const { getChainTransform, getFixBalances } = require('./portedTokens')
99
const { getUniqueAddresses, normalizeAddress } = require('./tokenMapping')
1010
const creamAbi = require('./abis/cream.json')
11-
const { isLP, log, sliceIntoChunks, isICHIVaultToken, } = require('./utils')
11+
const { isLP, log, sliceIntoChunks, isICHIVaultToken, createIncrementArray } = require('./utils')
1212
const { sumArtBlocks, whitelistedNFTs, } = require('./nft')
1313
const wildCreditABI = require('../wildcredit/abi.json');
1414
const { covalentGetTokens, } = require("./token");
15+
const SOLIDLY_VE_NFT_ABI = require('./abis/solidlyVeNft.json');
1516

1617
const lpReservesAbi = 'function getReserves() view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast)'
1718
const lpSuppliesAbi = "uint256:totalSupply"
@@ -697,6 +698,7 @@ async function sumTokens2({
697698
sumChunkSize = undefined,
698699
uniV3ExtraConfig = {},
699700
resolveICHIVault = false,
701+
solidlyVeNfts = [],
700702
}) {
701703
if (api) {
702704
chain = api.chain ?? chain
@@ -733,6 +735,14 @@ async function sumTokens2({
733735
nftTokens.forEach((tokens, i) => ownerTokens.push([[tokens, coreNftTokens].flat(), owners[i]]))
734736
}
735737

738+
if(solidlyVeNfts.length) {
739+
await Promise.all(
740+
owners.map(
741+
owner => solidlyVeNfts.map(veNftDetails => unwrapSolidlyVeNft({ api, owner, ...veNftDetails }))
742+
)
743+
.flat()
744+
)
745+
}
736746

737747
if (ownerTokens.length) {
738748
ownerTokens.map(([tokens, owner]) => {
@@ -901,6 +911,20 @@ async function unwrapConvexRewardPools({ api, tokensAndOwners }) {
901911
return api.getBalances()
902912
}
903913

914+
async function unwrapSolidlyVeNft({ api, baseToken, veNft, owner, hasTokensOfOwnerAbi = false, isAltAbi = false, lockedAbi, nftIdGetterAbi }) {
915+
let tokenIds
916+
const _lockedAbi = lockedAbi || (hasTokensOfOwnerAbi || isAltAbi ? SOLIDLY_VE_NFT_ABI.lockedSimple : SOLIDLY_VE_NFT_ABI.locked)
917+
const _nftIdGetterAbi = nftIdGetterAbi || (isAltAbi ? SOLIDLY_VE_NFT_ABI.tokenOfOwnerByIndex : SOLIDLY_VE_NFT_ABI.ownerToNFTokenIdList)
918+
if(hasTokensOfOwnerAbi) {
919+
tokenIds = await api.call({ abi: SOLIDLY_VE_NFT_ABI.tokensOfOwner, params: owner, target: veNft })
920+
} else {
921+
const count = await api.call({ abi: 'erc20:balanceOf', target: veNft, params: owner })
922+
tokenIds = await api.multiCall({ abi: _nftIdGetterAbi, calls: createIncrementArray(count).map(i => ({ params: [owner, i] })), target: veNft })
923+
}
924+
const bals = await api.multiCall({ abi: _lockedAbi, calls: tokenIds, target: veNft })
925+
bals.forEach(i => api.add(baseToken, i.amount))
926+
}
927+
904928
module.exports = {
905929
PANCAKE_NFT_ADDRESS,
906930
unwrapUniswapLPs,
@@ -925,4 +949,5 @@ module.exports = {
925949
unwrapMakerPositions,
926950
unwrap4626Tokens,
927951
unwrapConvexRewardPools,
952+
unwrapSolidlyVeNft,
928953
}

projects/tangible/insurance-fund-base.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
const VE_VELO_ABI = require('./abi/VeVeloNFT.json');
2-
const { createIncrementArray } = require('../helper/utils');
1+
const { unwrapSolidlyVeNft } = require('../helper/unwrapLPs');
32

43
const insuranceTokensBase = {
54
AERO: '0x940181a94A35A4569E4529A3CDfB74e38FD98631',
@@ -8,10 +7,7 @@ const insuranceTokensBase = {
87
const VE_AERO_NFT = "0xeBf418Fe2512e7E6bd9b87a8F0f294aCDC67e6B4";
98

109
async function getInsuranceFundValueBase(api, INSURANCE_FUND) {
11-
const count = await api.call({ abi: 'erc20:balanceOf', target: VE_AERO_NFT, params: INSURANCE_FUND })
12-
const tokenIds = await api.multiCall({ abi: VE_VELO_ABI.ownerToNFTokenIdList, calls: createIncrementArray(count).map(i => ({ params: [INSURANCE_FUND, i] })), target: VE_AERO_NFT })
13-
const bals = await api.multiCall({ abi: VE_VELO_ABI.locked, calls: tokenIds, target: VE_AERO_NFT })
14-
bals.forEach(i => api.add(insuranceTokensBase.AERO, i.amount))
10+
await unwrapSolidlyVeNft({ api, baseToken: insuranceTokensBase.AERO, veNft: VE_AERO_NFT, owner: INSURANCE_FUND })
1511
}
1612

1713
module.exports = {

projects/tangible/insurance-fund-optimism.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
const VE_VELO_ABI = require('./abi/VeVeloNFT.json');
2-
const { createIncrementArray } = require('../helper/utils');
1+
const { unwrapSolidlyVeNft } = require('../helper/unwrapLPs');
32

43
const insuranceTokensOp = {
54
VELO: '0x9560e827af36c94d2ac33a39bce1fe78631088db',
@@ -8,10 +7,7 @@ const insuranceTokensOp = {
87
const VE_VELO_NFT = "0xFAf8FD17D9840595845582fCB047DF13f006787d";
98

109
async function getInsuranceFundValueOp(api, INSURANCE_FUND) {
11-
const count = await api.call({ abi: 'erc20:balanceOf', target: VE_VELO_NFT, params: INSURANCE_FUND })
12-
const tokenIds = await api.multiCall({ abi: VE_VELO_ABI.ownerToNFTokenIdList, calls: createIncrementArray(count).map(i => ({ params: [INSURANCE_FUND, i]})), target: VE_VELO_NFT })
13-
const bals = await api.multiCall({ abi: VE_VELO_ABI.locked, calls: tokenIds, target: VE_VELO_NFT })
14-
bals.forEach(i => api.add(insuranceTokensOp.VELO, i.amount))
10+
await unwrapSolidlyVeNft({ api, baseToken: insuranceTokensOp.VELO, veNft: VE_VELO_NFT, owner: INSURANCE_FUND })
1511
}
1612

1713
module.exports = {

projects/treasury/inverse.js

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { treasuryExports, nullAddress } = require("../helper/treasury");
33

44
const inv = "0x41D5D79431A913C4aE7d69a668ecdfE5fF9DFB68";
55
const anchorTreasury = "0x926df14a23be491164dcf93f4c468a50ef659d5b";
6-
const multisig = "0x9D5Df30F475CEA915b1ed4C0CCa59255C897b61B";
6+
const treasurymultisig = "0x9D5Df30F475CEA915b1ed4C0CCa59255C897b61B";
77
const opmultisig = "0xa283139017a2f5bade8d8e25412c600055d318f8";
88
const bnbmultisig = "0xf7da4bc9b7a6bb3653221ae333a9d2a2c2d5bda7";
99
const basemultisig = "0x586CF50c2874f3e3997660c0FD0996B090FB9764";
@@ -12,7 +12,7 @@ const arbmultisig2 = "0x23dEDab98D7828AFBD2B7Ab8C71089f2C517774a";
1212
const polmultisig = "0x5D18b089e838DFFbb417A87874435175F3A9B000";
1313
const avaxmultisig = "0x1A927B237a57421C414EB511a33C4B82C2718677";
1414
const pcmultisig = "0x4b6c63e6a94ef26e2df60b89372db2d8e211f1b7"
15-
const treasurymultisig = "0x943dbdc995add25a1728a482322f9b3c575b16fb"
15+
const bugbountymultisig = "0x943dbdc995add25a1728a482322f9b3c575b16fb"
1616
const fedchair = "0x8f97cca30dbe80e7a8b462f1dd1a51c32accdfc8"
1717

1818
module.exports = treasuryExports({
@@ -35,14 +35,15 @@ module.exports = treasuryExports({
3535
ADDRESSES.ethereum.SAFE,
3636
"0x22915f309EC0182c85cD8331C23bD187fd761360", // DOLA USDC Stable Pool Aura Deposit Vault
3737
"0x7f50786A0b15723D741727882ee99a0BF34e3466", // Stake DAO sdCRV Gauge
38+
"0xf24d8651578a55b0c119b9910759a351a3458895", // sdBAL
3839
"0x445494F823f3483ee62d854eBc9f58d5B9972A25", // 50DOLA-50DBR
3940
"0xb204BF10bc3a5435017D3db247f56dA601dFe08A", // 50DOLA-50WETH
4041
"0x7e05540A61b531793742fde0514e6c136b5fbAfE", // xFODL
4142
"0xAD038Eb671c44b853887A7E32528FaB35dC5D710", // DBR
4243
"0x0a6B1d9F920019BAbc4De3F10c94ECB822106104",
4344
"0x73E02EAAb68a41Ea63bdae9Dbd4b7678827B2352",
4445
],
45-
owners: [anchorTreasury, multisig, pcmultisig, treasurymultisig, fedchair],
46+
owners: [anchorTreasury, treasurymultisig, pcmultisig, bugbountymultisig, fedchair],
4647
ownTokens: [
4748
inv,
4849
"0x73E02EAAb68a41Ea63bdae9Dbd4b7678827B2352", // Uniswap INV/ETH LP
@@ -60,9 +61,12 @@ module.exports = treasuryExports({
6061
nullAddress,
6162
ADDRESSES.optimism.USDC,
6263
ADDRESSES.optimism.USDC_CIRCLE,
63-
"0x8aE125E8653821E851F12A49F7765db9a9ce7384", // DOLA
64-
"0xFAf8FD17D9840595845582fCB047DF13f006787d", // veVELO
65-
],
64+
"0x8aE125E8653821E851F12A49F7765db9a9ce7384", // DOLA
65+
"0x9560e827af36c94d2ac33a39bce1fe78631088db", // VELO
66+
],
67+
solidlyVeNfts: [
68+
{ baseToken: "0x9560e827af36c94d2ac33a39bce1fe78631088db", veNft: "0xFAf8FD17D9840595845582fCB047DF13f006787d" },// veVelo
69+
],
6670
owners: [opmultisig],
6771
ownTokens: [],
6872
},
@@ -71,21 +75,25 @@ module.exports = treasuryExports({
7175
nullAddress,
7276
ADDRESSES.base.USDC,
7377
ADDRESSES.base.USDbC,
74-
"0x4621b7A9c75199271F773Ebd9A499dbd165c3191", // DOLA
75-
"0xeBf418Fe2512e7E6bd9b87a8F0f294aCDC67e6B4", // veAERO
78+
"0x4621b7A9c75199271F773Ebd9A499dbd165c3191", // DOLA
7679
"0x940181a94A35A4569E4529A3CDfB74e38FD98631", // AERO
77-
],
80+
],
81+
solidlyVeNfts: [
82+
{ baseToken: "0x940181a94A35A4569E4529A3CDfB74e38FD98631", veNft: "0xeBf418Fe2512e7E6bd9b87a8F0f294aCDC67e6B4" },// veVelo
83+
],
7884
owners: [basemultisig],
7985
ownTokens: [],
8086
},
8187
bsc: {
8288
tokens: [
8389
nullAddress,
8490
ADDRESSES.bsc.WBNB,
85-
"0x2F29Bc0FFAF9bff337b31CBe6CB5Fb3bf12e5840", // DOLA
86-
"0xfBBF371C9B0B994EebFcC977CEf603F7f31c070D", // veTHE
91+
"0x2F29Bc0FFAF9bff337b31CBe6CB5Fb3bf12e5840", // DOLA
8792
"0xF4C8E32EaDEC4BFe97E0F595AdD0f4450a863a11", // THENA
88-
],
93+
],
94+
solidlyVeNfts: [
95+
{ isAltAbi: true, baseToken: "0xF4C8E32EaDEC4BFe97E0F595AdD0f4450a863a11", veNft: "0xfBBF371C9B0B994EebFcC977CEf603F7f31c070D" },// veTHENA
96+
],
8997
owners: [bnbmultisig],
9098
ownTokens: [],
9199
},
@@ -94,9 +102,11 @@ module.exports = treasuryExports({
94102
nullAddress,
95103
ADDRESSES.avax.USDC,
96104
'0x221743dc9E954bE4f86844649Bf19B43D6F8366d', // DOLA
97-
'0xeeee99b35Eb6aF5E7d76dd846DbE4bcc0c60cA1d', // SNEK
98-
'0xeeee3Bf0E550505C0C17a8432065F2f6b9D06350', // veSNEK
99-
],
105+
'0xeeee99b35Eb6aF5E7d76dd846DbE4bcc0c60cA1d', // SNEK
106+
],
107+
solidlyVeNfts: [
108+
{ isAltAbi: true, baseToken: "0xeeee99b35Eb6aF5E7d76dd846DbE4bcc0c60cA1d", veNft: "0xeeee3Bf0E550505C0C17a8432065F2f6b9D06350" },// veSNEK
109+
],
100110
owners: [avaxmultisig],
101111
ownTokens: [],
102112
},
@@ -106,9 +116,14 @@ module.exports = treasuryExports({
106116
ADDRESSES.arbitrum.DAI,
107117
ADDRESSES.arbitrum.ARB,
108118
ADDRESSES.arbitrum.WETH,
109-
"0xAAA6C1E32C55A7Bfa8066A6FAE9b42650F262418", // RAM
110-
"0xAAA343032aA79eE9a6897Dab03bef967c3289a06", // veRAM
119+
"0xAAA6C1E32C55A7Bfa8066A6FAE9b42650F262418", // RAM
111120
],
121+
solidlyVeNfts: [
122+
{ isAltAbi: true, baseToken: "0xAAA6C1E32C55A7Bfa8066A6FAE9b42650F262418", veNft: "0xAAA343032aA79eE9a6897Dab03bef967c3289a06" },// veRAM
123+
{ isAltAbi: true, baseToken: "0x5DB7b150c5F38c5F5db11dCBDB885028fcC51D68", veNft: "0x450330Df68E1ed6e0683373D684064bDa9115fEe" },// veSTR
124+
{ isAltAbi: true, baseToken: "0x463913D3a3D3D291667D53B8325c598Eb88D3B0e", veNft: "0x29d3622c78615A1E7459e4bE434d816b7de293e4" },// veSLIZ
125+
{ hasTokensOfOwnerAbi: true, baseToken: "0x15b2fb8f08E4Ac1Ce019EADAe02eE92AeDF06851", veNft: "0x9A01857f33aa382b1d5bb96C3180347862432B0d" },// veCHRONOS
126+
],
112127
owners: [arbmultisig2, arbmultisig],
113128
ownTokens: [],
114129
},
@@ -117,7 +132,7 @@ module.exports = treasuryExports({
117132
nullAddress,
118133
ADDRESSES.polygon.USDC,
119134
'0xbC2b48BC930Ddc4E5cFb2e87a45c379Aab3aac5C', // DOLA
120-
],
135+
],
121136
owners: [polmultisig],
122137
},
123138
});

0 commit comments

Comments
 (0)