@merkl/api 0.10.351 → 0.10.352
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/libs/campaigns/campaignTypes/CompoundDynamicData.js +27 -4
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/GenericProcessor.d.ts +1 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/GenericProcessor.js +1 -0
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import { BN2Number, CTokenInterface, CompFork, CompoundSubCampaignType, IonicERC20_INTERFACE, LayerBankERC20Interface, YEAR, } from "@sdk";
|
1
|
+
import { BN2Number, CTokenInterface, CompFork, CompoundSubCampaignType, ERC20Interface, 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) {
|
@@ -14,10 +14,24 @@ export async function CompoundDynamicData(_chainId, campaigns) {
|
|
14
14
|
});
|
15
15
|
}
|
16
16
|
else {
|
17
|
+
if (campaign.campaignParameters.compFork === CompFork.LayerBank) {
|
18
|
+
calls.push({
|
19
|
+
allowFailure: true,
|
20
|
+
callData: LayerBankERC20Interface.encodeFunctionData("totalBorrow"),
|
21
|
+
target: campaign.campaignParameters.targetToken,
|
22
|
+
});
|
23
|
+
}
|
24
|
+
else {
|
25
|
+
calls.push({
|
26
|
+
allowFailure: true,
|
27
|
+
callData: CTokenInterface.encodeFunctionData("totalBorrows"),
|
28
|
+
target: campaign.campaignParameters.targetToken,
|
29
|
+
});
|
30
|
+
}
|
17
31
|
calls.push({
|
18
32
|
allowFailure: true,
|
19
|
-
callData:
|
20
|
-
target: campaign.campaignParameters.
|
33
|
+
callData: ERC20Interface.encodeFunctionData("balanceOf", [campaign.campaignParameters.targetToken]),
|
34
|
+
target: campaign.campaignParameters.underlyingToken,
|
21
35
|
});
|
22
36
|
}
|
23
37
|
}
|
@@ -48,13 +62,22 @@ export async function CompoundDynamicData(_chainId, campaigns) {
|
|
48
62
|
const dynamicData = [];
|
49
63
|
for (const campaign of campaigns) {
|
50
64
|
let totalSupplyTargetToken;
|
65
|
+
let borrowedAmount;
|
66
|
+
let nonUtilizedSupplied;
|
51
67
|
if (campaign.campaignSubType === CompoundSubCampaignType.supply) {
|
52
68
|
try {
|
53
69
|
if (campaign.campaignParameters.compFork === CompFork.Ionic) {
|
54
70
|
totalSupplyTargetToken = BN2Number(IonicERC20_INTERFACE.decodeFunctionResult("getTotalUnderlyingSupplied", result[i++])[0], campaign.campaignParameters.decimalsUnderlyingToken);
|
55
71
|
}
|
56
72
|
else {
|
57
|
-
|
73
|
+
if (campaign.campaignParameters.compFork === CompFork.LayerBank) {
|
74
|
+
borrowedAmount = BN2Number(LayerBankERC20Interface.decodeFunctionResult("totalBorrow", result[i++])[0], campaign.campaignParameters.decimalsUnderlyingToken);
|
75
|
+
}
|
76
|
+
else {
|
77
|
+
borrowedAmount = BN2Number(CTokenInterface.decodeFunctionResult("totalBorrows", result[i++])[0], campaign.campaignParameters.decimalsUnderlyingToken);
|
78
|
+
}
|
79
|
+
nonUtilizedSupplied = BN2Number(ERC20Interface.decodeFunctionResult("balanceOf", result[i++])[0], campaign.campaignParameters.decimalsUnderlyingToken);
|
80
|
+
totalSupplyTargetToken = borrowedAmount + nonUtilizedSupplied;
|
58
81
|
}
|
59
82
|
}
|
60
83
|
catch {
|
@@ -39,6 +39,7 @@ export class GenericProcessor {
|
|
39
39
|
const priceTargetToken = (await pricer.get({ symbol: campaign.campaignParameters.symbolTargetToken })) ?? 0;
|
40
40
|
const tvl = whitelistedSupplyTargetToken * priceTargetToken;
|
41
41
|
return {
|
42
|
+
type,
|
42
43
|
whitelistedSupplyTargetToken,
|
43
44
|
totalSupply,
|
44
45
|
priceTargetToken,
|