@dhedge/v2-sdk 1.7.2 → 1.8.1
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 +0 -1
- package/dist/entities/pool.d.ts +16 -7
- package/dist/services/futures/constants.d.ts +3 -0
- package/dist/services/futures/index.d.ts +2 -0
- package/dist/services/futures/margin.d.ts +2 -0
- package/dist/services/futures/trade.d.ts +2 -0
- package/dist/services/velodrome/liquidity.d.ts +2 -2
- package/dist/test/constants.d.ts +24 -2
- package/dist/test/utils/token.d.ts +3 -0
- package/dist/utils/deadline.d.ts +2 -0
- package/dist/v2-sdk.cjs.development.js +4540 -5103
- 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 +7341 -7904
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +5 -2
- package/src/abi/IDhedgeEasySwapper.json +99 -239
- package/src/abi/ISynthetiXFuturesMarketV2.json +531 -0
- package/src/config.ts +4 -5
- package/src/entities/pool.ts +68 -44
- package/src/services/futures/constants.ts +4 -0
- package/src/services/futures/index.ts +2 -0
- package/src/services/futures/margin.ts +10 -0
- package/src/services/futures/trade.ts +15 -0
- package/src/services/oneInch/protocols.ts +3 -4
- package/src/services/toros/easySwapper.ts +3 -2
- package/src/services/uniswap/V3Liquidity.ts +2 -3
- package/src/services/velodrome/liquidity.ts +7 -7
- package/src/test/constants.ts +27 -2
- package/src/test/futures.test.ts +48 -0
- package/src/test/oneInch.test.ts +32 -36
- package/src/test/pool.test.ts +42 -85
- package/src/test/toros.test.ts +50 -98
- package/src/test/uniswap.test.ts +65 -30
- package/src/test/utils/token.ts +31 -0
- package/src/test/velodrome.test.ts +74 -101
- package/src/test/wallet.ts +5 -3
- package/src/utils/deadline.ts +6 -0
- package/dist/services/claim-balancer/claim.service.d.ts +0 -17
- package/dist/services/claim-balancer/claim.worker.d.ts +0 -4
- package/dist/services/claim-balancer/ipfs.service.d.ts +0 -4
- package/dist/services/claim-balancer/types.d.ts +0 -54
- package/src/services/claim-balancer/MultiTokenClaim.json +0 -115
- package/src/services/claim-balancer/claim.service.ts +0 -262
- package/src/services/claim-balancer/claim.worker.ts +0 -32
- package/src/services/claim-balancer/ipfs.service.ts +0 -12
- package/src/services/claim-balancer/types.ts +0 -66
- package/src/test/1inch.test.ts +0 -54
package/src/test/pool.test.ts
CHANGED
|
@@ -1,103 +1,60 @@
|
|
|
1
|
-
import { Dhedge } from "..";
|
|
2
|
-
import { Network } from "../types";
|
|
3
|
-
import { TEST_POOL } from "./constants";
|
|
4
|
-
|
|
1
|
+
import { Dhedge, ethers, Pool } from "..";
|
|
2
|
+
import { AssetEnabled, Network } from "../types";
|
|
3
|
+
import { CONTRACT_ADDRESS, TEST_POOL } from "./constants";
|
|
4
|
+
import { allowanceDelta, balanceDelta } from "./utils/token";
|
|
5
5
|
import { wallet } from "./wallet";
|
|
6
6
|
|
|
7
7
|
let dhedge: Dhedge;
|
|
8
|
+
let pool: Pool;
|
|
8
9
|
|
|
9
10
|
jest.setTimeout(100000);
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
// gasLimit: 5000000,
|
|
13
|
-
// gasPrice: ethers.utils.parseUnits("35", "gwei")
|
|
14
|
-
// };
|
|
12
|
+
const network = Network.POLYGON;
|
|
15
13
|
|
|
16
14
|
describe("pool", () => {
|
|
17
|
-
beforeAll(() => {
|
|
18
|
-
dhedge = new Dhedge(wallet,
|
|
15
|
+
beforeAll(async () => {
|
|
16
|
+
dhedge = new Dhedge(wallet, network);
|
|
17
|
+
pool = await dhedge.loadPool(TEST_POOL[network]);
|
|
19
18
|
});
|
|
20
19
|
|
|
21
20
|
it("checks fund composition", async () => {
|
|
22
|
-
const pool = await dhedge.loadPool(TEST_POOL);
|
|
23
21
|
const result = await pool.getComposition();
|
|
24
|
-
console.log(result);
|
|
25
22
|
expect(result.length).toBeGreaterThan(0);
|
|
26
23
|
});
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// }
|
|
42
|
-
// expect(result).not.toBe(null);
|
|
43
|
-
// });
|
|
44
|
-
|
|
45
|
-
// it("deposit 0.1 USDC into Pool", async () => {
|
|
46
|
-
// let result;
|
|
47
|
-
// const pool = await dhedge.loadPool(myPool);
|
|
48
|
-
// try {
|
|
49
|
-
// result = await pool.deposit(usdc, depositAmountUsdc);
|
|
50
|
-
// } catch (e) {
|
|
51
|
-
// console.log(e);
|
|
52
|
-
// }
|
|
53
|
-
// expect(result).not.toBe(null);
|
|
54
|
-
// });
|
|
55
|
-
|
|
56
|
-
// it("adds LpUSDCWETH/SUSHI/WMATIC to enabled assets", async () => {
|
|
57
|
-
// let result;
|
|
58
|
-
// const pool = await dhedge.loadPool(myPool);
|
|
59
|
-
// const newAssets: AssetEnabled[] = [
|
|
60
|
-
// { asset: usdc, isDeposit: true },
|
|
61
|
-
// { asset: weth, isDeposit: true },
|
|
62
|
-
// { asset: usdt, isDeposit: true },
|
|
63
|
-
// { asset: amusdc, isDeposit: false },
|
|
64
|
-
// { asset: lpUsdcUsdt, isDeposit: false }
|
|
65
|
-
// ];
|
|
66
|
-
// try {
|
|
67
|
-
// result = await pool.changeAssets(newAssets);
|
|
68
|
-
// console.log(result);
|
|
69
|
-
// } catch (e) {
|
|
70
|
-
// console.log(e);
|
|
71
|
-
// }
|
|
72
|
-
// expect(result).not.toBe(null);
|
|
73
|
-
// });
|
|
25
|
+
it("approves USDC balance of User for Deposit", async () => {
|
|
26
|
+
await pool.approveDeposit(
|
|
27
|
+
CONTRACT_ADDRESS[network].USDC,
|
|
28
|
+
ethers.constants.MaxUint256
|
|
29
|
+
);
|
|
30
|
+
const UsdcAllowanceDelta = await allowanceDelta(
|
|
31
|
+
pool.signer.address,
|
|
32
|
+
CONTRACT_ADDRESS[network].USDC,
|
|
33
|
+
pool.address,
|
|
34
|
+
pool.signer
|
|
35
|
+
);
|
|
36
|
+
expect(UsdcAllowanceDelta.gt(0));
|
|
37
|
+
});
|
|
74
38
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
// console.log(result);
|
|
85
|
-
// } catch (e) {
|
|
86
|
-
// console.log(e);
|
|
87
|
-
// }
|
|
88
|
-
// expect(result).not.toBe(null);
|
|
89
|
-
// });
|
|
39
|
+
it("deposits 1 USDC into Pool", async () => {
|
|
40
|
+
await pool.deposit(CONTRACT_ADDRESS[network].USDC, (1e6).toString());
|
|
41
|
+
const poolTokenDelta = await balanceDelta(
|
|
42
|
+
pool.signer.address,
|
|
43
|
+
pool.address,
|
|
44
|
+
pool.signer
|
|
45
|
+
);
|
|
46
|
+
expect(poolTokenDelta.gt(0));
|
|
47
|
+
});
|
|
90
48
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
// });
|
|
49
|
+
it("adds WBTC to enabled assets", async () => {
|
|
50
|
+
const assetsBefore = await pool.getComposition();
|
|
51
|
+
const newAssets: AssetEnabled[] = [
|
|
52
|
+
{ asset: CONTRACT_ADDRESS[network].USDC, isDeposit: true },
|
|
53
|
+
{ asset: CONTRACT_ADDRESS[network].WETH, isDeposit: false },
|
|
54
|
+
{ asset: CONTRACT_ADDRESS[network].WBTC, isDeposit: false }
|
|
55
|
+
];
|
|
56
|
+
await pool.changeAssets(newAssets);
|
|
57
|
+
const assetsAfter = await pool.getComposition();
|
|
58
|
+
expect(assetsAfter.length).toBeGreaterThan(assetsBefore.length);
|
|
59
|
+
});
|
|
103
60
|
});
|
package/src/test/toros.test.ts
CHANGED
|
@@ -1,117 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
getPoolDepositAsset
|
|
6
|
-
} from "../services/toros/easySwapper";
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
import { Dhedge, Pool } from "..";
|
|
4
|
+
import { routerAddress } from "../config";
|
|
7
5
|
import { Dapp, Network } from "../types";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { CONTRACT_ADDRESS, MAX_AMOUNT, TEST_POOL } from "./constants";
|
|
7
|
+
import { allowanceDelta, balanceDelta } from "./utils/token";
|
|
10
8
|
|
|
11
9
|
import { wallet } from "./wallet";
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const ETHy = "0xb2cfb909e8657c0ec44d3dd898c1053b87804755";
|
|
12
|
+
const network = Network.OPTIMISM;
|
|
13
|
+
const SUSD = CONTRACT_ADDRESS[network].SUSD;
|
|
15
14
|
|
|
15
|
+
let dhedge: Dhedge;
|
|
16
|
+
let pool: Pool;
|
|
16
17
|
jest.setTimeout(100000);
|
|
17
18
|
|
|
18
19
|
describe("pool", () => {
|
|
19
20
|
beforeAll(async () => {
|
|
20
|
-
dhedge = new Dhedge(wallet,
|
|
21
|
-
|
|
21
|
+
dhedge = new Dhedge(wallet, network);
|
|
22
|
+
pool = await dhedge.loadPool(TEST_POOL[network]);
|
|
22
23
|
});
|
|
23
24
|
|
|
24
|
-
it("
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
pool.address,
|
|
34
|
-
USDC,
|
|
35
|
-
depositAsset,
|
|
36
|
-
ethers.BigNumber.from("100000000")
|
|
37
|
-
);
|
|
38
|
-
console.log("deposit quote", result.toString());
|
|
39
|
-
} catch (e) {
|
|
40
|
-
console.log(e);
|
|
41
|
-
}
|
|
42
|
-
expect(result).not.toBe(null);
|
|
25
|
+
it("approves unlimited ETHy on Toros (Easyswapper)", async () => {
|
|
26
|
+
await pool.approve(Dapp.TOROS, ETHy, MAX_AMOUNT);
|
|
27
|
+
const ETHyAllowanceDelta = await allowanceDelta(
|
|
28
|
+
pool.address,
|
|
29
|
+
ETHy,
|
|
30
|
+
routerAddress[network].toros!,
|
|
31
|
+
pool.signer
|
|
32
|
+
);
|
|
33
|
+
expect(ETHyAllowanceDelta.gt(0));
|
|
43
34
|
});
|
|
44
35
|
|
|
45
|
-
it("
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
);
|
|
55
|
-
console.log("withdrawal quote", result.toString());
|
|
56
|
-
} catch (e) {
|
|
57
|
-
console.log(e);
|
|
58
|
-
}
|
|
59
|
-
expect(result).not.toBe(null);
|
|
36
|
+
it("sell ETHy to SUSD on Toros", async () => {
|
|
37
|
+
const ETHyBalance = await pool.utils.getBalance(ETHy, pool.address);
|
|
38
|
+
await pool.trade(Dapp.TOROS, ETHy, SUSD, ETHyBalance, 3);
|
|
39
|
+
const ETHyBalanceDelta = await balanceDelta(
|
|
40
|
+
pool.address,
|
|
41
|
+
SUSD,
|
|
42
|
+
pool.signer
|
|
43
|
+
);
|
|
44
|
+
expect(ETHyBalanceDelta.lt(0));
|
|
60
45
|
});
|
|
61
46
|
|
|
62
|
-
it("approves unlimited
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
);
|
|
72
|
-
console.log(result);
|
|
73
|
-
} catch (e) {
|
|
74
|
-
console.log(e);
|
|
75
|
-
}
|
|
76
|
-
expect(result).not.toBe(null);
|
|
47
|
+
it("approves unlimited sUSD on Toros (Easyswapper)", async () => {
|
|
48
|
+
await pool.approve(Dapp.TOROS, SUSD, MAX_AMOUNT, { gasLimit: "3000000" });
|
|
49
|
+
const sUSDAllowanceDelta = await allowanceDelta(
|
|
50
|
+
pool.address,
|
|
51
|
+
SUSD,
|
|
52
|
+
routerAddress[network].toros!,
|
|
53
|
+
pool.signer
|
|
54
|
+
);
|
|
55
|
+
expect(sUSDAllowanceDelta.gt(0));
|
|
77
56
|
});
|
|
78
57
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
// options
|
|
90
|
-
// );
|
|
91
|
-
// console.log(result);
|
|
92
|
-
// } catch (e) {
|
|
93
|
-
// console.log(e);
|
|
94
|
-
// }
|
|
95
|
-
// expect(result).not.toBe(null);
|
|
96
|
-
// });
|
|
97
|
-
|
|
98
|
-
it("sells ETHBULL3X balance for USDC", async () => {
|
|
99
|
-
let result;
|
|
100
|
-
const pool = await dhedge.loadPool(TEST_POOL);
|
|
101
|
-
const balance = await pool.utils.getBalance(ETHBULL3X, pool.address);
|
|
102
|
-
try {
|
|
103
|
-
result = await pool.trade(
|
|
104
|
-
Dapp.TOROS,
|
|
105
|
-
ETHBULL3X,
|
|
106
|
-
USDC,
|
|
107
|
-
balance,
|
|
108
|
-
3,
|
|
109
|
-
options
|
|
110
|
-
);
|
|
111
|
-
console.log(result);
|
|
112
|
-
} catch (e) {
|
|
113
|
-
console.log(e);
|
|
114
|
-
}
|
|
115
|
-
expect(result).not.toBe(null);
|
|
58
|
+
it("buys ETHy for 3 sUSD", async () => {
|
|
59
|
+
await pool.trade(Dapp.TOROS, SUSD, ETHy, (3 * 10e18).toString(), 3, {
|
|
60
|
+
gasLimit: "3000000"
|
|
61
|
+
});
|
|
62
|
+
const ETHyBalanceDelta = await balanceDelta(
|
|
63
|
+
pool.address,
|
|
64
|
+
ETHy,
|
|
65
|
+
pool.signer
|
|
66
|
+
);
|
|
67
|
+
expect(ETHyBalanceDelta.gt(0));
|
|
116
68
|
});
|
|
117
69
|
});
|
package/src/test/uniswap.test.ts
CHANGED
|
@@ -1,35 +1,70 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import {
|
|
2
|
+
import { FeeAmount } from "@uniswap/v3-sdk";
|
|
3
|
+
import { Dhedge, ethers, Pool } from "..";
|
|
4
|
+
import { routerAddress } from "../config";
|
|
3
5
|
import { Dapp, Network } from "../types";
|
|
4
|
-
import { TEST_POOL } from "./constants";
|
|
5
|
-
import {
|
|
6
|
+
import { CONTRACT_ADDRESS, TEST_POOL } from "./constants";
|
|
7
|
+
import { allowanceDelta, balanceDelta } from "./utils/token";
|
|
6
8
|
|
|
7
9
|
import { wallet } from "./wallet";
|
|
8
10
|
|
|
9
11
|
let dhedge: Dhedge;
|
|
10
|
-
let
|
|
12
|
+
let pool: Pool;
|
|
11
13
|
jest.setTimeout(100000);
|
|
12
14
|
|
|
15
|
+
const network = Network.POLYGON;
|
|
16
|
+
|
|
13
17
|
describe("pool", () => {
|
|
14
18
|
beforeAll(async () => {
|
|
15
|
-
dhedge = new Dhedge(wallet,
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
dhedge = new Dhedge(wallet, network);
|
|
20
|
+
pool = await dhedge.loadPool(TEST_POOL[network]);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("approves unlimited USDC on for trading on UniswapV3", async () => {
|
|
24
|
+
await pool.approve(
|
|
25
|
+
Dapp.UNISWAPV3,
|
|
26
|
+
CONTRACT_ADDRESS[network].USDC,
|
|
27
|
+
ethers.constants.MaxUint256
|
|
28
|
+
);
|
|
29
|
+
const UsdcAllowanceDelta = await allowanceDelta(
|
|
30
|
+
pool.address,
|
|
31
|
+
CONTRACT_ADDRESS[network].USDC,
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
33
|
+
routerAddress[network].uniswapV3!,
|
|
34
|
+
pool.signer
|
|
35
|
+
);
|
|
36
|
+
expect(UsdcAllowanceDelta.gte(0));
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("should swap 5 USDC into WETH on UniswapV3", async () => {
|
|
40
|
+
await pool.tradeUniswapV3(
|
|
41
|
+
CONTRACT_ADDRESS[network].USDC,
|
|
42
|
+
CONTRACT_ADDRESS[network].WETH,
|
|
43
|
+
"5000000",
|
|
44
|
+
FeeAmount.LOW,
|
|
45
|
+
0.5
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const wethAllowanceDelta = await balanceDelta(
|
|
49
|
+
pool.address,
|
|
50
|
+
CONTRACT_ADDRESS[network].WETH,
|
|
51
|
+
pool.signer
|
|
52
|
+
);
|
|
53
|
+
expect(wethAllowanceDelta.gt(0));
|
|
18
54
|
});
|
|
19
55
|
|
|
20
56
|
// it("approves unlimited WETH on for UniswapV3 LP", async () => {
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
// }
|
|
57
|
+
// await pool.approveUniswapV3Liquidity(
|
|
58
|
+
// CONTRACT_ADDRESS[network].USDC,
|
|
59
|
+
// ethers.constants.MaxInt256
|
|
60
|
+
// );
|
|
61
|
+
// const UsdcAllowanceDelta = await allowanceDelta(
|
|
62
|
+
// pool.address,
|
|
63
|
+
// CONTRACT_ADDRESS[network].USDC,
|
|
64
|
+
// pool.address,
|
|
65
|
+
// pool.signer
|
|
66
|
+
// );
|
|
67
|
+
|
|
33
68
|
// expect(result).not.toBe(null);
|
|
34
69
|
// });
|
|
35
70
|
|
|
@@ -59,17 +94,17 @@ describe("pool", () => {
|
|
|
59
94
|
// expect(result).not.toBe(null);
|
|
60
95
|
// });
|
|
61
96
|
|
|
62
|
-
it("should remove liquidity from an existing pool ", async () => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
97
|
+
// it("should remove liquidity from an existing pool ", async () => {
|
|
98
|
+
// const pool = await dhedge.loadPool(TEST_POOL);
|
|
99
|
+
// const result = await pool.decreaseLiquidity(
|
|
100
|
+
// Dapp.UNISWAPV3,
|
|
101
|
+
// "110507",
|
|
102
|
+
// 100,
|
|
103
|
+
// options
|
|
104
|
+
// );
|
|
105
|
+
// console.log("result", result);
|
|
106
|
+
// expect(result).not.toBe(null);
|
|
107
|
+
// });
|
|
73
108
|
|
|
74
109
|
// it("should increase liquidity in an existing pool WETH/WBTC pool", async () => {
|
|
75
110
|
// const pool = await dhedge.loadPool(TEST_POOL);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BigNumber, Wallet, Contract } from "ethers";
|
|
2
|
+
import IERC20 from "../../abi/IERC20.json";
|
|
3
|
+
|
|
4
|
+
export const balanceDelta = async (
|
|
5
|
+
owner: string,
|
|
6
|
+
asset: string,
|
|
7
|
+
signer: Wallet
|
|
8
|
+
): Promise<BigNumber> => {
|
|
9
|
+
const block = await signer.provider.getBlockNumber();
|
|
10
|
+
const iERC20 = new Contract(asset, IERC20.abi, signer);
|
|
11
|
+
const [balanceBefore, balanceAfter] = await Promise.all(
|
|
12
|
+
[block - 1, block].map(e => iERC20.balanceOf(owner, { blockTag: e }))
|
|
13
|
+
);
|
|
14
|
+
return balanceAfter.sub(balanceBefore);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const allowanceDelta = async (
|
|
18
|
+
owner: string,
|
|
19
|
+
asset: string,
|
|
20
|
+
spender: string,
|
|
21
|
+
signer: Wallet
|
|
22
|
+
): Promise<BigNumber> => {
|
|
23
|
+
const block = await signer.provider.getBlockNumber();
|
|
24
|
+
const iERC20 = new Contract(asset, IERC20.abi, signer);
|
|
25
|
+
const [allowanceBefore, allowanceAfter] = await Promise.all(
|
|
26
|
+
[block - 1, block].map(e =>
|
|
27
|
+
iERC20.allowance(owner, spender, { blockTag: e })
|
|
28
|
+
)
|
|
29
|
+
);
|
|
30
|
+
return allowanceAfter.sub(allowanceBefore);
|
|
31
|
+
};
|