forked from DefiLlama/yield-server
-
Notifications
You must be signed in to change notification settings - Fork 0
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
b01a135
commit bacd0c3
Showing
3 changed files
with
26 additions
and
21 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,23 @@ | ||
const poolAbi = require('./abis/pool.json') | ||
const { web3 } = require('./connection') | ||
|
||
const unitsMap = { | ||
6: 'mwei', | ||
18: 'ether' | ||
} | ||
|
||
async function getPoolValues(poolAddress: string, tokenDecimals: number) { | ||
const pool = new web3.eth.Contract(poolAbi, poolAddress) | ||
|
||
const poolValueRaw: string = await pool.methods.poolValue().call() | ||
const poolValue = web3.utils.fromWei(poolValueRaw, unitsMap[tokenDecimals]) | ||
|
||
const liquidValueRaw: string = await pool.methods.liquidValue().call() | ||
const liquidValue = web3.utils.fromWei(liquidValueRaw, unitsMap[tokenDecimals]) | ||
|
||
return { poolValue, liquidValue } | ||
} | ||
|
||
module.exports = { | ||
getPoolValues | ||
} |
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