@dhedge/v2-sdk 1.9.9 → 1.10.1
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/config.d.ts +1 -1
- package/dist/entities/pool.d.ts +17 -7
- package/dist/services/uniswap/V3Liquidity.d.ts +8 -7
- package/dist/services/uniswap/V3Trade.d.ts +1 -2
- package/dist/services/velodrome/liquidity.d.ts +7 -3
- package/dist/services/velodrome/staking.d.ts +1 -0
- package/dist/test/constants.d.ts +14 -0
- package/dist/test/utils/testingHelper.d.ts +6 -0
- package/dist/types.d.ts +1 -0
- package/dist/v2-sdk.cjs.development.js +2675 -1370
- 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 +2688 -1383
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/abi/IERC721.json +217 -0
- package/src/abi/IVelodromeCLGauge.json +165 -0
- package/src/abi/IVelodromeNonfungiblePositionManager.json +408 -0
- package/src/config.ts +17 -7
- package/src/entities/pool.ts +141 -82
- package/src/services/lyra/trade.ts +1 -1
- package/src/services/uniswap/V3Liquidity.ts +141 -18
- package/src/services/uniswap/V3Trade.ts +1 -2
- package/src/services/velodrome/liquidity.ts +77 -5
- package/src/services/velodrome/staking.ts +6 -0
- package/src/test/constants.ts +22 -6
- package/src/test/uniswap.test.ts +24 -15
- package/src/test/utils/testingHelper.ts +25 -1
- package/src/test/velodromeCL.test.ts +223 -0
- package/src/types.ts +1 -0
- package/dist/services/uniswap/types.d.ts +0 -3
- package/src/services/uniswap/types.ts +0 -16
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import {
|
|
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
|
+
}
|
package/src/test/constants.ts
CHANGED
|
@@ -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: "
|
|
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]:
|
|
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
|
+
};
|
package/src/test/uniswap.test.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { FeeAmount } from "@uniswap/v3-sdk";
|
|
3
2
|
import { Dhedge, ethers, Pool } from "..";
|
|
4
3
|
import { routerAddress } from "../config";
|
|
5
4
|
import { AssetEnabled, Dapp, Network } from "../types";
|
|
@@ -76,7 +75,7 @@ const testUniswapV3 = ({ wallet, network, provider }: TestingRunParams) => {
|
|
|
76
75
|
CONTRACT_ADDRESS[network].USDC,
|
|
77
76
|
CONTRACT_ADDRESS[network].WETH,
|
|
78
77
|
new BigNumber(5000).times(1e6).toFixed(0),
|
|
79
|
-
|
|
78
|
+
500,
|
|
80
79
|
0.5
|
|
81
80
|
);
|
|
82
81
|
|
|
@@ -121,15 +120,16 @@ const testUniswapV3 = ({ wallet, network, provider }: TestingRunParams) => {
|
|
|
121
120
|
|
|
122
121
|
try {
|
|
123
122
|
result = await pool.addLiquidityUniswapV3(
|
|
123
|
+
Dapp.UNISWAPV3,
|
|
124
124
|
CONTRACT_ADDRESS[network].WETH,
|
|
125
125
|
CONTRACT_ADDRESS[network].USDC,
|
|
126
126
|
wethBalance,
|
|
127
127
|
usdcBalance,
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
3500,
|
|
129
|
+
4000,
|
|
130
130
|
null,
|
|
131
131
|
null,
|
|
132
|
-
|
|
132
|
+
500
|
|
133
133
|
// options
|
|
134
134
|
);
|
|
135
135
|
await result.wait(1);
|
|
@@ -155,11 +155,20 @@ const testUniswapV3 = ({ wallet, network, provider }: TestingRunParams) => {
|
|
|
155
155
|
});
|
|
156
156
|
|
|
157
157
|
it("should increase liquidity in the existing WETH/USDC pool", async () => {
|
|
158
|
+
const usdcBalance = await dhedge.utils.getBalance(
|
|
159
|
+
CONTRACT_ADDRESS[network].USDC,
|
|
160
|
+
pool.address
|
|
161
|
+
);
|
|
162
|
+
const wethBalance = await dhedge.utils.getBalance(
|
|
163
|
+
CONTRACT_ADDRESS[network].WETH,
|
|
164
|
+
pool.address
|
|
165
|
+
);
|
|
166
|
+
|
|
158
167
|
const result = await pool.increaseLiquidity(
|
|
159
168
|
Dapp.UNISWAPV3,
|
|
160
169
|
tokenId.toString(),
|
|
161
|
-
|
|
162
|
-
|
|
170
|
+
wethBalance,
|
|
171
|
+
usdcBalance // eth
|
|
163
172
|
);
|
|
164
173
|
// console.log("result", result);
|
|
165
174
|
expect(result).not.toBe(null);
|
|
@@ -210,12 +219,12 @@ testingHelper({
|
|
|
210
219
|
testingRun: testUniswapV3
|
|
211
220
|
});
|
|
212
221
|
|
|
213
|
-
testingHelper({
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
});
|
|
222
|
+
// testingHelper({
|
|
223
|
+
// network: Network.POLYGON,
|
|
224
|
+
// testingRun: testUniswapV3
|
|
225
|
+
// });
|
|
217
226
|
|
|
218
|
-
testingHelper({
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
});
|
|
227
|
+
// testingHelper({
|
|
228
|
+
// network: Network.ARBITRUM,
|
|
229
|
+
// testingRun: testUniswapV3
|
|
230
|
+
// });
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { BigNumber, ethers } from "ethers";
|
|
2
2
|
import { Network } from "../../types";
|
|
3
3
|
import { getWalletData } from "../wallet";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
CONTRACT_ADDRESS,
|
|
6
|
+
USDC_BALANCEOF_SLOT,
|
|
7
|
+
WETH_BALANCEOF_SLOT
|
|
8
|
+
} from "../constants";
|
|
5
9
|
|
|
6
10
|
export type TestingRunParams = {
|
|
7
11
|
network: Network;
|
|
@@ -92,6 +96,26 @@ export const setUSDCAmount = async ({
|
|
|
92
96
|
});
|
|
93
97
|
};
|
|
94
98
|
|
|
99
|
+
export const setWETHAmount = async ({
|
|
100
|
+
provider,
|
|
101
|
+
userAddress,
|
|
102
|
+
amount,
|
|
103
|
+
network
|
|
104
|
+
}: {
|
|
105
|
+
amount: string;
|
|
106
|
+
userAddress: string;
|
|
107
|
+
provider: ethers.providers.JsonRpcProvider;
|
|
108
|
+
network: Network;
|
|
109
|
+
}): Promise<void> => {
|
|
110
|
+
await setTokenAmount({
|
|
111
|
+
amount,
|
|
112
|
+
userAddress,
|
|
113
|
+
provider,
|
|
114
|
+
tokenAddress: CONTRACT_ADDRESS[network].WETH,
|
|
115
|
+
slot: WETH_BALANCEOF_SLOT[network]
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
|
|
95
119
|
export const wait = (seconds: number): Promise<void> => {
|
|
96
120
|
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
|
|
97
121
|
};
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
import BigNumber from "bignumber.js";
|
|
4
|
+
import { Dhedge, Pool, ethers } from "..";
|
|
5
|
+
import { nonfungiblePositionManagerAddress } from "../config";
|
|
6
|
+
import { AssetEnabled, Dapp, Network } from "../types";
|
|
7
|
+
import { CONTRACT_ADDRESS, MAX_AMOUNT, TEST_POOL } from "./constants";
|
|
8
|
+
import {
|
|
9
|
+
TestingRunParams,
|
|
10
|
+
beforeAfterReset,
|
|
11
|
+
setUSDCAmount,
|
|
12
|
+
setWETHAmount,
|
|
13
|
+
testingHelper
|
|
14
|
+
} from "./utils/testingHelper";
|
|
15
|
+
import { balanceDelta } from "./utils/token";
|
|
16
|
+
import INonfungiblePositionManager from "../abi/INonfungiblePositionManager.json";
|
|
17
|
+
|
|
18
|
+
const testVelodromeCL = ({ wallet, network, provider }: TestingRunParams) => {
|
|
19
|
+
const VELODROME_POSITION_MANGER = nonfungiblePositionManagerAddress[network][
|
|
20
|
+
Dapp.VELODROMECL
|
|
21
|
+
]!;
|
|
22
|
+
|
|
23
|
+
const USDC = CONTRACT_ADDRESS[network].USDC;
|
|
24
|
+
const WETH = CONTRACT_ADDRESS[network].WETH;
|
|
25
|
+
const USDC_WETH_CL_GAUGE =
|
|
26
|
+
CONTRACT_ADDRESS[network].VELODROME_CL_USDC_WETH_GAUGE;
|
|
27
|
+
const VELO = CONTRACT_ADDRESS[network].VELO;
|
|
28
|
+
|
|
29
|
+
let dhedge: Dhedge;
|
|
30
|
+
let pool: Pool;
|
|
31
|
+
let velodromePositionManager: ethers.Contract;
|
|
32
|
+
let tokenId: string;
|
|
33
|
+
jest.setTimeout(100000);
|
|
34
|
+
|
|
35
|
+
describe(`[${network}] veldorome CL tests`, () => {
|
|
36
|
+
beforeAll(async () => {
|
|
37
|
+
// top up ETH (gas)
|
|
38
|
+
await provider.send("hardhat_setBalance", [
|
|
39
|
+
wallet.address,
|
|
40
|
+
"0x100000000000000"
|
|
41
|
+
]);
|
|
42
|
+
dhedge = new Dhedge(wallet, network);
|
|
43
|
+
pool = await dhedge.loadPool(TEST_POOL[network]);
|
|
44
|
+
await setUSDCAmount({
|
|
45
|
+
amount: new BigNumber(10000).times(1e6).toFixed(0),
|
|
46
|
+
userAddress: pool.address,
|
|
47
|
+
network,
|
|
48
|
+
provider
|
|
49
|
+
});
|
|
50
|
+
await setWETHAmount({
|
|
51
|
+
amount: new BigNumber(3).times(1e18).toFixed(0),
|
|
52
|
+
userAddress: pool.address,
|
|
53
|
+
network,
|
|
54
|
+
provider
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const newAssets: AssetEnabled[] = [
|
|
58
|
+
{ asset: USDC, isDeposit: true },
|
|
59
|
+
{ asset: WETH, isDeposit: true },
|
|
60
|
+
{
|
|
61
|
+
asset: VELODROME_POSITION_MANGER,
|
|
62
|
+
isDeposit: false
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
await pool.changeAssets(newAssets);
|
|
66
|
+
|
|
67
|
+
velodromePositionManager = new ethers.Contract(
|
|
68
|
+
VELODROME_POSITION_MANGER,
|
|
69
|
+
INonfungiblePositionManager.abi,
|
|
70
|
+
pool.signer
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
beforeAfterReset({ beforeAll, afterAll, provider });
|
|
75
|
+
|
|
76
|
+
// describe("Liquidity", () => {
|
|
77
|
+
// it("approves unlimited USDC and WETH on for Velodrome CL", async () => {
|
|
78
|
+
// await pool.approveSpender(VELODROME_POSITION_MANGER, USDC, MAX_AMOUNT);
|
|
79
|
+
// await pool.approveSpender(VELODROME_POSITION_MANGER, WETH, MAX_AMOUNT);
|
|
80
|
+
// const UsdcAllowanceDelta = await allowanceDelta(
|
|
81
|
+
// pool.address,
|
|
82
|
+
// USDC,
|
|
83
|
+
// VELODROME_POSITION_MANGER,
|
|
84
|
+
// pool.signer
|
|
85
|
+
// );
|
|
86
|
+
// await expect(UsdcAllowanceDelta.gt(0));
|
|
87
|
+
// });
|
|
88
|
+
|
|
89
|
+
// it("adds USDC and WETH to a Velodrome CL (mint position)", async () => {
|
|
90
|
+
// const usdcBalance = await pool.utils.getBalance(USDC, pool.address);
|
|
91
|
+
// const wethBalance = await pool.utils.getBalance(WETH, pool.address);
|
|
92
|
+
// await pool.addLiquidityUniswapV3(
|
|
93
|
+
// Dapp.VELODROMECL,
|
|
94
|
+
// USDC,
|
|
95
|
+
// WETH,
|
|
96
|
+
// usdcBalance.div(2),
|
|
97
|
+
// wethBalance.div(2),
|
|
98
|
+
// null,
|
|
99
|
+
// null,
|
|
100
|
+
// 193700,
|
|
101
|
+
// 193900,
|
|
102
|
+
// 100
|
|
103
|
+
// );
|
|
104
|
+
|
|
105
|
+
// tokenId = (
|
|
106
|
+
// await velodromePositionManager.tokenOfOwnerByIndex(pool.address, 0)
|
|
107
|
+
// ).toString();
|
|
108
|
+
// expect(tokenId).not.toBe(null);
|
|
109
|
+
// });
|
|
110
|
+
|
|
111
|
+
// it("increases liquidity in a CL position", async () => {
|
|
112
|
+
// const usdcBalance = await pool.utils.getBalance(USDC, pool.address);
|
|
113
|
+
// const wethBalance = await pool.utils.getBalance(WETH, pool.address);
|
|
114
|
+
// const positionBefore = await velodromePositionManager.positions(
|
|
115
|
+
// tokenId
|
|
116
|
+
// );
|
|
117
|
+
// await pool.increaseLiquidity(
|
|
118
|
+
// Dapp.VELODROMECL,
|
|
119
|
+
// tokenId,
|
|
120
|
+
// usdcBalance.div(2),
|
|
121
|
+
// wethBalance.div(2)
|
|
122
|
+
// );
|
|
123
|
+
// const positionAfter = await velodromePositionManager.positions(tokenId);
|
|
124
|
+
// expect(positionAfter.liquidity.gt(positionBefore.liquidity));
|
|
125
|
+
// });
|
|
126
|
+
|
|
127
|
+
// it("decreases liquidity from a CL position", async () => {
|
|
128
|
+
// const positionBefore = await velodromePositionManager.positions(
|
|
129
|
+
// tokenId
|
|
130
|
+
// );
|
|
131
|
+
// await pool.decreaseLiquidity(Dapp.VELODROMECL, tokenId, 50);
|
|
132
|
+
// const positionAfter = await velodromePositionManager.positions(tokenId);
|
|
133
|
+
// expect(positionAfter.liquidity.lt(positionBefore.liquidity));
|
|
134
|
+
// });
|
|
135
|
+
|
|
136
|
+
// it("collects fess of a CL position", async () => {
|
|
137
|
+
// await provider.send("evm_increaseTime", [24 * 3600 * 3]); // 1 day
|
|
138
|
+
// await provider.send("evm_mine", []);
|
|
139
|
+
// await pool.claimFees(Dapp.VELODROMECL, tokenId);
|
|
140
|
+
// expect((await balanceDelta(pool.address, USDC, pool.signer)).gt(0));
|
|
141
|
+
// });
|
|
142
|
+
// });
|
|
143
|
+
describe("Liquidity staking", () => {
|
|
144
|
+
it("stakes a CL position in gauge", async () => {
|
|
145
|
+
await pool.approveSpender(VELODROME_POSITION_MANGER, USDC, MAX_AMOUNT);
|
|
146
|
+
await pool.approveSpender(VELODROME_POSITION_MANGER, WETH, MAX_AMOUNT);
|
|
147
|
+
const usdcBalance = await pool.utils.getBalance(USDC, pool.address);
|
|
148
|
+
const wethBalance = await pool.utils.getBalance(WETH, pool.address);
|
|
149
|
+
await pool.addLiquidityUniswapV3(
|
|
150
|
+
Dapp.VELODROMECL,
|
|
151
|
+
USDC,
|
|
152
|
+
WETH,
|
|
153
|
+
usdcBalance.div(2),
|
|
154
|
+
wethBalance.div(2),
|
|
155
|
+
null,
|
|
156
|
+
null,
|
|
157
|
+
193700,
|
|
158
|
+
193900,
|
|
159
|
+
100
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
tokenId = (
|
|
163
|
+
await velodromePositionManager.tokenOfOwnerByIndex(pool.address, 0)
|
|
164
|
+
).toString();
|
|
165
|
+
await pool.approveSpenderNFT(
|
|
166
|
+
USDC_WETH_CL_GAUGE,
|
|
167
|
+
VELODROME_POSITION_MANGER,
|
|
168
|
+
tokenId
|
|
169
|
+
);
|
|
170
|
+
await pool.stakeInGauge(Dapp.VELODROMECL, USDC_WETH_CL_GAUGE, tokenId);
|
|
171
|
+
expect(await velodromePositionManager.ownerOf(tokenId)).toBe(
|
|
172
|
+
USDC_WETH_CL_GAUGE
|
|
173
|
+
);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it("decreases liquidity from a staked CL position", async () => {
|
|
177
|
+
const positionBefore = await velodromePositionManager.positions(
|
|
178
|
+
tokenId
|
|
179
|
+
);
|
|
180
|
+
await pool.decreaseLiquidity(Dapp.VELODROMECL, tokenId, 50);
|
|
181
|
+
const positionAfter = await velodromePositionManager.positions(tokenId);
|
|
182
|
+
expect(positionAfter.liquidity.lt(positionBefore.liquidity));
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it("increases liquidity in a staked CL position", async () => {
|
|
186
|
+
const usdcBalance = await pool.utils.getBalance(USDC, pool.address);
|
|
187
|
+
const wethBalance = await pool.utils.getBalance(WETH, pool.address);
|
|
188
|
+
const positionBefore = await velodromePositionManager.positions(
|
|
189
|
+
tokenId
|
|
190
|
+
);
|
|
191
|
+
await pool.approveSpender(USDC_WETH_CL_GAUGE, USDC, MAX_AMOUNT);
|
|
192
|
+
await pool.approveSpender(USDC_WETH_CL_GAUGE, WETH, MAX_AMOUNT);
|
|
193
|
+
await pool.increaseLiquidity(
|
|
194
|
+
Dapp.VELODROMECL,
|
|
195
|
+
tokenId,
|
|
196
|
+
usdcBalance.div(2),
|
|
197
|
+
wethBalance.div(2)
|
|
198
|
+
);
|
|
199
|
+
const positionAfter = await velodromePositionManager.positions(tokenId);
|
|
200
|
+
expect(positionAfter.liquidity.gt(positionBefore.liquidity));
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it("collects fess of a staked CL position", async () => {
|
|
204
|
+
await provider.send("evm_increaseTime", [24 * 3600]); // 1 day
|
|
205
|
+
await provider.send("evm_mine", []);
|
|
206
|
+
await pool.claimFees(Dapp.VELODROMECL, tokenId);
|
|
207
|
+
expect((await balanceDelta(pool.address, VELO, pool.signer)).gt(0));
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it("unstakes a CL position from a gauge", async () => {
|
|
211
|
+
await pool.unstakeFromGauge(USDC_WETH_CL_GAUGE, tokenId);
|
|
212
|
+
expect(
|
|
213
|
+
(await velodromePositionManager.ownerOf(tokenId)).toLowerCase()
|
|
214
|
+
).toBe(pool.address.toLowerCase());
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
testingHelper({
|
|
221
|
+
network: Network.OPTIMISM,
|
|
222
|
+
testingRun: testVelodromeCL
|
|
223
|
+
});
|
package/src/types.ts
CHANGED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { FeeAmount } from "@uniswap/v3-sdk";
|
|
2
|
-
import { ethers } from "ethers";
|
|
3
|
-
export declare type UniswapV3MintParams = [string, string, FeeAmount, number, number, ethers.BigNumber | string, ethers.BigNumber | string, ethers.BigNumber | string, ethers.BigNumber | string, string, number];
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FeeAmount } from "@uniswap/v3-sdk";
|
|
2
|
-
import { ethers } from "ethers";
|
|
3
|
-
|
|
4
|
-
export type UniswapV3MintParams = [
|
|
5
|
-
string,
|
|
6
|
-
string,
|
|
7
|
-
FeeAmount,
|
|
8
|
-
number,
|
|
9
|
-
number,
|
|
10
|
-
ethers.BigNumber | string,
|
|
11
|
-
ethers.BigNumber | string,
|
|
12
|
-
ethers.BigNumber | string,
|
|
13
|
-
ethers.BigNumber | string,
|
|
14
|
-
string,
|
|
15
|
-
number
|
|
16
|
-
];
|