forked from DefiLlama/DefiLlama-Adapters
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add MetaStreet Airdrop Pass functionality (DefiLlama#11367)
* add metastreet-airdrop-pass * code refactor * code refactor --------- Co-authored-by: wegory <[email protected]>
- Loading branch information
1 parent
6e7e2f4
commit be55c84
Showing
4 changed files
with
45 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const { getLogs2, } = require('../helper/cache/getLogs') | ||
const { getUniqueAddresses } = require('../helper/tokenMapping') | ||
const { sumTokens2 } = require('../helper/unwrapLPs') | ||
|
||
async function tvl(api) { | ||
const tokens = await getLogs2({ | ||
api, | ||
factory: '0x00000000000000447e69651d841bD8D104Bed493', | ||
fromBlock: 18184587, | ||
eventAbi: 'event DelegateERC721 (address indexed from, address indexed to, address indexed contract, uint256 tokenId, bytes32 rights, bool enable)', | ||
customCacheFunction: ({ cache, logs }) => { | ||
if (!cache.logs) cache.logs = [] | ||
cache.logs.push(...logs.map(i => i.contract)) | ||
cache.logs = getUniqueAddresses(cache.logs) | ||
return cache | ||
}, | ||
}) | ||
return sumTokens2({ owner: '0xc2e257476822377dfb549f001b4cb00103345e66', tokens, permitFailure: true, sumChunkSize: 50 }) | ||
} | ||
|
||
module.exports = { | ||
ethereum: { | ||
tvl, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
async function tvl(api) { | ||
const factory = '0xA8a7e295c19b7D9239A992B8D9C053917b8841C6' | ||
const delegateV2 = '0x00000000000000447e69651d841bD8D104Bed493' | ||
const delegations = await api.call({ abi: abi.getIncomingDelegations, target: delegateV2, params: factory }) | ||
delegations.filter(i => i.type_ === '3').forEach(i => api.add(i.contract_, 1)) | ||
} | ||
|
||
module.exports = { | ||
ethereum: { | ||
tvl, | ||
}, | ||
methodology: "TVL is calculated by summing the value of underlying NFTs of the delegation tokens owned by MetaStreet Airdrop Pass Factory." | ||
} | ||
|
||
const abi = { | ||
"getIncomingDelegations": "function getIncomingDelegations(address to) view returns ((uint8 type_, address to, address from, bytes32 rights, address contract_, uint256 tokenId, uint256 amount)[] delegations_)", | ||
} |