-
Notifications
You must be signed in to change notification settings - Fork 826
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* init * calculate apy+tvl * tvl calculation using BigInt to avoid potential overflows * reads 10-day moving average --------- Co-authored-by: 0xwildhare <[email protected]>
- Loading branch information
1 parent
7b7f779
commit 5afa690
Showing
2 changed files
with
82 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,28 @@ | ||
{ | ||
"totalSupply": { | ||
"inputs": [], | ||
"name": "totalSupply", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "totalSupply", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
"ethPerAPEth": { | ||
"inputs": [], | ||
"name": "ethPerAPEth", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "ethPerAPEth", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
} | ||
} |
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,54 @@ | ||
const utils = require('../utils'); | ||
const sdk = require('@defillama/sdk'); | ||
const abi = require('./abi.json'); | ||
const axios = require('axios'); | ||
|
||
const APETH = '0xAaAaAAaBC6CBc3A1FD3a0fe0FDec43251C6562F5'; | ||
const ETH = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE' | ||
|
||
|
||
const getApy = async () => { | ||
const apy = await utils.getData('https://wallet.aquapatina.com/api/apy_current'); | ||
|
||
tvl = await tvlUsd(); | ||
|
||
return [ | ||
{ | ||
pool: APETH, | ||
chain: utils.formatChain('ethereum'), | ||
project: 'aqua-patina', | ||
symbol: utils.formatSymbol('APETH'), | ||
tvlUsd: tvl, | ||
apy: apy.data.apy, | ||
}, | ||
]; | ||
}; | ||
|
||
async function tvlUsd() { | ||
|
||
const supply = await sdk.api.abi.call({ | ||
target: APETH, | ||
abi: abi['totalSupply'], | ||
chain: 'ethereum' | ||
}); | ||
|
||
const multiplier = await sdk.api.abi.call({ | ||
target: APETH, | ||
abi: abi['ethPerAPEth'], | ||
chain: 'ethereum' | ||
}); | ||
|
||
const ethPrice = ( | ||
await axios.get('https://coins.llama.fi/prices/current/coingecko:ethereum') | ||
).data.coins['coingecko:ethereum'].price; | ||
|
||
let tvl = BigInt(supply.output) * BigInt(multiplier.output) / BigInt(1e18) / BigInt(1e18); | ||
|
||
return Number(tvl) * ethPrice; | ||
} | ||
|
||
module.exports = { | ||
timetravel: false, | ||
apy: getApy, | ||
url: 'https://aquapatina.eth/', | ||
}; |