@merkl/api 0.10.390 → 0.10.391
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/HyperdriveDynamicData.js +22 -19
- package/dist/src/modules/v4/opportunity/opportunity.service.js +1 -1
- package/dist/src/modules/v4/opportunity/subservices/getHyperdriveMetadata.service.d.ts +1 -1
- package/dist/src/modules/v4/opportunity/subservices/getHyperdriveMetadata.service.js +4 -0
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import { BN2Number, HyperdriveTargetInterface, } from "@sdk";
|
1
|
+
import { BN2Number, ETH_ADDRESS, HyperDriveSubCampaignType, HyperdriveTargetInterface, } from "@sdk";
|
2
2
|
import { Pricer } from "../../../utils/pricer";
|
3
3
|
export async function HyperdriveDynamicData(chainId, campaigns) {
|
4
4
|
const pricer = await Pricer.load();
|
@@ -12,10 +12,6 @@ export async function HyperdriveDynamicData(chainId, campaigns) {
|
|
12
12
|
allowFailure: false,
|
13
13
|
callData: HyperdriveTargetInterface.encodeFunctionData("getPoolConfig"),
|
14
14
|
target: campaign.campaignParameters.targetToken,
|
15
|
-
}, {
|
16
|
-
allowFailure: false,
|
17
|
-
callData: HyperdriveTargetInterface.encodeFunctionData("totalSupply", [campaign.campaignParameters.tokenId]),
|
18
|
-
target: campaign.campaignParameters.targetToken,
|
19
15
|
});
|
20
16
|
}
|
21
17
|
return {
|
@@ -29,27 +25,34 @@ export async function HyperdriveDynamicData(chainId, campaigns) {
|
|
29
25
|
for (const campaign of campaigns) {
|
30
26
|
const poolInfo = HyperdriveTargetInterface.decodeFunctionResult("getPoolInfo", result[i++])[0];
|
31
27
|
const poolConfig = HyperdriveTargetInterface.decodeFunctionResult("getPoolConfig", result[i++])[0];
|
32
|
-
const totalSupplyVaultToken = BN2Number(HyperdriveTargetInterface.decodeFunctionResult("totalSupply", result[i++])[0]);
|
33
28
|
const priceRewardToken = (await pricer.get({
|
34
29
|
address: campaign.rewardToken,
|
35
30
|
chainId,
|
36
31
|
symbol: campaign.campaignParameters.symbolRewardToken,
|
37
32
|
})) ?? 0;
|
38
|
-
const
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
33
|
+
const lpSupply = BN2Number(poolInfo.lpTotalSupply, 18);
|
34
|
+
const longSupply = BN2Number(poolInfo.longsOutstanding, 18);
|
35
|
+
const shortSupply = BN2Number(poolInfo.shortsOutstanding, 18);
|
36
|
+
const marketSupply = lpSupply * BN2Number(poolInfo.lpSharePrice, 18);
|
37
|
+
const priceBaseToken = (poolConfig.baseToken === ETH_ADDRESS
|
38
|
+
? await pricer.get({
|
39
|
+
chainId,
|
40
|
+
symbol: "ETH",
|
41
|
+
})
|
42
|
+
: await pricer.get({
|
43
|
+
address: campaign.campaignParameters.baseToken,
|
44
|
+
chainId,
|
45
|
+
symbol: campaign.campaignParameters.baseTokenSymbol,
|
46
|
+
})) ?? 0;
|
47
|
+
const tvl = campaign.campaignSubType === HyperDriveSubCampaignType.LP
|
48
|
+
? priceBaseToken * marketSupply
|
49
|
+
: campaign.campaignSubType === HyperDriveSubCampaignType.LONG
|
50
|
+
? priceBaseToken * longSupply
|
51
|
+
: priceBaseToken * shortSupply;
|
49
52
|
dynamicData.push({
|
50
53
|
...campaign,
|
51
|
-
totalSupplyTargetToken:
|
52
|
-
tvl:
|
54
|
+
totalSupplyTargetToken: marketSupply,
|
55
|
+
tvl: tvl,
|
53
56
|
apr: 0,
|
54
57
|
priceRewardToken: priceRewardToken,
|
55
58
|
});
|
@@ -85,7 +85,7 @@ export class OpportunityService {
|
|
85
85
|
return getEulerMetadata(chainId, campaign.campaignId, campaign.subType, campaign.rewardTokenAddress, campaign.amount, campaignParams);
|
86
86
|
case "HYPERDRIVELOGPROCESSOR":
|
87
87
|
case "HYPERDRIVELOGFIXPROCESSOR":
|
88
|
-
return getHyperdriveMetadata(chainId,
|
88
|
+
return getHyperdriveMetadata(chainId, campaignParams.subCampaignType, campaignParams);
|
89
89
|
case "INVALID":
|
90
90
|
return {
|
91
91
|
name: "Invalid Campaigns",
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import type
|
1
|
+
import { type ChainId, type HyperDriveLogCampaign } from "@sdk";
|
2
2
|
import type { OpportunityMetadata } from "../opportunity.model";
|
3
3
|
export declare const getHyperdriveMetadata: (chainId: ChainId, campaignSubType: HyperDriveLogCampaign["campaignSubType"], params: HyperDriveLogCampaign["campaignParameters"]) => OpportunityMetadata;
|
@@ -1,10 +1,14 @@
|
|
1
1
|
import { OpportunityAction } from "../../../../../database/api/.generated";
|
2
|
+
import { HyperDriveSubCampaignType } from "@sdk";
|
2
3
|
export const getHyperdriveMetadata = (chainId, campaignSubType, params) => {
|
3
4
|
const subtypes = [
|
4
5
|
{ name: "Add Liquidity on", action: OpportunityAction.POOL },
|
5
6
|
{ name: "Open Long on", action: OpportunityAction.LONG },
|
6
7
|
{ name: "Open Short on", action: OpportunityAction.SHORT },
|
7
8
|
];
|
9
|
+
if (campaignSubType === HyperDriveSubCampaignType.LP) {
|
10
|
+
campaignSubType = 0;
|
11
|
+
}
|
8
12
|
const subtype = subtypes[campaignSubType];
|
9
13
|
return {
|
10
14
|
action: subtype.action,
|