@dhedge/v2-sdk 1.9.1 → 1.9.3

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.
@@ -3,44 +3,52 @@ import { Dhedge, Pool } from "..";
3
3
  import { routerAddress } from "../config";
4
4
  import { Dapp, Network } from "../types";
5
5
  import { CONTRACT_ADDRESS, MAX_AMOUNT, TEST_POOL } from "./constants";
6
+ import { TestingRunParams, testingHelper } from "./utils/testingHelper";
6
7
  import { allowanceDelta, balanceDelta } from "./utils/token";
7
8
 
8
- import { wallet } from "./wallet";
9
+ const testZeroEx = ({ wallet, network }: TestingRunParams) => {
10
+ const USDC = CONTRACT_ADDRESS[network].USDC;
11
+ const WETH = CONTRACT_ADDRESS[network].WETH;
9
12
 
10
- //const network = Network.OPTIMISM;
11
- const network = Network.POLYGON;
12
- // const network = Network.ARBITRUM;
13
- const USDC = CONTRACT_ADDRESS[network].USDC;
14
- const WETH = CONTRACT_ADDRESS[network].WETH;
13
+ let dhedge: Dhedge;
14
+ let pool: Pool;
15
+ jest.setTimeout(100000);
15
16
 
16
- let dhedge: Dhedge;
17
- let pool: Pool;
18
- jest.setTimeout(100000);
17
+ describe(`[${network}] 0x trade`, () => {
18
+ beforeAll(async () => {
19
+ dhedge = new Dhedge(wallet, network);
20
+ pool = await dhedge.loadPool(TEST_POOL[network]);
21
+ });
19
22
 
20
- describe("pool", () => {
21
- beforeAll(async () => {
22
- dhedge = new Dhedge(wallet, network);
23
- pool = await dhedge.loadPool(TEST_POOL[network]);
24
- });
23
+ it("approves unlimited USDC on 0x", async () => {
24
+ await pool.approve(Dapp.ZEROEX, USDC, MAX_AMOUNT);
25
+ const usdcAllowanceDelta = await allowanceDelta(
26
+ pool.address,
27
+ USDC,
28
+ routerAddress[network]["0x"]!,
29
+ pool.signer
30
+ );
31
+ await expect(usdcAllowanceDelta.gt(0));
32
+ });
25
33
 
26
- it("approves unlimited USDC on 0x", async () => {
27
- await pool.approve(Dapp.ZEROEX, USDC, MAX_AMOUNT);
28
- const usdcAllowanceDelta = await allowanceDelta(
29
- pool.address,
30
- USDC,
31
- routerAddress[network]["0x"]!,
32
- pool.signer
33
- );
34
- await expect(usdcAllowanceDelta.gt(0));
34
+ it("trades 2 USDC into WETH on 0x", async () => {
35
+ await pool.trade(Dapp.ZEROEX, USDC, WETH, "2000000", 0.5);
36
+ const wethBalanceDelta = await balanceDelta(
37
+ pool.address,
38
+ WETH,
39
+ pool.signer
40
+ );
41
+ expect(wethBalanceDelta.gt(0));
42
+ });
35
43
  });
44
+ };
36
45
 
37
- it("trades 2 USDC into WETH on 0x", async () => {
38
- await pool.trade(Dapp.ZEROEX, USDC, WETH, "2000000", 0.5);
39
- const wethBalanceDelta = await balanceDelta(
40
- pool.address,
41
- WETH,
42
- pool.signer
43
- );
44
- expect(wethBalanceDelta.gt(0));
45
- });
46
+ testingHelper({
47
+ network: Network.OPTIMISM,
48
+ testingRun: testZeroEx
49
+ });
50
+
51
+ testingHelper({
52
+ network: Network.POLYGON,
53
+ testingRun: testZeroEx
46
54
  });
@@ -1 +0,0 @@
1
- export declare function getOneInchProtocols(chainId: number): Promise<string>;
@@ -1,17 +0,0 @@
1
- import axios from "axios";
2
-
3
- export async function getOneInchProtocols(chainId: number): Promise<string> {
4
- try {
5
- const response = await axios.get(
6
- `https://api.1inch.io/v5.0/${chainId}/liquidity-sources`
7
- );
8
- const protocols = response.data.protocols.map((e: { id: string }) => e.id);
9
- const filteredProtocols = protocols.filter(
10
- (e: string) => !e.includes("PMM")
11
- );
12
-
13
- return `&protocols=${filteredProtocols.join(",")}`;
14
- } catch {
15
- return "";
16
- }
17
- }