@dhedge/v2-sdk 1.9.8 → 1.10.0

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.
Files changed (47) hide show
  1. package/README.md +34 -0
  2. package/dist/config.d.ts +8 -2
  3. package/dist/entities/pool.d.ts +39 -8
  4. package/dist/services/flatmoney/keeperFee.d.ts +6 -0
  5. package/dist/services/flatmoney/stableLp.d.ts +9 -0
  6. package/dist/services/flatmoney/stableModule.d.ts +4 -0
  7. package/dist/services/uniswap/V3Liquidity.d.ts +8 -7
  8. package/dist/services/uniswap/V3Trade.d.ts +1 -2
  9. package/dist/services/velodrome/liquidity.d.ts +7 -3
  10. package/dist/services/velodrome/staking.d.ts +1 -0
  11. package/dist/test/constants.d.ts +14 -0
  12. package/dist/test/utils/testingHelper.d.ts +8 -1
  13. package/dist/test/wallet.d.ts +1 -0
  14. package/dist/types.d.ts +1 -0
  15. package/dist/v2-sdk.cjs.development.js +14286 -10087
  16. package/dist/v2-sdk.cjs.development.js.map +1 -1
  17. package/dist/v2-sdk.cjs.production.min.js +1 -1
  18. package/dist/v2-sdk.cjs.production.min.js.map +1 -1
  19. package/dist/v2-sdk.esm.js +14292 -10093
  20. package/dist/v2-sdk.esm.js.map +1 -1
  21. package/package.json +2 -2
  22. package/src/abi/IERC721.json +217 -0
  23. package/src/abi/IVelodromeCLGauge.json +165 -0
  24. package/src/abi/IVelodromeNonfungiblePositionManager.json +408 -0
  25. package/src/abi/flatmoney/DelayedOrder.json +547 -0
  26. package/src/abi/flatmoney/IFlatcoinVault.json +570 -0
  27. package/src/abi/flatmoney/KeeperFee.json +364 -0
  28. package/src/abi/flatmoney/StableModule.json +770 -0
  29. package/src/config.ts +33 -6
  30. package/src/entities/pool.ts +208 -82
  31. package/src/services/flatmoney/keeperFee.ts +84 -0
  32. package/src/services/flatmoney/stableLp.ts +135 -0
  33. package/src/services/flatmoney/stableModule.ts +43 -0
  34. package/src/services/lyra/trade.ts +1 -1
  35. package/src/services/uniswap/V3Liquidity.ts +141 -18
  36. package/src/services/uniswap/V3Trade.ts +1 -2
  37. package/src/services/velodrome/liquidity.ts +77 -5
  38. package/src/services/velodrome/staking.ts +6 -0
  39. package/src/test/constants.ts +22 -6
  40. package/src/test/flatmoney.test.ts +164 -0
  41. package/src/test/uniswap.test.ts +24 -15
  42. package/src/test/utils/testingHelper.ts +29 -4
  43. package/src/test/velodromeCL.test.ts +223 -0
  44. package/src/test/wallet.ts +4 -1
  45. package/src/types.ts +1 -0
  46. package/dist/services/uniswap/types.d.ts +0 -3
  47. package/src/services/uniswap/types.ts +0 -16
