-
Notifications
You must be signed in to change notification settings - Fork 833
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c13958c
commit 268f9c7
Showing
1 changed file
with
84 additions
and
0 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,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', | ||
}; |