@dhedge/v2-sdk 1.9.7 → 1.9.8
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/README.md +4 -4
- package/dist/entities/pool.d.ts +4 -4
- package/dist/types.d.ts +2 -1
- package/dist/v2-sdk.cjs.development.js +6 -5
- 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 +6 -5
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/config.ts +3 -1
- package/src/entities/pool.ts +6 -4
- package/src/test/aerodrome.test.ts +154 -0
- package/src/types.ts +2 -1
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -54,7 +54,9 @@ export const routerAddress: AddressDappNetworkMap = {
|
|
|
54
54
|
},
|
|
55
55
|
[Network.BASE]: {
|
|
56
56
|
[Dapp.ONEINCH]: "0x1111111254EEB25477B68fb85Ed929f73A960582",
|
|
57
|
-
[Dapp.ZEROEX]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff"
|
|
57
|
+
[Dapp.ZEROEX]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
|
|
58
|
+
[Dapp.AERODROME]: "0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43",
|
|
59
|
+
[Dapp.AAVEV3]: "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5"
|
|
58
60
|
}
|
|
59
61
|
};
|
|
60
62
|
|
package/src/entities/pool.ts
CHANGED
|
@@ -531,6 +531,7 @@ export class Pool {
|
|
|
531
531
|
stakeTxData = getVelodromeStakeTxData(amount, false);
|
|
532
532
|
break;
|
|
533
533
|
case Dapp.VELODROMEV2:
|
|
534
|
+
case Dapp.AERODROME:
|
|
534
535
|
stakeTxData = getVelodromeStakeTxData(amount, true);
|
|
535
536
|
break;
|
|
536
537
|
default:
|
|
@@ -1153,6 +1154,7 @@ export class Pool {
|
|
|
1153
1154
|
txData = getVelodromeClaimTxData(this, tokenId, false);
|
|
1154
1155
|
break;
|
|
1155
1156
|
case Dapp.VELODROMEV2:
|
|
1157
|
+
case Dapp.AERODROME:
|
|
1156
1158
|
contractAddress = tokenId;
|
|
1157
1159
|
txData = getVelodromeClaimTxData(this, tokenId, true);
|
|
1158
1160
|
break;
|
|
@@ -1356,7 +1358,7 @@ export class Pool {
|
|
|
1356
1358
|
|
|
1357
1359
|
/**
|
|
1358
1360
|
* Add liquidity to Velodrome V2 or Ramses pool
|
|
1359
|
-
* @param {Dapp} dapp VelodromeV2 or
|
|
1361
|
+
* @param {Dapp} dapp VelodromeV2, Ramses or Aerodrome
|
|
1360
1362
|
* @param {string} assetA First asset
|
|
1361
1363
|
* @param {string} assetB Second asset
|
|
1362
1364
|
* @param {BigNumber | string} amountA Amount first asset
|
|
@@ -1367,7 +1369,7 @@ export class Pool {
|
|
|
1367
1369
|
* @returns {Promise<any>} Transaction
|
|
1368
1370
|
*/
|
|
1369
1371
|
async addLiquidityV2(
|
|
1370
|
-
dapp: Dapp.VELODROMEV2 | Dapp.RAMSES,
|
|
1372
|
+
dapp: Dapp.VELODROMEV2 | Dapp.RAMSES | Dapp.AERODROME,
|
|
1371
1373
|
assetA: string,
|
|
1372
1374
|
assetB: string,
|
|
1373
1375
|
amountA: BigNumber | string,
|
|
@@ -1397,7 +1399,7 @@ export class Pool {
|
|
|
1397
1399
|
|
|
1398
1400
|
/**
|
|
1399
1401
|
* Remove liquidity from Velodrome V2 or Ramses pool
|
|
1400
|
-
* @param {Dapp} dapp VelodromeV2 or
|
|
1402
|
+
* @param {Dapp} dapp VelodromeV2, Ramses or Aerodrome
|
|
1401
1403
|
* @param {string} assetA First asset
|
|
1402
1404
|
* @param {string} assetB Second asset
|
|
1403
1405
|
* @param {BigNumber | string} amount Amount of LP tokens
|
|
@@ -1407,7 +1409,7 @@ export class Pool {
|
|
|
1407
1409
|
* @returns {Promise<any>} Transaction
|
|
1408
1410
|
*/
|
|
1409
1411
|
async removeLiquidityV2(
|
|
1410
|
-
dapp: Dapp.VELODROMEV2 | Dapp.RAMSES,
|
|
1412
|
+
dapp: Dapp.VELODROMEV2 | Dapp.RAMSES | Dapp.AERODROME,
|
|
1411
1413
|
assetA: string,
|
|
1412
1414
|
assetB: string,
|
|
1413
1415
|
amount: BigNumber | string,
|
|
@@ -0,0 +1,154 @@
|
|
|
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 } from "..";
|
|
5
|
+
import { routerAddress } from "../config";
|
|
6
|
+
import { Dapp, Network } from "../types";
|
|
7
|
+
import { CONTRACT_ADDRESS, MAX_AMOUNT, TEST_POOL } from "./constants";
|
|
8
|
+
import {
|
|
9
|
+
TestingRunParams,
|
|
10
|
+
beforeAfterReset,
|
|
11
|
+
setUSDCAmount,
|
|
12
|
+
testingHelper
|
|
13
|
+
} from "./utils/testingHelper";
|
|
14
|
+
import { allowanceDelta, balanceDelta } from "./utils/token";
|
|
15
|
+
import { getWalletData } from "./wallet";
|
|
16
|
+
|
|
17
|
+
const testAerodrome = ({ network, provider }: TestingRunParams) => {
|
|
18
|
+
const WETH_USDC_Lp = "0xcDAC0d6c6C59727a65F871236188350531885C43";
|
|
19
|
+
const WETH_USDC__Gauge = "0x519BBD1Dd8C6A94C46080E24f316c14Ee758C025";
|
|
20
|
+
|
|
21
|
+
const USDC = CONTRACT_ADDRESS[network].USDC;
|
|
22
|
+
const WETH = CONTRACT_ADDRESS[network].WETH;
|
|
23
|
+
const AERO = "0x940181a94A35A4569E4529A3CDfB74e38FD98631";
|
|
24
|
+
|
|
25
|
+
let dhedge: Dhedge;
|
|
26
|
+
let pool: Pool;
|
|
27
|
+
jest.setTimeout(100000);
|
|
28
|
+
|
|
29
|
+
describe(`[${network}] aerodrome tests`, () => {
|
|
30
|
+
beforeAll(async () => {
|
|
31
|
+
const { wallet } = getWalletData(network);
|
|
32
|
+
// top up ETH (gas)
|
|
33
|
+
await provider.send("hardhat_setBalance", [
|
|
34
|
+
wallet.address,
|
|
35
|
+
"0x100000000000000"
|
|
36
|
+
]);
|
|
37
|
+
dhedge = new Dhedge(wallet, network);
|
|
38
|
+
pool = await dhedge.loadPool(TEST_POOL[network]);
|
|
39
|
+
await setUSDCAmount({
|
|
40
|
+
amount: new BigNumber(10).times(1e6).toFixed(0),
|
|
41
|
+
userAddress: pool.address,
|
|
42
|
+
network,
|
|
43
|
+
provider
|
|
44
|
+
});
|
|
45
|
+
await pool.approve(Dapp.ONEINCH, USDC, MAX_AMOUNT);
|
|
46
|
+
await pool.trade(Dapp.ONEINCH, USDC, WETH, (5 * 1e6).toString());
|
|
47
|
+
});
|
|
48
|
+
beforeAfterReset({ beforeAll, afterAll, provider });
|
|
49
|
+
|
|
50
|
+
it("approves unlimited USDC and swETH on for Aerodrome", async () => {
|
|
51
|
+
await pool.approve(Dapp.AERODROME, USDC, MAX_AMOUNT);
|
|
52
|
+
await pool.approve(Dapp.AERODROME, WETH, MAX_AMOUNT);
|
|
53
|
+
const UsdcAllowanceDelta = await allowanceDelta(
|
|
54
|
+
pool.address,
|
|
55
|
+
USDC,
|
|
56
|
+
routerAddress[network].aerodrome!,
|
|
57
|
+
pool.signer
|
|
58
|
+
);
|
|
59
|
+
await expect(UsdcAllowanceDelta.gt(0));
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("adds USDC and WETH to a Aerodrome volatile pool", async () => {
|
|
63
|
+
const usdcBalance = await pool.utils.getBalance(USDC, pool.address);
|
|
64
|
+
const wethBalance = await pool.utils.getBalance(WETH, pool.address);
|
|
65
|
+
await pool.addLiquidityV2(
|
|
66
|
+
Dapp.AERODROME,
|
|
67
|
+
WETH,
|
|
68
|
+
USDC,
|
|
69
|
+
wethBalance,
|
|
70
|
+
usdcBalance,
|
|
71
|
+
false
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const lpTokenDelta = await balanceDelta(
|
|
75
|
+
pool.address,
|
|
76
|
+
WETH_USDC_Lp,
|
|
77
|
+
pool.signer
|
|
78
|
+
);
|
|
79
|
+
expect(lpTokenDelta.gt(0));
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("should stake WETH-USDC LP in a gauge", async () => {
|
|
83
|
+
const balance = await dhedge.utils.getBalance(WETH_USDC_Lp, pool.address);
|
|
84
|
+
await pool.approveSpender(WETH_USDC__Gauge, WETH_USDC_Lp, MAX_AMOUNT);
|
|
85
|
+
await pool.stakeInGauge(Dapp.AERODROME, WETH_USDC__Gauge, balance);
|
|
86
|
+
const gaugeBalance = await balanceDelta(
|
|
87
|
+
pool.address,
|
|
88
|
+
WETH_USDC__Gauge,
|
|
89
|
+
pool.signer
|
|
90
|
+
);
|
|
91
|
+
expect(gaugeBalance.gt(0));
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("should claim rewards from Gauge", async () => {
|
|
95
|
+
await provider.send("evm_increaseTime", [24 * 60 * 60]); // 1 day
|
|
96
|
+
await provider.send("evm_mine", []);
|
|
97
|
+
const claimTx = await pool.claimFees(Dapp.AERODROME, WETH_USDC__Gauge);
|
|
98
|
+
expect(claimTx).not.toBe(null);
|
|
99
|
+
const aeroBalanceDelta = await balanceDelta(
|
|
100
|
+
pool.address,
|
|
101
|
+
AERO,
|
|
102
|
+
pool.signer
|
|
103
|
+
);
|
|
104
|
+
expect(aeroBalanceDelta.gt(0));
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("should unStakeWETH-USDC LP from a gauge", async () => {
|
|
108
|
+
const gaugeBalance = await dhedge.utils.getBalance(
|
|
109
|
+
WETH_USDC__Gauge,
|
|
110
|
+
pool.address
|
|
111
|
+
);
|
|
112
|
+
await pool.unstakeFromGauge(WETH_USDC__Gauge, gaugeBalance);
|
|
113
|
+
const lpTokenDelta = await balanceDelta(
|
|
114
|
+
pool.address,
|
|
115
|
+
WETH_USDC_Lp,
|
|
116
|
+
pool.signer
|
|
117
|
+
);
|
|
118
|
+
expect(lpTokenDelta.gt(0));
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("approves unlimited WETH-USDC LP for Aerodrome", async () => {
|
|
122
|
+
await pool.approve(Dapp.AERODROME, WETH_USDC_Lp, MAX_AMOUNT);
|
|
123
|
+
const lpAllowanceDelta = await allowanceDelta(
|
|
124
|
+
pool.address,
|
|
125
|
+
WETH_USDC_Lp,
|
|
126
|
+
routerAddress[network].aerodrome!,
|
|
127
|
+
pool.signer
|
|
128
|
+
);
|
|
129
|
+
expect(lpAllowanceDelta.gt(0));
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("should remove all liquidity from an existing pool ", async () => {
|
|
133
|
+
const balance = await dhedge.utils.getBalance(WETH_USDC_Lp, pool.address);
|
|
134
|
+
await pool.removeLiquidityV2(Dapp.AERODROME, WETH, USDC, balance, false);
|
|
135
|
+
const usdcBalanceDelta = await balanceDelta(
|
|
136
|
+
pool.address,
|
|
137
|
+
USDC,
|
|
138
|
+
pool.signer
|
|
139
|
+
);
|
|
140
|
+
const wethBalanceDelta = await balanceDelta(
|
|
141
|
+
pool.address,
|
|
142
|
+
WETH,
|
|
143
|
+
pool.signer
|
|
144
|
+
);
|
|
145
|
+
expect(usdcBalanceDelta.gt(0));
|
|
146
|
+
expect(wethBalanceDelta.gt(0));
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
testingHelper({
|
|
152
|
+
network: Network.BASE,
|
|
153
|
+
testingRun: testAerodrome
|
|
154
|
+
});
|