-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtesting.ts
51 lines (48 loc) · 1.46 KB
/
testing.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { holdings } from "./holdings";
import { totalCounterPartyLiqudity } from "./totalCounterPartyLiqudity";
import { BigNumber, utils } from "ethers";
import { ethers } from "ethers";
const moonBeamDiamondAddress = "0xcF79046a903F17e886E8d35d3A52FeBF188e077E";
const moonBeamRpcUrl = "https://rpc.ankr.com/moonbeam";
const provider = new ethers.providers.JsonRpcProvider(moonBeamRpcUrl);
const erc20Abi = ["function decimals() public view returns (uint8)"];
const bigToNumber = (number: BigNumber, decimals: BigNumber) => {
return utils.formatUnits(number, decimals);
};
const holding = await holdings(
moonBeamDiamondAddress,
"Beam4Pool",
moonBeamRpcUrl
);
console.log("Holdings");
for (let i = 0; i < holding.length; i++) {
const tokenContract = new ethers.Contract(
holding[i].tokenAddress,
erc20Abi,
provider
);
const decimals = await tokenContract.decimals();
console.log(
`${holding[i].tokenAddress}: ${bigToNumber(holding[i].balance, decimals)}`
);
}
const totalLiqudity = await totalCounterPartyLiqudity(
moonBeamDiamondAddress,
"Beam4Pool",
moonBeamRpcUrl
);
console.log("Total Liquidity");
for (let i = 0; i < totalLiqudity.length; i++) {
const tokenContract = new ethers.Contract(
totalLiqudity[i].tokenAddress,
erc20Abi,
provider
);
const decimals = await tokenContract.decimals();
console.log(
`${totalLiqudity[i].tokenAddress}: ${bigToNumber(
totalLiqudity[i].balance,
decimals
)}`
);
}