Skip to content

Commit

Permalink
zETH yield added (#1062)
Browse files Browse the repository at this point in the history
  • Loading branch information
barrosozeroliquid authored Nov 3, 2023
1 parent c13958c commit 268f9c7
Showing 1 changed file with 84 additions and 0 deletions.
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',
};

0 comments on commit 268f9c7

Please sign in to comment.