@gearbox-protocol/sdk 1.23.2 → 1.23.3

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.
@@ -12,6 +12,7 @@ export interface Rewards {
12
12
  }
13
13
  export interface AdapterWithType {
14
14
  contractAddress: string;
15
+ adapter: string;
15
16
  contract: SupportedContract;
16
17
  }
17
18
  export declare class RewardClaimer {
@@ -8,6 +8,7 @@ import { CreditAccountData } from "./creditAccount";
8
8
  import { CreditManagerData } from "./creditManager";
9
9
  import { AdapterWithType, Rewards } from "./rewardClaimer";
10
10
  export interface RewardDistribution {
11
+ adapter: string;
11
12
  contractAddress: string;
12
13
  contract: SupportedContract;
13
14
  token: SupportedToken;
@@ -21,6 +22,6 @@ export declare class RewardConvex {
21
22
  static findRewards(ca: CreditAccountData, cm: CreditManagerData, network: NetworkType, provider: providers.Provider): Promise<Array<Rewards>>;
22
23
  static findAdapters(cm: CreditManagerData): Array<AdapterWithType>;
23
24
  static prepareMultiCalls(creditAccount: string, cm: CreditManagerData, network: NetworkType): MCallPreparation;
24
- static parseResults(creditAccount: string, rewards: Array<BigNumber>, distribution: Array<RewardDistribution>): Array<Rewards>;
25
+ static parseResults(rewards: Array<BigNumber>, distribution: Array<RewardDistribution>): Array<Rewards>;
25
26
  }
26
27
  export {};
@@ -20,7 +20,7 @@ class RewardConvex {
20
20
  });
21
21
  const rewards = await (0, multicall_1.multicall)(mcalls, provider);
22
22
  const totalSupply = rewards.pop();
23
- const results = RewardConvex.parseResults(ca.addr, rewards, distribution);
23
+ const results = RewardConvex.parseResults(rewards, distribution);
24
24
  results.forEach(r => {
25
25
  r.rewards.CVX = (0, apy_1.getCVXMintAmount)(r.rewards.CRV || 0n, (0, formatter_1.toBigInt)(totalSupply));
26
26
  });
@@ -31,7 +31,8 @@ class RewardConvex {
31
31
  .filter(([_, params]) => params.type === adapters_1.AdapterInterface.CONVEX_V1_BASE_REWARD_POOL)
32
32
  .map(([contract]) => contract);
33
33
  return Object.entries(cm.adapters)
34
- .map(([contract]) => ({
34
+ .map(([contract, adapter]) => ({
35
+ adapter,
35
36
  contractAddress: contract,
36
37
  contract: contracts_1.contractsByAddress[contract.toLowerCase()],
37
38
  }))
@@ -50,6 +51,7 @@ class RewardConvex {
50
51
  });
51
52
  distribution.push({
52
53
  contractAddress: a.contractAddress,
54
+ adapter: a.adapter,
53
55
  contract: a.contract,
54
56
  token: "CRV",
55
57
  });
@@ -63,6 +65,7 @@ class RewardConvex {
63
65
  });
64
66
  distribution.push({
65
67
  contractAddress: a.contractAddress,
68
+ adapter: a.adapter,
66
69
  contract: a.contract,
67
70
  token: er.rewardToken,
68
71
  });
@@ -73,11 +76,11 @@ class RewardConvex {
73
76
  distribution,
74
77
  };
75
78
  }
76
- static parseResults(creditAccount, rewards, distribution) {
79
+ static parseResults(rewards, distribution) {
77
80
  const result = {};
78
- const callData = RewardConvex.poolInterface.encodeFunctionData("getReward(address,bool)", [creditAccount, true]);
81
+ const callData = RewardConvex.poolInterface.encodeFunctionData("getReward()");
79
82
  for (let i = 0; i < rewards.length; i++) {
80
- const { contract, contractAddress, token } = distribution[i];
83
+ const { contract, adapter, token } = distribution[i];
81
84
  const reward = rewards[i];
82
85
  if (!reward.isZero()) {
83
86
  if (!result[contract]) {
@@ -86,7 +89,7 @@ class RewardConvex {
86
89
  rewards: {},
87
90
  calls: [
88
91
  {
89
- target: contractAddress,
92
+ target: adapter,
90
93
  callData,
91
94
  },
92
95
  ],
@@ -22,10 +22,12 @@ describe("RewardConvex test", () => {
22
22
  {
23
23
  contract: "CONVEX_3CRV_POOL",
24
24
  contractAddress: contracts_1.contractsByNetwork.Mainnet.CONVEX_3CRV_POOL,
25
+ adapter: ADAPTER_CONVEX_3CRV_POOL,
25
26
  },
26
27
  {
27
28
  contract: "CONVEX_FRAX3CRV_POOL",
28
29
  contractAddress: contracts_1.contractsByNetwork.Goerli.CONVEX_FRAX3CRV_POOL,
30
+ adapter: ADAPTER_CONVEX_FRAX3CRV_POOL,
29
31
  },
30
32
  ];
31
33
  const result = rewardConvex_1.RewardConvex.findAdapters(cm);
@@ -62,16 +64,19 @@ describe("RewardConvex test", () => {
62
64
  ];
63
65
  const distribution = [
64
66
  {
67
+ adapter: ADAPTER_CONVEX_3CRV_POOL,
65
68
  contractAddress: contracts_1.contractsByNetwork.Mainnet.CONVEX_3CRV_POOL,
66
69
  contract: "CONVEX_3CRV_POOL",
67
70
  token: "CRV",
68
71
  },
69
72
  {
73
+ adapter: ADAPTER_CONVEX_FRAX3CRV_POOL,
70
74
  contractAddress: contracts_1.contractsByNetwork.Goerli.CONVEX_FRAX3CRV_POOL,
71
75
  contract: "CONVEX_FRAX3CRV_POOL",
72
76
  token: "CRV",
73
77
  },
74
78
  {
79
+ adapter: ADAPTER_CONVEX_FRAX3CRV_POOL,
75
80
  contractAddress: contracts_1.contractsByNetwork.Goerli.CONVEX_FRAX3CRV_POOL,
76
81
  contract: "CONVEX_FRAX3CRV_POOL",
77
82
  token: "FXS",
@@ -88,23 +93,26 @@ describe("RewardConvex test", () => {
88
93
  ];
89
94
  const distribution = [
90
95
  {
96
+ adapter: ADAPTER_CONVEX_3CRV_POOL,
91
97
  contractAddress: contracts_1.contractsByNetwork.Mainnet.CONVEX_3CRV_POOL,
92
98
  contract: "CONVEX_3CRV_POOL",
93
99
  token: "CRV",
94
100
  },
95
101
  {
102
+ adapter: ADAPTER_CONVEX_FRAX3CRV_POOL,
96
103
  contractAddress: contracts_1.contractsByNetwork.Goerli.CONVEX_FRAX3CRV_POOL,
97
104
  contract: "CONVEX_FRAX3CRV_POOL",
98
105
  token: "CRV",
99
106
  },
100
107
  {
108
+ adapter: ADAPTER_CONVEX_FRAX3CRV_POOL,
101
109
  contractAddress: contracts_1.contractsByNetwork.Goerli.CONVEX_FRAX3CRV_POOL,
102
110
  contract: "CONVEX_FRAX3CRV_POOL",
103
111
  token: "FXS",
104
112
  },
105
113
  ];
106
- const parsed = rewardConvex_1.RewardConvex.parseResults(CREDIT_ACCOUNT, rewards, distribution);
107
- const callData = rewardConvex_1.RewardConvex.poolInterface.encodeFunctionData("getReward(address,bool)", [CREDIT_ACCOUNT, true]);
114
+ const parsed = rewardConvex_1.RewardConvex.parseResults(rewards, distribution);
115
+ const callData = rewardConvex_1.RewardConvex.poolInterface.encodeFunctionData("getReward()");
108
116
  const expected = [
109
117
  {
110
118
  contract: "CONVEX_3CRV_POOL",
@@ -113,7 +121,7 @@ describe("RewardConvex test", () => {
113
121
  },
114
122
  calls: [
115
123
  {
116
- target: contracts_1.contractsByNetwork.Mainnet.CONVEX_3CRV_POOL,
124
+ target: ADAPTER_CONVEX_3CRV_POOL,
117
125
  callData,
118
126
  },
119
127
  ],
@@ -126,7 +134,7 @@ describe("RewardConvex test", () => {
126
134
  },
127
135
  calls: [
128
136
  {
129
- target: contracts_1.contractsByNetwork.Goerli.CONVEX_FRAX3CRV_POOL,
137
+ target: ADAPTER_CONVEX_FRAX3CRV_POOL,
130
138
  callData,
131
139
  },
132
140
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "1.23.2",
3
+ "version": "1.23.3",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",