@@ -0,0 +1,135 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+
3
+ import BigNumber from "bignumber.js";
4
+ import { Pool, ethers } from "../..";
5
+ import DelayedOrderAbi from "../../abi/flatmoney/DelayedOrder.json";
6
+ import { flatMoneyContractAddresses } from "../../config";
7
+ import { getPoolTxOrGasEstimate } from "../../utils/contract";
8
+ import { getStableDepositQuote, getStableWithdrawQuote } from "./stableModule";
9
+ import { getKeeperFee } from "./keeperFee";
10
+
11
+ export function getAnnounceStableDepositTxData(
12
+ depositAmount: ethers.BigNumber | string,
13
+ minAmountOut: ethers.BigNumber | string,
14
+ keeperFee: ethers.BigNumber | string
15
+ ): string {
16
+ return new ethers.utils.Interface(
17
+ DelayedOrderAbi
18
+ ).encodeFunctionData("announceStableDeposit", [
19
+ depositAmount,
20
+ minAmountOut,
21
+ keeperFee
22
+ ]);
23
+ }
24
+
25
+ export function getAnnounceStableWithdrawTxData(
26
+ withdrawAmount: ethers.BigNumber | string,
27
+ minAmountOut: ethers.BigNumber | string,
28
+ keeperFee: ethers.BigNumber | string
29
+ ): string {
30
+ return new ethers.utils.Interface(
31
+ DelayedOrderAbi
32
+ ).encodeFunctionData("announceStableWithdraw", [
33
+ withdrawAmount,
34
+ minAmountOut,
35
+ keeperFee
36
+ ]);
37
+ }
38
+
39
+ export function getCancelExistingOrderTxData(account: string): string {
40
+ return new ethers.utils.Interface(
41
+ DelayedOrderAbi
42
+ ).encodeFunctionData("cancelExistingOrder", [account]);
43
+ }
44
+
45
+ export async function mintUnitViaFlatMoney(
46
+ pool: Pool,
47
+ depositAmount: ethers.BigNumber | string,
48
+ slippage: number, // 0.5 means 0.5%
49
+ maxKeeperFeeInUsd: number | null,
50
+ options: any = null,
51
+ estimateGas = false
52
+ ): Promise<any> {
53
+ const flatMoneyContracts = flatMoneyContractAddresses[pool.network];
54
+ if (!flatMoneyContracts) {
55
+ throw new Error("mintUnitViaFlatMoney: network not supported");
56
+ }
57
+
58
+ const keeperfee = await getKeeperFee(pool, maxKeeperFeeInUsd); // in RETH
59
+
60
+ const adjustedDepositAmount = new BigNumber(depositAmount.toString()).minus(
61
+ keeperfee.toString() // keeper fee deducted from amountIn
62
+ );
63
+
64
+ const amountOut = await getStableDepositQuote(
65
+ pool,
66
+ adjustedDepositAmount.toFixed(0)
67
+ );
68
+ const minAmountOut = new BigNumber(amountOut.toString())
69
+ .times(1 - slippage / 100)
70
+ .toFixed(0);
71
+
72
+ const mintUnitTxData = await getAnnounceStableDepositTxData(
73
+ adjustedDepositAmount.toFixed(0),
74
+ minAmountOut,
75
+ keeperfee
76
+ );
77
+
78
+ const tx = await getPoolTxOrGasEstimate(
79
+ pool,
80
+ [flatMoneyContracts.DelayedOrder, mintUnitTxData, options],
81
+ estimateGas
82
+ );
83
+ return tx;
84
+ }
85
+
86
+ export async function redeemUnitViaFlatMoney(
87
+ pool: Pool,
88
+ withdrawAmount: ethers.BigNumber | string,
89
+ slippage: number, // 0.5 means 0.5%
90
+ maxKeeperFeeInUsd: number | null,
91
+ options: any = null,
92
+ estimateGas = false
93
+ ): Promise<any> {
94
+ const flatMoneyContracts = flatMoneyContractAddresses[pool.network];
95
+ if (!flatMoneyContracts) {
96
+ throw new Error("redeemUnitViaFlatMoney: network not supported");
97
+ }
98
+ const keeperfee = await getKeeperFee(pool, maxKeeperFeeInUsd); // in RETH
99
+
100
+ const amountOut = await getStableWithdrawQuote(pool, withdrawAmount);
101
+ const minAmountOut = new BigNumber(amountOut.toString())
102
+ .times(1 - slippage / 100)
103
+ .minus(keeperfee.toString()) // keeper fee deducted from amountOut
104
+ .toFixed(0);
105
+
106
+ const redeemUnitTxData = await getAnnounceStableWithdrawTxData(
107
+ withdrawAmount,
108
+ minAmountOut,
109
+ keeperfee
110
+ );
111
+ const tx = await getPoolTxOrGasEstimate(
112
+ pool,
113
+ [flatMoneyContracts.DelayedOrder, redeemUnitTxData, options],
114
+ estimateGas
115
+ );
116
+ return tx;
117
+ }
118
+
119
+ export async function cancelOrderViaFlatMoney(
120
+ pool: Pool,
121
+ options: any = null,
122
+ estimateGas = false
123
+ ): Promise<any> {
124
+ const flatMoneyContracts = flatMoneyContractAddresses[pool.network];
125
+ if (!flatMoneyContracts) {
126
+ throw new Error("cancelOrderViaFlatMoney: network not supported");
127
+ }
128
+ const cancelOrderTxData = await getCancelExistingOrderTxData(pool.address);
129
+ const tx = await getPoolTxOrGasEstimate(
130
+ pool,
131
+ [flatMoneyContracts.DelayedOrder, cancelOrderTxData, options],
132
+ estimateGas
133
+ );
134
+ return tx;
135
+ }
@@ -0,0 +1,43 @@
1
+ import { BigNumber, Contract } from "ethers";
2
+ import { flatMoneyContractAddresses } from "../../config";
3
+ import { Pool } from "../../entities";
4
+ import StableModuleAbi from "../../abi/flatmoney/StableModule.json";
5
+
6
+ const getStableModuleContract = (pool: Pool): Contract => {
7
+ const flatMoneyContracts = flatMoneyContractAddresses[pool.network];
8
+ if (!flatMoneyContracts) {
9
+ throw new Error(
10
+ `getStableModuleContract: network of ${pool.network} not supported`
11
+ );
12
+ }
13
+ const stableModuleContract = new Contract(
14
+ flatMoneyContracts.StableModule,
15
+ StableModuleAbi,
16
+ pool.signer
17
+ );
18
+ return stableModuleContract;
19
+ };
20
+
21
+ /// @notice Quoter function for getting the stable deposit amount out.
22
+ export const getStableDepositQuote = async (
23
+ pool: Pool,
24
+ depositAmount: string | BigNumber
25
+ ): Promise<BigNumber> => {
26
+ const stableModuleContract = getStableModuleContract(pool);
27
+ const amountOut: BigNumber = await stableModuleContract.stableDepositQuote(
28
+ depositAmount.toString()
29
+ );
30
+ return amountOut;
31
+ };
32
+
33
+ /// @notice Quoter function for getting the stable withdraw amount out.
34
+ export const getStableWithdrawQuote = async (
35
+ pool: Pool,
36
+ withdrawAmount: string | BigNumber
37
+ ): Promise<BigNumber> => {
38
+ const stableModuleContract = getStableModuleContract(pool);
39
+ const amountOut: BigNumber = await stableModuleContract.stableWithdrawQuote(
40
+ withdrawAmount.toString()
41
+ );
42
+ return amountOut;
43
+ };
@@ -27,7 +27,7 @@ export async function getLyraOptionTxData(
27
27
  const filteredPosition = positions.filter(
28
28
  e =>
29
29
  e.strikeId.toNumber() === strikeId &&
30
- isCall(e.optionType) == (optionType === "call") &&
30
+ isCall(e.optionType) === (optionType === "call") &&
31
31
  e.state === 1
32
32
  );
33
33
  const positionId =
@@ -1,4 +1,6 @@
1
- import { Price, Token } from "@uniswap/sdk-core";
1
+ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ import { Token, Price } from "@uniswap/sdk-core";
2
4
  import {
3
5
  encodeSqrtRatioX96,
4
6
  FeeAmount,
@@ -9,14 +11,17 @@ import {
9
11
  } from "@uniswap/v3-sdk";
10
12
  import { ethers } from "ethers";
11
13
  import JSBI from "jsbi";
12
- import { Pool } from "../..";
14
+ import { Dapp, Pool, Transaction } from "../..";
13
15
  import {
16
+ MaxUint128,
14
17
  networkChainIdMap,
15
18
  nonfungiblePositionManagerAddress
16
19
  } from "../../config";
17
- import { UniswapV3MintParams } from "./types";
18
20
  import INonfungiblePositionManager from "../../abi/INonfungiblePositionManager.json";
21
+ import IVeldodromePositionManager from "../../abi/IVelodromeNonfungiblePositionManager.json";
22
+ import IArrakisV1RouterStaking from "../../abi/IArrakisV1RouterStaking.json";
19
23
  import { getDeadline } from "../../utils/deadline";
24
+ import BigNumber from "bignumber.js";
20
25
 
21
26
  export function tryParsePrice(
22
27
  baseToken: Token,
@@ -42,7 +47,7 @@ export function tryParsePrice(
42
47
  export function tryParseTick(
43
48
  baseToken: Token,
44
49
  quoteToken: Token,
45
- feeAmount: FeeAmount,
50
+ feeAmount: number,
46
51
  value: string
47
52
  ): number {
48
53
  const price = tryParsePrice(baseToken, quoteToken, value);
@@ -61,10 +66,11 @@ export function tryParseTick(
61
66
  tick = priceToClosestTick(price);
62
67
  }
63
68
 
64
- return nearestUsableTick(tick, TICK_SPACINGS[feeAmount]);
69
+ return nearestUsableTick(tick, TICK_SPACINGS[feeAmount as FeeAmount]);
65
70
  }
66
71
 
67
- export async function getUniswapV3MintParams(
72
+ export async function getUniswapV3MintTxData(
73
+ dapp: Dapp.UNISWAPV3 | Dapp.VELODROMECL,
68
74
  pool: Pool,
69
75
  assetA: string,
70
76
  assetB: string,
@@ -74,8 +80,8 @@ export async function getUniswapV3MintParams(
74
80
  maxPrice: number | null,
75
81
  minTick: number | null,
76
82
  maxTick: number | null,
77
- feeAmount: FeeAmount
78
- ): Promise<UniswapV3MintParams> {
83
+ feeAmountOrTickSpacing: number
84
+ ): Promise<any> {
79
85
  let tickLower = 0;
80
86
  let tickUpper = 0;
81
87
  const chainId = networkChainIdMap[pool.network];
@@ -88,14 +94,33 @@ export async function getUniswapV3MintParams(
88
94
  ? [tokenA, tokenB]
89
95
  : [tokenB, tokenA];
90
96
  const invertPrice = !tokenA.equals(token0);
91
-
92
97
  if (minPrice && maxPrice) {
93
98
  tickLower = invertPrice
94
- ? tryParseTick(token1, token0, feeAmount, maxPrice.toString())
95
- : tryParseTick(token0, token1, feeAmount, minPrice.toString());
99
+ ? tryParseTick(
100
+ token1,
101
+ token0,
102
+ feeAmountOrTickSpacing,
103
+ maxPrice.toString()
104
+ )
105
+ : tryParseTick(
106
+ token0,
107
+ token1,
108
+ feeAmountOrTickSpacing,
109
+ minPrice.toString()
110
+ );
96
111
  tickUpper = invertPrice
97
- ? tryParseTick(token1, token0, feeAmount, minPrice.toString())
98
- : tryParseTick(token0, token1, feeAmount, maxPrice.toString());
112
+ ? tryParseTick(
113
+ token1,
114
+ token0,
115
+ feeAmountOrTickSpacing,
116
+ minPrice.toString()
117
+ )
118
+ : tryParseTick(
119
+ token0,
120
+ token1,
121
+ feeAmountOrTickSpacing,
122
+ maxPrice.toString()
123
+ );
99
124
  } else if (minTick && maxTick) {
100
125
  tickLower = minTick;
101
126
  tickUpper = maxTick;
@@ -104,10 +129,10 @@ export async function getUniswapV3MintParams(
104
129
  ? [amountB, amountA]
105
130
  : [amountA, amountB];
106
131
 
107
- return [
132
+ const mintParams = [
108
133
  token0.address,
109
134
  token1.address,
110
- feeAmount,
135
+ feeAmountOrTickSpacing,
111
136
  tickLower,
112
137
  tickUpper,
113
138
  amount0,
@@ -117,17 +142,115 @@ export async function getUniswapV3MintParams(
117
142
  pool.address,
118
143
  await getDeadline(pool)
119
144
  ];
145
+
146
+ let iNonfungiblePositionManager = new ethers.utils.Interface(
147
+ INonfungiblePositionManager.abi
148
+ );
149
+
150
+ if (dapp === Dapp.VELODROMECL) {
151
+ iNonfungiblePositionManager = new ethers.utils.Interface(
152
+ IVeldodromePositionManager.abi
153
+ );
154
+ mintParams.push(0);
155
+ }
156
+
157
+ return iNonfungiblePositionManager.encodeFunctionData(Transaction.MINT, [
158
+ mintParams
159
+ ]);
160
+
161
+ return;
120
162
  }
121
163
 
122
164
  export async function getUniswapV3Liquidity(
165
+ dapp: Dapp.UNISWAPV3 | Dapp.VELODROMECL,
123
166
  tokenId: string,
124
167
  pool: Pool
125
- ): Promise<ethers.BigNumber> {
168
+ ): Promise<BigNumber> {
126
169
  const iNonfungiblePositionManager = new ethers.Contract(
127
- nonfungiblePositionManagerAddress[pool.network],
170
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
171
+ nonfungiblePositionManagerAddress[pool.network][dapp]!,
128
172
  INonfungiblePositionManager.abi,
129
173
  pool.signer
130
174
  );
131
175
  const result = await iNonfungiblePositionManager.positions(tokenId);
132
- return result.liquidity;
176
+ return new BigNumber(result.liquidity.toString());
177
+ }
178
+
179
+ export async function getIncreaseLiquidityTxData(
180
+ pool: Pool,
181
+ dapp: Dapp,
182
+ tokenId: string,
183
+ amountA: ethers.BigNumber | string,
184
+ amountB: ethers.BigNumber | string
185
+ ): Promise<any> {
186
+ let txData;
187
+ if (dapp === Dapp.UNISWAPV3 || dapp === Dapp.VELODROMECL) {
188
+ const abi = new ethers.utils.Interface(INonfungiblePositionManager.abi);
189
+ txData = abi.encodeFunctionData(Transaction.INCREASE_LIQUIDITY, [
190
+ [tokenId, amountA, amountB, 0, 0, await getDeadline(pool)]
191
+ ]);
192
+ } else if (dapp === Dapp.ARRAKIS) {
193
+ const abi = new ethers.utils.Interface(IArrakisV1RouterStaking.abi);
194
+ txData = abi.encodeFunctionData(Transaction.ADD_LIQUIDITY_STAKE, [
195
+ tokenId,
196
+ amountA,
197
+ amountB,
198
+ 0,
199
+ 0,
200
+ 0,
201
+ pool.address
202
+ ]);
203
+ } else {
204
+ throw new Error("dapp not supported");
205
+ }
206
+
207
+ return txData;
208
+ }
209
+
210
+ export async function getDecreaseLiquidityTxData(
211
+ pool: Pool,
212
+ dapp: Dapp,
213
+ tokenId: string,
214
+ amount = 100
215
+ ): Promise<any> {
216
+ let txData;
217
+ if (dapp === Dapp.UNISWAPV3 || dapp === Dapp.VELODROMECL) {
218
+ const abi = new ethers.utils.Interface(INonfungiblePositionManager.abi);
219
+ const liquidity = (await getUniswapV3Liquidity(dapp, tokenId, pool))
220
+ .times(amount)
221
+ .div(100);
222
+
223
+ const decreaseLiquidityTxData = abi.encodeFunctionData(
224
+ Transaction.DECREASE_LIQUIDITY,
225
+ [[tokenId, liquidity.toFixed(0), 0, 0, await getDeadline(pool)]]
226
+ );
227
+ const collectTxData = abi.encodeFunctionData(Transaction.COLLECT, [
228
+ [tokenId, pool.address, MaxUint128, MaxUint128]
229
+ ]);
230
+
231
+ const multicallParams = [decreaseLiquidityTxData, collectTxData];
232
+
233
+ if (amount === 100) {
234
+ const burnTxData = abi.encodeFunctionData(Transaction.BURN, [tokenId]);
235
+ multicallParams.push(burnTxData);
236
+ }
237
+ txData = abi.encodeFunctionData(Transaction.MULTI_CALL, [multicallParams]);
238
+ } else if (dapp === Dapp.ARRAKIS) {
239
+ const abi = new ethers.utils.Interface(IArrakisV1RouterStaking.abi);
240
+ const liquidity = new BigNumber(
241
+ (await pool.utils.getBalance(tokenId, pool.address)).toString()
242
+ )
243
+ .times(amount)
244
+ .div(100);
245
+ txData = abi.encodeFunctionData(Transaction.REMOVE_LIQUIDITY_UNSTAKE, [
246
+ tokenId,
247
+ liquidity,
248
+ 0,
249
+ 0,
250
+ pool.address
251
+ ]);
252
+ } else {
253
+ throw new Error("dapp not supported");
254
+ }
255
+ return txData;
133
256
  }
@@ -1,4 +1,3 @@
1
- import { FeeAmount } from "@uniswap/v3-sdk";
2
1
  import { ethers } from "ethers";
3
2
  import { Pool } from "../..";
4
3
 
@@ -12,7 +11,7 @@ export async function getUniswapV3SwapTxData(
12
11
  assetB: string,
13
12
  amountIn: string | ethers.BigNumber,
14
13
  slippage: number,
15
- feeAmount: FeeAmount
14
+ feeAmount: number
16
15
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
16
  ): Promise<any> {
18
17
  const quoterContract = new ethers.Contract(
@@ -1,16 +1,20 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { BigNumber, ethers } from "ethers";
2
+ import { ethers } from "ethers";
3
3
  import IVelodromeRouter from "../../abi/IVeldodromeRouter.json";
4
+ import IVelodromeCLGauge from "../../abi/IVelodromeCLGauge.json";
4
5
  import { Pool } from "../../entities";
5
- import { Transaction } from "../../types";
6
+ import { Dapp, Transaction } from "../../types";
6
7
  import { getDeadline } from "../../utils/deadline";
8
+ import { getUniswapV3Liquidity } from "../uniswap/V3Liquidity";
9
+ import { nonfungiblePositionManagerAddress } from "../../config";
10
+ import INonfungiblePositionManager from "../../abi/INonfungiblePositionManager.json";
7
11
 
8
12
  export async function getVelodromeAddLiquidityTxData(
9
13
  pool: Pool,
10
14
  assetA: string,
11
15
  assetB: string,
12
- amountA: BigNumber | string,
13
- amountB: BigNumber | string,
16
+ amountA: ethers.BigNumber | string,
17
+ amountB: ethers.BigNumber | string,
14
18
  isStable: boolean
15
19
  ): Promise<any> {
16
20
  const iVelodromeRouter = new ethers.utils.Interface(IVelodromeRouter.abi);
@@ -31,7 +35,7 @@ export async function getVelodromeRemoveLiquidityTxData(
31
35
  pool: Pool,
32
36
  assetA: string,
33
37
  assetB: string,
34
- amount: BigNumber | string,
38
+ amount: ethers.BigNumber | string,
35
39
  isStable: boolean
36
40
  ): Promise<any> {
37
41
  const iVelodromeRouter = new ethers.utils.Interface(IVelodromeRouter.abi);
@@ -46,3 +50,71 @@ export async function getVelodromeRemoveLiquidityTxData(
46
50
  await getDeadline(pool)
47
51
  ]);
48
52
  }
53
+
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
+ export async function getVelodromeClOwner(
110
+ pool: Pool,
111
+ tokenId: string
112
+ ): Promise<string> {
113
+ const iNonfungiblePositionManager = new ethers.Contract(
114
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
115
+ nonfungiblePositionManagerAddress[pool.network][Dapp.VELODROMECL]!,
116
+ INonfungiblePositionManager.abi,
117
+ pool.signer
118
+ );
119
+ return await iNonfungiblePositionManager.ownerOf(tokenId);
120
+ }
@@ -2,6 +2,7 @@
2
2
  import { BigNumber, ethers } from "ethers";
3
3
  import IVelodromeGaugeV1 from "../../abi/IVelodromeGauge.json";
4
4
  import IVelodromeGaugeV2 from "../../abi/IVelodromeGaugeV2.json";
5
+ import IVelodromeCLGauge from "../../abi/IVelodromeCLGauge.json";
5
6
  import { Pool } from "../../entities";
6
7
  import { call } from "../../utils/contract";
7
8
  const iVelodromeGaugeV1 = new ethers.utils.Interface(IVelodromeGaugeV1.abi);
@@ -42,3 +43,8 @@ export async function getVelodromeClaimTxData(
42
43
  ]);
43
44
  }
44
45
  }
46
+
47
+ export async function getVelodromeCLClaimTxData(tokenId: string): Promise<any> {
48
+ const iVelodromeCLGauge = new ethers.utils.Interface(IVelodromeCLGauge.abi);
49
+ return iVelodromeCLGauge.encodeFunctionData("getReward(uint256)", [tokenId]);
50
+ }
@@ -56,11 +56,13 @@ export const CONTRACT_ADDRESS = {
56
56
  WMATIC: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
57
57
  uniswapV3: {
58
58
  nonfungiblePositionManager: "0xC36442b4a4522E871399CD717aBDD847Ab11FE88"
59
- }
59
+ },
60
+ VELODROME_CL_USDC_WETH_GAUGE: "",
61
+ VELO: ""
60
62
  },
61
63
 
62
64
  [Network.OPTIMISM]: {
63
- USDC: "0x7F5c764cBc14f9669B88837ca1490cCa17c31607",
65
+ USDC: "0x0b2c639c533813f4aa9d7837caf62653d097ff85",
64
66
  SUSD: "0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9",
65
67
  SWETH: "",
66
68
  WETH: "0x4200000000000000000000000000000000000006",
@@ -69,10 +71,13 @@ export const CONTRACT_ADDRESS = {
69
71
  uniswapV3: {
70
72
  nonfungiblePositionManager: "0xC36442b4a4522E871399CD717aBDD847Ab11FE88"
71
73
  },
74
+
72
75
  WMATIC: "",
73
76
  //
74
77
  ARRAKIS_USDC_WETH_GAUGE: "",
75
- ARRAKIS_USDC_WETH_LP: ""
78
+ ARRAKIS_USDC_WETH_LP: "",
79
+ VELODROME_CL_USDC_WETH_GAUGE: "0x8d8d1CdDD5960276A1CDE360e7b5D210C3387948",
80
+ VELO: "0x9560e827aF36c94D2Ac33a39bCE1Fe78631088Db"
76
81
  },
77
82
  [Network.ARBITRUM]: {
78
83
  USDC: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
@@ -90,7 +95,9 @@ export const CONTRACT_ADDRESS = {
90
95
  //
91
96
  ARRAKIS_USDC_WETH_GAUGE: "",
92
97
  ARRAKIS_USDC_WETH_LP: "",
93
- WMATIC: ""
98
+ WMATIC: "",
99
+ VELODROME_CL_USDC_WETH_GAUGE: "",
100
+ VELO: ""
94
101
  },
95
102
  [Network.BASE]: {
96
103
  USDC: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
@@ -103,15 +110,24 @@ export const CONTRACT_ADDRESS = {
103
110
  //
104
111
  ARRAKIS_USDC_WETH_GAUGE: "",
105
112
  ARRAKIS_USDC_WETH_LP: "",
106
- WMATIC: ""
113
+ WMATIC: "",
114
+ VELODROME_CL_USDC_WETH_GAUGE: "",
115
+ VELO: ""
107
116
  }
108
117
  };
109
118
 
110
119
  export const MAX_AMOUNT = ethers.constants.MaxUint256;
111
120
 
112
121
  export const USDC_BALANCEOF_SLOT = {
113
- [Network.OPTIMISM]: 0,
122
+ [Network.OPTIMISM]: 9,
114
123
  [Network.ARBITRUM]: 9,
115
124
  [Network.POLYGON]: 0,
116
125
  [Network.BASE]: 9
117
126
  };
127
+
128
+ export const WETH_BALANCEOF_SLOT = {
129
+ [Network.OPTIMISM]: 3,
130
+ [Network.ARBITRUM]: 51,
131
+ [Network.POLYGON]: 0,
132
+ [Network.BASE]: 0
133
+ };