@merkl/api 0.17.5 → 0.17.7
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/backgroundJobs/jobs/opportunityUpdater.js +2 -0
- package/dist/src/jobs/etl/update-dynamic-data.js +80 -80
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/hardcoded.js +3 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType.d.ts +2 -1
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType.js +2 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/implementations/processorMapping.js +2 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/implementations/xU308Processor.d.ts +37 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/implementations/xU308Processor.js +49 -0
- package/dist/src/libs/positions/clamm/index.js +1 -1
- package/dist/src/modules/v4/campaign/campaign.controller.js +1 -1
- package/dist/src/modules/v4/claims/claims.controller.js +1 -1
- package/dist/src/modules/v4/interaction/interaction.service.d.ts +1 -1
- package/dist/src/modules/v4/interaction/interaction.service.js +3 -3
- package/dist/src/modules/v4/merklRoot/merklRoot.service.js +1 -1
- package/dist/src/modules/v4/opportunity/subservices/getEulerMetadata.service.js +4 -1
- package/dist/src/modules/v4/programPayload/programPayload.repository.d.ts +49 -2
- package/dist/src/modules/v4/programPayload/programPayload.repository.js +51 -0
- package/dist/src/modules/v4/protocol/protocol.service.js +1 -1
- package/dist/src/modules/v4/reward/reward.service.js +1 -1
- package/dist/src/modules/v4/user/user.model.js +1 -1
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/src/modules/v4/chain/index.d.ts +0 -4
- package/dist/src/modules/v4/chain/index.js +0 -8
- package/dist/src/modules/v4/chainInteraction/index.d.ts +0 -1
- package/dist/src/modules/v4/chainInteraction/index.js +0 -1
@@ -53,8 +53,10 @@ export const opportunityUpdater = (app) => {
|
|
53
53
|
await Redis.safeSet("Opportunities", opportunities);
|
54
54
|
await Redis.safeSet("OpportunitiesWithTest", opportunitiesWithTest);
|
55
55
|
log.info("✅ opportunity cache updated successfully");
|
56
|
+
await OpportunityConvertorService.logKeyAndTTLV3Opportunities(true, false, undefined, undefined);
|
56
57
|
await OpportunityConvertorService.setV3Opportunities(true, false, undefined, undefined);
|
57
58
|
log.info("✅ opportunity v3 cache updated successfully");
|
59
|
+
await OpportunityConvertorService.logKeyAndTTLV3Opportunities(true, true, undefined, undefined);
|
58
60
|
await OpportunityConvertorService.setV3Opportunities(true, true, undefined, undefined);
|
59
61
|
log.info("✅ opportunity v3 test cache updated successfully");
|
60
62
|
return new Response(JSON.stringify({
|
@@ -14,52 +14,46 @@ if (!chainId)
|
|
14
14
|
throw new Error("Environment variable CHAIN_ID is required.");
|
15
15
|
// ─── Update Dynamic Data (APR / TVL / Daily Rewards) ─────────────────────────
|
16
16
|
async function updateDynamicData(liveCampaigns, campaignType) {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
oppMap[`${data.campaignType}_${data.mainParameter}`][data.campaignId] = data;
|
40
|
-
}
|
41
|
-
}
|
42
|
-
for (const entry of Object.entries(oppMap)) {
|
43
|
-
const [type, mainParameter] = entry[0].split("_");
|
44
|
-
try {
|
45
|
-
const apr = AprService.extractFromDynamicData(+type, Object.values(entry[1]));
|
46
|
-
const tvl = TvlService.extractFromDynamicData(+type, Object.values(entry[1]));
|
47
|
-
const dailyRewards = await RewardService.extractDailyRewardsRecordFromDynamicData(+type, Object.values(entry[1]));
|
48
|
-
const opportunityId = OpportunityService.hashId({
|
49
|
-
chainId,
|
50
|
-
identifier: mainParameter,
|
51
|
-
type: type,
|
52
|
-
});
|
53
|
-
await OpportunityRepository.updateRecords(opportunityId, apr, tvl, dailyRewards);
|
54
|
-
}
|
55
|
-
catch (err) {
|
56
|
-
console.log(mainParameter);
|
57
|
-
console.error(err);
|
58
|
-
}
|
17
|
+
// Input: list of campaigns of same type
|
18
|
+
// Output: for each campaign, APR, TVL, Daily Rewards
|
19
|
+
// Constraint: needs to use multicalls to reduce RPC calls and speed
|
20
|
+
// - Needs to be robust to a single campaign's call failing
|
21
|
+
// - Needs to be quite easy for the engine team to setup new campaign types
|
22
|
+
// abstract GenericDynamicDataComputer
|
23
|
+
// compute(chainId, type, campaigns) => { apr, tvl, dailyRewards } with breakdowns
|
24
|
+
// UNISWAP V4
|
25
|
+
// Round 1 - (chainId, type, campaigns) -> tokens of the pools
|
26
|
+
// Round 2 - (chainId, type, campaigns, output of previous round) -> balance in tokens of forwarders
|
27
|
+
// Round 3 - ...
|
28
|
+
// Round Final - (chainId, type, campaigns, output of previous round) -> { apr, tvl, dailyRewards }
|
29
|
+
const dynamicData = await executeSimple(chainId, campaignsDynamicData(chainId, liveCampaigns, campaignType));
|
30
|
+
const oppMap = {};
|
31
|
+
for (const data of dynamicData) {
|
32
|
+
if (!!data) {
|
33
|
+
// Main Parameter OVERRIDING
|
34
|
+
if (data.campaignType === CampaignTypesEnum.SILO && data.campaignParameters.whitelist?.length === 1)
|
35
|
+
data.mainParameter = `${data.mainParameter}-${data.campaignParameters.whitelist[0]}`;
|
36
|
+
if (!oppMap[`${data.campaignType}_${data.mainParameter}`])
|
37
|
+
oppMap[`${data.campaignType}_${data.mainParameter}`] = {};
|
38
|
+
oppMap[`${data.campaignType}_${data.mainParameter}`][data.campaignId] = data;
|
59
39
|
}
|
60
40
|
}
|
61
|
-
|
62
|
-
|
41
|
+
for (const entry of Object.entries(oppMap)) {
|
42
|
+
const [type, mainParameter] = entry[0].split("_");
|
43
|
+
try {
|
44
|
+
const apr = AprService.extractFromDynamicData(+type, Object.values(entry[1]));
|
45
|
+
const tvl = TvlService.extractFromDynamicData(+type, Object.values(entry[1]));
|
46
|
+
const dailyRewards = await RewardService.extractDailyRewardsRecordFromDynamicData(+type, Object.values(entry[1]));
|
47
|
+
const opportunityId = OpportunityService.hashId({
|
48
|
+
chainId,
|
49
|
+
identifier: mainParameter,
|
50
|
+
type: type,
|
51
|
+
});
|
52
|
+
await OpportunityRepository.updateRecords(opportunityId, apr, tvl, dailyRewards);
|
53
|
+
}
|
54
|
+
catch (err) {
|
55
|
+
console.error(err);
|
56
|
+
}
|
63
57
|
}
|
64
58
|
}
|
65
59
|
// ─── Get And Transform Live Campaigns Into A Map ─────────────────────────────
|
@@ -94,45 +88,51 @@ const getLiveCampaignsByType = async (chainId) => {
|
|
94
88
|
};
|
95
89
|
// ─── Main function / entry point ─────────────────────────────────────────────
|
96
90
|
const main = async () => {
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
91
|
+
// 1. Get a map of campaigns by campaign type
|
92
|
+
const liveCampaigns = await getLiveCampaignsByType(chainId);
|
93
|
+
// 2. Call updateDynamicData with each entries of the map (process by campaign type)
|
94
|
+
for (const [type, campaigns] of liveCampaigns.entries()) {
|
95
|
+
try {
|
102
96
|
await updateDynamicData(campaigns, type);
|
103
|
-
// 3. Update status of opportunities
|
104
|
-
// 3.1 Get current live opportunities
|
105
|
-
const liveOpportunities = await OpportunityService.findLiveWithCampaigns(chainId);
|
106
|
-
// 3.2 For each currently live opportunities, infer its updated status by looping through its campaigns
|
107
|
-
const now = moment().unix();
|
108
|
-
for (const opportunity of liveOpportunities) {
|
109
|
-
let status = "NONE";
|
110
|
-
const campaigns = opportunity.campaigns;
|
111
|
-
for (const campaign of campaigns) {
|
112
|
-
if (status !== "LIVE" && campaign.endTimestamp < now)
|
113
|
-
status = "PAST";
|
114
|
-
else if (campaign.startTimestamp < now && campaign.endTimestamp > now)
|
115
|
-
status = "LIVE";
|
116
|
-
else if (status !== "LIVE" && campaign.startTimestamp > now)
|
117
|
-
status = "SOON";
|
118
|
-
}
|
119
|
-
await OpportunityService.updateStatus(opportunity.id, status);
|
120
97
|
}
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
98
|
+
catch (err) {
|
99
|
+
console.error(`Failed to update dynamic data for campaign type ${type}`, err);
|
100
|
+
}
|
101
|
+
}
|
102
|
+
// 3. Update status of opportunities
|
103
|
+
// 3.1 Get current live opportunities
|
104
|
+
const liveOpportunities = await OpportunityService.findLiveWithCampaigns(chainId);
|
105
|
+
// 3.2 For each currently live opportunities, infer its updated status by looping through its campaigns
|
106
|
+
const now = moment().unix();
|
107
|
+
for (const opportunity of liveOpportunities) {
|
108
|
+
let status = "NONE";
|
109
|
+
const campaigns = opportunity.campaigns;
|
110
|
+
for (const campaign of campaigns) {
|
111
|
+
if (status !== "LIVE" && campaign.endTimestamp < now)
|
112
|
+
status = "PAST";
|
113
|
+
else if (campaign.startTimestamp < now && campaign.endTimestamp > now)
|
114
|
+
status = "LIVE";
|
115
|
+
else if (status !== "LIVE" && campaign.startTimestamp > now)
|
116
|
+
status = "SOON";
|
128
117
|
}
|
129
|
-
|
130
|
-
await OpportunityService.updateMany(Array.from(opportunities), { status: "LIVE" });
|
131
|
-
process.exit(0);
|
118
|
+
await OpportunityService.updateStatus(opportunity.id, status);
|
132
119
|
}
|
133
|
-
|
134
|
-
|
135
|
-
|
120
|
+
// 4. Compute opportunity ids of liveCampaigns
|
121
|
+
const opportunities = new Set();
|
122
|
+
for (const [type, campaigns] of liveCampaigns.entries()) {
|
123
|
+
for (const campaign of campaigns) {
|
124
|
+
const opportunityId = OpportunityService.hashId({ chainId, identifier: campaign.mainParameter, type });
|
125
|
+
opportunities.add(opportunityId);
|
126
|
+
}
|
136
127
|
}
|
128
|
+
// 5. Update the status of the liveCampaigns opportunities
|
129
|
+
await OpportunityService.updateMany(Array.from(opportunities), { status: "LIVE" });
|
137
130
|
};
|
138
|
-
|
131
|
+
try {
|
132
|
+
await main();
|
133
|
+
process.exit(0);
|
134
|
+
}
|
135
|
+
catch (err) {
|
136
|
+
console.error(err);
|
137
|
+
process.exit(1);
|
138
|
+
}
|
@@ -20,6 +20,9 @@ const chainAddressToType = {
|
|
20
20
|
[ChainId.BOB]: {
|
21
21
|
"0x9998e05030Aee3Af9AD3df35A34F5C51e1628779": tokenType.veda,
|
22
22
|
},
|
23
|
+
[ChainId.ETHERLINK]: {
|
24
|
+
"0x79052Ab3C166D4899a1e0DD033aC3b379AF0B1fD": tokenType.xU308,
|
25
|
+
},
|
23
26
|
};
|
24
27
|
export function getTypeFromAddressChain(chain, token) {
|
25
28
|
if (!!chainAddressToType[chain] && !!chainAddressToType[chain][token]) {
|
@@ -89,7 +89,8 @@ export declare enum tokenType {
|
|
89
89
|
hourglass = "hourglass",
|
90
90
|
katana = "katana",
|
91
91
|
balancerV3 = "balancerV3",
|
92
|
-
hanji_liquidity_vault_token = "hanji_liquidity_vault_token"
|
92
|
+
hanji_liquidity_vault_token = "hanji_liquidity_vault_token",
|
93
|
+
xU308 = "xU308"
|
93
94
|
}
|
94
95
|
export declare const tokenTypeToProtocol: {
|
95
96
|
[key in tokenType]: {
|
@@ -91,6 +91,7 @@ export var tokenType;
|
|
91
91
|
tokenType["katana"] = "katana";
|
92
92
|
tokenType["balancerV3"] = "balancerV3";
|
93
93
|
tokenType["hanji_liquidity_vault_token"] = "hanji_liquidity_vault_token";
|
94
|
+
tokenType["xU308"] = "xU308";
|
94
95
|
})(tokenType || (tokenType = {}));
|
95
96
|
export const tokenTypeToProtocol = {
|
96
97
|
[tokenType.aave_borrowing]: { protocol: "Aave", action: OpportunityAction.BORROW },
|
@@ -182,4 +183,5 @@ export const tokenTypeToProtocol = {
|
|
182
183
|
[tokenType.katana]: { protocol: "Katana", action: OpportunityAction.POOL },
|
183
184
|
[tokenType.balancerV3]: { protocol: "Balancer", action: OpportunityAction.POOL },
|
184
185
|
[tokenType.hanji_liquidity_vault_token]: { protocol: "Hanji", action: OpportunityAction.POOL },
|
186
|
+
[tokenType.xU308]: { protocol: "Uranium", action: OpportunityAction.HOLD },
|
185
187
|
};
|
package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/implementations/processorMapping.js
CHANGED
@@ -42,6 +42,7 @@ import { ZkSwapThreePoolProcessor } from "./ZkSwapThreePoolProcessor";
|
|
42
42
|
import { CurveNPoolProcessor } from "./curveNPoolProcessor";
|
43
43
|
import { CurveProcessor } from "./curveProcessor";
|
44
44
|
import { StakedCurveProcessor } from "./stakedCurveProcessor";
|
45
|
+
import { xU308Processor } from "./xU308Processor";
|
45
46
|
export const processorMapping = {
|
46
47
|
[tokenType.uniswapv2]: UniswapProcessor,
|
47
48
|
[tokenType.balancerGauge]: BalancerGaugeProcessor,
|
@@ -132,4 +133,5 @@ export const processorMapping = {
|
|
132
133
|
[tokenType.katana]: UniswapProcessor,
|
133
134
|
[tokenType.balancerV3]: BalancerV3PoolProcessor,
|
134
135
|
[tokenType.hanji_liquidity_vault_token]: HanjiVaultProcessor,
|
136
|
+
[tokenType.xU308]: xU308Processor,
|
135
137
|
};
|
package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/implementations/xU308Processor.d.ts
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
import type { Pricer } from "../../../../../utils/pricer";
|
2
|
+
import { type Campaign, type CampaignParameters } from "@sdk";
|
3
|
+
import { GenericProcessor, type dataType, type mandatoryCallKeys } from "../GenericProcessor";
|
4
|
+
import type { tokenType } from "../helpers/tokenType";
|
5
|
+
type callType = {
|
6
|
+
key: keyof dataRawxU308;
|
7
|
+
call: string;
|
8
|
+
target: keyof callKeysxU308;
|
9
|
+
metaData?: keyof callKeysxU308;
|
10
|
+
};
|
11
|
+
type callKeysxU308 = mandatoryCallKeys & {
|
12
|
+
pool: string;
|
13
|
+
token0: string;
|
14
|
+
token1: string;
|
15
|
+
symbolToken0: string;
|
16
|
+
symbolToken1: string;
|
17
|
+
decimalsToken0: string;
|
18
|
+
decimalsToken1: string;
|
19
|
+
balanceToken0: string;
|
20
|
+
balanceToken1: string;
|
21
|
+
totalAssets: string;
|
22
|
+
};
|
23
|
+
type dataRawxU308 = callKeysxU308 & {};
|
24
|
+
type dataTypexU308 = dataType & {
|
25
|
+
pool: string;
|
26
|
+
};
|
27
|
+
export declare class xU308Processor extends GenericProcessor<callKeysxU308, dataRawxU308, dataTypexU308> {
|
28
|
+
rounds: {
|
29
|
+
round1: callType[];
|
30
|
+
round2: callType[];
|
31
|
+
round3: callType[];
|
32
|
+
round4: callType[];
|
33
|
+
};
|
34
|
+
processingRound2(typeInfo: dataRawxU308): void;
|
35
|
+
processingRound5(_index: number, type: tokenType, typeInfo: dataRawxU308, _calls: string[], campaign: CampaignParameters<Campaign.ERC20> | CampaignParameters<Campaign.EULER>, pricer: Pricer): Promise<dataTypexU308>;
|
36
|
+
}
|
37
|
+
export {};
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { generateCardName } from "../../../../../utils/generateCardName";
|
2
|
+
import { BN2Number } from "@sdk";
|
3
|
+
import { GenericProcessor } from "../GenericProcessor";
|
4
|
+
export class xU308Processor extends GenericProcessor {
|
5
|
+
rounds = {
|
6
|
+
round1: [],
|
7
|
+
round2: [
|
8
|
+
{ key: "token0", call: "token0", target: "pool" },
|
9
|
+
{ key: "token1", call: "token1", target: "pool" },
|
10
|
+
],
|
11
|
+
round3: [
|
12
|
+
{ key: "symbolToken0", call: "symbol", target: "token0" },
|
13
|
+
{ key: "symbolToken1", call: "symbol", target: "token1" },
|
14
|
+
{ key: "decimalsToken0", call: "decimals", target: "token0" },
|
15
|
+
{ key: "decimalsToken1", call: "decimals", target: "token1" },
|
16
|
+
{ key: "balanceToken0", call: "balanceOf", target: "token0", metaData: "pool" },
|
17
|
+
{ key: "balanceToken1", call: "balanceOf", target: "token1", metaData: "pool" },
|
18
|
+
],
|
19
|
+
round4: [{ key: "totalSupply", call: "totalSupply", target: "tokenAddress" }],
|
20
|
+
};
|
21
|
+
// override computeRound1(): void {}
|
22
|
+
processingRound2(typeInfo) {
|
23
|
+
typeInfo.pool = "0xB387D0A73619791420De4a1e5e710023Cb0f49c0";
|
24
|
+
}
|
25
|
+
async processingRound5(_index, type, typeInfo, _calls, campaign, pricer) {
|
26
|
+
const { whitelistedSupplyTargetToken, totalSupply, blacklistedSupply } = this.handleWhiteListBlacklistRound5(typeInfo, campaign);
|
27
|
+
let priceTargetToken = 0;
|
28
|
+
if (typeInfo.token0 !== typeInfo.tokenAddress) {
|
29
|
+
const priceToken0 = (await pricer.get({ symbol: typeInfo.symbolToken0 })) ?? 0;
|
30
|
+
priceTargetToken =
|
31
|
+
(priceToken0 * BN2Number(typeInfo.balanceToken0, Number(typeInfo.decimalsToken0))) /
|
32
|
+
BN2Number(typeInfo.balanceToken1, Number(typeInfo.decimalsToken1));
|
33
|
+
}
|
34
|
+
const priceToken1 = (await pricer.get({ symbol: typeInfo.symbolToken1 })) ?? 0;
|
35
|
+
priceTargetToken =
|
36
|
+
(priceToken1 * BN2Number(typeInfo.balanceToken1, Number(typeInfo.decimalsToken1))) /
|
37
|
+
BN2Number(typeInfo.balanceToken0, Number(typeInfo.decimalsToken0));
|
38
|
+
const tvl = priceTargetToken * totalSupply;
|
39
|
+
return {
|
40
|
+
...typeInfo,
|
41
|
+
tvl,
|
42
|
+
whitelistedSupplyTargetToken,
|
43
|
+
blacklistedSupply,
|
44
|
+
priceTargetToken,
|
45
|
+
totalSupply,
|
46
|
+
cardName: generateCardName(type, typeInfo, campaign),
|
47
|
+
};
|
48
|
+
}
|
49
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { CacheService } from "../../../modules/v4/cache";
|
2
2
|
import { TTLPresets } from "../../../modules/v4/cache/cache.model";
|
3
|
-
import { ChainInteractionService } from "../../../modules/v4/chainInteraction";
|
3
|
+
import { ChainInteractionService } from "../../../modules/v4/chainInteraction/chainInteraction.service";
|
4
4
|
import { ALM, AMMAlgorithmMapping, BN2Number, NETWORK_LABELS, NFTManagerAddress, NonFungiblePositionManagerInterface, PoolInterface, PoolState, SqrtPrice, YEAR, getAmountsForLiquidity, getSupportedNFPWrapperMapping, getTickAtSqrtRatio, spNFTInterface, } from "@sdk";
|
5
5
|
import { BigNumber, Contract, utils } from "ethers";
|
6
6
|
import JSBI from "jsbi";
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { NotFoundError } from "../../../errors";
|
2
2
|
import { BackOfficeGuard } from "../../../guards/BackOffice.guard";
|
3
3
|
import { AuthorizationHeadersDto, EngineGuard } from "../../../guards/Engine.guard";
|
4
|
+
import { ChainUniqueDto } from "../chain/chain.model";
|
4
5
|
import Elysia, { t } from "elysia";
|
5
6
|
import { throwOnUnsupportedChainId } from "src/utils/throw";
|
6
|
-
import { ChainUniqueDto } from "../chain";
|
7
7
|
import { CampaignResourceDto, CreateCampaignDto, GetCampaignQueryDto, UpdateCampaignDto, UpdateMetaDataCampaignDto, } from "./campaign.model";
|
8
8
|
import { CampaignService } from "./campaign.service";
|
9
9
|
// ─── Campaigns Controller ────────────────────────────────────────────────────
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { throwOnInvalidRequiredAddress, throwOnUnsupportedChainId } from "../../../utils/throw";
|
2
2
|
import Elysia from "elysia";
|
3
|
-
import { ChainArrayOptionalDto } from "../chain";
|
3
|
+
import { ChainArrayOptionalDto } from "../chain/chain.model";
|
4
4
|
import { UserUniqueDto } from "../user";
|
5
5
|
import { ClaimService } from "./claims.service";
|
6
6
|
// ─── Claim Controller ───────────────────────────────────────────────────────
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { ProtocolId } from "../protocol";
|
1
|
+
import type { ProtocolId } from "../protocol/protocol.model";
|
2
2
|
import type { InteractionQuote } from "./interaction.model";
|
3
3
|
export declare abstract class InteractionService {
|
4
4
|
static routers: import("./interaction.model").Router[];
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import {
|
2
|
-
import { decodeFunctionResult, encodeFunctionData, parseAbi } from "viem";
|
3
|
-
import { ChainInteractionService } from "../chainInteraction";
|
1
|
+
import { ChainInteractionService } from "../chainInteraction/chainInteraction.service";
|
4
2
|
import { EnsoService } from "../enso/enso.service";
|
5
3
|
import { KyberZapService } from "../kyberzap/kyberzap.service";
|
4
|
+
import { ETH_ADDRESS, ETH_ZKSYNC_ADDRESS } from "@sdk";
|
5
|
+
import { decodeFunctionResult, encodeFunctionData, parseAbi } from "viem";
|
6
6
|
export class InteractionService {
|
7
7
|
static routers = [KyberZapService, EnsoService].map(service => service.getRouter());
|
8
8
|
/**
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { CacheService } from "../cache";
|
2
2
|
import { TTLPresets } from "../cache/cache.model";
|
3
|
-
import { ChainService } from "../chain";
|
3
|
+
import { ChainService } from "../chain/chain.service";
|
4
4
|
import { MerklRootRepository } from "./merklRoot.repository";
|
5
5
|
export class MerklRootService {
|
6
6
|
static async firstRoot(chainId) {
|
@@ -24,7 +24,10 @@ export const getEulerMetadata = async (chainId, campaignId, campaignSubType, rew
|
|
24
24
|
}
|
25
25
|
return {
|
26
26
|
name,
|
27
|
-
tokens: [
|
27
|
+
tokens: [
|
28
|
+
{ chainId, address: params.targetToken },
|
29
|
+
{ chainId, address: params.addressAsset },
|
30
|
+
],
|
28
31
|
action: [OpportunityAction.LEND, OpportunityAction.BORROW, OpportunityAction.BORROW][campaignSubType],
|
29
32
|
mainProtocol: "euler",
|
30
33
|
};
|
@@ -9,7 +9,13 @@ export declare enum program {
|
|
9
9
|
Beets = "Beets",
|
10
10
|
Celo = "Celo",
|
11
11
|
Swapx = "Swapx",
|
12
|
-
Etherlink = "Etherlink"
|
12
|
+
Etherlink = "Etherlink",
|
13
|
+
Angles = "Angles"
|
14
|
+
}
|
15
|
+
export declare enum anglesCampaigns {
|
16
|
+
Angles_supply_in_angles_liquid = "0x15E96CDecA34B9DE1B31586c1206206aDb92E69D",
|
17
|
+
hold_anS = "0x0C4E186Eae8aCAA7F7de1315D5AD174BE39Ec987",
|
18
|
+
hold_wANS = "0xfA85Fe5A8F5560e9039C04f2b0a90dE1415aBD70"
|
13
19
|
}
|
14
20
|
export declare enum etherlinkCampaigns {
|
15
21
|
Superlend_Supply_WBTC_Etherlink = "Superlend Supply WBTC Etherlink 0xfCA0802cb10b3b134a91e07f03965f63eF4B23eA",
|
@@ -381,6 +387,47 @@ export declare enum modeCampaigns {
|
|
381
387
|
Bedrock_Ionic_Supply_ionuniBTC_Mode = "Bedrock Ionic Supply uniBTC 0xa48750877a83f7dec11f722178c317b54a44d142",
|
382
388
|
Bedrock_Ironclad_Supply_uniBTC_Mode = "Bedrock Ironclad Supply uniBTC 0x0F041cf2ae959f39215EFfB50d681Df55D4d90B1"
|
383
389
|
}
|
390
|
+
declare const AnglesInterfaceCampaigns: {
|
391
|
+
"0x15E96CDecA34B9DE1B31586c1206206aDb92E69D": {
|
392
|
+
campaignType: any;
|
393
|
+
computeChainId: any;
|
394
|
+
hooks: never[];
|
395
|
+
targetToken: string;
|
396
|
+
whitelist: never[];
|
397
|
+
blacklist: never[];
|
398
|
+
targetTokenPricing: boolean;
|
399
|
+
rewardTokenPricing: boolean;
|
400
|
+
apr: string;
|
401
|
+
url: string;
|
402
|
+
forwarders: never[];
|
403
|
+
};
|
404
|
+
"0x0C4E186Eae8aCAA7F7de1315D5AD174BE39Ec987": {
|
405
|
+
campaignType: any;
|
406
|
+
computeChainId: any;
|
407
|
+
hooks: never[];
|
408
|
+
targetToken: string;
|
409
|
+
whitelist: never[];
|
410
|
+
blacklist: never[];
|
411
|
+
targetTokenPricing: boolean;
|
412
|
+
rewardTokenPricing: boolean;
|
413
|
+
apr: string;
|
414
|
+
url: string;
|
415
|
+
forwarders: never[];
|
416
|
+
};
|
417
|
+
"0xfA85Fe5A8F5560e9039C04f2b0a90dE1415aBD70": {
|
418
|
+
campaignType: any;
|
419
|
+
computeChainId: any;
|
420
|
+
hooks: never[];
|
421
|
+
targetToken: string;
|
422
|
+
whitelist: never[];
|
423
|
+
blacklist: never[];
|
424
|
+
targetTokenPricing: boolean;
|
425
|
+
rewardTokenPricing: boolean;
|
426
|
+
apr: string;
|
427
|
+
url: string;
|
428
|
+
forwarders: never[];
|
429
|
+
};
|
430
|
+
};
|
384
431
|
declare const EtherlinkInterfaceCampaigns: {
|
385
432
|
"Superlend Supply WBTC Etherlink 0xfCA0802cb10b3b134a91e07f03965f63eF4B23eA": {
|
386
433
|
campaignType: any;
|
@@ -533,6 +580,6 @@ declare const PufferInterfaceCampaigns: {
|
|
533
580
|
[key in pufferCampaigns]: partialConfig;
|
534
581
|
};
|
535
582
|
export declare const MerklInterfaceCampaigns: {
|
536
|
-
[key in program]: typeof PufferInterfaceCampaigns | typeof ZkSyncInterfaceCampaigns | typeof ModeInterfaceCampaigns | typeof VicunaInterfaceCampaigns | typeof SonicmarketInterfaceCampaigns | typeof ReserveInterfaceCampaigns | typeof BeetsInterfaceCampaigns | typeof CeloInterfaceCampaigns | typeof EtherlinkInterfaceCampaigns | typeof SwapxInterfaceCampaigns;
|
583
|
+
[key in program]: typeof PufferInterfaceCampaigns | typeof ZkSyncInterfaceCampaigns | typeof ModeInterfaceCampaigns | typeof VicunaInterfaceCampaigns | typeof SonicmarketInterfaceCampaigns | typeof ReserveInterfaceCampaigns | typeof BeetsInterfaceCampaigns | typeof CeloInterfaceCampaigns | typeof EtherlinkInterfaceCampaigns | typeof SwapxInterfaceCampaigns | typeof AnglesInterfaceCampaigns;
|
537
584
|
};
|
538
585
|
export {};
|
@@ -11,7 +11,16 @@ export var program;
|
|
11
11
|
program["Celo"] = "Celo";
|
12
12
|
program["Swapx"] = "Swapx";
|
13
13
|
program["Etherlink"] = "Etherlink";
|
14
|
+
program["Angles"] = "Angles";
|
14
15
|
})(program || (program = {}));
|
16
|
+
export var anglesCampaigns;
|
17
|
+
(function (anglesCampaigns) {
|
18
|
+
anglesCampaigns["Angles_supply_in_angles_liquid"] = "0x15E96CDecA34B9DE1B31586c1206206aDb92E69D";
|
19
|
+
anglesCampaigns["hold_anS"] = "0x0C4E186Eae8aCAA7F7de1315D5AD174BE39Ec987";
|
20
|
+
anglesCampaigns["hold_wANS"] = "0xfA85Fe5A8F5560e9039C04f2b0a90dE1415aBD70";
|
21
|
+
// pendle_lp =
|
22
|
+
// pendle PT
|
23
|
+
})(anglesCampaigns || (anglesCampaigns = {}));
|
15
24
|
export var etherlinkCampaigns;
|
16
25
|
(function (etherlinkCampaigns) {
|
17
26
|
etherlinkCampaigns["Superlend_Supply_WBTC_Etherlink"] = "Superlend Supply WBTC Etherlink 0xfCA0802cb10b3b134a91e07f03965f63eF4B23eA";
|
@@ -392,6 +401,47 @@ export var modeCampaigns;
|
|
392
401
|
modeCampaigns["Bedrock_Ionic_Supply_ionuniBTC_Mode"] = "Bedrock Ionic Supply uniBTC 0xa48750877a83f7dec11f722178c317b54a44d142";
|
393
402
|
modeCampaigns["Bedrock_Ironclad_Supply_uniBTC_Mode"] = "Bedrock Ironclad Supply uniBTC 0x0F041cf2ae959f39215EFfB50d681Df55D4d90B1";
|
394
403
|
})(modeCampaigns || (modeCampaigns = {}));
|
404
|
+
const AnglesInterfaceCampaigns = {
|
405
|
+
[anglesCampaigns.Angles_supply_in_angles_liquid]: {
|
406
|
+
campaignType: Campaign.ERC20_FIX_APR,
|
407
|
+
computeChainId: ChainId.SONIC,
|
408
|
+
hooks: [],
|
409
|
+
targetToken: "0x15E96CDecA34B9DE1B31586c1206206aDb92E69D",
|
410
|
+
whitelist: [],
|
411
|
+
blacklist: [],
|
412
|
+
targetTokenPricing: false,
|
413
|
+
rewardTokenPricing: false,
|
414
|
+
apr: "1095",
|
415
|
+
url: "https://sonicscan.org/token/0x15E96CDecA34B9DE1B31586c1206206aDb92E69D#readContract",
|
416
|
+
forwarders: [],
|
417
|
+
},
|
418
|
+
[anglesCampaigns.hold_anS]: {
|
419
|
+
campaignType: Campaign.ERC20_FIX_APR,
|
420
|
+
computeChainId: ChainId.SONIC,
|
421
|
+
hooks: [],
|
422
|
+
targetToken: "0x0C4E186Eae8aCAA7F7de1315D5AD174BE39Ec987",
|
423
|
+
whitelist: [],
|
424
|
+
blacklist: [],
|
425
|
+
targetTokenPricing: false,
|
426
|
+
rewardTokenPricing: false,
|
427
|
+
apr: "365",
|
428
|
+
url: "https://sonicscan.org/token/0x0C4E186Eae8aCAA7F7de1315D5AD174BE39Ec987#readContract",
|
429
|
+
forwarders: [],
|
430
|
+
},
|
431
|
+
[anglesCampaigns.hold_wANS]: {
|
432
|
+
campaignType: Campaign.ERC20_FIX_APR,
|
433
|
+
computeChainId: ChainId.SONIC,
|
434
|
+
hooks: [],
|
435
|
+
targetToken: "0xfA85Fe5A8F5560e9039C04f2b0a90dE1415aBD70",
|
436
|
+
whitelist: [],
|
437
|
+
blacklist: [],
|
438
|
+
targetTokenPricing: false,
|
439
|
+
rewardTokenPricing: false,
|
440
|
+
apr: "365",
|
441
|
+
url: "https://sonicscan.org/token/0xfA85Fe5A8F5560e9039C04f2b0a90dE1415aBD70#readContract",
|
442
|
+
forwarders: [],
|
443
|
+
},
|
444
|
+
};
|
395
445
|
const EtherlinkInterfaceCampaigns = {
|
396
446
|
[etherlinkCampaigns.Superlend_Supply_WBTC_Etherlink]: {
|
397
447
|
campaignType: Campaign.ERC20,
|
@@ -5099,4 +5149,5 @@ export const MerklInterfaceCampaigns = {
|
|
5099
5149
|
[program.Celo]: CeloInterfaceCampaigns,
|
5100
5150
|
[program.Swapx]: SwapxInterfaceCampaigns,
|
5101
5151
|
[program.Etherlink]: EtherlinkInterfaceCampaigns,
|
5152
|
+
[program.Angles]: AnglesInterfaceCampaigns,
|
5102
5153
|
};
|
@@ -1,6 +1,6 @@
|
|
1
|
+
import { ChainService } from "../chain/chain.service";
|
1
2
|
import { TokenService } from "../token/token.service";
|
2
3
|
import { log } from "../../../utils/logger";
|
3
|
-
import { ChainService } from "../chain";
|
4
4
|
import { ProtocolRepository } from "./protocol.repository";
|
5
5
|
// ─── Protocols Services ──────────────────────────────────────────────────────
|
6
6
|
export class ProtocolService {
|
@@ -5,7 +5,7 @@ import { BlacklistService } from "../blacklist";
|
|
5
5
|
import { CacheService } from "../cache";
|
6
6
|
import { TTLPresets } from "../cache/cache.model";
|
7
7
|
import { CampaignService } from "../campaign";
|
8
|
-
import { ChainService } from "../chain";
|
8
|
+
import { ChainService } from "../chain/chain.service";
|
9
9
|
import { MerklRootService } from "../merklRoot";
|
10
10
|
import { OpportunityService } from "../opportunity";
|
11
11
|
import { TokenService } from "../token/token.service";
|
@@ -1,5 +1,5 @@
|
|
1
|
+
import { ChainResourceDto } from "../chain/chain.model";
|
1
2
|
import { t } from "elysia";
|
2
|
-
import { ChainResourceDto } from "../chain";
|
3
3
|
// ─── Dtos ────────────────────────────────────────────────────────────────────
|
4
4
|
export const UserRewardRouteDto = t.Object({
|
5
5
|
chainId: t
|