@dhedge/v2-sdk 1.5.2 → 1.5.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.
- package/dist/v2-sdk.cjs.development.js +9 -3
- 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 +9 -3
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/entities/utils.ts +7 -1
- package/src/test/balancer.test.ts +46 -42
package/package.json
CHANGED
package/src/entities/utils.ts
CHANGED
|
@@ -273,6 +273,12 @@ export class Utils {
|
|
|
273
273
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
274
274
|
): Promise<any> {
|
|
275
275
|
const iBalancerV2Vault = new ethers.utils.Interface(IBalancerV2Vault.abi);
|
|
276
|
+
const bptAddress = ethers.utils.getAddress(balancerPoolId.slice(0, 42));
|
|
277
|
+
const bptIndex = assets.findIndex(
|
|
278
|
+
e => e.toLowerCase() === bptAddress.toLocaleLowerCase()
|
|
279
|
+
);
|
|
280
|
+
const poolAssetsAmounts = amountsIn.slice();
|
|
281
|
+
if (bptIndex >= 0) poolAssetsAmounts.splice(bptIndex, 1);
|
|
276
282
|
const txData = [
|
|
277
283
|
balancerPoolId,
|
|
278
284
|
pool.address,
|
|
@@ -282,7 +288,7 @@ export class Utils {
|
|
|
282
288
|
amountsIn,
|
|
283
289
|
ethers.utils.defaultAbiCoder.encode(
|
|
284
290
|
["uint256", "uint256[]", "uint256"],
|
|
285
|
-
[1,
|
|
291
|
+
[1, poolAssetsAmounts, 0]
|
|
286
292
|
),
|
|
287
293
|
false
|
|
288
294
|
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dhedge } from "..";
|
|
2
2
|
import { Network } from "../types";
|
|
3
|
-
import {
|
|
3
|
+
import { TEST_POOL, WMATIC } from "./constants";
|
|
4
4
|
import { getTxOptions } from "./txOptions";
|
|
5
5
|
|
|
6
6
|
import { wallet } from "./wallet";
|
|
@@ -13,7 +13,7 @@ jest.setTimeout(100000);
|
|
|
13
13
|
describe("pool", () => {
|
|
14
14
|
beforeAll(async () => {
|
|
15
15
|
dhedge = new Dhedge(wallet, Network.POLYGON);
|
|
16
|
-
options = await getTxOptions();
|
|
16
|
+
options = await getTxOptions(Network.POLYGON);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
// it("approves unlimited USDC on Balancer", async () => {
|
|
@@ -105,24 +105,28 @@ describe("pool", () => {
|
|
|
105
105
|
// expect(result).not.toBe(null);
|
|
106
106
|
// });
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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 = [
|
|
112
|
+
WMATIC,
|
|
113
|
+
"0xb20fC01D21A50d2C734C4a1262B4404d41fA7BF0",
|
|
114
|
+
"0xfa68FB4628DFF1028CFEc22b4162FCcd0d45efb6"
|
|
115
|
+
];
|
|
116
|
+
const amounts = ["29500317230801455961187", "0", "0"];
|
|
117
|
+
try {
|
|
118
|
+
result = await pool.joinBalancerPool(
|
|
119
|
+
"0xb20fc01d21a50d2c734c4a1262b4404d41fa7bf000000000000000000000075c",
|
|
120
|
+
assets,
|
|
121
|
+
amounts,
|
|
122
|
+
options
|
|
123
|
+
);
|
|
124
|
+
console.log("result", result);
|
|
125
|
+
} catch (e) {
|
|
126
|
+
console.log(e);
|
|
127
|
+
}
|
|
128
|
+
expect(result).not.toBe(null);
|
|
129
|
+
});
|
|
126
130
|
|
|
127
131
|
// it("allows unlimited WMATIC-stMATIC LP on gauge", async () => {
|
|
128
132
|
// let result;
|
|
@@ -189,26 +193,26 @@ describe("pool", () => {
|
|
|
189
193
|
// expect(result).not.toBe(null);
|
|
190
194
|
// });
|
|
191
195
|
|
|
192
|
-
it("exits from WMATIC-stMATIC LP into WMATIC", async () => {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
});
|
|
196
|
+
// it("exits from WMATIC-stMATIC LP into WMATIC", async () => {
|
|
197
|
+
// let result;
|
|
198
|
+
// const pool = await dhedge.loadPool(TEST_POOL);
|
|
199
|
+
// const assets = [WMATIC, STMATIC];
|
|
200
|
+
// const amount = await dhedge.utils.getBalance(
|
|
201
|
+
// "0xaF5E0B5425dE1F5a630A8cB5AA9D97B8141C908D",
|
|
202
|
+
// pool.address
|
|
203
|
+
// );
|
|
204
|
+
// try {
|
|
205
|
+
// result = await pool.exitBalancerPool(
|
|
206
|
+
// "0xaf5e0b5425de1f5a630a8cb5aa9d97b8141c908d000200000000000000000366",
|
|
207
|
+
// assets,
|
|
208
|
+
// amount,
|
|
209
|
+
// 1,
|
|
210
|
+
// options
|
|
211
|
+
// );
|
|
212
|
+
// console.log("result", result);
|
|
213
|
+
// } catch (e) {
|
|
214
|
+
// console.log(e);
|
|
215
|
+
// }
|
|
216
|
+
// expect(result).not.toBe(null);
|
|
217
|
+
// });
|
|
214
218
|
});
|