@merkl/api 0.10.162 → 0.10.164

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.
@@ -51,7 +51,8 @@ export declare enum tokenType {
51
51
  woofi = "woofi",
52
52
  pendle = "pendle",
53
53
  maverickBoostedPosition = "maverickBoostedPosition",
54
- zkSwapThreePool = "zkSwapThreePool"
54
+ zkSwapThreePool = "zkSwapThreePool",
55
+ maha = "maha"
55
56
  }
56
57
  export declare const tokenTypeToProtocol: {
57
58
  [key in tokenType]: {
@@ -53,6 +53,7 @@ export var tokenType;
53
53
  tokenType["pendle"] = "pendle";
54
54
  tokenType["maverickBoostedPosition"] = "maverickBoostedPosition";
55
55
  tokenType["zkSwapThreePool"] = "zkSwapThreePool";
56
+ tokenType["maha"] = "maha";
56
57
  })(tokenType || (tokenType = {}));
57
58
  export const tokenTypeToProtocol = {
58
59
  [tokenType.aave_borrowing]: { protocol: "Aave" },
@@ -115,4 +116,7 @@ export const tokenTypeToProtocol = {
115
116
  [tokenType.zkSwapThreePool]: {
116
117
  protocol: "ZKSwap",
117
118
  },
119
+ [tokenType.maha]: {
120
+ protocol: "Maha",
121
+ },
118
122
  };
@@ -25,6 +25,7 @@ import { UniswapProcessor } from "./UniswapProcessor";
25
25
  import { WoofiProcessor } from "./WoofiProcessor";
26
26
  import { ZkSwapThreePoolProcessor } from "./ZkSwapThreePoolProcessor";
27
27
  import { CurveProcessor } from "./curveProcessor";
28
+ import { StakedCurveProcessor } from "./stakedCurveProcessor";
28
29
  export const processorMapping = {
29
30
  [tokenType.uniswapv2]: UniswapProcessor,
30
31
  [tokenType.balancerGauge]: BalancerGaugeProcessor,
@@ -78,4 +79,5 @@ export const processorMapping = {
78
79
  [tokenType.woofi]: WoofiProcessor,
79
80
  [tokenType.maverickBoostedPosition]: MaverickBPProcessor,
80
81
  [tokenType.zkSwapThreePool]: ZkSwapThreePoolProcessor,
82
+ [tokenType.maha]: StakedCurveProcessor,
81
83
  };
@@ -0,0 +1,54 @@
1
+ import type { Pricer } from "../../../../../utils/pricer";
2
+ import { type Campaign, type CampaignParameters } from "@sdk";
3
+ import { tokenType } from "../helpers/tokenType";
4
+ import { GenericProcessor, type dataType, type mandatoryCallKeys } from "./GenericProcessor";
5
+ type callType = {
6
+ key: keyof dataRawStakedCurve;
7
+ call: string;
8
+ target: keyof callKeysStakedCurve;
9
+ metaData?: keyof callKeysStakedCurve;
10
+ optional?: boolean;
11
+ };
12
+ type callKeysStakedCurve = mandatoryCallKeys & {
13
+ lp_price: string;
14
+ token0: string;
15
+ token1: string;
16
+ token2: string;
17
+ symbolToken0: string;
18
+ symbolToken1: string;
19
+ symbolToken2: string;
20
+ underlying: string;
21
+ amount: string;
22
+ };
23
+ type dataRawStakedCurve = callKeysStakedCurve & {
24
+ poolTokens: {
25
+ [key: string]: string;
26
+ };
27
+ toAssets: string;
28
+ symbolUnderlyingToken: string;
29
+ };
30
+ type dataTypeStakedCurve = dataType & {
31
+ lp_price: number;
32
+ token0: string;
33
+ token1: string;
34
+ token2: string;
35
+ symbolToken0: string;
36
+ symbolToken1: string;
37
+ underlying: string;
38
+ symbolToken2: string;
39
+ symbolUnderlyingToken: string;
40
+ poolTokens: {
41
+ [key: string]: string;
42
+ };
43
+ };
44
+ export declare class StakedCurveProcessor extends GenericProcessor<callKeysStakedCurve, dataRawStakedCurve, dataTypeStakedCurve> {
45
+ rounds: {
46
+ round1: callType[];
47
+ round2: callType[];
48
+ round3: callType[];
49
+ round4: callType[];
50
+ };
51
+ processingRound3(typeInfo: dataRawStakedCurve): void;
52
+ processingRound5(_index: number, type: tokenType, typeInfo: dataRawStakedCurve, _calls: string[], campaign: CampaignParameters<Campaign.ERC20> | CampaignParameters<Campaign.EULER>, pricer: Pricer): Promise<dataTypeStakedCurve>;
53
+ }
54
+ export {};
@@ -0,0 +1,77 @@
1
+ import { generateCardName } from "../../../../../utils/generateCardName";
2
+ import { BN2Number } from "@sdk";
3
+ import { BigNumber } from "ethers";
4
+ import { tokenType } from "../helpers/tokenType";
5
+ import { GenericProcessor } from "./GenericProcessor";
6
+ export class StakedCurveProcessor extends GenericProcessor {
7
+ rounds = {
8
+ round1: [{ key: "underlying", call: "underlying", target: "tokenAddress" }],
9
+ round2: [
10
+ { key: "lp_price", call: "lp_price", target: "underlying" },
11
+ { key: "symbolUnderlyingToken", call: "symbol", target: "underlying" },
12
+ { key: "token0", call: "coin0", target: "underlying" },
13
+ { key: "token1", call: "coin1", target: "underlying" },
14
+ { key: "token2", call: "coin2", target: "underlying", optional: true },
15
+ ],
16
+ round3: [
17
+ { key: "symbolToken0", call: "symbol", target: "token0" },
18
+ { key: "symbolToken1", call: "symbol", target: "token1" },
19
+ { key: "symbolToken2", call: "symbol", target: "token2", optional: true },
20
+ ],
21
+ round4: [
22
+ { key: "toAssets", call: "convertToAssets", target: "tokenAddress", metaData: "amount" },
23
+ { key: "totalSupply", call: "totalSupply", target: "tokenAddress" },
24
+ ],
25
+ };
26
+ // override computeRound1(): void {}
27
+ processingRound3(typeInfo) {
28
+ typeInfo.amount = BigNumber.from(10).pow(18).toString();
29
+ }
30
+ async processingRound5(_index, type, typeInfo, _calls, campaign, pricer) {
31
+ const { whitelistedSupplyTargetToken, totalSupply, blacklistedSupply } = this.handleWhiteListBlacklistRound5(typeInfo, campaign);
32
+ const lp_price = BN2Number(typeInfo.lp_price, 18);
33
+ let priceTargetToken = lp_price;
34
+ if (typeInfo.token2) {
35
+ typeInfo.poolTokens = {
36
+ [typeInfo.token0]: typeInfo.symbolToken0,
37
+ [typeInfo.token1]: typeInfo.symbolToken1,
38
+ [typeInfo.token2]: typeInfo.symbolToken2,
39
+ };
40
+ }
41
+ else {
42
+ typeInfo.poolTokens = {
43
+ [typeInfo.token0]: typeInfo.symbolToken0,
44
+ [typeInfo.token1]: typeInfo.symbolToken1,
45
+ };
46
+ }
47
+ if (type === tokenType.curve_2) {
48
+ const prices = [];
49
+ for (const symbol of Object.values(typeInfo.poolTokens)) {
50
+ const price = (await pricer.get({ symbol: symbol })) ?? 0;
51
+ prices.push(price);
52
+ }
53
+ let minPrice = Math.min(...prices);
54
+ if (!minPrice) {
55
+ minPrice = 1;
56
+ }
57
+ priceTargetToken = priceTargetToken * minPrice;
58
+ }
59
+ const exchangeRate = BN2Number(typeInfo.toAssets, 18);
60
+ const tvl = priceTargetToken * totalSupply * exchangeRate;
61
+ return {
62
+ ...typeInfo,
63
+ lp_price,
64
+ poolTokens: {
65
+ [typeInfo.token0]: typeInfo.symbolToken0,
66
+ [typeInfo.token1]: typeInfo.symbolToken1,
67
+ [typeInfo.token2]: typeInfo.symbolToken2,
68
+ },
69
+ totalSupply,
70
+ tvl,
71
+ whitelistedSupplyTargetToken,
72
+ blacklistedSupply,
73
+ priceTargetToken,
74
+ cardName: generateCardName(type, typeInfo, campaign),
75
+ };
76
+ }
77
+ }
@@ -88,6 +88,8 @@ function satisfiesNameConditions(name, type) {
88
88
  return lowerCaseName.includes("maverick");
89
89
  case tokenType.zkSwapThreePool:
90
90
  return lowerCaseName.includes("zf");
91
+ case tokenType.maha:
92
+ return lowerCaseName.includes("staked") && lowerCaseName.includes("maha");
91
93
  default:
92
94
  return false;
93
95
  }
@@ -265,10 +265,12 @@ export class RewardService {
265
265
  return acc;
266
266
  }, {});
267
267
  const data = await RewardRepository.getUnclaimed(x);
268
- return data.reduce((acc, { amount, campaignId }) => {
268
+ return data.reduce((acc, { amount, campaignId, claimed }) => {
269
269
  if (!acc[campaignToCampaignIds[campaignId]])
270
270
  acc[campaignToCampaignIds[campaignId]] = "0";
271
- acc[campaignToCampaignIds[campaignId]] = (BigInt(acc[campaignToCampaignIds[campaignId]]) + BigInt(amount)).toString();
271
+ acc[campaignToCampaignIds[campaignId]] = (BigInt(acc[campaignToCampaignIds[campaignId]]) +
272
+ BigInt(amount) -
273
+ BigInt(claimed)).toString();
272
274
  return acc;
273
275
  }, {});
274
276
  }
@@ -1,5 +1,10 @@
1
1
  import type { App } from "../../index";
2
2
  import { RewardService } from "../../modules/v4/reward";
3
+ export declare const query: import("@sinclair/typebox").TObject<{
4
+ chainIds: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>]>>;
5
+ user: import("@sinclair/typebox").TString;
6
+ creatorTag: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
7
+ }>;
3
8
  declare const _default: (app: App) => import("elysia").default<"", false, {
4
9
  decorator: {};
5
10
  store: {};
@@ -1,14 +1,14 @@
1
1
  import { RewardService } from "../../modules/v4/reward";
2
2
  import { RewardConvertorService } from "../../modules/v4/reward/subservices/converter";
3
- import { throwOnInvalidRequiredAddress } from "../../utils/throw";
4
3
  import { ChainId, isSupportedChain } from "@sdk";
5
4
  import { t } from "elysia";
6
- const QueryDto = t.Object({
5
+ import checkQueryAddressValidity from "../../hooks/checkQueryAddressValidity";
6
+ export const query = t.Object({
7
7
  chainIds: t.Optional(t.Union([t.String(), t.Array(t.String())])),
8
8
  user: t.String(),
9
9
  creatorTag: t.Optional(t.String()),
10
10
  });
11
- export default (app) => app.get("", async ({ query }) => {
11
+ export default (app) => app.use(checkQueryAddressValidity()).get("", async ({ query }) => {
12
12
  let rawChainIds = query.chainIds;
13
13
  if (typeof rawChainIds === "string" && rawChainIds.includes(",")) {
14
14
  rawChainIds = rawChainIds.split(",");
@@ -30,10 +30,4 @@ export default (app) => app.get("", async ({ query }) => {
30
30
  const v4Res = await RewardService.getUserRewardsByChain(user, false, chainIds);
31
31
  const v3Res = RewardConvertorService.convertV4toRewardV3(v4Res);
32
32
  return v3Res;
33
- }, {
34
- query: QueryDto,
35
- tags: ["Rewards"],
36
- beforeHandle: ({ query }) => {
37
- throwOnInvalidRequiredAddress(query.user);
38
- },
39
- });
33
+ }, { query, tags: ["Rewards"] });
@@ -79,6 +79,7 @@ export function decodeCall(calls, index, key, type) {
79
79
  return LayerBankInterface.decodeFunctionResult("underlying", returnData)[0];
80
80
  case tokenType.euler_borrow:
81
81
  case tokenType.euler_lend:
82
+ case tokenType.maha:
82
83
  return EulerInterface.decodeFunctionResult("asset", returnData)[0];
83
84
  default:
84
85
  throw new Error(`Need tokenType for this key ${key}, or type ${type} not matched`);
@@ -111,6 +112,7 @@ export function decodeCall(calls, index, key, type) {
111
112
  case tokenType.curve:
112
113
  return CurveInterface.decodeFunctionResult("lp_price", returnData)[0];
113
114
  case tokenType.curve_2:
115
+ case tokenType.maha:
114
116
  return CurveInterface.decodeFunctionResult("get_virtual_price", returnData)[0];
115
117
  default:
116
118
  throw new Error(`Need tokenType for this key ${key}`);
@@ -12,6 +12,7 @@ export function createCall(target, key, type, metaData) {
12
12
  case tokenType.curve:
13
13
  return { allowFailure: true, callData: CurveInterface.encodeFunctionData("lp_price"), target };
14
14
  case tokenType.curve_2:
15
+ case tokenType.maha:
15
16
  return { allowFailure: true, callData: CurveInterface.encodeFunctionData("get_virtual_price"), target };
16
17
  default:
17
18
  throw new Error(`Need tokenType for this key ${key}`);
@@ -68,6 +69,7 @@ export function createCall(target, key, type, metaData) {
68
69
  case tokenType.fluid:
69
70
  return { allowFailure: true, callData: FluidInterface.encodeFunctionData("asset"), target };
70
71
  case tokenType.euler_borrow:
72
+ case tokenType.maha:
71
73
  case tokenType.euler_lend:
72
74
  return {
73
75
  allowFailure: true,
@@ -87,6 +87,8 @@ export function generateCardName(type, typeInfo, campaign, symbols = [""]) {
87
87
  return `Hold (or stake) Maverick Boosted Position ${campaign.campaignParameters.symbolTargetToken} on ${typeInfo.protocol}`;
88
88
  case tokenType.zkSwapThreePool:
89
89
  return `Hold (or stake) ${campaign.campaignParameters.symbolTargetToken} ${typeInfo.symbolToken0}-${typeInfo.symbolToken1}-${typeInfo.symbolToken2} on ${typeInfo.protocol}`;
90
+ case tokenType.maha:
91
+ return `Stake ${typeInfo.symbolToken0}/${typeInfo.symbolToken1} LP on ${typeInfo.protocol}`;
90
92
  default:
91
93
  return `Hold ${typeInfo.name} (${campaign.campaignParameters.symbolTargetToken})`;
92
94
  }