@dhedge/v2-sdk 1.4.0 → 1.4.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.
@@ -1,21 +1,19 @@
1
- import { Dhedge, ethers } from "..";
1
+ import { Dhedge } from "..";
2
2
  import { Network } from "../types";
3
- import { TEST_POOL } from "./constants";
3
+ import { STMATIC, TEST_POOL, WMATIC } from "./constants";
4
+ import { getTxOptions } from "./txOptions";
4
5
 
5
6
  import { wallet } from "./wallet";
6
7
 
7
8
  let dhedge: Dhedge;
9
+ let options: any;
8
10
 
9
11
  jest.setTimeout(100000);
10
12
 
11
- const options = {
12
- gasLimit: 2000000,
13
- gasPrice: ethers.utils.parseUnits("1000", "gwei")
14
- };
15
-
16
13
  describe("pool", () => {
17
- beforeAll(() => {
14
+ beforeAll(async () => {
18
15
  dhedge = new Dhedge(wallet, Network.POLYGON);
16
+ options = await getTxOptions();
19
17
  });
20
18
 
21
19
  // it("approves unlimited USDC on Balancer", async () => {
@@ -95,11 +93,118 @@ describe("pool", () => {
95
93
  // expect(result).not.toBe(null);
96
94
  // });
97
95
 
98
- it("claims balancer rewards", async () => {
96
+ // it("claims balancer rewards", async () => {
97
+ // let result;
98
+ // const pool = await dhedge.loadPool(TEST_POOL);
99
+ // try {
100
+ // result = await pool.harvestBalancerRewards(options);
101
+ // console.log("result", result);
102
+ // } catch (e) {
103
+ // console.log(e);
104
+ // }
105
+ // expect(result).not.toBe(null);
106
+ // });
107
+
108
+ // it("adds 5 WMATIC to a WMATIC/stMATIC balancer pool", async () => {
109
+ // let result;
110
+ // const pool = await dhedge.loadPool(TEST_POOL);
111
+ // const assets = [WMATIC, STMATIC];
112
+ // const amounts = ["5000000000000000000", "0"];
113
+ // try {
114
+ // result = await pool.joinBalancerPool(
115
+ // "0xaf5e0b5425de1f5a630a8cb5aa9d97b8141c908d000200000000000000000366",
116
+ // assets,
117
+ // amounts,
118
+ // options
119
+ // );
120
+ // console.log("result", result);
121
+ // } catch (e) {
122
+ // console.log(e);
123
+ // }
124
+ // expect(result).not.toBe(null);
125
+ // });
126
+
127
+ // it("allows unlimited WMATIC-stMATIC LP on gauge", async () => {
128
+ // let result;
129
+ // const pool = await dhedge.loadPool(TEST_POOL);
130
+ // try {
131
+ // result = await pool.approveSpender(
132
+ // "0x9928340f9E1aaAd7dF1D95E27bd9A5c715202a56",
133
+ // WMATIC_STMATIC_LP,
134
+ // ethers.constants.MaxUint256,
135
+ // options
136
+ // );
137
+ // console.log("result", result);
138
+ // } catch (e) {
139
+ // console.log(e);
140
+ // }
141
+ // expect(result).not.toBe(null);
142
+ // });
143
+
144
+ // it("stakes WMATIC-stMATIC LP in gauge", async () => {
145
+ // let result;
146
+ // const pool = await dhedge.loadPool(TEST_POOL);
147
+ // try {
148
+ // result = await pool.stakeInGauge(
149
+ // "0x9928340f9E1aaAd7dF1D95E27bd9A5c715202a56",
150
+ // "4978534455005333156",
151
+ // options
152
+ // );
153
+ // console.log("result", result);
154
+ // } catch (e) {
155
+ // console.log(e);
156
+ // }
157
+ // expect(result).not.toBe(null);
158
+ // });
159
+
160
+ // it("claim fess pf staked WMATIC-stMATIC LP in gauge", async () => {
161
+ // let result;
162
+ // const pool = await dhedge.loadPool(TEST_POOL);
163
+ // try {
164
+ // result = await pool.claimFees(
165
+ // Dapp.BALANCER,
166
+ // "0x9928340f9E1aaAd7dF1D95E27bd9A5c715202a56",
167
+ // options
168
+ // );
169
+ // console.log("result", result);
170
+ // } catch (e) {
171
+ // console.log(e);
172
+ // }
173
+ // expect(result).not.toBe(null);
174
+ // });
175
+
176
+ // it("unstakes WMATIC-stMATIC LP from gauge", async () => {
177
+ // let result;
178
+ // const pool = await dhedge.loadPool(TEST_POOL);
179
+ // try {
180
+ // result = await pool.unstakeFromGauge(
181
+ // "0x9928340f9E1aaAd7dF1D95E27bd9A5c715202a56",
182
+ // "4978534455005333156",
183
+ // options
184
+ // );
185
+ // console.log("result", result);
186
+ // } catch (e) {
187
+ // console.log(e);
188
+ // }
189
+ // expect(result).not.toBe(null);
190
+ // });
191
+
192
+ it("exits from WMATIC-stMATIC LP into WMATIC", async () => {
99
193
  let result;
100
194
  const pool = await dhedge.loadPool(TEST_POOL);
195
+ const assets = [WMATIC, STMATIC];
196
+ const amount = await dhedge.utils.getBalance(
197
+ "0xaF5E0B5425dE1F5a630A8cB5AA9D97B8141C908D",
198
+ pool.address
199
+ );
101
200
  try {
102
- result = await pool.harvestBalancerRewards(options);
201
+ result = await pool.exitBalancerPool(
202
+ "0xaf5e0b5425de1f5a630a8cb5aa9d97b8141c908d000200000000000000000366",
203
+ assets,
204
+ amount,
205
+ 1,
206
+ options
207
+ );
103
208
  console.log("result", result);
104
209
  } catch (e) {
105
210
  console.log(e);
@@ -12,10 +12,14 @@ export const AMUSDC = "0x1a13f4ca1d028320a707d99520abfefca3998b7f";
12
12
  export const VDEBTWETH = "0xede17e9d79fc6f9ff9250d9eefbdb88cc18038b5";
13
13
  export const ARRAKIS_USDC_WETH_GAUGE =
14
14
  "0x33d1ad9Cd88A509397CD924C2d7613C285602C20";
15
+ export const STMATIC = "0x3A58a54C066FdC0f2D55FC9C89F0415C92eBf3C4";
16
+ export const WMATIC_STMATIC_LP = "0xaF5E0B5425dE1F5a630A8cB5AA9D97B8141C908D";
17
+ export const AARAKIS_WNATIC_STMATIC_GAUGE =
18
+ "0x9928340f9E1aaAd7dF1D95E27bd9A5c715202a56";
15
19
 
16
20
  //Optimism
17
21
  // export const WETH = "0x4200000000000000000000000000000000000006";
18
22
  // export const USDC = "0x7F5c764cBc14f9669B88837ca1490cCa17c31607";
19
23
  // export const DAI = "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1";
20
24
 
21
- export const TEST_POOL = "TEST_POOL_ADDRESS";
25
+ export const TEST_POOL = "TEST_POOL";
@@ -1,15 +1,21 @@
1
1
  import axios from "axios";
2
2
  import BigNumber from "bignumber.js";
3
+ import { Network } from "../types";
3
4
 
4
5
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
- export const getTxOptions = async (): Promise<any> => {
6
- const result = await axios("https://gasstation-mainnet.matic.network/v2");
7
-
8
- return {
9
- gasLimit: "3000000",
10
- maxPriorityFeePerGas: new BigNumber(result.data.fast.maxPriorityFee)
11
- .shiftedBy(9)
12
- .toFixed(0),
13
- maxFeePerGas: new BigNumber(result.data.fast.maxFee).shiftedBy(9).toFixed(0)
14
- };
6
+ export const getTxOptions = async (network: Network): Promise<any> => {
7
+ if (network === Network.POLYGON) {
8
+ const result = await axios("https://gasstation-mainnet.matic.network/v2");
9
+ return {
10
+ gasLimit: "3000000",
11
+ maxPriorityFeePerGas: new BigNumber(result.data.fast.maxPriorityFee)
12
+ .shiftedBy(9)
13
+ .toFixed(0),
14
+ maxFeePerGas: new BigNumber(result.data.fast.maxFee)
15
+ .shiftedBy(9)
16
+ .toFixed(0),
17
+ };
18
+ } else {
19
+ return { gasLimit: "3000000" };
20
+ }
15
21
  };