@merkl/api 0.16.14 → 0.16.16

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.
Files changed (26) hide show
  1. package/dist/src/eden/index.d.ts +270 -0
  2. package/dist/src/entities/opportunity.js +7 -200
  3. package/dist/src/index.d.ts +62 -0
  4. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType.js +1 -1
  5. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/AuraProcessor.d.ts +8 -0
  6. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/AuraProcessor.js +10 -12
  7. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/BalancerPoolProcessor.d.ts +8 -1
  8. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/BalancerPoolProcessor.js +11 -15
  9. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/BalancerV3PoolProcessor.js +4 -5
  10. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/GenericProcessor.js +6 -1
  11. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/StakingProcessor.js +1 -0
  12. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/VicunaProcessor.js +0 -1
  13. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/curveProcessor.d.ts +2 -0
  14. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/curveProcessor.js +2 -0
  15. package/dist/src/modules/v4/referral/referral.controller.d.ts +82 -0
  16. package/dist/src/modules/v4/referral/referral.controller.js +25 -0
  17. package/dist/src/modules/v4/referral/referral.model.d.ts +10 -0
  18. package/dist/src/modules/v4/referral/referral.model.js +12 -0
  19. package/dist/src/modules/v4/referral/referral.service.d.ts +216 -0
  20. package/dist/src/modules/v4/referral/referral.service.js +170 -0
  21. package/dist/src/modules/v4/router.d.ts +62 -0
  22. package/dist/src/modules/v4/router.js +3 -1
  23. package/dist/src/utils/generateIcons.d.ts +3 -0
  24. package/dist/src/utils/generateIcons.js +53 -0
  25. package/dist/tsconfig.package.tsbuildinfo +1 -1
  26. package/package.json +1 -1
@@ -22,6 +22,10 @@ type dataRawBP = callKeysBP & {
22
22
  poolTokens: Array<{
23
23
  token: string;
24
24
  balance: string;
25
+ amountInPool: number;
26
+ symbol: string;
27
+ decimals: number;
28
+ price: number;
25
29
  }>;
26
30
  };
