@dhedge/v2-sdk 1.10.0 → 1.10.2
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/dist/services/velodrome/liquidity.d.ts +0 -3
- package/dist/test/utils/testingHelper.d.ts +13 -1
- package/dist/test/wallet.d.ts +1 -2
- package/dist/v2-sdk.cjs.development.js +225 -294
- package/dist/v2-sdk.cjs.development.js.map +1 -1
- package/dist/v2-sdk.cjs.production.min.js +1 -1
- package/dist/v2-sdk.cjs.production.min.js.map +1 -1
- package/dist/v2-sdk.esm.js +225 -294
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/abi/AssetHandler.json +286 -0
- package/src/config.ts +10 -7
- package/src/entities/pool.ts +4 -11
- package/src/services/oneInch/index.ts +14 -5
- package/src/services/velodrome/liquidity.ts +0 -57
- package/src/test/constants.ts +1 -1
- package/src/test/oneInch.test.ts +17 -12
- package/src/test/utils/testingHelper.ts +55 -3
- package/src/test/velodromeCL.test.ts +72 -90
- package/src/test/wallet.ts +6 -28
- package/src/test/zeroEx.test.ts +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhedge/v2-sdk",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "🛠 An SDK for building applications on top of dHEDGE V2",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@size-limit/preset-small-lib": "^5.0.1",
|
|
35
35
|
"@types/jest": "^28.1.7",
|
|
36
36
|
"@types/lodash": "^4.14.178",
|
|
37
|
-
"hardhat": "
|
|
37
|
+
"hardhat": "2.19.3",
|
|
38
38
|
"husky": "^7.0.1",
|
|
39
39
|
"jest": "^28.1.3",
|
|
40
40
|
"size-limit": "^5.0.1",
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
{
|
|
2
|
+
"abi": [
|
|
3
|
+
{
|
|
4
|
+
"anonymous": false,
|
|
5
|
+
"inputs": [
|
|
6
|
+
{
|
|
7
|
+
"indexed": false,
|
|
8
|
+
"internalType": "address",
|
|
9
|
+
"name": "asset",
|
|
10
|
+
"type": "address"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"indexed": false,
|
|
14
|
+
"internalType": "uint16",
|
|
15
|
+
"name": "assetType",
|
|
16
|
+
"type": "uint16"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"indexed": false,
|
|
20
|
+
"internalType": "address",
|
|
21
|
+
"name": "aggregator",
|
|
22
|
+
"type": "address"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"name": "AddedAsset",
|
|
26
|
+
"type": "event"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"anonymous": false,
|
|
30
|
+
"inputs": [
|
|
31
|
+
{
|
|
32
|
+
"indexed": true,
|
|
33
|
+
"internalType": "address",
|
|
34
|
+
"name": "previousOwner",
|
|
35
|
+
"type": "address"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"indexed": true,
|
|
39
|
+
"internalType": "address",
|
|
40
|
+
"name": "newOwner",
|
|
41
|
+
"type": "address"
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"name": "OwnershipTransferred",
|
|
45
|
+
"type": "event"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"anonymous": false,
|
|
49
|
+
"inputs": [
|
|
50
|
+
{
|
|
51
|
+
"indexed": false,
|
|
52
|
+
"internalType": "address",
|
|
53
|
+
"name": "asset",
|
|
54
|
+
"type": "address"
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"name": "RemovedAsset",
|
|
58
|
+
"type": "event"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"anonymous": false,
|
|
62
|
+
"inputs": [
|
|
63
|
+
{
|
|
64
|
+
"indexed": false,
|
|
65
|
+
"internalType": "uint256",
|
|
66
|
+
"name": "_chainlinkTimeout",
|
|
67
|
+
"type": "uint256"
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"name": "SetChainlinkTimeout",
|
|
71
|
+
"type": "event"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"inputs": [
|
|
75
|
+
{
|
|
76
|
+
"internalType": "address",
|
|
77
|
+
"name": "asset",
|
|
78
|
+
"type": "address"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"internalType": "uint16",
|
|
82
|
+
"name": "assetType",
|
|
83
|
+
"type": "uint16"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"internalType": "address",
|
|
87
|
+
"name": "aggregator",
|
|
88
|
+
"type": "address"
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
"name": "addAsset",
|
|
92
|
+
"outputs": [],
|
|
93
|
+
"stateMutability": "nonpayable",
|
|
94
|
+
"type": "function"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"inputs": [
|
|
98
|
+
{
|
|
99
|
+
"components": [
|
|
100
|
+
{
|
|
101
|
+
"internalType": "address",
|
|
102
|
+
"name": "asset",
|
|
103
|
+
"type": "address"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"internalType": "uint16",
|
|
107
|
+
"name": "assetType",
|
|
108
|
+
"type": "uint16"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"internalType": "address",
|
|
112
|
+
"name": "aggregator",
|
|
113
|
+
"type": "address"
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"internalType": "struct IAssetHandler.Asset[]",
|
|
117
|
+
"name": "assets",
|
|
118
|
+
"type": "tuple[]"
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
"name": "addAssets",
|
|
122
|
+
"outputs": [],
|
|
123
|
+
"stateMutability": "nonpayable",
|
|
124
|
+
"type": "function"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"inputs": [
|
|
128
|
+
{
|
|
129
|
+
"internalType": "address",
|
|
130
|
+
"name": "",
|
|
131
|
+
"type": "address"
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
"name": "assetTypes",
|
|
135
|
+
"outputs": [
|
|
136
|
+
{
|
|
137
|
+
"internalType": "uint16",
|
|
138
|
+
"name": "",
|
|
139
|
+
"type": "uint16"
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"stateMutability": "view",
|
|
143
|
+
"type": "function"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"inputs": [],
|
|
147
|
+
"name": "chainlinkTimeout",
|
|
148
|
+
"outputs": [
|
|
149
|
+
{
|
|
150
|
+
"internalType": "uint256",
|
|
151
|
+
"name": "",
|
|
152
|
+
"type": "uint256"
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
"stateMutability": "view",
|
|
156
|
+
"type": "function"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"inputs": [
|
|
160
|
+
{
|
|
161
|
+
"internalType": "address",
|
|
162
|
+
"name": "asset",
|
|
163
|
+
"type": "address"
|
|
164
|
+
}
|
|
165
|
+
],
|
|
166
|
+
"name": "getUSDPrice",
|
|
167
|
+
"outputs": [
|
|
168
|
+
{
|
|
169
|
+
"internalType": "uint256",
|
|
170
|
+
"name": "price",
|
|
171
|
+
"type": "uint256"
|
|
172
|
+
}
|
|
173
|
+
],
|
|
174
|
+
"stateMutability": "view",
|
|
175
|
+
"type": "function"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"inputs": [
|
|
179
|
+
{
|
|
180
|
+
"components": [
|
|
181
|
+
{
|
|
182
|
+
"internalType": "address",
|
|
183
|
+
"name": "asset",
|
|
184
|
+
"type": "address"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"internalType": "uint16",
|
|
188
|
+
"name": "assetType",
|
|
189
|
+
"type": "uint16"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"internalType": "address",
|
|
193
|
+
"name": "aggregator",
|
|
194
|
+
"type": "address"
|
|
195
|
+
}
|
|
196
|
+
],
|
|
197
|
+
"internalType": "struct IAssetHandler.Asset[]",
|
|
198
|
+
"name": "assets",
|
|
199
|
+
"type": "tuple[]"
|
|
200
|
+
}
|
|
201
|
+
],
|
|
202
|
+
"name": "initialize",
|
|
203
|
+
"outputs": [],
|
|
204
|
+
"stateMutability": "nonpayable",
|
|
205
|
+
"type": "function"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"inputs": [],
|
|
209
|
+
"name": "owner",
|
|
210
|
+
"outputs": [
|
|
211
|
+
{
|
|
212
|
+
"internalType": "address",
|
|
213
|
+
"name": "",
|
|
214
|
+
"type": "address"
|
|
215
|
+
}
|
|
216
|
+
],
|
|
217
|
+
"stateMutability": "view",
|
|
218
|
+
"type": "function"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"inputs": [
|
|
222
|
+
{
|
|
223
|
+
"internalType": "address",
|
|
224
|
+
"name": "",
|
|
225
|
+
"type": "address"
|
|
226
|
+
}
|
|
227
|
+
],
|
|
228
|
+
"name": "priceAggregators",
|
|
229
|
+
"outputs": [
|
|
230
|
+
{
|
|
231
|
+
"internalType": "address",
|
|
232
|
+
"name": "",
|
|
233
|
+
"type": "address"
|
|
234
|
+
}
|
|
235
|
+
],
|
|
236
|
+
"stateMutability": "view",
|
|
237
|
+
"type": "function"
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"inputs": [
|
|
241
|
+
{
|
|
242
|
+
"internalType": "address",
|
|
243
|
+
"name": "asset",
|
|
244
|
+
"type": "address"
|
|
245
|
+
}
|
|
246
|
+
],
|
|
247
|
+
"name": "removeAsset",
|
|
248
|
+
"outputs": [],
|
|
249
|
+
"stateMutability": "nonpayable",
|
|
250
|
+
"type": "function"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"inputs": [],
|
|
254
|
+
"name": "renounceOwnership",
|
|
255
|
+
"outputs": [],
|
|
256
|
+
"stateMutability": "nonpayable",
|
|
257
|
+
"type": "function"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"inputs": [
|
|
261
|
+
{
|
|
262
|
+
"internalType": "uint256",
|
|
263
|
+
"name": "newTimeoutPeriod",
|
|
264
|
+
"type": "uint256"
|
|
265
|
+
}
|
|
266
|
+
],
|
|
267
|
+
"name": "setChainlinkTimeout",
|
|
268
|
+
"outputs": [],
|
|
269
|
+
"stateMutability": "nonpayable",
|
|
270
|
+
"type": "function"
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"inputs": [
|
|
274
|
+
{
|
|
275
|
+
"internalType": "address",
|
|
276
|
+
"name": "newOwner",
|
|
277
|
+
"type": "address"
|
|
278
|
+
}
|
|
279
|
+
],
|
|
280
|
+
"name": "transferOwnership",
|
|
281
|
+
"outputs": [],
|
|
282
|
+
"stateMutability": "nonpayable",
|
|
283
|
+
"type": "function"
|
|
284
|
+
}
|
|
285
|
+
]
|
|
286
|
+
}
|
package/src/config.ts
CHANGED
|
@@ -25,7 +25,7 @@ export const routerAddress: AddressDappNetworkMap = {
|
|
|
25
25
|
[Dapp.SUSHISWAP]: "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506",
|
|
26
26
|
[Dapp.AAVE]: "0x8dFf5E27EA6b7AC08EbFdf9eB090F32ee9a30fcf",
|
|
27
27
|
[Dapp.AAVEV3]: "0x794a61358D6845594F94dc1DB02A252b5b4814aD",
|
|
28
|
-
[Dapp.ONEINCH]: "
|
|
28
|
+
[Dapp.ONEINCH]: "0x111111125421ca6dc452d289314280a0f8842a65",
|
|
29
29
|
[Dapp.QUICKSWAP]: "0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff",
|
|
30
30
|
[Dapp.BALANCER]: "0xBA12222222228d8Ba445958a75a0704d566BF2C8",
|
|
31
31
|
[Dapp.UNISWAPV3]: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
|
|
@@ -37,7 +37,7 @@ export const routerAddress: AddressDappNetworkMap = {
|
|
|
37
37
|
[Dapp.UNISWAPV3]: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
|
|
38
38
|
[Dapp.SYNTHETIX]: "0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4",
|
|
39
39
|
[Dapp.AAVEV3]: "0x794a61358D6845594F94dc1DB02A252b5b4814aD",
|
|
40
|
-
[Dapp.ONEINCH]: "
|
|
40
|
+
[Dapp.ONEINCH]: "0x111111125421ca6dc452d289314280a0f8842a65",
|
|
41
41
|
[Dapp.TOROS]: "0x3988513793bCE39f0167064A9F7fC3617FaF35AB",
|
|
42
42
|
[Dapp.VELODROME]: "0x9c12939390052919aF3155f41Bf4160Fd3666A6f",
|
|
43
43
|
[Dapp.VELODROMEV2]: "0xa062ae8a9c5e11aaa026fc2670b0d65ccc8b2858",
|
|
@@ -46,14 +46,15 @@ export const routerAddress: AddressDappNetworkMap = {
|
|
|
46
46
|
[Dapp.ZEROEX]: "0xdef1abe32c034e558cdd535791643c58a13acc10"
|
|
47
47
|
},
|
|
48
48
|
[Network.ARBITRUM]: {
|
|
49
|
-
[Dapp.ONEINCH]: "
|
|
49
|
+
[Dapp.ONEINCH]: "0x111111125421ca6dc452d289314280a0f8842a65",
|
|
50
50
|
[Dapp.UNISWAPV3]: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
|
|
51
51
|
[Dapp.AAVEV3]: "0x794a61358D6845594F94dc1DB02A252b5b4814aD",
|
|
52
52
|
[Dapp.BALANCER]: "0xBA12222222228d8Ba445958a75a0704d566BF2C8",
|
|
53
|
-
[Dapp.RAMSES]: "0xaaa87963efeb6f7e0a2711f397663105acb1805e"
|
|
53
|
+
[Dapp.RAMSES]: "0xaaa87963efeb6f7e0a2711f397663105acb1805e",
|
|
54
|
+
[Dapp.ZEROEX]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff"
|
|
54
55
|
},
|
|
55
56
|
[Network.BASE]: {
|
|
56
|
-
[Dapp.ONEINCH]: "
|
|
57
|
+
[Dapp.ONEINCH]: "0x111111125421ca6dc452d289314280a0f8842a65",
|
|
57
58
|
[Dapp.ZEROEX]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
|
|
58
59
|
[Dapp.AERODROME]: "0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43",
|
|
59
60
|
[Dapp.AAVEV3]: "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5"
|
|
@@ -77,7 +78,9 @@ export const stakingAddress: AddressDappNetworkMap = {
|
|
|
77
78
|
[Dapp.AAVE]: "0x357D51124f59836DeD84c8a1730D72B749d8BC23",
|
|
78
79
|
[Dapp.AAVEV3]: "0x929EC64c34a17401F460460D4B9390518E5B473e"
|
|
79
80
|
},
|
|
80
|
-
[Network.OPTIMISM]: {
|
|
81
|
+
[Network.OPTIMISM]: {
|
|
82
|
+
[Dapp.AAVEV3]: "0x929EC64c34a17401F460460D4B9390518E5B473e"
|
|
83
|
+
},
|
|
81
84
|
[Network.ARBITRUM]: {},
|
|
82
85
|
[Network.BASE]: {}
|
|
83
86
|
};
|
|
@@ -104,7 +107,7 @@ export const nonfungiblePositionManagerAddress: AddressDappNetworkMap = {
|
|
|
104
107
|
},
|
|
105
108
|
[Network.OPTIMISM]: {
|
|
106
109
|
[Dapp.UNISWAPV3]: "0xC36442b4a4522E871399CD717aBDD847Ab11FE88",
|
|
107
|
-
[Dapp.VELODROMECL]: "
|
|
110
|
+
[Dapp.VELODROMECL]: "0x416b433906b1B72FA758e166e239c43d68dC6F29"
|
|
108
111
|
},
|
|
109
112
|
[Network.ARBITRUM]: {
|
|
110
113
|
[Dapp.UNISWAPV3]: "0xC36442b4a4522E871399CD717aBDD847Ab11FE88"
|
package/src/entities/pool.ts
CHANGED
|
@@ -44,8 +44,6 @@ import { getEasySwapperTxData } from "../services/toros/easySwapper";
|
|
|
44
44
|
import { getAaveV3ClaimTxData } from "../services/aave/incentives";
|
|
45
45
|
import {
|
|
46
46
|
getVelodromeAddLiquidityTxData,
|
|
47
|
-
getVelodromeCLDecreaseStakedLiquidityTxData,
|
|
48
|
-
getVelodromeCLIncreaseStakedLiquidityTxData,
|
|
49
47
|
getVelodromeClOwner,
|
|
50
48
|
getVelodromeRemoveLiquidityTxData
|
|
51
49
|
} from "../services/velodrome/liquidity";
|
|
@@ -1085,10 +1083,8 @@ export class Pool {
|
|
|
1085
1083
|
if (!isStaked) {
|
|
1086
1084
|
txData = await getDecreaseLiquidityTxData(this, dapp, tokenId, amount);
|
|
1087
1085
|
} else {
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
tokenId,
|
|
1091
|
-
amount
|
|
1086
|
+
throw new Error(
|
|
1087
|
+
"unsupported decreaseStakedLiquidity: unstake first to decrease lp"
|
|
1092
1088
|
);
|
|
1093
1089
|
}
|
|
1094
1090
|
const tx = await getPoolTxOrGasEstimate(
|
|
@@ -1149,11 +1145,8 @@ export class Pool {
|
|
|
1149
1145
|
amountB
|
|
1150
1146
|
);
|
|
1151
1147
|
} else {
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
tokenId,
|
|
1155
|
-
amountA,
|
|
1156
|
-
amountB
|
|
1148
|
+
throw new Error(
|
|
1149
|
+
"unsupported increaseStakedLiquidity: unstake first to increase lp"
|
|
1157
1150
|
);
|
|
1158
1151
|
}
|
|
1159
1152
|
const tx = await getPoolTxOrGasEstimate(
|
|
@@ -4,7 +4,7 @@ import { ApiError, ethers } from "../..";
|
|
|
4
4
|
import { networkChainIdMap } from "../../config";
|
|
5
5
|
import { Pool } from "../../entities";
|
|
6
6
|
|
|
7
|
-
const oneInchBaseUrl = "https://api.1inch.dev/swap/
|
|
7
|
+
const oneInchBaseUrl = "https://api.1inch.dev/swap/v6.0/";
|
|
8
8
|
|
|
9
9
|
export async function getOneInchSwapTxData(
|
|
10
10
|
pool: Pool,
|
|
@@ -17,14 +17,23 @@ export async function getOneInchSwapTxData(
|
|
|
17
17
|
throw new Error("ONEINCH_API_KEY not configured in .env file");
|
|
18
18
|
|
|
19
19
|
const chainId = networkChainIdMap[pool.network];
|
|
20
|
-
const apiUrl = `${oneInchBaseUrl}${chainId}/swap
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const apiUrl = `${oneInchBaseUrl}${chainId}/swap`;
|
|
21
|
+
const params = {
|
|
22
|
+
src: assetFrom,
|
|
23
|
+
dst: assetTo,
|
|
24
|
+
amount: amountIn.toString(),
|
|
25
|
+
from: pool.address,
|
|
26
|
+
origin: pool.signer.address,
|
|
27
|
+
slippage: slippage,
|
|
28
|
+
disableEstimate: true,
|
|
29
|
+
usePermit2: false
|
|
30
|
+
};
|
|
23
31
|
try {
|
|
24
32
|
const response = await axios.get(apiUrl, {
|
|
25
33
|
headers: {
|
|
26
34
|
Authorization: `Bearer ${process.env.ONEINCH_API_KEY}`
|
|
27
|
-
}
|
|
35
|
+
},
|
|
36
|
+
params
|
|
28
37
|
});
|
|
29
38
|
return response.data.tx.data;
|
|
30
39
|
} catch (e) {
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import { ethers } from "ethers";
|
|
3
3
|
import IVelodromeRouter from "../../abi/IVeldodromeRouter.json";
|
|
4
|
-
import IVelodromeCLGauge from "../../abi/IVelodromeCLGauge.json";
|
|
5
4
|
import { Pool } from "../../entities";
|
|
6
5
|
import { Dapp, Transaction } from "../../types";
|
|
7
6
|
import { getDeadline } from "../../utils/deadline";
|
|
8
|
-
import { getUniswapV3Liquidity } from "../uniswap/V3Liquidity";
|
|
9
7
|
import { nonfungiblePositionManagerAddress } from "../../config";
|
|
10
8
|
import INonfungiblePositionManager from "../../abi/INonfungiblePositionManager.json";
|
|
11
9
|
|
|
@@ -51,61 +49,6 @@ export async function getVelodromeRemoveLiquidityTxData(
|
|
|
51
49
|
]);
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
export async function getVelodromeCLDecreaseStakedLiquidityTxData(
|
|
55
|
-
pool: Pool,
|
|
56
|
-
tokenId: string,
|
|
57
|
-
amount: number
|
|
58
|
-
): Promise<any> {
|
|
59
|
-
const abi = new ethers.utils.Interface(IVelodromeCLGauge.abi);
|
|
60
|
-
const liquidity = (
|
|
61
|
-
await getUniswapV3Liquidity(Dapp.VELODROMECL, tokenId, pool)
|
|
62
|
-
)
|
|
63
|
-
.times(amount)
|
|
64
|
-
.div(100);
|
|
65
|
-
|
|
66
|
-
return abi.encodeFunctionData("decreaseStakedLiquidity", [
|
|
67
|
-
tokenId,
|
|
68
|
-
liquidity.toFixed(0),
|
|
69
|
-
0,
|
|
70
|
-
0,
|
|
71
|
-
await getDeadline(pool)
|
|
72
|
-
]);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export async function getVelodromeCLIncreaseStakedLiquidityTxData(
|
|
76
|
-
pool: Pool,
|
|
77
|
-
tokenId: string,
|
|
78
|
-
amountA: ethers.BigNumber | string,
|
|
79
|
-
amountB: ethers.BigNumber | string
|
|
80
|
-
): Promise<any> {
|
|
81
|
-
const abi = new ethers.utils.Interface(IVelodromeCLGauge.abi);
|
|
82
|
-
return abi.encodeFunctionData("increaseStakedLiquidity", [
|
|
83
|
-
tokenId,
|
|
84
|
-
amountA,
|
|
85
|
-
amountB,
|
|
86
|
-
0,
|
|
87
|
-
0,
|
|
88
|
-
await getDeadline(pool)
|
|
89
|
-
]);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export async function getVelodromeCLIncreaseLiquidityTxData(
|
|
93
|
-
pool: Pool,
|
|
94
|
-
tokenId: string,
|
|
95
|
-
amountA: ethers.BigNumber | string,
|
|
96
|
-
amountB: ethers.BigNumber | string
|
|
97
|
-
): Promise<any> {
|
|
98
|
-
const abi = new ethers.utils.Interface(IVelodromeCLGauge.abi);
|
|
99
|
-
return abi.encodeFunctionData("increaseStakedLiquidity", [
|
|
100
|
-
tokenId,
|
|
101
|
-
amountA,
|
|
102
|
-
amountB,
|
|
103
|
-
0,
|
|
104
|
-
0,
|
|
105
|
-
await getDeadline(pool)
|
|
106
|
-
]);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
52
|
export async function getVelodromeClOwner(
|
|
110
53
|
pool: Pool,
|
|
111
54
|
tokenId: string
|
package/src/test/constants.ts
CHANGED
|
@@ -76,7 +76,7 @@ export const CONTRACT_ADDRESS = {
|
|
|
76
76
|
//
|
|
77
77
|
ARRAKIS_USDC_WETH_GAUGE: "",
|
|
78
78
|
ARRAKIS_USDC_WETH_LP: "",
|
|
79
|
-
VELODROME_CL_USDC_WETH_GAUGE: "
|
|
79
|
+
VELODROME_CL_USDC_WETH_GAUGE: "0xa75127121d28a9BF848F3B70e7Eea26570aa7700",
|
|
80
80
|
VELO: "0x9560e827aF36c94D2Ac33a39bCE1Fe78631088Db"
|
|
81
81
|
},
|
|
82
82
|
[Network.ARBITRUM]: {
|
package/src/test/oneInch.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { Dhedge, Pool } from "..";
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
import { Dapp, Network } from "../types";
|
|
6
6
|
import { CONTRACT_ADDRESS, MAX_AMOUNT, TEST_POOL } from "./constants";
|
|
7
7
|
import {
|
|
@@ -12,6 +12,9 @@ import {
|
|
|
12
12
|
} from "./utils/testingHelper";
|
|
13
13
|
import { allowanceDelta, balanceDelta } from "./utils/token";
|
|
14
14
|
import { getTxOptions } from "./txOptions";
|
|
15
|
+
import BigNumber from "bignumber.js";
|
|
16
|
+
import { routerAddress } from "../config";
|
|
17
|
+
// import { routerAddress } from "../config";
|
|
15
18
|
|
|
16
19
|
const testOneInch = ({ wallet, network, provider }: TestingRunParams) => {
|
|
17
20
|
const USDC = CONTRACT_ADDRESS[network].USDC;
|
|
@@ -57,7 +60,7 @@ const testOneInch = ({ wallet, network, provider }: TestingRunParams) => {
|
|
|
57
60
|
USDC,
|
|
58
61
|
WETH,
|
|
59
62
|
"2000000",
|
|
60
|
-
|
|
63
|
+
1,
|
|
61
64
|
await getTxOptions(network),
|
|
62
65
|
true
|
|
63
66
|
);
|
|
@@ -73,7 +76,7 @@ const testOneInch = ({ wallet, network, provider }: TestingRunParams) => {
|
|
|
73
76
|
USDC,
|
|
74
77
|
WETH,
|
|
75
78
|
"200000000",
|
|
76
|
-
|
|
79
|
+
1,
|
|
77
80
|
await getTxOptions(network),
|
|
78
81
|
true
|
|
79
82
|
);
|
|
@@ -106,12 +109,14 @@ testingHelper({
|
|
|
106
109
|
testingRun: testOneInch
|
|
107
110
|
});
|
|
108
111
|
|
|
109
|
-
testingHelper({
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
// testingHelper({
|
|
113
|
+
// network: Network.POLYGON,
|
|
114
|
+
// onFork: false,
|
|
115
|
+
// testingRun: testOneInch
|
|
116
|
+
// });
|
|
113
117
|
|
|
114
|
-
testingHelper({
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
+
// testingHelper({
|
|
119
|
+
// network: Network.BASE,
|
|
120
|
+
// onFork: false,
|
|
121
|
+
// testingRun: testOneInch
|
|
122
|
+
// });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BigNumber, ethers } from "ethers";
|
|
1
|
+
import { BigNumber, Contract, ethers } from "ethers";
|
|
2
2
|
import { Network } from "../../types";
|
|
3
3
|
import { getWalletData } from "../wallet";
|
|
4
4
|
import {
|
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
USDC_BALANCEOF_SLOT,
|
|
7
7
|
WETH_BALANCEOF_SLOT
|
|
8
8
|
} from "../constants";
|
|
9
|
+
import { Pool } from "../../entities";
|
|
10
|
+
import AssetHandler from "../../abi/AssetHandler.json";
|
|
9
11
|
|
|
10
12
|
export type TestingRunParams = {
|
|
11
13
|
network: Network;
|
|
@@ -16,13 +18,14 @@ export type TestingRunParams = {
|
|
|
16
18
|
|
|
17
19
|
type TestHelperParams = {
|
|
18
20
|
testingRun: (testingRunParams: TestingRunParams) => void;
|
|
19
|
-
} & { network: Network };
|
|
21
|
+
} & { network: Network; onFork?: boolean };
|
|
20
22
|
|
|
21
23
|
export const testingHelper = ({
|
|
22
24
|
network,
|
|
25
|
+
onFork = true,
|
|
23
26
|
testingRun
|
|
24
27
|
}: TestHelperParams): void => {
|
|
25
|
-
const { wallet, provider, rpcUrl } = getWalletData(network);
|
|
28
|
+
const { wallet, provider, rpcUrl } = getWalletData(network, onFork);
|
|
26
29
|
testingRun({ network, wallet, provider, rpcUrl });
|
|
27
30
|
};
|
|
28
31
|
|
|
@@ -119,3 +122,52 @@ export const setWETHAmount = async ({
|
|
|
119
122
|
export const wait = (seconds: number): Promise<void> => {
|
|
120
123
|
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
|
|
121
124
|
};
|
|
125
|
+
|
|
126
|
+
export const runWithImpersonateAccount = async (
|
|
127
|
+
{
|
|
128
|
+
account,
|
|
129
|
+
provider
|
|
130
|
+
}: {
|
|
131
|
+
account: string;
|
|
132
|
+
provider: ethers.providers.JsonRpcProvider;
|
|
133
|
+
},
|
|
134
|
+
fnToRun: ({ signer }: { signer: ethers.providers.JsonRpcSigner }) => void
|
|
135
|
+
): Promise<void> => {
|
|
136
|
+
await provider.send("hardhat_impersonateAccount", [account]);
|
|
137
|
+
|
|
138
|
+
await provider.send("hardhat_setBalance", [
|
|
139
|
+
account,
|
|
140
|
+
ethers.utils.hexValue(ethers.utils.parseEther("1000"))
|
|
141
|
+
]);
|
|
142
|
+
const signer = provider.getSigner(account);
|
|
143
|
+
await fnToRun({ signer });
|
|
144
|
+
|
|
145
|
+
await provider.send("hardhat_stopImpersonatingAccount", [account]);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export const setChainlinkTimeout = async (
|
|
149
|
+
{
|
|
150
|
+
pool,
|
|
151
|
+
provider
|
|
152
|
+
}: {
|
|
153
|
+
pool: Pool;
|
|
154
|
+
provider: ethers.providers.JsonRpcProvider;
|
|
155
|
+
},
|
|
156
|
+
time: number
|
|
157
|
+
): Promise<void> => {
|
|
158
|
+
const assetHandler = await pool.factory.callStatic.getAssetHandler();
|
|
159
|
+
const assetHandlerContract = new Contract(
|
|
160
|
+
assetHandler,
|
|
161
|
+
AssetHandler.abi,
|
|
162
|
+
provider
|
|
163
|
+
);
|
|
164
|
+
const ownerOfAssetHandler = await assetHandlerContract.callStatic.owner();
|
|
165
|
+
await runWithImpersonateAccount(
|
|
166
|
+
{ provider, account: ownerOfAssetHandler },
|
|
167
|
+
async ({ signer }) => {
|
|
168
|
+
await assetHandlerContract
|
|
169
|
+
.connect(signer)
|
|
170
|
+
.functions.setChainlinkTimeout(time);
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
};
|