@merkl/api 0.19.47 → 0.19.49
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/engine/dynamicData/implementations/Morpho.d.ts +2 -0
- package/dist/src/engine/dynamicData/implementations/Morpho.js +36 -16
- package/dist/src/modules/v4/opportunity/opportunity.controller.js +2 -2
- package/dist/src/modules/v4/opportunity/opportunity.service.js +2 -2
- package/dist/src/modules/v4/programPayload/programPayload.repository.d.ts +52 -1
- package/dist/src/modules/v4/programPayload/programPayload.repository.js +62 -0
- package/dist/src/utils/prices/priceService.js +1 -1
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -1,6 +1,8 @@
|
|
1
1
|
import { type Campaign, type CampaignParameters, type MerklChainId } from "@sdk";
|
2
|
+
import { utils } from "ethers";
|
2
3
|
import type { DynamicDataBuilder } from "../interface";
|
3
4
|
type campaignType = Campaign.MORPHO;
|
5
|
+
export declare const MORPHO_INTERFACE: utils.Interface;
|
4
6
|
export declare class MorphoDynamicData implements DynamicDataBuilder<campaignType> {
|
5
7
|
build(chainId: MerklChainId, campaigns: CampaignParameters<campaignType>[]): Promise<MorphoCampaignDynamicData[]>;
|
6
8
|
}
|
@@ -1,7 +1,15 @@
|
|
1
1
|
import { TokenService } from "@/modules/v4/token/token.service";
|
2
|
-
import { BN2Number, ChainInteractionService, MetamorphoInterface, MorphoSubCampaignType, YEAR, } from "@sdk";
|
2
|
+
import { BN2Number, ChainInteractionService, MetamorphoInterface, MorphoSubCampaignType, YEAR, morphoAddresses, } from "@sdk";
|
3
3
|
import axios from "axios";
|
4
|
+
import { utils } from "ethers";
|
5
|
+
import { zeroAddress } from "viem";
|
4
6
|
import { Pricer } from "../../../utils/pricer";
|
7
|
+
// TODO add the ABI
|
8
|
+
const MORPHO_ABI = [
|
9
|
+
"function position(bytes32,address) external view returns (uint256,uint128,uint128)",
|
10
|
+
"function market(bytes32) external view returns (uint128,uint128,uint128,uint128,uint128,uint128)",
|
11
|
+
];
|
12
|
+
export const MORPHO_INTERFACE = new utils.Interface(MORPHO_ABI);
|
5
13
|
export class MorphoDynamicData {
|
6
14
|
async build(chainId, campaigns) {
|
7
15
|
const pricer = await Pricer.load();
|
@@ -22,6 +30,14 @@ export class MorphoDynamicData {
|
|
22
30
|
target: campaign.campaignParameters.targetToken,
|
23
31
|
});
|
24
32
|
}
|
33
|
+
if (campaign.campaignSubType === MorphoSubCampaignType.BORROWING_BLUE ||
|
34
|
+
campaign.campaignSubType === MorphoSubCampaignType.SUPPLY_BLUE) {
|
35
|
+
calls.push({
|
36
|
+
allowFailure: true,
|
37
|
+
callData: MORPHO_INTERFACE.encodeFunctionData("market", [campaign.campaignParameters.marketId]),
|
38
|
+
target: morphoAddresses[campaign.computeChainId] ?? zeroAddress,
|
39
|
+
});
|
40
|
+
}
|
25
41
|
}
|
26
42
|
const result = await ChainInteractionService(chainId).fetchState(calls);
|
27
43
|
const dynamicData = [];
|
@@ -45,9 +61,23 @@ export class MorphoDynamicData {
|
|
45
61
|
tvl = priceAsset * totalAssets;
|
46
62
|
totalSupplyTargetToken = totalSupply;
|
47
63
|
}
|
48
|
-
if (campaign.campaignSubType === MorphoSubCampaignType.SUPPLY_BLUE
|
49
|
-
|
50
|
-
|
64
|
+
if (campaign.campaignSubType === MorphoSubCampaignType.SUPPLY_BLUE) {
|
65
|
+
const totalSupplyAssets = BN2Number(MORPHO_INTERFACE.decodeFunctionResult("market", result[index++].returnData)[0], Number(campaign.campaignParameters.decimalsLoanToken));
|
66
|
+
const priceAsset = (await pricer.get({
|
67
|
+
symbol: campaign.campaignParameters.symbolLoanToken,
|
68
|
+
})) ?? 0;
|
69
|
+
tvl = priceAsset * totalSupplyAssets;
|
70
|
+
totalSupplyTargetToken = totalSupplyAssets;
|
71
|
+
}
|
72
|
+
if (campaign.campaignSubType === MorphoSubCampaignType.BORROWING_BLUE) {
|
73
|
+
const totalBorrowAssets = BN2Number(MORPHO_INTERFACE.decodeFunctionResult("market", result[index++].returnData)[2], Number(campaign.campaignParameters.decimalsLoanToken));
|
74
|
+
const priceAsset = (await pricer.get({
|
75
|
+
symbol: campaign.campaignParameters.symbolLoanToken,
|
76
|
+
})) ?? 0;
|
77
|
+
tvl = priceAsset * totalBorrowAssets;
|
78
|
+
totalSupplyTargetToken = totalBorrowAssets;
|
79
|
+
}
|
80
|
+
if (campaign.campaignSubType === MorphoSubCampaignType.COLLATERAL_BLUE) {
|
51
81
|
const graphqlQueryMarket = {
|
52
82
|
query: `query MarketByUniqueKey($uniqueKey: String!, $chainId: Int) {
|
53
83
|
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
@@ -74,18 +104,8 @@ export class MorphoDynamicData {
|
|
74
104
|
headers: headers,
|
75
105
|
data: graphqlQueryMarket,
|
76
106
|
});
|
77
|
-
|
78
|
-
|
79
|
-
totalSupplyTargetToken = response.data.data.marketByUniqueKey.state.supplyAssets;
|
80
|
-
}
|
81
|
-
if (campaign.campaignSubType === MorphoSubCampaignType.BORROWING_BLUE) {
|
82
|
-
tvl = response.data.data.marketByUniqueKey.state.borrowAssetsUsd;
|
83
|
-
totalSupplyTargetToken = response.data.data.marketByUniqueKey.state.borrowAssets;
|
84
|
-
}
|
85
|
-
if (campaign.campaignSubType === MorphoSubCampaignType.COLLATERAL_BLUE) {
|
86
|
-
tvl = response.data.data.marketByUniqueKey.state.collateralAssetsUsd;
|
87
|
-
totalSupplyTargetToken = response.data.data.marketByUniqueKey.state.collateralAssets;
|
88
|
-
}
|
107
|
+
tvl = response.data.data.marketByUniqueKey.state.collateralAssetsUsd;
|
108
|
+
totalSupplyTargetToken = response.data.data.marketByUniqueKey.state.collateralAssets;
|
89
109
|
}
|
90
110
|
catch (e) {
|
91
111
|
console.log(e);
|
@@ -103,13 +103,13 @@ export const OpportunityController = new Elysia({
|
|
103
103
|
.get("/:id/campaigns", async ({ query, params }) => {
|
104
104
|
try {
|
105
105
|
if (!params.id.includes("-"))
|
106
|
-
return await OpportunityService.getUniqueWithCampaignsOrThrow(params.id, query.test ?? false);
|
106
|
+
return await OpportunityService.getUniqueWithCampaignsOrThrow(params.id, query.test ?? false, query.point ?? false);
|
107
107
|
const [chainId, type, identifier] = params.id.split("-");
|
108
108
|
return await OpportunityService.getUniqueWithCampaignsOrThrow({
|
109
109
|
chainId: +chainId,
|
110
110
|
type: type,
|
111
111
|
identifier,
|
112
|
-
}, query.test ?? false);
|
112
|
+
}, query.test ?? false, query.point ?? false);
|
113
113
|
}
|
114
114
|
catch (err) {
|
115
115
|
if (err.code && err.code === "P2025")
|
@@ -151,12 +151,12 @@ export class OpportunityService {
|
|
151
151
|
}
|
152
152
|
static async getUniqueWithCampaignsOrThrow(opportunityId, withTest = false, withPoints = false) {
|
153
153
|
const id = typeof opportunityId === "string" ? opportunityId : OpportunityService.hashId(opportunityId);
|
154
|
-
const opportunity = await OpportunityRepository.findUniqueOrThrow(id, withTest, withTest
|
154
|
+
const opportunity = await OpportunityRepository.findUniqueOrThrow(id, withTest, withTest ? withTest : withPoints, true);
|
155
155
|
return OpportunityService.formatResponse(opportunity);
|
156
156
|
}
|
157
157
|
static async getUniqueOrThrow(opportunityId, withTest = false, withPoints = false) {
|
158
158
|
const id = typeof opportunityId === "string" ? opportunityId : OpportunityService.hashId(opportunityId);
|
159
|
-
const opportunity = await OpportunityRepository.findUniqueOrThrow(id, withTest, withTest
|
159
|
+
const opportunity = await OpportunityRepository.findUniqueOrThrow(id, withTest, withTest ? withTest : withPoints);
|
160
160
|
return OpportunityService.formatResponse(opportunity);
|
161
161
|
}
|
162
162
|
/**
|
@@ -25,6 +25,8 @@ export declare enum etherlinkCampaigns {
|
|
25
25
|
Superlend_Supply_USDC_Etherlink = "Superlend Supply USDC Etherlink 0xd03bfdF9B26DB1e6764724d914d7c3d18106a9Fb",
|
26
26
|
Superlend_Supply_USDT_Etherlink = "Superlend Supply USDT Etherlink 0x998098A1B2E95e2b8f15360676428EdFd976861f",
|
27
27
|
Superlend_Supply_WXTZ_Etherlink = "Superlend Supply WXTZ Etherlink 0x008ae222661B6A42e3A097bd7AAC15412829106b",
|
28
|
+
Superlend_Supply_mTBILL_Etherlink = "Superlend Supply mTBILL Etherlink 0x187B7b83e8CaB442AD0BFEAe38067f3eb38a2d72",
|
29
|
+
Superlend_Supply_mBASIS_Etherlink = "Superlend Supply mBASIS Etherlink 0x660ADeF5993167ACdb490DF287f4Db6Cc226fFeB",
|
28
30
|
Iguana_WETH_WXTZ = "Iguana WETH/WXTZ Etherlink 0x478F067b0Ed73d120BBcd8c6f4f33438FC483912",
|
29
31
|
Iguana_USDC_USDT = "Iguana USDC/USDT Etherlink 0x86456e2E2A203Da82E61ed34eF4137Fbe545f0DC",
|
30
32
|
Iguana_XTZ_USDC = "Iguana XTZ/USDT Etherlink 0x508060A01f11d6a2Eb774B55aEba95931265E0cc",
|
@@ -231,7 +233,8 @@ export declare enum pufferCampaigns {
|
|
231
233
|
CARROT_USDC = "0xf00032d0F95e8f43E750C51d0188DCa33cC5a8eA",
|
232
234
|
sonex_pufETH_USDCe_1 = "0x4A0e0E8d5DF4AEC0a08359e599720628b179F7eD",
|
233
235
|
sonex_pufETH_USDCe_5 = "0x2646FAD13ef9BD063790d2719De1da290865D58f",
|
234
|
-
kyo_pufETH_ETH = "0x8C4f743C763aBe5CBAe4E50358b05C7D45921638"
|
236
|
+
kyo_pufETH_ETH = "0x8C4f743C763aBe5CBAe4E50358b05C7D45921638",
|
237
|
+
apufETH = "0x0526CF96Ad808f8E11A5a9F1012edf67F4BAf519"
|
235
238
|
}
|
236
239
|
export declare enum zkSyncCampaigns {
|
237
240
|
Izumi_Finance_Zk_Weth = "Izumi Finance ZK/WETH 0xd62bc9f19bd94fde9c41df4b6eb6419ea6b8e25c",
|
@@ -592,6 +595,54 @@ declare const EtherlinkInterfaceCampaigns: {
|
|
592
595
|
url: string;
|
593
596
|
forwarders: never[];
|
594
597
|
};
|
598
|
+
"Superlend Supply mBASIS Etherlink 0x660ADeF5993167ACdb490DF287f4Db6Cc226fFeB": {
|
599
|
+
campaignType: any;
|
600
|
+
computeChainId: any;
|
601
|
+
hooks: {
|
602
|
+
hookType: any;
|
603
|
+
key: string;
|
604
|
+
chainId: any;
|
605
|
+
contractAddress: string;
|
606
|
+
contractState: any;
|
607
|
+
boostForReferrer: any;
|
608
|
+
valueForBoostForReferrer: number;
|
609
|
+
boostForInvited: any;
|
610
|
+
valueForBoostForInvited: number;
|
611
|
+
defaultBoost: any;
|
612
|
+
maximumBoostReferrer: number;
|
613
|
+
maximumBoostInvited: number;
|
614
|
+
cumulativeBoost: boolean;
|
615
|
+
}[];
|
616
|
+
targetToken: string;
|
617
|
+
whitelist: never[];
|
618
|
+
blacklist: string[];
|
619
|
+
url: string;
|
620
|
+
forwarders: never[];
|
621
|
+
};
|
622
|
+
"Superlend Supply mTBILL Etherlink 0x187B7b83e8CaB442AD0BFEAe38067f3eb38a2d72": {
|
623
|
+
campaignType: any;
|
624
|
+
computeChainId: any;
|
625
|
+
hooks: {
|
626
|
+
hookType: any;
|
627
|
+
key: string;
|
628
|
+
chainId: any;
|
629
|
+
contractAddress: string;
|
630
|
+
contractState: any;
|
631
|
+
boostForReferrer: any;
|
632
|
+
valueForBoostForReferrer: number;
|
633
|
+
boostForInvited: any;
|
634
|
+
valueForBoostForInvited: number;
|
635
|
+
defaultBoost: any;
|
636
|
+
maximumBoostReferrer: number;
|
637
|
+
maximumBoostInvited: number;
|
638
|
+
cumulativeBoost: boolean;
|
639
|
+
}[];
|
640
|
+
targetToken: string;
|
641
|
+
whitelist: never[];
|
642
|
+
blacklist: string[];
|
643
|
+
url: string;
|
644
|
+
forwarders: never[];
|
645
|
+
};
|
595
646
|
"Uranium Hold xU308 Etherlink 0x79052Ab3C166D4899a1e0DD033aC3b379AF0B1fD": {
|
596
647
|
campaignType: any;
|
597
648
|
computeChainId: any;
|
@@ -29,6 +29,8 @@ export var etherlinkCampaigns;
|
|
29
29
|
etherlinkCampaigns["Superlend_Supply_USDC_Etherlink"] = "Superlend Supply USDC Etherlink 0xd03bfdF9B26DB1e6764724d914d7c3d18106a9Fb";
|
30
30
|
etherlinkCampaigns["Superlend_Supply_USDT_Etherlink"] = "Superlend Supply USDT Etherlink 0x998098A1B2E95e2b8f15360676428EdFd976861f";
|
31
31
|
etherlinkCampaigns["Superlend_Supply_WXTZ_Etherlink"] = "Superlend Supply WXTZ Etherlink 0x008ae222661B6A42e3A097bd7AAC15412829106b";
|
32
|
+
etherlinkCampaigns["Superlend_Supply_mTBILL_Etherlink"] = "Superlend Supply mTBILL Etherlink 0x187B7b83e8CaB442AD0BFEAe38067f3eb38a2d72";
|
33
|
+
etherlinkCampaigns["Superlend_Supply_mBASIS_Etherlink"] = "Superlend Supply mBASIS Etherlink 0x660ADeF5993167ACdb490DF287f4Db6Cc226fFeB";
|
32
34
|
etherlinkCampaigns["Iguana_WETH_WXTZ"] = "Iguana WETH/WXTZ Etherlink 0x478F067b0Ed73d120BBcd8c6f4f33438FC483912";
|
33
35
|
etherlinkCampaigns["Iguana_USDC_USDT"] = "Iguana USDC/USDT Etherlink 0x86456e2E2A203Da82E61ed34eF4137Fbe545f0DC";
|
34
36
|
etherlinkCampaigns["Iguana_XTZ_USDC"] = "Iguana XTZ/USDT Etherlink 0x508060A01f11d6a2Eb774B55aEba95931265E0cc";
|
@@ -65,6 +67,35 @@ const blacklistEtherlink = [
|
|
65
67
|
"0x6c1b204185A55E9DaA0bF026720Fe94458ddd89F",
|
66
68
|
"0x56A8b583276278513Eb78c3d132a80c1e81B9405",
|
67
69
|
"0x6a2f09Bc9E6b82b38FCa096792B94f36FAd657Ac",
|
70
|
+
"0xf99Fdd1e71838433516DE7aD98aa82BFa3f17AE2",
|
71
|
+
"0xf1fAD4fecd686a79Fd2a4618F657f0BA0332e18A",
|
72
|
+
"0x51832D40579d86fb95Cc843EF32326BD51904956",
|
73
|
+
"0x0D1C515CCb1B723eCBA2Cbb14c458168078529DA",
|
74
|
+
"0x4d6ab6cBd964Fa1D33dA0232DA21fA3E5d23d05D",
|
75
|
+
"0x6ECEc7954b61Da887B8f3e56111D7Dd6bebc3877",
|
76
|
+
"0x41Be85bf6c460b1DC35efBE2C3143F9732CD6496",
|
77
|
+
"0x635518E05BAe895F85680Ce66Fb8EA92EE64FE2f",
|
78
|
+
"0xB05D1019772a14bb8853A94469B45ECfC7A985E8",
|
79
|
+
"0x82DAa20C1781d142295a7cF2a8913798695E50a2",
|
80
|
+
"0xbC086a895F6c1fF7Dd09022cC7fDEd52a2451Be5",
|
81
|
+
"0xFdAD5D95246E8b5B5147bCDE23ddCc6BbF1f7fC0",
|
82
|
+
"0x19f898d95295D072235272C015B80787B177140e",
|
83
|
+
"0xE0133f4027c14eB3D5cD758E052B5AD1bC380C70",
|
84
|
+
"0x05e6e1DF3eA666E1fEa7920026F6Bf1cA1A64F48",
|
85
|
+
"0x45c1FE080f5d38889DAa81614b46DEdBC360A0E6",
|
86
|
+
"0x3f7F401a04564f4789bC8e9b8A1BDe0F44CDc322",
|
87
|
+
"0xbc11274F5779ee4E81b09CCcd4fA4360f7c78F9E",
|
88
|
+
"0x196A8F57ff3AfB509f0014EDBa108A0BFeF0a84a",
|
89
|
+
"0x2366C17D8E825ec799292bBEf04b414938526594",
|
90
|
+
"0x208F27ec5d040618610a536a1f25a93Df6079eb1",
|
91
|
+
"0xE4cC0ceBF07D98f9a6b05E5283cb4d8A53c8beb8",
|
92
|
+
"0xa9D957545BA1AA6582690adbAFCaD12119ce834B",
|
93
|
+
"0xfc03b2f8B4Fb6438cE7d4E4B5F91372157A514cd",
|
94
|
+
"0xa660FA94B26FAA4D20E061D7FCa3d7b1411C30f0",
|
95
|
+
"0x0893cA2b0f0b8B87815B61c7717C25B8Bf834082",
|
96
|
+
"0x9D0E0e95305872E0f8065093b66E5FA224B5826f",
|
97
|
+
"0xa0E147eA78D8d696D73bbd43dE353b3ab076B3a0",
|
98
|
+
"0x196A8F57ff3AfB509f0014EDBa108A0BFeF0a84a",
|
68
99
|
];
|
69
100
|
export var swapxCampaigns;
|
70
101
|
(function (swapxCampaigns) {
|
@@ -269,6 +300,7 @@ export var pufferCampaigns;
|
|
269
300
|
pufferCampaigns["sonex_pufETH_USDCe_1"] = "0x4A0e0E8d5DF4AEC0a08359e599720628b179F7eD";
|
270
301
|
pufferCampaigns["sonex_pufETH_USDCe_5"] = "0x2646FAD13ef9BD063790d2719De1da290865D58f";
|
271
302
|
pufferCampaigns["kyo_pufETH_ETH"] = "0x8C4f743C763aBe5CBAe4E50358b05C7D45921638";
|
303
|
+
pufferCampaigns["apufETH"] = "0x0526CF96Ad808f8E11A5a9F1012edf67F4BAf519";
|
272
304
|
})(pufferCampaigns || (pufferCampaigns = {}));
|
273
305
|
export var zkSyncCampaigns;
|
274
306
|
(function (zkSyncCampaigns) {
|
@@ -561,6 +593,26 @@ const EtherlinkInterfaceCampaigns = {
|
|
561
593
|
url: "https://markets.superlend.xyz/reserve-overview/?underlyingAsset=0xc9b53ab2679f573e480d01e0f49e2b5cfb7a3eab&marketName=etherlink",
|
562
594
|
forwarders: [],
|
563
595
|
},
|
596
|
+
[etherlinkCampaigns.Superlend_Supply_mBASIS_Etherlink]: {
|
597
|
+
campaignType: Campaign.ERC20,
|
598
|
+
computeChainId: ChainId.ETHERLINK,
|
599
|
+
hooks: [etherlinkReferralProgram],
|
600
|
+
targetToken: "0x660ADeF5993167ACdb490DF287f4Db6Cc226fFeB",
|
601
|
+
whitelist: [],
|
602
|
+
blacklist: blacklistEtherlink,
|
603
|
+
url: "https://markets.superlend.xyz/reserve-overview/?underlyingAsset=0x2247b5a46bb79421a314ab0f0b67ffd11dd37ee4&marketName=etherlink",
|
604
|
+
forwarders: [],
|
605
|
+
},
|
606
|
+
[etherlinkCampaigns.Superlend_Supply_mTBILL_Etherlink]: {
|
607
|
+
campaignType: Campaign.ERC20,
|
608
|
+
computeChainId: ChainId.ETHERLINK,
|
609
|
+
hooks: [etherlinkReferralProgram],
|
610
|
+
targetToken: "0x187B7b83e8CaB442AD0BFEAe38067f3eb38a2d72",
|
611
|
+
whitelist: [],
|
612
|
+
blacklist: blacklistEtherlink,
|
613
|
+
url: "https://markets.superlend.xyz/reserve-overview/?underlyingAsset=0xdd629e5241cbc5919847783e6c96b2de4754e438&marketName=etherlink",
|
614
|
+
forwarders: [],
|
615
|
+
},
|
564
616
|
[etherlinkCampaigns.Uranium_Hold_xU308_Etherlink]: {
|
565
617
|
campaignType: Campaign.ERC20,
|
566
618
|
computeChainId: ChainId.ETHERLINK,
|
@@ -5443,6 +5495,16 @@ const PufferInterfaceCampaigns = {
|
|
5443
5495
|
weightToken0: 5000,
|
5444
5496
|
weightToken1: 5000,
|
5445
5497
|
},
|
5498
|
+
[pufferCampaigns.apufETH]: {
|
5499
|
+
campaignType: Campaign.ERC20,
|
5500
|
+
computeChainId: ChainId.SONEIUM,
|
5501
|
+
hooks: [],
|
5502
|
+
targetToken: "0x0526CF96Ad808f8E11A5a9F1012edf67F4BAf519",
|
5503
|
+
whitelist: [],
|
5504
|
+
blacklist: [],
|
5505
|
+
url: "https://app.sakefinance.com/market/0x6c460b2c6d6719562d5da43e5152b375e79b9a8b",
|
5506
|
+
forwarders: [],
|
5507
|
+
},
|
5446
5508
|
};
|
5447
5509
|
export const MerklInterfaceCampaigns = {
|
5448
5510
|
[program.Puffer]: PufferInterfaceCampaigns,
|
@@ -1,10 +1,10 @@
|
|
1
|
+
import { getTokensListWithCache } from "@/libs/getTokensList";
|
1
2
|
import { PriceService as PriceSourceService } from "@/modules/v4/price";
|
2
3
|
import { PriceSourceMethod } from "@db/api";
|
3
4
|
import { BN2Number, ChainId, Stable, registry } from "@sdk";
|
4
5
|
import axios from "axios";
|
5
6
|
import { Contract } from "ethers";
|
6
7
|
import { constantChain } from "../../constants";
|
7
|
-
import { getTokensListWithCache } from "../../libs/getTokensList";
|
8
8
|
import { log } from "../logger";
|
9
9
|
import { providers } from "../providers";
|
10
10
|
import { getChainlinkLatestPrice } from "./chainlinkRead";
|