@dhedge/v2-sdk 1.10.6 → 1.10.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhedge/v2-sdk",
3
- "version": "1.10.6",
3
+ "version": "1.10.7",
4
4
  "license": "MIT",
5
5
  "description": "🛠 An SDK for building applications on top of dHEDGE V2",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,241 @@
1
+ [
2
+ {
3
+ "inputs": [
4
+ { "internalType": "address", "name": "governor_", "type": "address" }
5
+ ],
6
+ "stateMutability": "nonpayable",
7
+ "type": "constructor"
8
+ },
9
+ {
10
+ "inputs": [{ "internalType": "address", "name": "", "type": "address" }],
11
+ "name": "AlreadyConfigured",
12
+ "type": "error"
13
+ },
14
+ { "inputs": [], "name": "BadData", "type": "error" },
15
+ {
16
+ "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
17
+ "name": "InvalidUInt64",
18
+ "type": "error"
19
+ },
20
+ {
21
+ "inputs": [{ "internalType": "address", "name": "", "type": "address" }],
22
+ "name": "NotPermitted",
23
+ "type": "error"
24
+ },
25
+ {
26
+ "inputs": [{ "internalType": "address", "name": "", "type": "address" }],
27
+ "name": "NotSupported",
28
+ "type": "error"
29
+ },
30
+ {
31
+ "inputs": [
32
+ { "internalType": "address", "name": "", "type": "address" },
33
+ { "internalType": "uint256", "name": "", "type": "uint256" }
34
+ ],
35
+ "name": "TransferOutFailed",
36
+ "type": "error"
37
+ },
38
+ {
39
+ "anonymous": false,
40
+ "inputs": [
41
+ {
42
+ "indexed": true,
43
+ "internalType": "address",
44
+ "name": "oldGovernor",
45
+ "type": "address"
46
+ },
47
+ {
48
+ "indexed": true,
49
+ "internalType": "address",
50
+ "name": "newGovernor",
51
+ "type": "address"
52
+ }
53
+ ],
54
+ "name": "GovernorTransferred",
55
+ "type": "event"
56
+ },
57
+ {
58
+ "anonymous": false,
59
+ "inputs": [
60
+ {
61
+ "indexed": true,
62
+ "internalType": "address",
63
+ "name": "src",
64
+ "type": "address"
65
+ },
66
+ {
67
+ "indexed": true,
68
+ "internalType": "address",
69
+ "name": "recipient",
70
+ "type": "address"
71
+ },
72
+ {
73
+ "indexed": true,
74
+ "internalType": "address",
75
+ "name": "token",
76
+ "type": "address"
77
+ },
78
+ {
79
+ "indexed": false,
80
+ "internalType": "uint256",
81
+ "name": "amount",
82
+ "type": "uint256"
83
+ }
84
+ ],
85
+ "name": "RewardClaimed",
86
+ "type": "event"
87
+ },
88
+ {
89
+ "anonymous": false,
90
+ "inputs": [
91
+ {
92
+ "indexed": true,
93
+ "internalType": "address",
94
+ "name": "user",
95
+ "type": "address"
96
+ },
97
+ {
98
+ "indexed": true,
99
+ "internalType": "address",
100
+ "name": "comet",
101
+ "type": "address"
102
+ },
103
+ {
104
+ "indexed": false,
105
+ "internalType": "uint256",
106
+ "name": "amount",
107
+ "type": "uint256"
108
+ }
109
+ ],
110
+ "name": "RewardsClaimedSet",
111
+ "type": "event"
112
+ },
113
+ {
114
+ "inputs": [
115
+ { "internalType": "address", "name": "comet", "type": "address" },
116
+ { "internalType": "address", "name": "src", "type": "address" },
117
+ { "internalType": "bool", "name": "shouldAccrue", "type": "bool" }
118
+ ],
119
+ "name": "claim",
120
+ "outputs": [],
121
+ "stateMutability": "nonpayable",
122
+ "type": "function"
123
+ },
124
+ {
125
+ "inputs": [
126
+ { "internalType": "address", "name": "comet", "type": "address" },
127
+ { "internalType": "address", "name": "src", "type": "address" },
128
+ { "internalType": "address", "name": "to", "type": "address" },
129
+ { "internalType": "bool", "name": "shouldAccrue", "type": "bool" }
130
+ ],
131
+ "name": "claimTo",
132
+ "outputs": [],
133
+ "stateMutability": "nonpayable",
134
+ "type": "function"
135
+ },
136
+ {
137
+ "inputs": [
138
+ { "internalType": "address", "name": "comet", "type": "address" },
139
+ { "internalType": "address", "name": "account", "type": "address" }
140
+ ],
141
+ "name": "getRewardOwed",
142
+ "outputs": [
143
+ {
144
+ "components": [
145
+ { "internalType": "address", "name": "token", "type": "address" },
146
+ { "internalType": "uint256", "name": "owed", "type": "uint256" }
147
+ ],
148
+ "internalType": "struct CometRewards.RewardOwed",
149
+ "name": "",
150
+ "type": "tuple"
151
+ }
152
+ ],
153
+ "stateMutability": "nonpayable",
154
+ "type": "function"
155
+ },
156
+ {
157
+ "inputs": [],
158
+ "name": "governor",
159
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
160
+ "stateMutability": "view",
161
+ "type": "function"
162
+ },
163
+ {
164
+ "inputs": [{ "internalType": "address", "name": "", "type": "address" }],
165
+ "name": "rewardConfig",
166
+ "outputs": [
167
+ { "internalType": "address", "name": "token", "type": "address" },
168
+ { "internalType": "uint64", "name": "rescaleFactor", "type": "uint64" },
169
+ { "internalType": "bool", "name": "shouldUpscale", "type": "bool" },
170
+ { "internalType": "uint256", "name": "multiplier", "type": "uint256" }
171
+ ],
172
+ "stateMutability": "view",
173
+ "type": "function"
174
+ },
175
+ {
176
+ "inputs": [
177
+ { "internalType": "address", "name": "", "type": "address" },
178
+ { "internalType": "address", "name": "", "type": "address" }
179
+ ],
180
+ "name": "rewardsClaimed",
181
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
182
+ "stateMutability": "view",
183
+ "type": "function"
184
+ },
185
+ {
186
+ "inputs": [
187
+ { "internalType": "address", "name": "comet", "type": "address" },
188
+ { "internalType": "address", "name": "token", "type": "address" }
189
+ ],
190
+ "name": "setRewardConfig",
191
+ "outputs": [],
192
+ "stateMutability": "nonpayable",
193
+ "type": "function"
194
+ },
195
+ {
196
+ "inputs": [
197
+ { "internalType": "address", "name": "comet", "type": "address" },
198
+ { "internalType": "address", "name": "token", "type": "address" },
199
+ { "internalType": "uint256", "name": "multiplier", "type": "uint256" }
200
+ ],
201
+ "name": "setRewardConfigWithMultiplier",
202
+ "outputs": [],
203
+ "stateMutability": "nonpayable",
204
+ "type": "function"
205
+ },
206
+ {
207
+ "inputs": [
208
+ { "internalType": "address", "name": "comet", "type": "address" },
209
+ { "internalType": "address[]", "name": "users", "type": "address[]" },
210
+ {
211
+ "internalType": "uint256[]",
212
+ "name": "claimedAmounts",
213
+ "type": "uint256[]"
214
+ }
215
+ ],
216
+ "name": "setRewardsClaimed",
217
+ "outputs": [],
218
+ "stateMutability": "nonpayable",
219
+ "type": "function"
220
+ },
221
+ {
222
+ "inputs": [
223
+ { "internalType": "address", "name": "newGovernor", "type": "address" }
224
+ ],
225
+ "name": "transferGovernor",
226
+ "outputs": [],
227
+ "stateMutability": "nonpayable",
228
+ "type": "function"
229
+ },
230
+ {
231
+ "inputs": [
232
+ { "internalType": "address", "name": "token", "type": "address" },
233
+ { "internalType": "address", "name": "to", "type": "address" },
234
+ { "internalType": "uint256", "name": "amount", "type": "uint256" }
235
+ ],
236
+ "name": "withdrawToken",
237
+ "outputs": [],
238
+ "stateMutability": "nonpayable",
239
+ "type": "function"
240
+ }
241
+ ]
package/src/config.ts CHANGED
@@ -81,9 +81,12 @@ export const stakingAddress: AddressDappNetworkMap = {
81
81
  [Dapp.AAVEV3]: "0x929EC64c34a17401F460460D4B9390518E5B473e"
82
82
  },
