@dhedge/v2-sdk 2.1.2 → 2.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhedge/v2-sdk",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "license": "MIT",
5
5
  "description": "🛠 An SDK for building applications on top of dHEDGE V2",
6
6
  "main": "dist/index.js",
@@ -825,6 +825,32 @@
825
825
  "outputs": [],
826
826
  "stateMutability": "nonpayable",
827
827
  "type": "function"
828
+ },
829
+ {
830
+ "inputs": [
831
+ {
832
+ "internalType": "uint256",
833
+ "name": "_maxSupplyCapD18",
834
+ "type": "uint256"
835
+ }
836
+ ],
837
+ "name": "setMaxSupplyCap",
838
+ "outputs": [],
839
+ "stateMutability": "nonpayable",
840
+ "type": "function"
841
+ },
842
+ {
843
+ "inputs": [],
844
+ "name": "maxSupplyCap",
845
+ "outputs": [
846
+ {
847
+ "internalType": "uint256",
848
+ "name": "",
849
+ "type": "uint256"
850
+ }
851
+ ],
852
+ "stateMutability": "view",
853
+ "type": "function"
828
854
  }
829
855
  ]
830
- }
856
+ }
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
- import { Contract, ethers, Wallet, BigNumber } from "ethers";
3
+ import { Contract, ethers, Wallet, BigNumber, BigNumberish } from "ethers";
4
4
 
5
5
  import IERC20 from "../abi/IERC20.json";
6
6
 
@@ -1025,6 +1025,31 @@ export class Pool {
1025
1025
  return tx;
1026
1026
  }
1027
1027
 
1028
+ /**
1029
+ * Sets max supply cap for a pool
1030
+ * @param {BigNumberish} _maxSupplyCapD18 Max supply cap with 18 decimals
1031
+ * @param {any} options Transaction options
1032
+ * @param {boolean} estimateGas Simulate/estimate gas
1033
+ * @returns {Promise<any>} Transaction
1034
+ */
1035
+ async setMaxCap(
1036
+ _maxSupplyCapD18: BigNumberish,
1037
+ options: any = null,
1038
+ estimateGas = false
1039
+ ): Promise<any> {
1040
+ if (estimateGas) {
1041
+ return await this.managerLogic.estimateGas.setMaxSupplyCap(
1042
+ _maxSupplyCapD18,
1043
+ options
1044
+ );
1045
+ }
1046
+ const tx = await this.managerLogic.setMaxSupplyCap(
1047
+ _maxSupplyCapD18,
1048
+ options
1049
+ );
1050
+ return tx;
1051
+ }
1052
+
1028
1053
  /**
1029
1054
  * Invest into a Balancer pool
1030
1055
  * @param {string} poolId Balancer pool id
@@ -1,16 +1,15 @@
1
+ import { BigNumber } from "ethers";
1
2
  import { Dhedge, Pool } from "..";
2
3
  import { Network } from "../types";
3
- import { CONTRACT_ADDRESS, TEST_POOL } from "./constants";
4
+ import { TEST_POOL } from "./constants";
4
5
 
5
6
  import { testingHelper, TestingRunParams } from "./utils/testingHelper";
6
- import { balanceDelta } from "./utils/token";
7
+ // import { balanceDelta } from "./utils/token";
7
8
 
8
- const testPool = ({ wallet, network }: TestingRunParams) => {
9
+ const testPool = ({ wallet, network, provider }: TestingRunParams) => {
9
10
  let dhedge: Dhedge;
10
11
  let pool: Pool;
11
12
 
12
- const USDT = CONTRACT_ADDRESS[network].USDT;
13
-
14
13
  jest.setTimeout(200000);
15
14
 
16
15
  describe(`pool on ${network}`, () => {
@@ -18,18 +17,31 @@ const testPool = ({ wallet, network }: TestingRunParams) => {
18
17
  dhedge = new Dhedge(wallet, network);
19
18
  pool = await dhedge.loadPool(TEST_POOL[network]);
20
19
 
21
- // await provider.send("hardhat_setBalance", [
22
- // wallet.address,
23
- // "0x10000000000000000"
24
- // ]);
20
+ await provider.send("hardhat_setBalance", [
21
+ wallet.address,
22
+ "0x10000000000000000"
23
+ ]);
25
24
  });
26
25
 
27
26
  it("checks fund composition", async () => {
28
27
  const result = await pool.getComposition();
29
- console.log(result);
28
+ // console.log(result);
30
29
  expect(result.length).toBeGreaterThan(0);
31
30
  });
32
31
 
32
+ it("sets max supply cap", async () => {
33
+ const totalSupply: BigNumber = await pool.poolLogic.totalSupply();
34
+ let initCap = totalSupply;
35
+ if (totalSupply.eq(0)) {
36
+ initCap = BigNumber.from(1000).mul(BigNumber.from(10).pow(18));
37
+ }
38
+ await pool.setMaxCap(initCap.mul(2), null, true);
39
+ const tx = await pool.setMaxCap(initCap.mul(2));
40
+ await tx.wait(1);
41
+ const maxCapAfter: BigNumber = await pool.managerLogic.maxSupplyCap();
42
+ expect(maxCapAfter).toEqual(initCap.mul(2));
43
+ });
44
+
33
45
  // it("sets pool private", async () => {
34
46
  // const result = await pool.setPrivate(true);
35
47
  // expect(result).not.toBeNull();
@@ -65,18 +77,18 @@ const testPool = ({ wallet, network }: TestingRunParams) => {
65
77
  // expect(usdtAllowanceDelta.gt(0));
66
78
  // });
67
79
 
68
- it("deposits 200 USDT into Pool", async () => {
69
- await pool.deposit(
70
- CONTRACT_ADDRESS[network].USDT,
71
- (200000000).toString()
72
- );
73
- const poolTokenDelta = await balanceDelta(
74
- pool.address,
75
- USDT,
76
- pool.signer
77
- );
78
- expect(poolTokenDelta.gt(0));
79
- });
80
+ // it("deposits 200 USDT into Pool", async () => {
81
+ // await pool.deposit(
82
+ // CONTRACT_ADDRESS[network].USDT,
83
+ // (200000000).toString()
84
+ // );
85
+ // const poolTokenDelta = await balanceDelta(
86
+ // pool.address,
87
+ // USDT,
88
+ // pool.signer
89
+ // );
90
+ // expect(poolTokenDelta.gt(0));
91
+ // });
80
92
 
81
93
  // it("get available Manager Fee", async () => {
82
94
  // const result = await pool.getAvailableManagerFee();
@@ -108,7 +120,6 @@ const testPool = ({ wallet, network }: TestingRunParams) => {
108
120
  // });
109
121
 
110
122
  testingHelper({
111
- network: Network.PLASMA,
112
- onFork: false,
123
+ network: Network.ARBITRUM,
113
124
  testingRun: testPool
114
125
  });