@dhedge/v2-sdk 1.9.4 → 1.9.5
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/test/constants.d.ts +13 -0
- package/dist/test/utils/testingHelper.d.ts +13 -0
- package/dist/test/wallet.d.ts +1 -0
- package/dist/types.d.ts +2 -1
- package/dist/v2-sdk.cjs.development.js +11 -10
- 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 +11 -10
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +3 -2
- package/src/config.ts +23 -7
- package/src/test/constants.ts +15 -1
- package/src/test/lyra.test.ts +7 -6
- package/src/test/oneInch.test.ts +34 -3
- package/src/test/synthetix.test.ts +3 -1
- package/src/test/uniswap.test.ts +180 -148
- package/src/test/utils/testingHelper.ts +51 -1
- package/src/test/wallet.ts +2 -1
- package/src/test/zeroEx.test.ts +40 -4
- package/src/types.ts +3 -2
package/src/test/zeroEx.test.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
|
+
import BigNumber from "bignumber.js";
|
|
2
3
|
import { Dhedge, Pool } from "..";
|
|
3
4
|
import { routerAddress } from "../config";
|
|
4
5
|
import { Dapp, Network } from "../types";
|
|
5
6
|
import { CONTRACT_ADDRESS, MAX_AMOUNT, TEST_POOL } from "./constants";
|
|
6
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
TestingRunParams,
|
|
9
|
+
setUSDCAmount,
|
|
10
|
+
testingHelper
|
|
11
|
+
} from "./utils/testingHelper";
|
|
7
12
|
import { allowanceDelta, balanceDelta } from "./utils/token";
|
|
13
|
+
import { getTxOptions } from "./txOptions";
|
|
8
14
|
|
|
9
|
-
const testZeroEx = ({ wallet, network }: TestingRunParams) => {
|
|
15
|
+
const testZeroEx = ({ wallet, network, provider }: TestingRunParams) => {
|
|
10
16
|
const USDC = CONTRACT_ADDRESS[network].USDC;
|
|
11
17
|
const WETH = CONTRACT_ADDRESS[network].WETH;
|
|
12
18
|
|
|
@@ -18,10 +24,28 @@ const testZeroEx = ({ wallet, network }: TestingRunParams) => {
|
|
|
18
24
|
beforeAll(async () => {
|
|
19
25
|
dhedge = new Dhedge(wallet, network);
|
|
20
26
|
pool = await dhedge.loadPool(TEST_POOL[network]);
|
|
27
|
+
// top up gas
|
|
28
|
+
await provider.send("hardhat_setBalance", [
|
|
29
|
+
wallet.address,
|
|
30
|
+
"0x10000000000000000"
|
|
31
|
+
]);
|
|
32
|
+
await provider.send("evm_mine", []);
|
|
33
|
+
// top up USDC
|
|
34
|
+
await setUSDCAmount({
|
|
35
|
+
amount: new BigNumber(100).times(1e18).toFixed(0),
|
|
36
|
+
userAddress: pool.address,
|
|
37
|
+
network,
|
|
38
|
+
provider
|
|
39
|
+
});
|
|
21
40
|
});
|
|
22
41
|
|
|
23
42
|
it("approves unlimited USDC on 0x", async () => {
|
|
24
|
-
await pool.approve(
|
|
43
|
+
await pool.approve(
|
|
44
|
+
Dapp.ZEROEX,
|
|
45
|
+
USDC,
|
|
46
|
+
MAX_AMOUNT,
|
|
47
|
+
await getTxOptions(network)
|
|
48
|
+
);
|
|
25
49
|
const usdcAllowanceDelta = await allowanceDelta(
|
|
26
50
|
pool.address,
|
|
27
51
|
USDC,
|
|
@@ -32,7 +56,14 @@ const testZeroEx = ({ wallet, network }: TestingRunParams) => {
|
|
|
32
56
|
});
|
|
33
57
|
|
|
34
58
|
it("trades 2 USDC into WETH on 0x", async () => {
|
|
35
|
-
await pool.trade(
|
|
59
|
+
await pool.trade(
|
|
60
|
+
Dapp.ZEROEX,
|
|
61
|
+
USDC,
|
|
62
|
+
WETH,
|
|
63
|
+
"2000000",
|
|
64
|
+
0.5,
|
|
65
|
+
await getTxOptions(network)
|
|
66
|
+
);
|
|
36
67
|
const wethBalanceDelta = await balanceDelta(
|
|
37
68
|
pool.address,
|
|
38
69
|
WETH,
|
|
@@ -52,3 +83,8 @@ testingHelper({
|
|
|
52
83
|
network: Network.POLYGON,
|
|
53
84
|
testingRun: testZeroEx
|
|
54
85
|
});
|
|
86
|
+
|
|
87
|
+
testingHelper({
|
|
88
|
+
network: Network.BASE,
|
|
89
|
+
testingRun: testZeroEx
|
|
90
|
+
});
|
package/src/types.ts
CHANGED
|
@@ -5,6 +5,7 @@ export enum Network {
|
|
|
5
5
|
POLYGON = "polygon",
|
|
6
6
|
OPTIMISM = "optimism",
|
|
7
7
|
ARBITRUM = "arbitrum",
|
|
8
|
+
BASE = "base"
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export enum Dapp {
|
|
@@ -22,7 +23,7 @@ export enum Dapp {
|
|
|
22
23
|
VELODROMEV2 = "velodromeV2",
|
|
23
24
|
LYRA = "lyra",
|
|
24
25
|
ZEROEX = "0x",
|
|
25
|
-
RAMSES = "ramses"
|
|
26
|
+
RAMSES = "ramses"
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
export enum Transaction {
|
|
@@ -44,7 +45,7 @@ export enum Transaction {
|
|
|
44
45
|
BURN = "burn",
|
|
45
46
|
SWAP_SYNTHS = "exchangeWithTracking",
|
|
46
47
|
ADD_LIQUIDITY_STAKE = "addLiquidityAndStake",
|
|
47
|
-
REMOVE_LIQUIDITY_UNSTAKE = "removeLiquidityAndUnstake"
|
|
48
|
+
REMOVE_LIQUIDITY_UNSTAKE = "removeLiquidityAndUnstake"
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
export type AddressNetworkMap = Readonly<Record<Network, string>>;
|