@dhedge/v2-sdk 1.10.10 → 1.10.12
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 +2 -1
- package/dist/entities/dhedge.d.ts +1 -1
- package/dist/entities/pool.d.ts +2 -1
- package/dist/services/flatmoney/stableLp.d.ts +1 -0
- package/dist/test/constants.d.ts +4 -0
- package/dist/types.d.ts +0 -1
- package/dist/v2-sdk.cjs.development.js +311 -172
- 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 +311 -172
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/abi/flatmoney/v2/IOrderExecutionModule.json +96 -0
- package/src/config.ts +10 -6
- package/src/entities/dhedge.ts +5 -4
- package/src/entities/pool.ts +4 -12
- package/src/services/flatmoney/keeperFee.ts +12 -4
- package/src/services/flatmoney/stableLp.ts +30 -8
- package/src/test/constants.ts +6 -1
- package/src/test/flatmoney.test.ts +30 -11
- package/src/types.ts +0 -1
- package/src/utils/contract.ts +19 -7
- package/dist/services/zeroEx/zeroExTrade.d.ts +0 -3
- package/src/services/zeroEx/zeroExTrade.ts +0 -52
- package/src/test/zeroEx.test.ts +0 -95
package/src/test/zeroEx.test.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
|
-
import BigNumber from "bignumber.js";
|
|
3
|
-
import { Dhedge, Pool } from "..";
|
|
4
|
-
import { routerAddress } from "../config";
|
|
5
|
-
import { Dapp, Network } from "../types";
|
|
6
|
-
import { CONTRACT_ADDRESS, MAX_AMOUNT, TEST_POOL } from "./constants";
|
|
7
|
-
import {
|
|
8
|
-
TestingRunParams,
|
|
9
|
-
setUSDCAmount,
|
|
10
|
-
testingHelper
|
|
11
|
-
} from "./utils/testingHelper";
|
|
12
|
-
import { allowanceDelta, balanceDelta } from "./utils/token";
|
|
13
|
-
import { getTxOptions } from "./txOptions";
|
|
14
|
-
|
|
15
|
-
const testZeroEx = ({ wallet, network, provider }: TestingRunParams) => {
|
|
16
|
-
const USDC = CONTRACT_ADDRESS[network].USDC;
|
|
17
|
-
const WETH = CONTRACT_ADDRESS[network].WETH;
|
|
18
|
-
|
|
19
|
-
let dhedge: Dhedge;
|
|
20
|
-
let pool: Pool;
|
|
21
|
-
jest.setTimeout(100000);
|
|
22
|
-
|
|
23
|
-
describe(`[${network}] 0x trade`, () => {
|
|
24
|
-
beforeAll(async () => {
|
|
25
|
-
dhedge = new Dhedge(wallet, network);
|
|
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
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("approves unlimited USDC on 0x", async () => {
|
|
43
|
-
await pool.approve(
|
|
44
|
-
Dapp.ZEROEX,
|
|
45
|
-
USDC,
|
|
46
|
-
MAX_AMOUNT,
|
|
47
|
-
await getTxOptions(network)
|
|
48
|
-
);
|
|
49
|
-
const usdcAllowanceDelta = await allowanceDelta(
|
|
50
|
-
pool.address,
|
|
51
|
-
USDC,
|
|
52
|
-
routerAddress[network]["0x"]!,
|
|
53
|
-
pool.signer
|
|
54
|
-
);
|
|
55
|
-
await expect(usdcAllowanceDelta.gt(0));
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("trades 2 USDC into WETH on 0x", async () => {
|
|
59
|
-
await pool.trade(
|
|
60
|
-
Dapp.ZEROEX,
|
|
61
|
-
USDC,
|
|
62
|
-
WETH,
|
|
63
|
-
"2000000",
|
|
64
|
-
0.5,
|
|
65
|
-
await getTxOptions(network)
|
|
66
|
-
);
|
|
67
|
-
const wethBalanceDelta = await balanceDelta(
|
|
68
|
-
pool.address,
|
|
69
|
-
WETH,
|
|
70
|
-
pool.signer
|
|
71
|
-
);
|
|
72
|
-
expect(wethBalanceDelta.gt(0));
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
testingHelper({
|
|
78
|
-
network: Network.OPTIMISM,
|
|
79
|
-
testingRun: testZeroEx
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
testingHelper({
|
|
83
|
-
network: Network.POLYGON,
|
|
84
|
-
testingRun: testZeroEx
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
testingHelper({
|
|
88
|
-
network: Network.BASE,
|
|
89
|
-
testingRun: testZeroEx
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
testingHelper({
|
|
93
|
-
network: Network.ARBITRUM,
|
|
94
|
-
testingRun: testZeroEx
|
|
95
|
-
});
|