83
83
  [Network.OPTIMISM]: {
84
- [Dapp.AAVEV3]: "0x929EC64c34a17401F460460D4B9390518E5B473e"
84
+ [Dapp.AAVEV3]: "0x929EC64c34a17401F460460D4B9390518E5B473e",
85
+ [Dapp.COMPOUNDV3]: "0x443ea0340cb75a160f31a440722dec7b5bc3c2e9"
86
+ },
87
+ [Network.ARBITRUM]: {
88
+ [Dapp.COMPOUNDV3]: "0x88730d254a2f7e6ac8388c3198afd694ba9f7fae"
85
89
  },
86
- [Network.ARBITRUM]: {},
87
90
  [Network.BASE]: {}
88
91
  };
89
92
 
@@ -80,6 +80,7 @@ import {
80
80
  getCompoundV3LendTxData,
81
81
  getCompoundV3WithdrawTxData
82
82
  } from "../services/compound/lending";
83
+ import { getCompoundV3ClaimTxData } from "../services/compound/rewards";
83
84
 
84
85
  export class Pool {
85
86
  public readonly poolLogic: Contract;
@@ -1040,6 +1041,31 @@ export class Pool {
1040
1041
  return tx;
1041
1042
  }
1042
1043
 
1044
+ /**
1045
+ * Claim rewards from CompoundV3
1046
+ * @param {string} asset Compound lending asset
1047
+ * @param {any} options Transaction options
1048
+ * @param {boolean} estimateGas Simulate/estimate gas
1049
+ * @returns {Promise<any>} Transaction
1050
+ */
1051
+ async harvestCompoundV3Rewards(
1052
+ asset: string,
1053
+ options: any = null,
1054
+ estimateGas = false
1055
+ ): Promise<any> {
1056
+ const claimTxData = await getCompoundV3ClaimTxData(this, asset);
1057
+ const tx = await getPoolTxOrGasEstimate(
1058
+ this,
1059
+ [
1060
+ stakingAddress[this.network][Dapp.COMPOUNDV3] as string,
1061
+ claimTxData,
1062
+ options
1063
+ ],
1064
+ estimateGas
1065
+ );
1066
+ return tx;
1067
+ }
1068
+
1043
1069
  /**
1044
1070
  * Create UniswapV3 liquidity pool
1045
1071
  * @param {dapp} Platform UniswapV3, VelodromeCL, AerodromeCL or RamesesCL
@@ -0,0 +1,9 @@
1
+ import { ethers } from "ethers";
2
+ import ICometRewards from "../../abi/compound/ICometRewards.json";
3
+ import { Pool } from "../..";
4
+
5
+ export function getCompoundV3ClaimTxData(pool: Pool, asset: string): string {
6
+ const iCometRewards = new ethers.utils.Interface(ICometRewards);
7
+
8
+ return iCometRewards.encodeFunctionData("claim", [asset, pool.address, true]);
9
+ }
@@ -81,6 +81,10 @@ const testCompoundV3 = ({ network, provider }: TestingRunParams) => {
81
81
  const wethBalance = await balanceDelta(pool.address, WETH, pool.signer);
82
82
  expect(wethBalance.gt(0));
83
83
  });
84
+
85
+ it("harvests rewards from CompundV3", async () => {
86
+ await pool.harvestCompoundV3Rewards(COMPOUNDV3_WETH);
87
+ });
84
88
  });
85
89
  };
86
90
 
package/src/types.ts CHANGED
@@ -27,7 +27,8 @@ export enum Dapp {
27
27
  RAMSES = "ramses",
28
28
  AERODROME = "aerodrome",
29
29
  AERODROMECL = "aerodromeCL",
30
- RAMSESCL = "ramsesCL"
30
+ RAMSESCL = "ramsesCL",
31
+ COMPOUNDV3 = "compoundV3"
31
32
  }
32
33
 
33
34
  export enum Transaction {