@merkl/api 0.10.305 → 0.10.307

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.
@@ -1374,9 +1374,12 @@ declare const app: Elysia<"", false, {
1374
1374
  engine: {
1375
1375
  post: {
1376
1376
  body: {
1377
+ pending: string;
1377
1378
  recipient: string;
1378
1379
  distributionChainId: number;
1380
+ amount: string;
1379
1381
  root: string;
1382
+ claimed: string;
1380
1383
  proofs: string[];
1381
1384
  rewardToken: string;
1382
1385
  }[];
@@ -4,32 +4,33 @@ export declare enum program {
4
4
  ZkSync = "ZkSync"
5
5
  }
6
6
  export declare enum pufferCampaigns {
7
- Zircuit_Restaking_Pool = "PufferProgram Zircuit Restaking Pool 0xF047ab4c75cebf0eB9ed34Ae2c186f3611aEAfa6",//
8
- Pendle_26_JUN_2025 = "PufferProgram Pendle 26 JUN 2025 0x784A0bb8208C70290cac6bcBC3650cEb9227813E",//
9
- Pendle_26_JUN_2025_YT = "PufferProgram YT Pendle 26 JUN 2025 0x784A0bb8208C70290cac6bcBC3650cEb9227813E",//
10
- Karak = "PufferProgram Karak 0x68754d29f2e97B837Cb622ccfF325adAC27E9977",//
11
- Curve_pufEth = "PufferProgram Curve pufEth 0xEEda34A377dD0ca676b9511EE1324974fA8d980D",//
12
- Morpho_pufETH_WETH = "PufferProgram Morpho Weth 0x0eed5a89c7d397d02fd0b9b8e42811ca67e50ed5aeaa4f22e506516c716cfbbf",//
13
- Pencils_ppufEth = "PufferProgram Pencils PufferVault 0x0C530882C0900b13FC6E8312B52c26e7a5b8e505",//
14
- Morpho_pufETH_USDC = "PufferProgram Morpho USDC 0x7e9c708876fa3816c46aeb08937b51aa0461c2af3865ecb306433db8a80b1d1b",//
15
- balancer_wstETH_pufETH = "PufferProgram Balancer Vault wstETH_pufETH 0x63E0d47A6964aD1565345Da9bfA66659F4983F02",//
16
- curve_llamalend = "PufferProgram Curve Llama wstETH 0xcd28cF8f7755f03967D27E128B38022B63919836",
17
- cyber_staking_pool = "PufferProgram Cyber Staking Pool 0x18eeD20f71BEf84B605253C89A7576E3634134C0",//
18
- aura_balancer_wstETH_pufETH = "PufferProgram Aura Balancer Vault wstETH_pufETH 0x6Ea41486A8f21EED7B20AfDB681b90a5B6C6D029",//
19
- kinza_pufETH = "PufferProgram Kinza Puf Eth 0x5651bb75dE3c78815D420602B4Ce67D04a233873",//
20
- zerolend_pufETH = "PufferProgram Zerolend Puf Eth 0xdD7Afc0f014A1E1716307Ff040704fA12E8D33A3",//
21
- desyn_pufETH = "PufferProgram Desyn 0x3a8099D8FE5C072bB035381003993393072D3ec7",//
22
- gamma_swap_pufETH = "PufferProgram GammaSwap V1 0x1a33B9be3Fe58C1Bde4325A68c09C1F7fA8aA1e5",//
23
- Morpho_pufETH_USDA = "PufferProgram Morpho USDA 0xa42ba90e4d3013dee8eb0d7bb7ae0817297337eeecd525dbdd48c7b5c5e6988d",
24
- pufETH_hold = "PufferProgram pufETH Hold 0xD9A442856C234a39a81a089C06451EBAa4306a72",//
25
- unifiETH_hold = "PufferProgram unifiETH Hold 0x196ead472583Bc1e9aF7A05F860D9857e1Bd3dCc",//
26
- vePuffer = "PufferProgram vePuffer 0x4d1C297d39C5c1277964D0E3f8Aa901493664530",//
27
- mindNetwork_pufETH = "PufferProgram Mind Network 0x0124183e894aED6558c445Ff125801753e834216",//
28
- pancakeSwap_xpufEth = "PufferProgram PancakeSwap xPufEth 0x2b8d093f22f7b6f53d02aca106de3eabc0937d45",//
29
- aerodrome_cl50_xpufETH = "PufferProgram Aerodrome CL50-xpufETH / WETH 0xCDf927C0F7b81b146C0C9e9323eb5A28D1BFA183",//
30
- uniswapv3_eth_pufETH = "PufferProgram Uniswap V3 eth_pufETH 0xBDB04e915B94FbFD6e8552ff7860E59Db7d4499a",//
31
- uniswapv3_weth_PUFFER = "PufferProgram Uniswap V3 weth_PUFFER 0xc5c9a9AB6403CDBa9722463000146C18b504F0bA",//
32
- uniswapv3_vt_weth = "PufferProgram Uniswap V3 vt_eth 0xa56600e670724b42F38d3A6e4B25e8D786B4F5f9"
7
+ Zircuit_Restaking_Pool = "0xF047ab4c75cebf0eB9ed34Ae2c186f3611aEAfa6",
8
+ Pendle_26_JUN_2025 = "0x58612beB0e8a126735b19BB222cbC7fC2C162D2a",
9
+ Pendle_26_JUN_2025_YT = "0x784A0bb8208C70290cac6bcBC3650cEb9227813E",
10
+ Karak = "0x1f2aa9680910aC5a4527FA72001dC249943f60b4",
11
+ Curve_pufEth = "0xEEda34A377dD0ca676b9511EE1324974fA8d980D",
12
+ Curve_pufEth_wETH = "0x39F5b252dE249790fAEd0C2F05aBead56D2088e1",
13
+ Morpho_pufETH_WETH = "0x0eed5a89c7d397d02fd0b9b8e42811ca67e50ed5aeaa4f22e506516c716cfbbf",
14
+ Pencils_ppufEth = "0x0C530882C0900b13FC6E8312B52c26e7a5b8e505",
15
+ Morpho_pufETH_USDC = "0x7e9c708876fa3816c46aeb08937b51aa0461c2af3865ecb306433db8a80b1d1b",
16
+ balancer_wstETH_pufETH = "0x63E0d47A6964aD1565345Da9bfA66659F4983F02",
17
+ curve_llamalend = "0xcd28cF8f7755f03967D27E128B38022B63919836",
18
+ cyber_staking_pool = "0x18eeD20f71BEf84B605253C89A7576E3634134C0",
19
+ aura_balancer_wstETH_pufETH = "0x6Ea41486A8f21EED7B20AfDB681b90a5B6C6D029",
20
+ kinza_pufETH = "0x64274835D88F5c0215da8AADd9A5f2D2A2569381",
21
+ zerolend_pufETH = "0xdD7Afc0f014A1E1716307Ff040704fA12E8D33A3",
22
+ desyn_pufETH = "0x3a8099D8FE5C072bB035381003993393072D3ec7",
23
+ gamma_swap_pufETH = "0x1a33B9be3Fe58C1Bde4325A68c09C1F7fA8aA1e5",
24
+ Morpho_pufETH_USDA = "0xa42ba90e4d3013dee8eb0d7bb7ae0817297337eeecd525dbdd48c7b5c5e6988d",
25
+ pufETH_hold = "0xD9A442856C234a39a81a089C06451EBAa4306a72",
26
+ unifiETH_hold = "0x196ead472583Bc1e9aF7A05F860D9857e1Bd3dCc",
27
+ vePuffer = "0x1b6ec227ceBeC25118270efbb4b67642fc29965E",
28
+ mindNetwork_pufETH = "0xdf69c0F65e1A2F50f15E531ea23bDd9cC5CFeA8d",
29
+ pancakeSwap_xpufEth = "0x2b8d093f22f7b6f53d02aca106de3eabc0937d45",
30
+ aerodrome_cl50_xpufETH = "0xCDf927C0F7b81b146C0C9e9323eb5A28D1BFA183",
31
+ uniswapv3_eth_pufETH = "0xBDB04e915B94FbFD6e8552ff7860E59Db7d4499a",
32
+ uniswapv3_weth_PUFFER = "0xc5c9a9AB6403CDBa9722463000146C18b504F0bA",
33
+ uniswapv3_vt_weth = "0xa56600e670724b42F38d3A6e4B25e8D786B4F5f9"
33
34
  }
34
35
  export declare enum zkSyncCampaigns {
35
36
  Izumi_Finance_Zk_Weth = "Izumi Finance ZK/WETH 0xd62bc9f19bd94fde9c41df4b6eb6419ea6b8e25c",
@@ -6,32 +6,33 @@ export var program;
6
6
  })(program || (program = {}));
7
7
  export var pufferCampaigns;
8
8
  (function (pufferCampaigns) {
9
- pufferCampaigns["Zircuit_Restaking_Pool"] = "PufferProgram Zircuit Restaking Pool 0xF047ab4c75cebf0eB9ed34Ae2c186f3611aEAfa6";
10
- pufferCampaigns["Pendle_26_JUN_2025"] = "PufferProgram Pendle 26 JUN 2025 0x784A0bb8208C70290cac6bcBC3650cEb9227813E";
11
- pufferCampaigns["Pendle_26_JUN_2025_YT"] = "PufferProgram YT Pendle 26 JUN 2025 0x784A0bb8208C70290cac6bcBC3650cEb9227813E";
12
- pufferCampaigns["Karak"] = "PufferProgram Karak 0x68754d29f2e97B837Cb622ccfF325adAC27E9977";
13
- pufferCampaigns["Curve_pufEth"] = "PufferProgram Curve pufEth 0xEEda34A377dD0ca676b9511EE1324974fA8d980D";
14
- pufferCampaigns["Morpho_pufETH_WETH"] = "PufferProgram Morpho Weth 0x0eed5a89c7d397d02fd0b9b8e42811ca67e50ed5aeaa4f22e506516c716cfbbf";
15
- pufferCampaigns["Pencils_ppufEth"] = "PufferProgram Pencils PufferVault 0x0C530882C0900b13FC6E8312B52c26e7a5b8e505";
16
- pufferCampaigns["Morpho_pufETH_USDC"] = "PufferProgram Morpho USDC 0x7e9c708876fa3816c46aeb08937b51aa0461c2af3865ecb306433db8a80b1d1b";
17
- pufferCampaigns["balancer_wstETH_pufETH"] = "PufferProgram Balancer Vault wstETH_pufETH 0x63E0d47A6964aD1565345Da9bfA66659F4983F02";
18
- pufferCampaigns["curve_llamalend"] = "PufferProgram Curve Llama wstETH 0xcd28cF8f7755f03967D27E128B38022B63919836";
19
- pufferCampaigns["cyber_staking_pool"] = "PufferProgram Cyber Staking Pool 0x18eeD20f71BEf84B605253C89A7576E3634134C0";
20
- pufferCampaigns["aura_balancer_wstETH_pufETH"] = "PufferProgram Aura Balancer Vault wstETH_pufETH 0x6Ea41486A8f21EED7B20AfDB681b90a5B6C6D029";
21
- pufferCampaigns["kinza_pufETH"] = "PufferProgram Kinza Puf Eth 0x5651bb75dE3c78815D420602B4Ce67D04a233873";
22
- pufferCampaigns["zerolend_pufETH"] = "PufferProgram Zerolend Puf Eth 0xdD7Afc0f014A1E1716307Ff040704fA12E8D33A3";
23
- pufferCampaigns["desyn_pufETH"] = "PufferProgram Desyn 0x3a8099D8FE5C072bB035381003993393072D3ec7";
24
- pufferCampaigns["gamma_swap_pufETH"] = "PufferProgram GammaSwap V1 0x1a33B9be3Fe58C1Bde4325A68c09C1F7fA8aA1e5";
25
- pufferCampaigns["Morpho_pufETH_USDA"] = "PufferProgram Morpho USDA 0xa42ba90e4d3013dee8eb0d7bb7ae0817297337eeecd525dbdd48c7b5c5e6988d";
26
- pufferCampaigns["pufETH_hold"] = "PufferProgram pufETH Hold 0xD9A442856C234a39a81a089C06451EBAa4306a72";
27
- pufferCampaigns["unifiETH_hold"] = "PufferProgram unifiETH Hold 0x196ead472583Bc1e9aF7A05F860D9857e1Bd3dCc";
28
- pufferCampaigns["vePuffer"] = "PufferProgram vePuffer 0x4d1C297d39C5c1277964D0E3f8Aa901493664530";
29
- pufferCampaigns["mindNetwork_pufETH"] = "PufferProgram Mind Network 0x0124183e894aED6558c445Ff125801753e834216";
30
- pufferCampaigns["pancakeSwap_xpufEth"] = "PufferProgram PancakeSwap xPufEth 0x2b8d093f22f7b6f53d02aca106de3eabc0937d45";
31
- pufferCampaigns["aerodrome_cl50_xpufETH"] = "PufferProgram Aerodrome CL50-xpufETH / WETH 0xCDf927C0F7b81b146C0C9e9323eb5A28D1BFA183";
32
- pufferCampaigns["uniswapv3_eth_pufETH"] = "PufferProgram Uniswap V3 eth_pufETH 0xBDB04e915B94FbFD6e8552ff7860E59Db7d4499a";
33
- pufferCampaigns["uniswapv3_weth_PUFFER"] = "PufferProgram Uniswap V3 weth_PUFFER 0xc5c9a9AB6403CDBa9722463000146C18b504F0bA";
34
- pufferCampaigns["uniswapv3_vt_weth"] = "PufferProgram Uniswap V3 vt_eth 0xa56600e670724b42F38d3A6e4B25e8D786B4F5f9";
9
+ pufferCampaigns["Zircuit_Restaking_Pool"] = "0xF047ab4c75cebf0eB9ed34Ae2c186f3611aEAfa6";
10
+ pufferCampaigns["Pendle_26_JUN_2025"] = "0x58612beB0e8a126735b19BB222cbC7fC2C162D2a";
11
+ pufferCampaigns["Pendle_26_JUN_2025_YT"] = "0x784A0bb8208C70290cac6bcBC3650cEb9227813E";
12
+ pufferCampaigns["Karak"] = "0x1f2aa9680910aC5a4527FA72001dC249943f60b4";
13
+ pufferCampaigns["Curve_pufEth"] = "0xEEda34A377dD0ca676b9511EE1324974fA8d980D";
14
+ pufferCampaigns["Curve_pufEth_wETH"] = "0x39F5b252dE249790fAEd0C2F05aBead56D2088e1";
15
+ pufferCampaigns["Morpho_pufETH_WETH"] = "0x0eed5a89c7d397d02fd0b9b8e42811ca67e50ed5aeaa4f22e506516c716cfbbf";
16
+ pufferCampaigns["Pencils_ppufEth"] = "0x0C530882C0900b13FC6E8312B52c26e7a5b8e505";
17
+ pufferCampaigns["Morpho_pufETH_USDC"] = "0x7e9c708876fa3816c46aeb08937b51aa0461c2af3865ecb306433db8a80b1d1b";
18
+ pufferCampaigns["balancer_wstETH_pufETH"] = "0x63E0d47A6964aD1565345Da9bfA66659F4983F02";
19
+ pufferCampaigns["curve_llamalend"] = "0xcd28cF8f7755f03967D27E128B38022B63919836";
20
+ pufferCampaigns["cyber_staking_pool"] = "0x18eeD20f71BEf84B605253C89A7576E3634134C0";
21
+ pufferCampaigns["aura_balancer_wstETH_pufETH"] = "0x6Ea41486A8f21EED7B20AfDB681b90a5B6C6D029";
22
+ pufferCampaigns["kinza_pufETH"] = "0x64274835D88F5c0215da8AADd9A5f2D2A2569381";
23
+ pufferCampaigns["zerolend_pufETH"] = "0xdD7Afc0f014A1E1716307Ff040704fA12E8D33A3";
24
+ pufferCampaigns["desyn_pufETH"] = "0x3a8099D8FE5C072bB035381003993393072D3ec7";
25
+ pufferCampaigns["gamma_swap_pufETH"] = "0x1a33B9be3Fe58C1Bde4325A68c09C1F7fA8aA1e5";
26
+ pufferCampaigns["Morpho_pufETH_USDA"] = "0xa42ba90e4d3013dee8eb0d7bb7ae0817297337eeecd525dbdd48c7b5c5e6988d";
27
+ pufferCampaigns["pufETH_hold"] = "0xD9A442856C234a39a81a089C06451EBAa4306a72";
28
+ pufferCampaigns["unifiETH_hold"] = "0x196ead472583Bc1e9aF7A05F860D9857e1Bd3dCc";
29
+ pufferCampaigns["vePuffer"] = "0x1b6ec227ceBeC25118270efbb4b67642fc29965E";
30
+ pufferCampaigns["mindNetwork_pufETH"] = "0xdf69c0F65e1A2F50f15E531ea23bDd9cC5CFeA8d";
31
+ pufferCampaigns["pancakeSwap_xpufEth"] = "0x2b8d093f22f7b6f53d02aca106de3eabc0937d45";
32
+ pufferCampaigns["aerodrome_cl50_xpufETH"] = "0xCDf927C0F7b81b146C0C9e9323eb5A28D1BFA183";
33
+ pufferCampaigns["uniswapv3_eth_pufETH"] = "0xBDB04e915B94FbFD6e8552ff7860E59Db7d4499a";
34
+ pufferCampaigns["uniswapv3_weth_PUFFER"] = "0xc5c9a9AB6403CDBa9722463000146C18b504F0bA";
35
+ pufferCampaigns["uniswapv3_vt_weth"] = "0xa56600e670724b42F38d3A6e4B25e8D786B4F5f9";
35
36
  })(pufferCampaigns || (pufferCampaigns = {}));
36
37
  export var zkSyncCampaigns;
37
38
  (function (zkSyncCampaigns) {
@@ -863,7 +864,7 @@ const PufferInterfaceCampaigns = {
863
864
  targetToken: "0x784A0bb8208C70290cac6bcBC3650cEb9227813E",
864
865
  whitelist: [],
865
866
  blacklist: [],
866
- url: "https://app.pendle.finance/trade/pools/0x58612beb0e8a126735b19bb222cbc7fc2c162d2a/zap/in?chain=ethereum",
867
+ url: "https://app.pendle.finance/trade/pools/0x784A0bb8208C70290cac6bcBC3650cEb9227813E/zap/in?chain=ethereum",
867
868
  forwarders: [],
868
869
  },
869
870
  [pufferCampaigns.Karak]: {
@@ -883,7 +884,17 @@ const PufferInterfaceCampaigns = {
883
884
  targetToken: "0xEEda34A377dD0ca676b9511EE1324974fA8d980D",
884
885
  whitelist: [],
885
886
  blacklist: [],
886
- url: "https://app.karak.network/pool/ethereum/pufETH",
887
+ url: "https://curve.fi/#/ethereum/pools/factory-stable-ng-113/deposit",
888
+ forwarders: [],
889
+ },
890
+ [pufferCampaigns.Curve_pufEth_wETH]: {
891
+ campaignType: Campaign.ERC20,
892
+ computeChainId: ChainId.MAINNET,
893
+ hooks: [],
894
+ targetToken: "0x39F5b252dE249790fAEd0C2F05aBead56D2088e1",
895
+ whitelist: [],
896
+ blacklist: [],
897
+ url: "https://curve.fi/#/ethereum/pools/factory-stable-ng-142/deposit",
887
898
  forwarders: [],
888
899
  },
889
900
  [pufferCampaigns.Morpho_pufETH_USDC]: {
@@ -983,9 +994,9 @@ const PufferInterfaceCampaigns = {
983
994
  campaignType: Campaign.ERC20,
984
995
  computeChainId: ChainId.BSC,
985
996
  hooks: [],
986
- targetToken: "0x9c6faE23FdffFBE1199bABB11bc9A6859493A5a1",
997
+ targetToken: "0x64274835D88F5c0215da8AADd9A5f2D2A2569381",
987
998
  whitelist: [],
988
- blacklist: [],
999
+ blacklist: ["0x2B8D093f22f7B6f53D02AcA106DE3eabC0937D45"],
989
1000
  url: "https://app.kinza.finance/#/details/pufETH",
990
1001
  forwarders: [],
991
1002
  },
@@ -132,9 +132,12 @@ export declare const RewardController: Elysia<"/rewards", false, {
132
132
  engine: {
133
133
  post: {
134
134
  body: {
135
+ pending: string;
135
136
  recipient: string;
136
137
  distributionChainId: number;
138
+ amount: string;
137
139
  root: string;
140
+ claimed: string;
138
141
  proofs: string[];
139
142
  rewardToken: string;
140
143
  }[];
@@ -99,6 +99,9 @@ declare const RewardDto: import("@sinclair/typebox").TObject<{
99
99
  recipient: import("@sinclair/typebox").TString;
100
100
  distributionChainId: import("@sinclair/typebox").TNumber;
101
101
  rewardToken: import("@sinclair/typebox").TString;
102
+ amount: import("@sinclair/typebox").TString;
103
+ claimed: import("@sinclair/typebox").TString;
104
+ pending: import("@sinclair/typebox").TString;
102
105
  proofs: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
103
106
  }>;
104
107
  export declare const CreateManyRewardDto: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
@@ -106,6 +109,9 @@ export declare const CreateManyRewardDto: import("@sinclair/typebox").TArray<imp
106
109
  recipient: import("@sinclair/typebox").TString;
107
110
  distributionChainId: import("@sinclair/typebox").TNumber;
108
111
  rewardToken: import("@sinclair/typebox").TString;
112
+ amount: import("@sinclair/typebox").TString;
113
+ claimed: import("@sinclair/typebox").TString;
114
+ pending: import("@sinclair/typebox").TString;
109
115
  proofs: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
110
116
  }>>;
111
117
  export declare const RegisterClaimsDto: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
@@ -37,6 +37,9 @@ const RewardDto = t.Object({
37
37
  recipient: t.String(),
38
38
  distributionChainId: t.Number(),
39
39
  rewardToken: t.String(),
40
+ amount: t.String(),
41
+ claimed: t.String(),
42
+ pending: t.String(),
40
43
  proofs: t.Array(t.String()),
41
44
  });
42
45
  export const CreateManyRewardDto = t.Array(RewardDto);
@@ -78,17 +78,20 @@ export declare abstract class RewardRepository {
78
78
  id: number;
79
79
  campaignId: string;
80
80
  amount: string;
81
- protocolId: string | null;
82
81
  claimed: string;
82
+ protocolId: string | null;
83
83
  auxiliaryData1: string | null;
84
84
  auxiliaryData2: string | null;
85
85
  rewardId: string;
86
86
  })[];
87
87
  } & {
88
+ pending: string;
88
89
  id: string;
89
90
  recipient: string;
90
91
  rewardTokenId: string;
92
+ amount: string;
91
93
  root: string;
94
+ claimed: string;
92
95
  proofs: string[];
93
96
  })[]>;
94
97
  static getByChainRecipientToken(recipient: string, root: string, tokenId: string): Promise<({
@@ -102,17 +105,20 @@ export declare abstract class RewardRepository {
102
105
  id: number;
103
106
  campaignId: string;
104
107
  amount: string;
105
- protocolId: string | null;
106
108
  claimed: string;
109
+ protocolId: string | null;
107
110
  auxiliaryData1: string | null;
108
111
  auxiliaryData2: string | null;
109
112
  rewardId: string;
110
113
  })[];
111
114
  } & {
115
+ pending: string;
112
116
  id: string;
113
117
  recipient: string;
114
118
  rewardTokenId: string;
119
+ amount: string;
115
120
  root: string;
121
+ claimed: string;
116
122
  proofs: string[];
117
123
  }) | null>;
118
124
  static countRewardPerRewardTokenIdAndRoot(): Promise<(Prisma.PickEnumerable<Prisma.RewardGroupByOutputType, ("rewardTokenId" | "root")[]> & {
@@ -131,49 +137,57 @@ export declare abstract class RewardRepository {
131
137
  campaignId: string;
132
138
  reason: string;
133
139
  }[]): Promise<({
134
- reason: string;
135
140
  pending: string;
136
- id: number;
137
- campaignId: string;
141
+ } | null)[]>;
142
+ static findManyRewardUniques(rewardIds: string[]): Promise<({
143
+ pending: string;
144
+ } | null)[]>;
145
+ static updateRewardPendings(rewardTokenId: string, root: string, toUpdate: {
146
+ recipient: string;
147
+ pending: string;
148
+ }[]): Promise<{
149
+ pending: string;
150
+ id: string;
151
+ recipient: string;
152
+ rewardTokenId: string;
138
153
  amount: string;
139
- protocolId: string | null;
154
+ root: string;
140
155
  claimed: string;
141
- auxiliaryData1: string | null;
142
- auxiliaryData2: string | null;
143
- rewardId: string;
144
- } | null)[]>;
145
- static upsertPendings(rewardTokenId: string, root: string, campaignId: string, toUpdate: PendingEntity[]): Promise<{
156
+ proofs: string[];
157
+ }[]>;
158
+ static updateBreakdownPendings(rewardTokenId: string, root: string, campaignId: string, toUpdate: PendingEntity[]): Promise<{
146
159
  reason: string;
147
160
  pending: string;
148
161
  id: number;
149
162
  campaignId: string;
150
163
  amount: string;
151
- protocolId: string | null;
152
164
  claimed: string;
165
+ protocolId: string | null;
153
166
  auxiliaryData1: string | null;
154
167
  auxiliaryData2: string | null;
155
168
  rewardId: string;
156
169
  }[]>;
157
- static updatePendings(rewardTokenId: string, root: string, campaignId: string, toUpdate: PendingEntity[]): Promise<{
158
- reason: string;
170
+ static createRewardPendings(rewardTokenId: string, root: string, toCreate: {
171
+ recipient: string;
159
172
  pending: string;
160
- id: number;
161
- campaignId: string;
173
+ }[]): Promise<{
174
+ pending: string;
175
+ id: string;
176
+ recipient: string;
177
+ rewardTokenId: string;
162
178
  amount: string;
163
- protocolId: string | null;
179
+ root: string;
164
180
  claimed: string;
165
- auxiliaryData1: string | null;
166
- auxiliaryData2: string | null;
167
- rewardId: string;
181
+ proofs: string[];
168
182
  }[]>;
169
- static createPendings(rewardTokenId: string, root: string, campaignId: string, toCreate: PendingEntity[]): Promise<{
183
+ static createBreakdownPendings(rewardTokenId: string, root: string, campaignId: string, toCreate: PendingEntity[]): Promise<{
170
184
  reason: string;
171
185
  pending: string;
172
186
  id: number;
173
187
  campaignId: string;
174
188
  amount: string;
175
- protocolId: string | null;
176
189
  claimed: string;
190
+ protocolId: string | null;
177
191
  auxiliaryData1: string | null;
178
192
  auxiliaryData2: string | null;
179
193
  rewardId: string;
@@ -17,6 +17,9 @@ export class RewardRepository {
17
17
  return {
18
18
  id: RewardService.hashId(reward.root, reward.recipient, rewardTokenId),
19
19
  root: reward.root,
20
+ amount: reward.amount,
21
+ pending: reward.pending,
22
+ claimed: reward.claimed,
20
23
  recipient: reward.recipient,
21
24
  rewardTokenId,
22
25
  proofs: reward.proofs,
@@ -141,6 +144,9 @@ export class RewardRepository {
141
144
  }
142
145
  static async findManyBreakdownUniques(uniques) {
143
146
  return await apiDbClient.$transaction(uniques.map(x => apiDbClient.rewardBreakdown.findUnique({
147
+ select: {
148
+ pending: true,
149
+ },
144
150
  where: {
145
151
  rewardId_campaignId_reason: {
146
152
  rewardId: x.rewardId,
@@ -150,47 +156,30 @@ export class RewardRepository {
150
156
  },
151
157
  })));
152
158
  }
153
- static async upsertPendings(rewardTokenId, root, campaignId, toUpdate) {
154
- const users = toUpdate.map(x => x.recipient);
155
- await UserService.createMany(users.map(x => ({ address: x, tags: [] })));
159
+ static async findManyRewardUniques(rewardIds) {
160
+ return await apiDbClient.$transaction(rewardIds.map(x => apiDbClient.reward.findUnique({
161
+ select: {
162
+ pending: true,
163
+ },
164
+ where: {
165
+ id: x,
166
+ },
167
+ })));
168
+ }
169
+ static async updateRewardPendings(rewardTokenId, root, toUpdate) {
156
170
  return await apiDbClient.$transaction(toUpdate.map(x => {
157
171
  const rewardId = RewardService.hashId(root, x.recipient, rewardTokenId);
158
- return apiDbClient.rewardBreakdown.upsert({
172
+ return apiDbClient.reward.update({
159
173
  where: {
160
- rewardId_campaignId_reason: {
161
- rewardId: RewardService.hashId(root, x.recipient, rewardTokenId),
162
- campaignId: campaignId,
163
- reason: x.reason,
164
- },
174
+ id: rewardId,
165
175
  },
166
- update: {
167
- pending: x.pending,
168
- auxiliaryData1: x.auxiliaryData1,
169
- auxiliaryData2: x.auxiliaryData2,
170
- },
171
- create: {
172
- reason: x.reason,
173
- amount: "0",
176
+ data: {
174
177
  pending: x.pending,
175
- claimed: "0",
176
- Reward: {
177
- connectOrCreate: {
178
- where: { id: rewardId },
179
- create: {
180
- id: rewardId,
181
- MerklRoot: { connect: { root } },
182
- User: { connect: { address: x.recipient } },
183
- RewardToken: { connect: { id: rewardTokenId } },
184
- proofs: [],
185
- },
186
- },
187
- },
188
- Campaign: { connect: { id: campaignId } },
189
178
  },
190
179
  });
191
180
  }));
192
181
  }
193
- static async updatePendings(rewardTokenId, root, campaignId, toUpdate) {
182
+ static async updateBreakdownPendings(rewardTokenId, root, campaignId, toUpdate) {
194
183
  return await apiDbClient.$transaction(toUpdate.map(x => {
195
184
  return apiDbClient.rewardBreakdown.update({
196
185
  where: {
@@ -208,7 +197,26 @@ export class RewardRepository {
208
197
  });
209
198
  }));
210
199
  }
211
- static async createPendings(rewardTokenId, root, campaignId, toCreate) {
200
+ static async createRewardPendings(rewardTokenId, root, toCreate) {
201
+ const users = toCreate.map(x => x.recipient);
202
+ await UserService.createMany(users.map(x => ({ address: x, tags: [] })));
203
+ return await apiDbClient.$transaction(toCreate.map(x => {
204
+ const rewardId = RewardService.hashId(root, x.recipient, rewardTokenId);
205
+ return apiDbClient.reward.create({
206
+ data: {
207
+ id: rewardId,
208
+ MerklRoot: { connect: { root } },
209
+ User: { connect: { address: x.recipient } },
210
+ RewardToken: { connect: { id: rewardTokenId } },
211
+ proofs: [],
212
+ amount: "0",
213
+ pending: x.pending,
214
+ claimed: "0",
215
+ },
216
+ });
217
+ }));
218
+ }
219
+ static async createBreakdownPendings(rewardTokenId, root, campaignId, toCreate) {
212
220
  const users = toCreate.map(x => x.recipient);
213
221
  await UserService.createMany(users.map(x => ({ address: x, tags: [] })));
214
222
  return await apiDbClient.$transaction(toCreate.map(x => {
@@ -220,15 +228,8 @@ export class RewardRepository {
220
228
  pending: x.pending,
221
229
  claimed: "0",
222
230
  Reward: {
223
- connectOrCreate: {
224
- where: { id: rewardId },
225
- create: {
226
- id: rewardId,
227
- MerklRoot: { connect: { root } },
228
- User: { connect: { address: x.recipient } },
229
- RewardToken: { connect: { id: rewardTokenId } },
230
- proofs: [],
231
- },
231
+ connect: {
232
+ id: rewardId,
232
233
  },
233
234
  },
234
235
  Campaign: { connect: { id: campaignId } },
@@ -319,7 +320,6 @@ export class RewardRepository {
319
320
  rb."pending",
320
321
  r."recipient",
321
322
  r."campaignId",
322
- r."reason",
323
323
  t."address" as "rewardTokenAddress"
324
324
  FROM
325
325
  "RewardBreakdown" rb
@@ -232,17 +232,20 @@ export declare abstract class RewardService {
232
232
  id: number;
233
233
  campaignId: string;
234
234
  amount: string;
235
- protocolId: string | null;
236
235
  claimed: string;
236
+ protocolId: string | null;
237
237
  auxiliaryData1: string | null;
238
238
  auxiliaryData2: string | null;
239
239
  rewardId: string;
240
240
  })[];
241
241
  } & {
242
+ pending: string;
242
243
  id: string;
243
244
  recipient: string;
244
245
  rewardTokenId: string;
246
+ amount: string;
245
247
  root: string;
248
+ claimed: string;
246
249
  proofs: string[];
247
250
  })[]>;
248
251
  /**
@@ -530,17 +533,20 @@ export declare abstract class RewardService {
530
533
  id: number;
531
534
  campaignId: string;
532
535
  amount: string;
533
- protocolId: string | null;
534
536
  claimed: string;
537
+ protocolId: string | null;
535
538
  auxiliaryData1: string | null;
536
539
  auxiliaryData2: string | null;
537
540
  rewardId: string;
538
541
  })[];
539
542
  } & {
543
+ pending: string;
540
544
  id: string;
541
545
  recipient: string;
542
546
  rewardTokenId: string;
547
+ amount: string;
543
548
  root: string;
549
+ claimed: string;
544
550
  proofs: string[];
545
551
  })[]>;
546
552
  static getUserRewardsByChain(user: string, withToken: boolean, chainFilter?: ChainId[], connectedChainId?: MerklChainId | null, withTestTokens?: boolean): Promise<{
@@ -238,17 +238,29 @@ export class RewardService {
238
238
  distributionChain: data.distributionChainId,
239
239
  campaignId: data.campaignId,
240
240
  });
241
+ const rewardUniques = {};
242
+ // Adds a record to the Reward row where pendings need to be updated
243
+ const updateRewardUniques = (recipient, pending, previousPending) => {
244
+ const rewardId = RewardService.hashId(data.root, recipient, rewardTokenId);
245
+ if (!rewardUniques[rewardId]) {
246
+ rewardUniques[rewardId] = { pending: "0", recipient: recipient };
247
+ }
248
+ rewardUniques[rewardId].pending = (BigInt(rewardUniques[rewardId].pending) +
249
+ BigInt(pending) -
250
+ BigInt(previousPending ?? "0")).toString();
251
+ };
241
252
  let totalCreated = 0;
242
253
  let totalUpdated = 0;
243
- const uniques = await data.data.map(({ recipient, reason }) => {
254
+ const breakdownUniques = await data.data.map(({ recipient, reason }) => {
244
255
  const rewardId = RewardService.hashId(data.root, recipient, rewardTokenId);
245
256
  return { rewardId, reason, campaignId };
246
257
  });
247
- for (let i = 0; i < uniques.length; i += 1000) {
258
+ for (let i = 0; i < breakdownUniques.length; i += 1_000) {
248
259
  const toUpdate = [];
249
260
  const toCreate = [];
250
- const exists = await RewardRepository.findManyBreakdownUniques(uniques.slice(i, Math.min(i + 1000, uniques.length)));
251
- for (const [pointIndex, point] of data.data.slice(i, Math.min(i + 1000, uniques.length)).entries()) {
261
+ const exists = await RewardRepository.findManyBreakdownUniques(breakdownUniques.slice(i, Math.min(i + 1_000, breakdownUniques.length)));
262
+ for (const [pointIndex, point] of data.data.slice(i, Math.min(i + 1_000, breakdownUniques.length)).entries()) {
263
+ updateRewardUniques(point.recipient, point.pending, exists[pointIndex]?.pending);
252
264
  if (!!exists[pointIndex]) {
253
265
  toUpdate.push(point);
254
266
  }
@@ -256,11 +268,36 @@ export class RewardService {
256
268
  toCreate.push(point);
257
269
  }
258
270
  }
259
- await RewardRepository.updatePendings(rewardTokenId, data.root, campaignId, toUpdate);
260
- await RewardRepository.createPendings(rewardTokenId, data.root, campaignId, toCreate);
271
+ await RewardRepository.updateBreakdownPendings(rewardTokenId, data.root, campaignId, toUpdate);
272
+ await RewardRepository.createBreakdownPendings(rewardTokenId, data.root, campaignId, toCreate);
261
273
  totalCreated += toCreate.length;
262
274
  totalUpdated += toUpdate.length;
263
275
  }
276
+ try {
277
+ for (let i = 0; i < Object.keys(rewardUniques).length; i += 1_000) {
278
+ const toUpdate = [];
279
+ const toCreate = [];
280
+ const exists = await RewardRepository.findManyRewardUniques(Object.keys(rewardUniques).slice(i, Math.min(i + 1_000, Object.keys(rewardUniques).length)));
281
+ for (const [pointIndex, point] of Object.values(rewardUniques)
282
+ .slice(i, Math.min(i + 1_000, Object.keys(rewardUniques).length))
283
+ .entries()) {
284
+ if (!!exists[pointIndex]) {
285
+ toUpdate.push({
286
+ ...point,
287
+ pending: (BigInt(exists[pointIndex].pending) + BigInt(point.pending)).toString(),
288
+ });
289
+ }
290
+ else {
291
+ toCreate.push(point);
292
+ }
293
+ }
294
+ await RewardRepository.updateRewardPendings(rewardTokenId, data.root, toUpdate);
295
+ await RewardRepository.createRewardPendings(rewardTokenId, data.root, toCreate);
296
+ }
297
+ }
298
+ catch (e) {
299
+ log.error("updatePendings - error updating reward pendings", e);
300
+ }
264
301
  return { created: totalCreated, updated: totalUpdated };
265
302
  }
266
303
  static async countAllchains() {
@@ -1252,9 +1252,12 @@ export declare const v4: Elysia<"/v4", false, {
1252
1252
  engine: {
1253
1253
  post: {
1254
1254
  body: {
1255
+ pending: string;
1255
1256
  recipient: string;
1256
1257
  distributionChainId: number;
1258
+ amount: string;
1257
1259
  root: string;
1260
+ claimed: string;
1258
1261
  proofs: string[];
1259
1262
  rewardToken: string;
1260
1263
  }[];