Skip to content
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

ZETH/WETH yield adapter #1062

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions src/adaptors/zeroliquid/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
const utils = require('../utils');
const { ethers } = require('ethers');

const liquidity_endpoint = 'https://api.thegraph.com/subgraphs/name/zackzeroliquid/zeroliquid-liquidity-mining'
const pricing_endpoint = 'https://api.thegraph.com/subgraphs/name/zackzeroliquid/zeroliquid'
const zETH = "0x776280f68ad33c4d49e6846507b7dbaf7811c89f";
const WETH = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";

const query_liquidity = `{
zeroLiquids {
amountETH
amountZETH
amountETHPOL
amountZETHPOL
currentMiningReward
}
}`

const query_price = `{
zethPrice : token(id: "${zETH}") {
drivedUSD
name
}
wethPrice : token(id: "${WETH}") {
drivedUSD
name
}
}`

const poolsFunction = async () => {
const data_liquidity = await fetch(liquidity_endpoint,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: JSON.stringify(
{query : query_liquidity}
),
},
)
.then((r) => r.json())
.then((data) => {
return data.data.zeroLiquids[0];
});


const data_pricing = await fetch(pricing_endpoint,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: JSON.stringify(
{query : query_price}
),
},
)
.then((r) => r.json())
.then((data) => {
return data.data;
});

console.log(data_pricing, "data_lllll")

const zethPool = {
pool: '0xb2C57D651dB0FcCc96cABda11191DF25E05B88b6',
chain: utils.formatChain('Ethereum'),
project: 'zeroliquid',
symbol: utils.formatSymbol('zETH-WETH'),
tvlUsd: (data_pricing.zethPrice.drivedUSD * data_liquidity.amountZETH / 1e18) + (data_pricing.wethPrice.drivedUSD * data_liquidity.amountETH / 1e18),
apy: ((data_liquidity.currentMiningReward * 12) / ((data_liquidity.amountETH-data_liquidity.amountETHPOL) + (data_liquidity.amountZETH - data_liquidity.amountZETHPOL)) ) * 100,
};

return [zethPool]; // Anchor only has a single pool with APY
};

module.exports = {
timetravel: false,
apy: poolsFunction,
url: 'https://app.zeroliquid.xyz/earn',
};
Loading