@merkl/api 0.10.137 → 0.10.138
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
|
|
1
|
-
import { BN2Number, CTokenInterface, CompFork, CompoundSubCampaignType, LayerBankERC20Interface, YEAR, } from "@sdk";
|
1
|
+
import { BN2Number, CTokenInterface, CompFork, CompoundSubCampaignType, IonicERC20_INTERFACE, LayerBankERC20Interface, YEAR, } from "@sdk";
|
2
2
|
import { log } from "../../../utils/logger";
|
3
3
|
import { Pricer } from "../../../utils/pricer";
|
4
4
|
export async function CompoundDynamicData(_chainId, campaigns) {
|
@@ -6,11 +6,20 @@ export async function CompoundDynamicData(_chainId, campaigns) {
|
|
6
6
|
const calls = [];
|
7
7
|
for (const campaign of campaigns) {
|
8
8
|
if (campaign.campaignSubType === CompoundSubCampaignType.supply) {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
if (campaign.campaignParameters.compFork === CompFork.Ionic) {
|
10
|
+
calls.push({
|
11
|
+
allowFailure: true,
|
12
|
+
callData: IonicERC20_INTERFACE.encodeFunctionData("getTotalUnderlyingSupplied"),
|
13
|
+
target: campaign.campaignParameters.targetToken,
|
14
|
+
});
|
15
|
+
}
|
16
|
+
else {
|
17
|
+
calls.push({
|
18
|
+
allowFailure: true,
|
19
|
+
callData: CTokenInterface.encodeFunctionData("totalSupply"),
|
20
|
+
target: campaign.campaignParameters.targetToken,
|
21
|
+
});
|
22
|
+
}
|
14
23
|
}
|
15
24
|
else {
|
16
25
|
if (campaign.campaignParameters.compFork === CompFork.LayerBank) {
|
@@ -41,7 +50,12 @@ export async function CompoundDynamicData(_chainId, campaigns) {
|
|
41
50
|
let totalSupplyTargetToken;
|
42
51
|
if (campaign.campaignSubType === CompoundSubCampaignType.supply) {
|
43
52
|
try {
|
44
|
-
|
53
|
+
if (campaign.campaignParameters.compFork === CompFork.Ionic) {
|
54
|
+
totalSupplyTargetToken = BN2Number(IonicERC20_INTERFACE.decodeFunctionResult("getTotalUnderlyingSupplied", result[i++])[0], campaign.campaignParameters.decimalsUnderlyingToken);
|
55
|
+
}
|
56
|
+
else {
|
57
|
+
totalSupplyTargetToken = BN2Number(CTokenInterface.decodeFunctionResult("totalSupply", result[i++])[0], campaign.campaignParameters.decimalsUnderlyingToken);
|
58
|
+
}
|
45
59
|
}
|
46
60
|
catch {
|
47
61
|
log.warn(`Error getting totalSupply for campaign ${campaign.campaignId} and token ${campaign.campaignParameters.targetToken}`);
|
@@ -1,7 +1,5 @@
|
|
1
1
|
import { type Forwarder, type ForwarderParameters, type MerklChainId } from "@sdk";
|
2
|
-
import { utils } from "ethers";
|
3
2
|
import type { UncachedResult } from "../../../utils/execute";
|
4
|
-
export declare const IONICCERC20_INTERFACE: utils.Interface;
|
5
3
|
type FetchedCampaign = {
|
6
4
|
rewardToken: string;
|
7
5
|
symbolRewardToken: string;
|
@@ -1,7 +1,4 @@
|
|
1
|
-
import { BN2Number, CTokenInterface, CompFork, CompoundSubCampaignType, ERC20Interface, LayerBankERC20Interface, } from "@sdk";
|
2
|
-
import { utils } from "ethers";
|
3
|
-
const IONICCERC20_ABI = ["function borrowBalanceCurrent(address account) public view returns (uint256)"];
|
4
|
-
export const IONICCERC20_INTERFACE = new utils.Interface(IONICCERC20_ABI);
|
1
|
+
import { BN2Number, CTokenInterface, CompFork, CompoundSubCampaignType, ERC20Interface, IonicERC20_INTERFACE, LayerBankERC20Interface, } from "@sdk";
|
5
2
|
export async function getCompoundUserPositions(user, _chainId, campaigns) {
|
6
3
|
/**
|
7
4
|
* Fetch user positions
|
@@ -19,7 +16,7 @@ export async function getCompoundUserPositions(user, _chainId, campaigns) {
|
|
19
16
|
case CompFork.Ionic || CompFork.Venus:
|
20
17
|
calls.push({
|
21
18
|
allowFailure: true,
|
22
|
-
callData:
|
19
|
+
callData: IonicERC20_INTERFACE.encodeFunctionData("borrowBalanceCurrent", [user]),
|
23
20
|
target: campaigns[mainParameter].targetToken,
|
24
21
|
});
|
25
22
|
break;
|
@@ -62,7 +59,7 @@ export async function getCompoundUserPositions(user, _chainId, campaigns) {
|
|
62
59
|
switch (campaigns[mainParameter].compFork) {
|
63
60
|
case CompFork.Ionic:
|
64
61
|
case CompFork.Venus:
|
65
|
-
balance = BN2Number(
|
62
|
+
balance = BN2Number(IonicERC20_INTERFACE.decodeFunctionResult("borrowBalanceCurrent", result[i])[0], campaigns[mainParameter].decimalsUnderlyingToken);
|
66
63
|
break;
|
67
64
|
case CompFork.LayerBank:
|
68
65
|
balance = BN2Number(LayerBankERC20Interface.decodeFunctionResult("borrowBalanceOf", result[i])[0], campaigns[mainParameter].decimalsUnderlyingToken);
|