@dhedge/v2-sdk 1.7.0 → 1.7.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhedge/v2-sdk",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
4
4
  "license": "MIT",
5
5
  "description": "🛠 An SDK for building applications on top of dHEDGE V2",
6
6
  "main": "dist/index.js",
package/src/config.ts CHANGED
@@ -37,7 +37,8 @@ export const routerAddress: AddressDappNetworkMap = {
37
37
  [Dapp.ONEINCH]: "0x1111111254760F7ab3F16433eea9304126DCd199",
38
38
  [Dapp.TOROS]: "0xf8C62BD5f2fEf9E1a329c197F32E77AD6866B022",
39
39
  [Dapp.VELODROME]: "0x9c12939390052919aF3155f41Bf4160Fd3666A6f",
40
- [Dapp.LYRA]: "0xCCE7819d65f348c64B7Beb205BA367b3fE33763B"
40
+ [Dapp.LYRA]: "0xCCE7819d65f348c64B7Beb205BA367b3fE33763B",
41
+ [Dapp.ARRAKIS]: "0x86d62a8ad19998e315e6242b63eb73f391d4674b"
41
42
  }
42
43
  };
43
44
 
@@ -63,13 +63,7 @@ export async function getLyraOptionTxData(
63
63
  txFunction = "closePosition";
64
64
  setCollateral = currentCollateral.sub(collateralAmount);
65
65
  //cover short
66
- if (
67
- !isLong(filteredPosition[0].optionType) &&
68
- !isCoveredCall &&
69
- collateralAmount.gt(netPremiun)
70
- ) {
71
- inputAmount = netPremiun.sub(collateralAmount);
72
- } else if (!isLong(filteredPosition[0].optionType) && isCoveredCall) {
66
+ if (!isLong(filteredPosition[0].optionType) && isCoveredCall) {
73
67
  inputAmount = netPremiun;
74
68
  } else {
75
69
  inputAmount = BigNumber.from(0);
@@ -1,9 +1,8 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { Dhedge } from "..";
2
+ import { Dhedge, ethers } from "..";
3
3
  import { Dapp, Network } from "../types";
4
- import { ARRAKIS_USDC_WETH_GAUGE, TEST_POOL } from "./constants";
4
+ import { ARRAKIS_USDC_WETH_GAUGE, TEST_POOL, USDC, WETH } from "./constants";
5
5
  import { getTxOptions } from "./txOptions";
6
- //import { getTxOptions } from "./txOptions";
7
6
 
8
7
  import { wallet } from "./wallet";
9
8
 
@@ -13,67 +12,81 @@ jest.setTimeout(100000);
13
12
 
14
13
  describe("pool", () => {
15
14
  beforeAll(async () => {
16
- dhedge = new Dhedge(wallet, Network.POLYGON);
17
- options = await getTxOptions(Network.POLYGON);
15
+ dhedge = new Dhedge(wallet, Network.OPTIMISM);
16
+ options = await getTxOptions(Network.OPTIMISM);
18
17
  });
19
18
 
20
- // it("approves unlimited WETH on Arrakis", async () => {
21
- // let result;
22
- // const pool = await dhedge.loadPool(TEST_POOL);
23
- // try {
24
- // result = await pool.approve(
25
- // Dapp.ARRAKIS,
26
- // USDC,
27
- // ethers.constants.MaxInt256,
28
- // options
29
- // );
30
- // console.log(result);
31
- // } catch (e) {
32
- // console.log(e);
33
- // }
34
- // expect(result).not.toBe(null);
35
- // });
19
+ it("approves unlimited USDC on Arrakis", async () => {
20
+ const pool = await dhedge.loadPool(TEST_POOL);
21
+ const result = await pool.approve(
22
+ Dapp.ARRAKIS,
23
+ USDC,
24
+ ethers.constants.MaxInt256,
25
+ options
26
+ );
27
+ expect(result).not.toBe(null);
28
+ });
36
29
 
37
- // it("should add liquidity and stake in an WETH/USDC Arrakis pool", async () => {
38
- // const pool = await dhedge.loadPool(TEST_POOL);
39
- // const result = await pool.increaseLiquidity(
40
- // Dapp.ARRAKIS,
41
- // "0x33d1ad9Cd88A509397CD924C2d7613C285602C20",
42
- // "776000",
43
- // "470000000000000",
44
- // options
45
- // );
46
- // console.log("result", result);
47
- // expect(result).not.toBe(null);
48
- // });
30
+ it("approves unlimited WETH on Arrakis", async () => {
31
+ const pool = await dhedge.loadPool(TEST_POOL);
32
+ const result = await pool.approve(
33
+ Dapp.ARRAKIS,
34
+ WETH,
35
+ ethers.constants.MaxInt256,
36
+ options
37
+ );
38
+ console.log(result);
39
+ expect(result).not.toBe(null);
40
+ });
49
41
 
50
- // it("approves unlimited LP staking Token before on Arrakis", async () => {
51
- // let result;
52
- // const pool = await dhedge.loadPool(TEST_POOL);
53
- // try {
54
- // result = await pool.approve(
55
- // Dapp.ARRAKIS,
56
- // ARRAKIS_USDC_WETH_GAUGE,
57
- // ethers.constants.MaxInt256,
58
- // options
59
- // );
60
- // console.log(result);
61
- // } catch (e) {
62
- // console.log(e);
63
- // }
64
- // expect(result).not.toBe(null);
65
- // });
42
+ it("should add liquidity and stake in an WETH/USDC Arrakis pool", async () => {
43
+ const pool = await dhedge.loadPool(TEST_POOL);
44
+ const wethBalance = await pool.utils.getBalance(WETH, pool.address);
45
+ const uasdBalance = await pool.utils.getBalance(USDC, pool.address);
46
+ const lpBalance = await pool.utils.getBalance(
47
+ ARRAKIS_USDC_WETH_GAUGE,
48
+ pool.address
49
+ );
50
+ const result = await pool.increaseLiquidity(
51
+ Dapp.ARRAKIS,
52
+ ARRAKIS_USDC_WETH_GAUGE,
53
+ uasdBalance,
54
+ wethBalance,
55
+ options
56
+ );
57
+ result.wait(1);
58
+ const lpBalanceAfter = await pool.utils.getBalance(
59
+ ARRAKIS_USDC_WETH_GAUGE,
60
+ pool.address
61
+ );
62
+ expect(lpBalanceAfter.gt(lpBalance));
63
+ });
64
+
65
+ it("approves unlimited LP staking Token before on Arrakis", async () => {
66
+ const pool = await dhedge.loadPool(TEST_POOL);
67
+ const result = await pool.approve(
68
+ Dapp.ARRAKIS,
69
+ ARRAKIS_USDC_WETH_GAUGE,
70
+ ethers.constants.MaxInt256,
71
+ options
72
+ );
73
+ expect(result).not.toBe(null);
74
+ });
66
75
 
67
76
  it("should remove liquidity from an existing pool ", async () => {
68
77
  const pool = await dhedge.loadPool(TEST_POOL);
69
78
  const result = await pool.decreaseLiquidity(
70
79
  Dapp.ARRAKIS,
71
80
  ARRAKIS_USDC_WETH_GAUGE,
72
- 50.6576575755,
81
+ 100,
73
82
  options
74
83
  );
75
- console.log("result", result);
76
- expect(result).not.toBe(null);
84
+ result.wait(1);
85
+ const lpBalanceAfter = await pool.utils.getBalance(
86
+ ARRAKIS_USDC_WETH_GAUGE,
87
+ pool.address
88
+ );
89
+ expect(lpBalanceAfter.eq(0));
77
90
  });
78
91
 
79
92
  // it("should claim fees an existing pool", async () => {
@@ -5,19 +5,19 @@
5
5
  // export const DAI = "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063";
6
6
  // export const TUSD = "0x2e1ad108ff1d8c782fcbbb89aad783ac49586756";
7
7
  // export const WBTC = "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6";
8
- export const SUSHI = "0x0b3f868e0be5597d5db7feb59e1cadbb0fdda50a";
9
- export const WMATIC = "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270";
10
- export const BAL = "0x9a71012B13CA4d3D0Cdc72A177DF3ef03b0E76A3";
11
- export const AMUSDC = "0x1a13f4ca1d028320a707d99520abfefca3998b7f";
12
- export const VDEBTWETH = "0xede17e9d79fc6f9ff9250d9eefbdb88cc18038b5";
13
- export const ARRAKIS_USDC_WETH_GAUGE =
14
- "0x33d1ad9Cd88A509397CD924C2d7613C285602C20";
15
- export const STMATIC = "0x3A58a54C066FdC0f2D55FC9C89F0415C92eBf3C4";
16
- export const WMATIC_STMATIC_LP = "0xaF5E0B5425dE1F5a630A8cB5AA9D97B8141C908D";
17
- export const AARAKIS_WNATIC_STMATIC_GAUGE =
18
- "0x9928340f9E1aaAd7dF1D95E27bd9A5c715202a56";
19
- export const ETHBULL3X = "0x460b60565cb73845d56564384ab84bf84c13e47d";
20
- export const BTCBEAR2X = "0x3dbce2c8303609c17aa23b69ebe83c2f5c510ada";
8
+ // export const SUSHI = "0x0b3f868e0be5597d5db7feb59e1cadbb0fdda50a";
9
+ // export const WMATIC = "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270";
10
+ // export const BAL = "0x9a71012B13CA4d3D0Cdc72A177DF3ef03b0E76A3";
11
+ // export const AMUSDC = "0x1a13f4ca1d028320a707d99520abfefca3998b7f";
12
+ // export const VDEBTWETH = "0xede17e9d79fc6f9ff9250d9eefbdb88cc18038b5";
13
+ // export const ARRAKIS_USDC_WETH_GAUGE =
14
+ // "0x33d1ad9Cd88A509397CD924C2d7613C285602C20";
15
+ // export const STMATIC = "0x3A58a54C066FdC0f2D55FC9C89F0415C92eBf3C4";
16
+ // export const WMATIC_STMATIC_LP = "0xaF5E0B5425dE1F5a630A8cB5AA9D97B8141C908D";
17
+ // export const AARAKIS_WNATIC_STMATIC_GAUGE =
18
+ // "0x9928340f9E1aaAd7dF1D95E27bd9A5c715202a56";
19
+ // export const ETHBULL3X = "0x460b60565cb73845d56564384ab84bf84c13e47d";
20
+ // export const BTCBEAR2X = "0x3dbce2c8303609c17aa23b69ebe83c2f5c510ada";
21
21
 
22
22
  //Optimism
23
23
  export const WETH = "0x4200000000000000000000000000000000000006";
@@ -29,5 +29,7 @@ export const OP = "4200000000000000000000000000000000000042";
29
29
  export const WSTETH = "0x1F32b1c2345538c0c6f582fCB022739c4A194Ebb";
30
30
  export const VEL = "0x3c8B650257cFb5f272f799F5e2b4e65093a11a05";
31
31
  export const SUSD = "0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9";
32
+ export const ARRAKIS_USDC_WETH_GAUGE =
33
+ "0xb8888ea29e2f70ad62a3b69b1a1342720612a00d";
32
34
 
33
- export const TEST_POOL = "TEST_POOL";
35
+ export const TEST_POOL = "0x3d45e539df0f9fa6015106a968d732a8f6c2a40b";