-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: margin zero #12971
feat: margin zero #12971
Conversation
The adapter at projects/margin-zero exports TVL:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
projects/margin-zero/index.js
Outdated
const chainConfig = { | ||
146: { | ||
chainName: "sonic", | ||
subgraph: "https://api.goldsky.com/api/public/project_cm58q8wq01kbk01ts09lc52kp/subgraphs/mz-subgraph/main/gn" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any way to get tokenIds of the uni v3 positions? we have helper code to unwrap and pull tvl from it, would simplify this adapter code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our contracts do not deposit through Nft position manager contract but rather directly into the pool, so we don't have the v3 tokenIds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not uni v3, but your position manager does?
https://sonicscan.org/tx/0x1ad74b93afde626b5c49174949efdc5e1cec8d5740e2fc27db9a0b19128c318e#eventlog
then, we can fetch value onchain using WagmiV3Handler ?
https://sonicscan.org/address/0xe7e225194e81729b27e8fa5c1ebd801d502c016b#readContract
projects/margin-zero/index.js
Outdated
} | ||
|
||
function LiquidityRangesQuery(first, skip) { | ||
return `{ liquidityRanges(first: ${first}, skip: ${skip}) {pool liquidity tickLower tickUpper }}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should add a liquidity_gt: 100
to filter out expired positions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, what do you mean by expired positions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@0xradishmz when liquidity is withdrawn, I saw a few positions with 0 liquidity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@0xradishmz when liquidity is withdrawn, I saw a few positions with 0 liquidity
sounds good, thanks for clarification
projects/margin-zero/index.js
Outdated
|
||
|
||
async function tvl(sdk) { | ||
if (sdk.api.chainId && chainConfig[sdk.api.chainId]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont think this check is needed
projects/margin-zero/index.js
Outdated
} | ||
|
||
|
||
async function tvl(sdk) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change sdk -> api
projects/margin-zero/index.js
Outdated
|
||
let counter = 0; | ||
while (true) { | ||
const { liquidityRanges } = await cachedGraphQuery('marign-zero/tvl', subgraphUrl, LiquidityRangesQuery(1000, 1000 * counter)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should use fetchById
here (also, update the query), like https://github.com/0xradishmz/DefiLlama-Adapters/blob/pr/0xradishmz/12971/projects/panoptic/index.js#L63
noticed that panoptic & this adapter have the same bug, if we use cached graph data, we will end up with incorrect liquidity data & wrong tvl, but using tokenIds fixing it (so we fetch liquidity on chain)
The adapter at projects/margin-zero exports TVL:
|
The adapter at projects/margin-zero exports TVL:
|
The adapter at projects/margin-zero exports TVL:
|
The adapter at projects/margin-zero exports TVL:
|
The adapter at projects/margin-zero exports TVL:
|
The adapter at projects/margin-zero exports TVL:
|
@0xradishmz thanks for the PR |
The adapter at projects/margin-zero exports TVL:
|
* Update index.js (DefiLlama#13027) * Fix: Pixel-Swap (FIX) (DefiLlama#13021) Co-authored-by: g1nt0ki <[email protected]> * track WavesBridge TVL (DefiLlama#13016) Co-authored-by: Ivan <[email protected]> * Idle DAO new Vault (DefiLlama#13028) Co-authored-by: Samster91 <samster91> Co-authored-by: g1nt0ki <[email protected]> * add hallmark * bugfix * Add support for ApeChain (DefiLlama#13032) * track Marlin Protocol TVL (DefiLlama#13029) Co-authored-by: NovaCrafter <[email protected]> * Add navigator.exchange (DefiLlama#13033) Co-authored-by: mummyguy <[email protected]> Co-authored-by: 0xpeluche <[email protected]> * sophon * fix popcorn * track sophon bridge * update blacksail * curve: track ink (DefiLlama#13039) * update drop DefiLlama#13038 * Updated TVL For Satoshi Protocol on B² Network chain (DefiLlama#13040) * update spiko * Update: BUIDL (DefiLlama#13044) * Update: D2Finance (DefiLlama#13043) Co-authored-by: dunglv-smartosc <[email protected]> * Crypto Valley Exchange (CVEX) listing (DefiLlama#13046) Co-authored-by: g1nt0ki <[email protected]> * feat(projects/silo): add support for Silo V2 on Sonic & Arbitrum (DefiLlama#13034) * feat: margin zero (DefiLlama#12971) Co-authored-by: g1nt0ki <[email protected]> * add kava config * Add Gracy Staking Season 7 * Add Gracy Staking Season 7 * add new vault to TVL calculation * delete duplicated vault * feat: add sonefi dex * swapx * revert sophon * Update Nodo TVL (DefiLlama#13052) * update bitlayer * add botto tvl * update (Segment Finance) adding bsquared chain; sunsetting staking * add base * added base factory (DefiLlama#13060) * Fix&Update: Sonicooo (ICP) (DefiLlama#13045) * Feat: Republic-Note (RWA) (DefiLlama#13041) * SwissBorg: Add new wallets (DefiLlama#13062) * Update/staking pool (DefiLlama#13058) Co-authored-by: deepak <[email protected]> * track aurum DefiLlama#13059 * Feat: Zoth zeusd (DefiLlama#13035) Co-authored-by: Paras Jain <[email protected]> * mark ztln as deprecated * Fix: Harvest-Finance (DefiLlama#13066) * Added base vaults (DefiLlama#13065) Co-authored-by: g1nt0ki <[email protected]> * feat: Update Loop TVL add CDP (DefiLlama#12819) * Add CDP Loop functionality (DefiLlama#12830) Co-authored-by: 0xd4n1el <[email protected]> * track SSI DefiLlama#12893 * Update stakedao treasury with new tokens (DefiLlama#13067) * Maxapy (DefiLlama#13072) Co-authored-by: fepvenancio <[email protected]> * added vault address (DefiLlama#13070) Co-authored-by: g1nt0ki <[email protected]> * track soneium * track sonefi-xyz * feat: add support zeta chain (DefiLlama#13079) * pluto-so add hallmarks (DefiLlama#13080) Co-authored-by: Dodi Pluto <[email protected]> * Jasper Vault : Add Support for BitLayer Chain and Update Pool Configurations (DefiLlama#13081) Co-authored-by: g1nt0ki <[email protected]> Co-authored-by: Gary.Leung <[email protected]> * correct registry address on op_bnb; add support for mantle and ethereum (DefiLlama#13082) * brBTC: add asset M-BTC on bsc chain. (DefiLlama#13077) Co-authored-by: Jun Luo <[email protected]> * update fx DefiLlama#13075 * fix: uncomment deadFrom property in multiple project configurations * fix broken adapters * Fix: Peapods-Finance (DefiLlama#13084) * Feat: Add staking TVL calculation for ParagonsDAO (DefiLlama#13083) * Fix: Datadex (DefiLlama#13089) * Add grow vault TVL calculation and refactor code (DefiLlama#13090) Co-authored-by: irlpotato <[email protected]> * Fix: Clober liquidity vault update (DefiLlama#13091) * Swell Earn (DefiLlama#13092) Co-authored-by: darvin <[email protected]> * Fix: Update Dexodus TVL calculation to include multiple owners DefiLlama#13093 * migrate tokens to coins repo * feat: add berachain vault * track untangled yield product DefiLlama#13085 * add plume factory address (DefiLlama#5) * update main * add plume chain * Add uniswap and spookyswap Sonic * add nElixir to vaults * sake-finance * add: untitledbank on soneium * Add SquidSwap uni v2 tvl adadapter * Add Superposition chain * Add Superposition RPC as env * feat: update soneium erc4626, univ3 * fix typo * Fix: Velvet-v3 (DefiLlama#13103) * add op and base to venus (DefiLlama#13104) * add double counted treehouse (DefiLlama#13107) * Add support for Ethereum, Arbitrum, and Base chains. (DefiLlama#13105) * update chi DefiLlama#13106 * Fix: Warp-Dex (DefiLlama#13108) * openeden: track USD0 supply * Update: D2Finance (DefiLlama#13110) Co-authored-by: dunglv-smartosc <[email protected]> * use token labels * update velodrome * fix asset * fix asset * include optimism * feat: Add ZKSync network for Harvest Finance TVL (DefiLlama#13116) * Add TVL for Sonic and re-order chains for readability (DefiLlama#13119) * Add momodrome project (DefiLlama#13113) Co-authored-by: 0xpeluche <[email protected]> * Add cian-bera (DefiLlama#13114) * Update the blacklisted markets from Tropykus The following markets have been deprecated and unlisted: kRIF: 0x3134b7fbfca5db217eca523eab1941452cf35163, kUSDT: 0xedaefc6b596ed38d712100976969975a37c84464 kXUSD: 0xe17551201eeaefbd625ca4fb48d49c06e7ac064b We would like to request an update to match the real data * Update KlimaDAO TVL to include autocompounder (DefiLlama#13130) Co-authored-by: g1nt0ki <[email protected]> * Update factory contract address for rbn (DefiLlama#13128) * [PDE-657] add usdc/usdt to nelixir vault (DefiLlama#13127) * fragmetric: change token account addresses (DefiLlama#13126) * Update Hedgehog-Markets support (DefiLlama#13125) * feat: added savings module for frankencoin (DefiLlama#13124) * added Neemo finance on Soneium (DefiLlama#13120) * Henjin Base (DefiLlama#13122) * Add OmniYield adapter (DefiLlama#13123) Co-authored-by: Hanumiel <[email protected]> Co-authored-by: g1nt0ki <[email protected]> * update more-markets DefiLlama#13121 * Feat: add new dualCORE vault (DefiLlama#13118) * track sacra staking DefiLlama#13117 * Two new Obelisk BTC Addresses (DefiLlama#13131) * fix: replace deprecated Levvy stats endpoint (DefiLlama#13112) * add Zarban Protocol (DefiLlama#13111) Co-authored-by: g1nt0ki <[email protected]> * Update index.js * add sailor finance project * Fix: Arcadia-v2 (DefiLlama#13138) * Update fx-Protocol TVL * Update fx-Protocol TVL * Add Sonic finance support and fix minor issues (DefiLlama#13147) Co-authored-by: TechGeorgii <[email protected]> * yel-finance: add new potion (DefiLlama#13141) * ADDED XSTRK SENSEI (DefiLlama#13146) Co-authored-by: ariyan-hashstack <[email protected]> Co-authored-by: akiraonstarknet <[email protected]> * Add Sonex uni v3 adapter (DefiLlama#13132) * Update Gyroscope TVL: adding avalanche / base factory contracts (DefiLlama#13149) * Update factory contract address. (DefiLlama#13142) * move staked LP to pool2 * Add Citrex Markets TVL calculation (DefiLlama#13150) * add tokens (DefiLlama#13134) * Track SailFish V3 and add OCC support (DefiLlama#13148) Co-authored-by: Alofe Oluwafemi <[email protected]> * update FX * minor fix * Add Metastable mUSD Adapter * add occ rpc * feat: shapeshift multichain update * add inElixir to vaults (DefiLlama#13156) * Refactor TVL calculation to filter pairs by locked value and improve error handling in validation * Add RONIN_RPC_MULTICALL to environment configuration * Update @defillama/sdk to version 5.0.112 in package-lock.json * fix typos * Add wagmi sonic * solana: remove rate limit * feat: add sonefi perp * del dex * add oBTC * Add olab * Update methodology of tvl on olab * add morph chain * feat: new collateral * bugfix * Bedrock brBTC: add kernel valut tvl * fix: Update index.js * update * refactor * Add Base chain * code refactor * Updating Gyroscope TVL: adding Sei * fix bitget * Update flipster (DefiLlama#13137) Co-authored-by: g1nt0ki <[email protected]> * Add Clave aggregator tvl (DefiLlama#13109) Co-authored-by: g1nt0ki <[email protected]> * Fix: Gearbox (DefiLlama#13176) * Add Blue Vault TVL in bluefin (DefiLlama#13143) Co-authored-by: 0xpeluche <[email protected]> * yoko live tvl (DefiLlama#13057) Co-authored-by: g1nt0ki <[email protected]> * fix: keep old addresses * add hallmark * feat: add skipCacheRead option to covalentGetTokens function * refactor meteora * break fluxbeam * optimize sol adapters * Update subgraph version of Royco (DefiLlama#13178) * Filament-V2 contracts and TVL updated (DefiLlama#13187) * code refactor * feat: add TVL Staking 5ire Dapp on ETH (DefiLlama#13183) Signed-off-by: dung5ire <[email protected]> * Feat/update address list (DefiLlama#13182) Co-authored-by: Leven <[email protected]> Co-authored-by: lorenzo <[email protected]> Co-authored-by: LevenR <[email protected]> * Add sUSDe Fluid Position and new issue YTs to Rumpel TVL (DefiLlama#13181) * Kriya (DefiLlama#13188) Co-authored-by: Knight <[email protected]> * Add cian-bera. (DefiLlama#13184) * fix ton * SwissBorg: Add new wallet (DefiLlama#13173) * Add sonic to Ulysses (DefiLlama#13174) Co-authored-by: 0xpeluche <[email protected]> * atoll protocol * new pools (DefiLlama#13191) Co-authored-by: g1nt0ki <[email protected]> * remove irrelevant hallmarks * Fix eclipse TVL to account for token2022 (DefiLlama#13194) * feat(lorenzo): update address list * chore(lorenzo): remove space * add lending program tvl to the calculation * feat: tvl of taiko-main * feat: tvl of bob-unibtc * feat: tvl of bob-lbtc * feat: tvl of sei-solv * feat(lorenzo): add new update enzoBTC address list * fix aura * ef: track new defi wallet * add new vaults * Add kyJTO * Fix: Sommelier (DefiLlama#13202) * Fix: Splash-protocol (DefiLlama#13205) * add liquity v2 helper * update sailor tvl fetch method (DefiLlama#13213) Co-authored-by: njj <[email protected]> * feat: add spectra on sonic (DefiLlama#13207) --------- Signed-off-by: dung5ire <[email protected]> Co-authored-by: 0xYFLOW <[email protected]> Co-authored-by: 0xpeluche <[email protected]> Co-authored-by: g1nt0ki <[email protected]> Co-authored-by: Ivan <[email protected]> Co-authored-by: Samster91 <[email protected]> Co-authored-by: realdealshaman <[email protected]> Co-authored-by: EVMlord <[email protected]> Co-authored-by: NovaCrafter <[email protected]> Co-authored-by: NovaCrafter <[email protected]> Co-authored-by: mummyguy <[email protected]> Co-authored-by: mummyguy <[email protected]> Co-authored-by: waynebruce0x <[email protected]> Co-authored-by: mo <[email protected]> Co-authored-by: imfeng <[email protected]> Co-authored-by: dunglv-smartosc <[email protected]> Co-authored-by: dunglv-smartosc <[email protected]> Co-authored-by: vladjito <[email protected]> Co-authored-by: Jay Welsh <[email protected]> Co-authored-by: 0xradishmz <[email protected]> Co-authored-by: LpcAries <[email protected]> Co-authored-by: backgroundjun <[email protected]> Co-authored-by: Winson Cheng <[email protected]> Co-authored-by: gengbingbing <[email protected]> Co-authored-by: Nguyen Phu Cuong <[email protected]> Co-authored-by: calebryan <[email protected]> Co-authored-by: sgmntp <[email protected]> Co-authored-by: lee <[email protected]> Co-authored-by: Antoine <[email protected]> Co-authored-by: Brandon <[email protected]> Co-authored-by: deepak <[email protected]> Co-authored-by: Paras Jain <[email protected]> Co-authored-by: 0xMBro <[email protected]> Co-authored-by: 0xd4n1el <[email protected]> Co-authored-by: 0xd4n1el <[email protected]> Co-authored-by: mevpanda <[email protected]> Co-authored-by: fepvenancio <[email protected]> Co-authored-by: noah-wasd3r <[email protected]> Co-authored-by: leeamijo <[email protected]> Co-authored-by: Dodi Triwibowo <[email protected]> Co-authored-by: Dodi Pluto <[email protected]> Co-authored-by: gaawai-l <[email protected]> Co-authored-by: Gary.Leung <[email protected]> Co-authored-by: MuesliW <[email protected]> Co-authored-by: Eggman00 <[email protected]> Co-authored-by: Jun Luo <[email protected]> Co-authored-by: 0xTea <[email protected]> Co-authored-by: irlpotato <[email protected]> Co-authored-by: 腾宇 <[email protected]> Co-authored-by: darvin <[email protected]> Co-authored-by: Tyler Tsai <[email protected]> Co-authored-by: joshualyguessennd <[email protected]> Co-authored-by: joshualyguessennd <[email protected]> Co-authored-by: Strategic Reserve <[email protected]> Co-authored-by: ungaro <[email protected]> Co-authored-by: ChunWang1998 <[email protected]> Co-authored-by: 0xnonamed <[email protected]> Co-authored-by: squidswap-ink <[email protected]> Co-authored-by: bayge <[email protected]> Co-authored-by: Define101 <[email protected]> Co-authored-by: ivicmad <[email protected]> Co-authored-by: CryptJS13 <[email protected]> Co-authored-by: tec05 <[email protected]> Co-authored-by: yongjun925 <[email protected]> Co-authored-by: Cian <[email protected]> Co-authored-by: David Carvajal <[email protected]> Co-authored-by: Chaz Schmidt <[email protected]> Co-authored-by: 0xshubh1 <[email protected]> Co-authored-by: Tommy Kang <[email protected]> Co-authored-by: James <[email protected]> Co-authored-by: samclassix <[email protected]> Co-authored-by: Sagar Chaurasia <[email protected]> Co-authored-by: Nekojita (猫舌) <[email protected]> Co-authored-by: Hanumiel <[email protected]> Co-authored-by: Hanumiel <[email protected]> Co-authored-by: thangnq <[email protected]> Co-authored-by: chainupk <[email protected]> Co-authored-by: Rico Miles Quiblat <[email protected]> Co-authored-by: Sajjad Keshavarz <[email protected]> Co-authored-by: LeeRyanj <[email protected]> Co-authored-by: njj <[email protected]> Co-authored-by: 0xAndrewClark <[email protected]> Co-authored-by: TechGeorgii <[email protected]> Co-authored-by: astroKo <[email protected]> Co-authored-by: minato <[email protected]> Co-authored-by: ariyan-hashstack <[email protected]> Co-authored-by: akiraonstarknet <[email protected]> Co-authored-by: Rick Chi <[email protected]> Co-authored-by: Lor3mipsvm <[email protected]> Co-authored-by: FedererKK <[email protected]> Co-authored-by: Alofe Oluwafemi <[email protected]> Co-authored-by: collin <[email protected]> Co-authored-by: Fireb0mb1 <[email protected]> Co-authored-by: ivanzzeth <[email protected]> Co-authored-by: David Zhang <[email protected]> Co-authored-by: mobydev02 <[email protected]> Co-authored-by: pavlo-tolok <[email protected]> Co-authored-by: wallet-flipster <[email protected]> Co-authored-by: Alim Şahin <[email protected]> Co-authored-by: burhanuddin03 <[email protected]> Co-authored-by: yoko-live <[email protected]> Co-authored-by: 0xajing <[email protected]> Co-authored-by: Uday Khokhariya <[email protected]> Co-authored-by: Rajeeb Kumar Malik <[email protected]> Co-authored-by: dung5ire <[email protected]> Co-authored-by: Leven <[email protected]> Co-authored-by: lorenzo <[email protected]> Co-authored-by: LevenR <[email protected]> Co-authored-by: Josh Levine <[email protected]> Co-authored-by: Knight <[email protected]> Co-authored-by: 0xLight <[email protected]> Co-authored-by: another_j0hn_smith <[email protected]> Co-authored-by: Zorag44 <[email protected]> Co-authored-by: 0xngmi <[email protected]> Co-authored-by: 0xodia <[email protected]> Co-authored-by: 0xajing <[email protected]> Co-authored-by: tpktpj <[email protected]> Co-authored-by: NeutralTrade <[email protected]> Co-authored-by: murmky <[email protected]> Co-authored-by: naijia.zheng <[email protected]> Co-authored-by: Ulysse Ramage <[email protected]>
NOTE
Please enable "Allow edits by maintainers" while putting up the PR.
package-lock.json
file as part of your changes, we use lockfileVersion 2, and most use v1 and using that messes up our CIName (to be shown on DefiLlama):
Margin Zero
Twitter Link:
https://x.com/marginzero_xyz
List of audit links if any:
https://github.com/marginzero-xyz/contracts/blob/main/audits/yAudits/MarginZero_yAudits_December2024_OptionsOTM.pdf
Website Link:
https://www.marginzero.xyz/
Logo (High resolution, will be shown with rounded borders):
Current TVL:
Treasury Addresses (if the protocol has treasury)
Chain:
Sonic (cross chain soon)
Coingecko ID (so your TVL can appear on Coingecko, leave empty if not listed): (https://api.coingecko.com/api/v3/coins/list)
Coinmarketcap ID (so your TVL can appear on Coinmarketcap, leave empty if not listed): (https://api.coinmarketcap.com/data-api/v3/map/all?listing_status=active,inactive,untracked&start=1&limit=10000)
Short Description (to be shown on DefiLlama):
MarginZero is an omni-chain, oracle-less and permission-less options & protected perpetual protocol
Token address and ticker if any:
Category (full list at https://defillama.com/categories) *Please choose only one:
Options
Oracle Provider(s): Specify the oracle(s) used (e.g., Chainlink, Band, API3, TWAP, etc.):
Implementation Details: Briefly describe how the oracle is integrated into your project:
Documentation/Proof: Provide links to documentation or any other resources that verify the oracle's usage:
forkedFrom (Does your project originate from another project):
methodology (what is being counted as tvl, how is tvl being calculated):
TVL is the total amount of tokens deposited in DEX's through Margin Zero's handler contracts.
Github org/user (Optional, if your code is open source, we can track activity):
https://github.com/marginzero-xyz