27
31
  type dataTypeBP = dataType & {
@@ -30,7 +34,10 @@ type dataTypeBP = dataType & {
30
34
  vault: string;
31
35
  poolTokens: Array<{
32
36
  token: string;
33
- balance: string;
37
+ amountInPool: number;
38
+ symbol: string;
39
+ decimals: number;
40
+ price: number;
34
41
  }>;
35
42
  totalSupply: number;
36
43
  blacklistedSupply: number;
@@ -25,7 +25,6 @@ export class BalancerPoolProcessor extends GenericProcessor {
25
25
  const vaultBalanceBN = BigNumber.from(typeInfo.vaultBalance);
26
26
  const totalSupplyUpdated = BN2Number(totalSupplyBN.sub(vaultBalanceBN), campaign.campaignParameters.decimalsTargetToken);
27
27
  const vaultBalance = BN2Number(vaultBalanceBN, campaign.campaignParameters.decimalsTargetToken);
28
- const poolTokensinfo = {};
29
28
  let tvl = 0;
30
29
  const symbols = [];
31
30
  let indexUpdated = index + this.rounds.round4.length;
@@ -36,23 +35,16 @@ export class BalancerPoolProcessor extends GenericProcessor {
36
35
  blacklistedSupply -= BN2Number(decodeCall(calls, index + vaultIndex, "balanceOf"), campaign.campaignParameters.decimalsTargetToken); // The vault balance was already removed from the total supply
37
36
  }
38
37
  for (const poolToken of typeInfo.poolTokens) {
39
- const symbol = decodeCall(calls, indexUpdated++, "symbol");
40
- const decimals = decodeCall(calls, indexUpdated++, "decimals");
41
- poolTokensinfo[poolToken.token] = {
42
- symbol: symbol,
43
- decimals: decimals,
44
- amountInPool: BN2Number(poolToken.balance, decimals),
45
- price: (await pricer.get({ symbol: symbol })) ?? 0,
46
- };
47
- tvl += poolTokensinfo[poolToken.token].price * poolTokensinfo[poolToken.token].amountInPool;
48
- symbols.push(symbol);
38
+ poolToken.symbol = decodeCall(calls, indexUpdated++, "symbol");
39
+ poolToken.decimals = decodeCall(calls, indexUpdated++, "decimals");
40
+ poolToken.amountInPool = BN2Number(poolToken.balance, poolToken.decimals);
41
+ poolToken.price = (await pricer.get({ symbol: poolToken.symbol })) ?? 0;
42
+ tvl += poolToken.price * poolToken.amountInPool;
43
+ symbols.push(poolToken.symbol);
49
44
  }
50
45
  const priceTargetToken = tvl / totalSupplyUpdated;
51
46
  return {
52
- tokenAddress: typeInfo.tokenAddress,
53
- poolId: typeInfo.poolId,
54
- vault: typeInfo.vault,
55
- poolTokens: poolTokensinfo,
47
+ ...typeInfo,
56
48
  totalSupply: totalSupplyUpdated,
57
49
  whitelistedSupplyTargetToken,
58
50
  blacklistedSupply,
@@ -72,6 +64,10 @@ export class BalancerPoolProcessor extends GenericProcessor {
72
64
  poolTokens.push({
73
65
  token: token,
74
66
  balance: balances[i].toString(),
67
+ amountInPool: 0,
68
+ symbol: "",
69
+ decimals: 0,
70
+ price: 0,
75
71
  });
76
72
  }
77
73
  i++;
@@ -40,8 +40,10 @@ export class BalancerV3PoolProcessor extends GenericProcessor {
40
40
  const { whitelistedSupplyTargetToken, totalSupply, blacklistedSupply } = this.handleWhiteListBlacklistRound5(typeInfo, campaign);
41
41
  let tvl = 0;
42
42
  for (let i = 0; i < typeInfo.numberTokens; i++) {
43
- const symbol = typeInfo[`symbolToken${i}`];
43
+ let symbol = typeInfo[`symbolToken${i}`];
44
44
  const price = (await pricer.get({ symbol: symbol })) ?? 0;
45
+ symbol = symbol.replace("wmooSiloV2Sonic", "");
46
+ typeInfo[`symbolToken${i}`] = symbol.replace(" (wS Market)", "");
45
47
  const decimals = Number(typeInfo[`decimalsToken${i}`]);
46
48
  const amount = BN2Number(typeInfo[`balanceToken${i}`], decimals);
47
49
  tvl += amount * price;
@@ -58,10 +60,7 @@ export class BalancerV3PoolProcessor extends GenericProcessor {
58
60
  }
59
61
  const symbols = [];
60
62
  for (let i = 0; i < typeInfo.numberTokens; i++) {
61
- let symbolToClean = typeInfo[`symbolToken${i}`];
62
- symbolToClean = symbolToClean.replace("wmooSiloV2Sonic", "");
63
- symbolToClean = symbolToClean.replace(" (wS Market)", "");
64
- symbols.push(symbolToClean);
63
+ symbols.push(typeInfo[`symbolToken${i}`]);
65
64
  }
66
65
  return {
67
66
  ...typeInfo,
@@ -1,6 +1,7 @@
1
1
  import { decodeCall } from "../../../../../utils/decodeCalls";
2
2
  import { createCall } from "../../../../../utils/encodeCalls";
3
3
  import { generateCardName } from "../../../../../utils/generateCardName";
4
+ import { generateIcons } from "../../../../../utils/generateIcons";
4
5
  import { BN2Number } from "@sdk";
5
6
  import { tokenTypeToProtocol } from "../helpers/tokenType";
6
7
  export var roundType;
@@ -130,7 +131,10 @@ export class GenericProcessor {
130
131
  console.log("Round 5", {
131
132
  type: type,
132
133
  calls: [],
133
- outputInfo,
134
+ typeInfo: {
135
+ ...outputInfo,
136
+ icons: generateIcons(type, typeInfo, campaign),
137
+ },
134
138
  });
135
139
  }
136
140
  return {
@@ -138,6 +142,7 @@ export class GenericProcessor {
138
142
  calls: [],
139
143
  typeInfo: {
140
144
  ...outputInfo,
145
+ icons: generateIcons(type, typeInfo, campaign),
141
146
  },
142
147
  };
143
148
  }
@@ -5,6 +5,7 @@ export class StakingProcessor extends GenericProcessor {
5
5
  round1: [
6
6
  { key: "lockNFT", call: "lockNFT", target: "stakingContract", optional: true },
7
7
  { key: "eip712DomainName", call: "eip712DomainName", target: "stakingContract", optional: true },
8
+ { key: "stakingSymbol", call: "symbol", target: "stakingContract", optional: true },
8
9
  ],
9
10
  round2: [{ key: "stakingSymbol", call: "symbol", target: "lockNFT", optional: true }],
10
11
  round3: [],
@@ -21,7 +21,6 @@ export class VicunaProcessor extends GenericProcessor {
21
21
  const vicunaTVL = (await axios("https://vicuna.orthae.xyz/tvl/details")).data;
22
22
  // find the entry that matches the vault address
23
23
  const tvl = findTvlByVaultAddress(vicunaTVL[campaign.chainId], typeInfo.tokenAddress) ?? 0;
24
- console.log("tvl", tvl);
25
24
  const priceTargetToken = tvl / totalSupply;
26
25
  return {
27
26
  ...typeInfo,
@@ -22,8 +22,10 @@ type dataRawCurve = callKeysCurve & {
22
22
  poolTokens: {
23
23
  [key: string]: string;
24
24
  };
25
+ numberTokens: number;
25
26
  };
26
27
  type dataTypeCurve = dataType & {
28
+ numberTokens: number;
27
29
  lp_price: number;
28
30
  token0: string;
29
31
  token1: string;
@@ -29,12 +29,14 @@ export class CurveProcessor extends GenericProcessor {
29
29
  [typeInfo.token1]: typeInfo.symbolToken1,
30
30
  [typeInfo.token2]: typeInfo.symbolToken2,
31
31
  };
32
+ typeInfo.numberTokens = 3;
32
33
  }
33
34
  else {
34
35
  typeInfo.poolTokens = {
35
36
  [typeInfo.token0]: typeInfo.symbolToken0,
36
37
  [typeInfo.token1]: typeInfo.symbolToken1,
37
38
  };
39
+ typeInfo.numberTokens = 2;
38
40
  }
39
41
  if (type === tokenType.curve_2) {
40
42
  const prices = [];
@@ -0,0 +1,82 @@
1
+ import Elysia from "elysia";
2
+ export declare const ReferralController: Elysia<"/referral", false, {
3
+ decorator: {};
4
+ store: {};
5
+ derive: {};
6
+ resolve: {};
7
+ }, {
8
+ type: {};
9
+ error: {};
10
+ }, {
11
+ schema: {};
12
+ macro: {};
13
+ macroFn: {};
14
+ }, {
15
+ referral: {
16
+ code: {
17
+ get: {
18
+ body: unknown;
19
+ params: {};
20
+ query: {
21
+ chainId: number;
22
+ address: string;
23
+ referralKey: string;
24
+ };
25
+ headers: unknown;
26
+ response: {
27
+ 200: {
28
+ code: string;
29
+ referrer: boolean;
30
+ referredUsers: never[];
31
+ transaction: {
32
+ to: string;
33
+ data: `0x${string}`;
34
+ };
35
+ } | {
36
+ code: any;
37
+ referrer: boolean;
38
+ referredUsers: any;
39
+ transaction?: undefined;
40
+ };
41
+ };
42
+ };
43
+ };
44
+ };
45
+ } & {
46
+ referral: {
47
+ redeem: {
48
+ get: {
49
+ body: unknown;
50
+ params: {};
51
+ query: {
52
+ code: string;
53
+ chainId: number;
54
+ referralKey: string;
55
+ };
56
+ headers: unknown;
57
+ response: {
58
+ 200: {
59
+ code: string;
60
+ referrer: any;
61
+ transaction?: undefined;
62
+ } | {
63
+ code: string;
64
+ referrer: any;
65
+ transaction: {
66
+ to: string;
67
+ data: `0x${string}`;
68
+ };
69
+ };
70
+ };
71
+ };
72
+ };
73
+ };
74
+ }, {
75
+ derive: {};
76
+ resolve: {};
77
+ schema: {};
78
+ }, {
79
+ derive: {};
80
+ resolve: {};
81
+ schema: {};
82
+ }>;
@@ -0,0 +1,25 @@
1
+ import { throwOnUnsupportedChainId } from "../../../utils/throw";
2
+ import Elysia from "elysia";
3
+ import { ReferralCodeDto, ReferralRedeemCodeDto } from "./referral.model";
4
+ import { ReferralService } from "./referral.service";
5
+ // ─── Rewards Controller ──────────────────────────────────────────────────────
6
+ export const ReferralController = new Elysia({ prefix: "/referral", detail: { tags: ["Referral"] } })
7
+ // ─── Get Reward Breakdowns For Campaign Ids ──────────────────────────
8
+ .get("/code", async ({ query: { chainId, referralKey, address } }) => await ReferralService.getCodeOrTransaction(chainId, referralKey, address), {
9
+ query: ReferralCodeDto,
10
+ beforeHandle: ({ query: { chainId } }) => {
11
+ throwOnUnsupportedChainId(chainId);
12
+ },
13
+ detail: {
14
+ description: "Returns the transaction to register user as a referrer on-chain and some additional state",
15
+ },
16
+ })
17
+ .get("/redeem", async ({ query: { chainId, referralKey, code } }) => await ReferralService.getReferralTransaction(chainId, referralKey, code), {
18
+ query: ReferralRedeemCodeDto,
19
+ beforeHandle: ({ query: { chainId } }) => {
20
+ throwOnUnsupportedChainId(chainId);
21
+ },
22
+ detail: {
23
+ description: "Returns the transaction to redeem a referral code on-chain and some additional state",
24
+ },
25
+ });
@@ -0,0 +1,10 @@
1
+ export declare const ReferralCodeDto: import("@sinclair/typebox").TObject<{
2
+ chainId: import("@sinclair/typebox").TNumber;
3
+ referralKey: import("@sinclair/typebox").TString;
4
+ address: import("@sinclair/typebox").TString;
5
+ }>;
6
+ export declare const ReferralRedeemCodeDto: import("@sinclair/typebox").TObject<{
7
+ chainId: import("@sinclair/typebox").TNumber;
8
+ referralKey: import("@sinclair/typebox").TString;
9
+ code: import("@sinclair/typebox").TString;
10
+ }>;
@@ -0,0 +1,12 @@
1
+ import { t } from "elysia";
2
+ // ─── DTOs ────────────────────────────────────────────────────────────────────
3
+ export const ReferralCodeDto = t.Object({
4
+ chainId: t.Number(),
5
+ referralKey: t.String(),
6
+ address: t.String(),
7
+ });
8
+ export const ReferralRedeemCodeDto = t.Object({
9
+ chainId: t.Number(),
10
+ referralKey: t.String(),
11
+ code: t.String(),
12
+ });
@@ -0,0 +1,216 @@
1
+ export declare abstract class ReferralService {
2
+ #private;
3
+ static abi: readonly [{
4
+ readonly name: "getReferralKeys";
5
+ readonly type: "function";
6
+ readonly stateMutability: "view";
7
+ readonly inputs: readonly [];
8
+ readonly outputs: readonly [{
9
+ readonly type: "string[]";
10
+ }];
11
+ }, {
12
+ readonly name: "getReferrerStatus";
13
+ readonly type: "function";
14
+ readonly stateMutability: "view";
15
+ readonly inputs: readonly [{
16
+ readonly type: "string";
17
+ readonly name: "key";
18
+ }, {
19
+ readonly type: "address";
20
+ readonly name: "user";
21
+ }];
22
+ readonly outputs: readonly [{
23
+ readonly type: "bytes32";
24
+ }];
25
+ }, {
26
+ readonly name: "referrerCodeMapping";
27
+ readonly type: "function";
28
+ readonly stateMutability: "view";
29
+ readonly inputs: readonly [{
30
+ readonly type: "string";
31
+ readonly name: "key";
32
+ }, {
33
+ readonly type: "address";
34
+ readonly name: "user";
35
+ }];
36
+ readonly outputs: readonly [{
37
+ readonly type: "string";
38
+ }];
39
+ }, {
40
+ readonly name: "codeToReferrer";
41
+ readonly type: "function";
42
+ readonly stateMutability: "view";
43
+ readonly inputs: readonly [{
44
+ readonly type: "string";
45
+ readonly name: "key";
46
+ }, {
47
+ readonly type: "string";
48
+ readonly name: "user";
49
+ }];
50
+ readonly outputs: readonly [{
51
+ readonly type: "address";
52
+ }];
53
+ }, {
54
+ readonly name: "getReferrer";
55
+ readonly type: "function";
56
+ readonly stateMutability: "view";
57
+ readonly inputs: readonly [{
58
+ readonly type: "string";
59
+ readonly name: "key";
60
+ }, {
61
+ readonly type: "address";
62
+ readonly name: "user";
63
+ }];
64
+ readonly outputs: readonly [{
65
+ readonly type: "address";
66
+ }];
67
+ }, {
68
+ readonly name: "getReferredUsers";
69
+ readonly type: "function";
70
+ readonly stateMutability: "view";
71
+ readonly inputs: readonly [{
72
+ readonly type: "string";
73
+ readonly name: "key";
74
+ }, {
75
+ readonly type: "address";
76
+ readonly name: "user";
77
+ }];
78
+ readonly outputs: readonly [{
79
+ readonly type: "address[]";
80
+ }];
81
+ }, {
82
+ readonly name: "acknowledgeReferrerByKey";
83
+ readonly type: "function";
84
+ readonly stateMutability: "nonpayable";
85
+ readonly inputs: readonly [{
86
+ readonly type: "string";
87
+ readonly name: "key";
88
+ }, {
89
+ readonly type: "string";
90
+ readonly name: "referrerCode";
91
+ }];
92
+ readonly outputs: readonly [];
93
+ }, {
94
+ readonly name: "getCostOfReferral";
95
+ readonly type: "function";
96
+ readonly stateMutability: "view";
97
+ readonly inputs: readonly [{
98
+ readonly type: "string";
99
+ readonly name: "key";
100
+ }];
101
+ readonly outputs: readonly [{
102
+ readonly type: "uint256";
103
+ }];
104
+ }, {
105
+ readonly name: "getPaymentToken";
106
+ readonly type: "function";
107
+ readonly stateMutability: "view";
108
+ readonly inputs: readonly [{
109
+ readonly type: "string";
110
+ readonly name: "key";
111
+ }];
112
+ readonly outputs: readonly [{
113
+ readonly type: "address";
114
+ }];
115
+ }, {
116
+ readonly name: "getReferrerStatusByKey";
117
+ readonly type: "function";
118
+ readonly stateMutability: "view";
119
+ readonly inputs: readonly [{
120
+ readonly type: "string";
121
+ readonly name: "key";
122
+ }, {
123
+ readonly type: "address";
124
+ readonly name: "referrer";
125
+ }];
126
+ readonly outputs: readonly [{
127
+ readonly type: "uint8";
128
+ }];
129
+ }, {
130
+ readonly name: "requiresAuthorization";
131
+ readonly type: "function";
132
+ readonly stateMutability: "view";
133
+ readonly inputs: readonly [{
134
+ readonly type: "string";
135
+ readonly name: "key";
136
+ }];
137
+ readonly outputs: readonly [{
138
+ readonly type: "bool";
139
+ }];
140
+ }, {
141
+ readonly name: "requiresRefererToBeSet";
142
+ readonly type: "function";
143
+ readonly stateMutability: "view";
144
+ readonly inputs: readonly [{
145
+ readonly type: "string";
146
+ readonly name: "key";
147
+ }];
148
+ readonly outputs: readonly [{
149
+ readonly type: "bool";
150
+ }];
151
+ }, {
152
+ readonly name: "becomeReferrer";
153
+ readonly type: "function";
154
+ readonly stateMutability: "payable";
155
+ readonly inputs: readonly [{
156
+ readonly type: "string";
157
+ readonly name: "key";
158
+ }, {
159
+ readonly type: "string";
160
+ readonly name: "referrerCode";
161
+ }];
162
+ readonly outputs: readonly [];
163
+ }];
164
+ static getReferralContract(chainId: number): "0xF39CC381B91f36238c77f42B9fF4D45376F80E5b" | undefined;
165
+ static isKeyAvailable(key: string, chainId: number): Promise<any>;
166
+ static getReferredUsers(chainId: number, key: string, address: string): Promise<any>;
167
+ static getReferralStatus(chainId: number, key: string, address: string): Promise<boolean>;
168
+ static generateCode(chainId: number, key: string, address: string): string;
169
+ static getCode(chainId: number, key: string, address: string): Promise<any>;
170
+ /**
171
+ * Get state & transaction for creating a referral code
172
+ * @param chainId of the referral contract
173
+ * @param key of referral
174
+ * @param address of the creator
175
+ */
176
+ static getCodeOrTransaction(chainId: number, key: string, address: string): Promise<{
177
+ code: string;
178
+ referrer: boolean;
179
+ referredUsers: never[];
180
+ transaction: {
181
+ to: string;
182
+ data: `0x${string}`;
183
+ };
184
+ } | {
185
+ code: any;
186
+ referrer: boolean;
187
+ referredUsers: any;
188
+ transaction?: undefined;
189
+ }>;
190
+ /**
191
+ * Checks if code exists in the contracts
192
+ * @param chainId of the referral contract
193
+ * @param key of referral
194
+ * @param code user referral code
195
+ * @returns referrerAddress if code exitst
196
+ */
197
+ static isCodeRegistered(chainId: number, key: string, code: string): Promise<any>;
198
+ /**
199
+ * Get state & transaction for redeeming a referral code
200
+ * @param chainId of the referral contract
201
+ * @param key of referral
202
+ * @param code user referral code
203
+ */
204
+ static getReferralTransaction(chainId: number, key: string, code: string): Promise<{
205
+ code: string;
206
+ referrer: any;
207
+ transaction?: undefined;
208
+ } | {
209
+ code: string;
210
+ referrer: any;
211
+ transaction: {
212
+ to: string;
213
+ data: `0x${string}`;
214
+ };
215
+ }>;
216
+ }