@dhedge/v2-sdk 1.9.7 → 1.9.9

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/README.md CHANGED
@@ -61,7 +61,7 @@ yarn add @dhedge/v2-sdk
61
61
  <a href="#uniswap-v3-style">Uniswap-v3 style protocols</a>
62
62
  </li>
63
63
  <li>
64
- <a href="#velodromev2--ramses">VelodromeV2 / Ramses</a>
64
+ <a href="#velodromev2--ramses">VelodromeV2 / Ramses / Aerodrome</a>
65
65
  </li>
66
66
  </ul>
67
67
  </li>
@@ -378,12 +378,12 @@ const result = await pool.increaseLiquidity(
378
378
  const tx = await pool.claimFees(Dapp.UNISWAPV3, tokenId);
379
379
  ```
380
380
 
381
- #### VelodromeV2 / Ramses
381
+ #### VelodromeV2 / Ramses / Aerodrome
382
382
 
383
- For VelodromeV2 / Ramses, we use `addLiquidityV2`, `stakeInGauge`, `unstakeFromGauge`, `removeLiquidityV2`, and `claimFees`.
383
+ For VelodromeV2 / Ramses / Aerodrome , we use `addLiquidityV2`, `stakeInGauge`, `unstakeFromGauge`, `removeLiquidityV2`, and `claimFees`.
384
384
 
385
385
  Add liquidity of 100 USDC and 0.00043 WETH to USDC/WETH Ramses pool
386
- (for Velodrome just use Dapp.VELODROMEV2). see example in the [arrakis test](https://github.com/dhedge/dhedge-v2-sdk/blob/master/src/test/ramses.test.ts) and [velodromeV2 test](https://github.com/dhedge/dhedge-v2-sdk/blob/master/src/test/velodromeV2.test.ts)
386
+ (for Velodrome just use Dapp.VELODROMEV2, for Aerodrome Dapp.AERODROME). see example in the [arrakis test](https://github.com/dhedge/dhedge-v2-sdk/blob/master/src/test/ramses.test.ts), [velodromeV2 test](https://github.com/dhedge/dhedge-v2-sdk/blob/master/src/test/velodromeV2.test.ts) and [aerdodrome test](https://github.com/dhedge/dhedge-v2-sdk/blob/master/src/test/aerdodrome.test.ts)
387
387
 
388
388
  ```ts
389
389
  const tx = await pool.addLiquidityV2(
@@ -427,3 +427,37 @@ const tx = await pool.borrow(Dapp.AAVE, WETH_TOKEN_ADDRESS, "100000000000000");
427
427
  ```ts
428
428
  const tx = await pool.repay(Dapp.AAVE, WETH_TOKEN_ADDRESS, "100000000000000");
429
429
  ```
430
+
431
+ <br>
432
+
433
+ ### The Flat Money Protocol
434
+
435
+ ---
436
+
437
+ ##### 1. Minting UNIT : deposit 1 rETH to mint UNIT
438
+
439
+ ```ts
440
+ const depositAmount = new BigNumber(1).times(1e18).toString();
441
+ const tx = await pool.mintUnitViaFlatMoney(
442
+ depositAmount,
443
+ 0.5, // slippage, 0.5%
444
+ 5, // maxKeeperFeeInUsd, $5
445
+ );
446
+ ```
447
+
448
+ ##### 2. Redeeming UNIT : Redeem 1 UNIT for rETH
449
+
450
+ ```ts
451
+ const withdrawAmount = new BigNumber(1).times(1e18).toString();
452
+ const tx = await pool.redeemUnitViaFlatMoney(
453
+ withdrawAmount,
454
+ 0.5, // slippage, 0.5%
455
+ 5, // maxKeeperFeeInUsd, $5
456
+ );
457
+ ```
458
+
459
+ ##### 3. Cancel announced order
460
+
461
+ ```ts
462
+ await pool.cancelOrderViaFlatMoney();
463
+ ```
package/dist/config.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AddressNetworkMap, AddressDappNetworkMap, LyraNetworkMap } from "./types";
1
+ import { AddressNetworkMap, Network, AddressDappNetworkMap, LyraNetworkMap } from "./types";
2
2
  import { NetworkChainIdMap } from ".";
3
3
  export declare const factoryAddress: AddressNetworkMap;
4
4
  export declare const routerAddress: AddressDappNetworkMap;
@@ -13,3 +13,9 @@ export declare const lyraNetworkMap: LyraNetworkMap;
13
13
  export declare const MaxUint128 = "0xffffffffffffffffffffffffffffffff";
14
14
  export declare const UNISWAPV3_QUOTER_ADDRESS = "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6";
15
15
  export declare const SYNTHETIX_TRACKING_CODE = "0x4448454447450000000000000000000000000000000000000000000000000000";
16
+ export declare const flatMoneyContractAddresses: Readonly<Partial<Record<Network, {
17
+ DelayedOrder: string;
18
+ FlatcoinVault: string;
19
+ StableModule: string;
20
+ RETH: string;
21
+ }>>>;
@@ -1,4 +1,4 @@
1
- import { Contract, Wallet, BigNumber } from "ethers";
1
+ import { Contract, ethers, Wallet, BigNumber } from "ethers";
2
2
  import { Dapp, FundComposition, AssetEnabled, Network, LyraOptionMarket, LyraOptionType, LyraTradeType, LyraPosition } from "../types";
3
3
  import { Utils } from "./utils";
4
4
  import { FeeAmount } from "@uniswap/v3-sdk";
@@ -368,7 +368,7 @@ export declare class Pool {
368
368
  removeLiquidityVelodromeV2(assetA: string, assetB: string, amount: BigNumber | string, isStable: boolean, options?: any, estimateGas?: boolean): Promise<any>;
369
369
  /**
370
370
  * Add liquidity to Velodrome V2 or Ramses pool
371
- * @param {Dapp} dapp VelodromeV2 or Ramses
371
+ * @param {Dapp} dapp VelodromeV2, Ramses or Aerodrome
372
372
  * @param {string} assetA First asset
373
373
  * @param {string} assetB Second asset
374
374
  * @param {BigNumber | string} amountA Amount first asset
@@ -378,10 +378,10 @@ export declare class Pool {
378
378
  * @param {boolean} estimateGas Simulate/estimate gas
379
379
  * @returns {Promise<any>} Transaction
380
380
  */
381
- addLiquidityV2(dapp: Dapp.VELODROMEV2 | Dapp.RAMSES, assetA: string, assetB: string, amountA: BigNumber | string, amountB: BigNumber | string, isStable: boolean, options?: any, estimateGas?: boolean): Promise<any>;
381
+ addLiquidityV2(dapp: Dapp.VELODROMEV2 | Dapp.RAMSES | Dapp.AERODROME, assetA: string, assetB: string, amountA: BigNumber | string, amountB: BigNumber | string, isStable: boolean, options?: any, estimateGas?: boolean): Promise<any>;
382
382
  /**
383
383
  * Remove liquidity from Velodrome V2 or Ramses pool
384
- * @param {Dapp} dapp VelodromeV2 or Ramses
384
+ * @param {Dapp} dapp VelodromeV2, Ramses or Aerodrome
385
385
  * @param {string} assetA First asset
386
386
  * @param {string} assetB Second asset
387
387
  * @param {BigNumber | string} amount Amount of LP tokens
@@ -390,7 +390,7 @@ export declare class Pool {
390
390
  * @param {boolean} estimateGas Simulate/estimate gas
391
391
  * @returns {Promise<any>} Transaction
392
392
  */
393
- removeLiquidityV2(dapp: Dapp.VELODROMEV2 | Dapp.RAMSES, assetA: string, assetB: string, amount: BigNumber | string, isStable: boolean, options?: any, estimateGas?: boolean): Promise<any>;
393
+ removeLiquidityV2(dapp: Dapp.VELODROMEV2 | Dapp.RAMSES | Dapp.AERODROME, assetA: string, assetB: string, amount: BigNumber | string, isStable: boolean, options?: any, estimateGas?: boolean): Promise<any>;
394
394
  /**
395
395
  * Trade options on lyra
396
396
  * @param {LyraOptionMarket} market Underlying market e.g. eth
@@ -468,4 +468,25 @@ export declare class Pool {
468
468
  * @returns {Promise<any>} Transaction
469
469
  */
470
470
  exitVestedToken(tokenAddress: string, id: number, options?: any, estimateGas?: boolean): Promise<any>;
471
+ /** deposit rETH to mint UNIT via the Flat Money protocol
472
+ *
473
+ * @param { BigNumber | string } depositAmount Amount of rETH to deposit
474
+ * @param { number } slippage slippage, 0.5 represents 0.5%
475
+ * @param { number | null } maxKeeperFeeInUsd 5 represents $5; null will skip the maxKeeperFee check
476
+ * @param {any} options Transaction options
477
+ * @param {boolean} estimateGas Simulate/estimate gas
478
+ * @returns {Promise<any>} Transaction
479
+ */
480
+ mintUnitViaFlatMoney(depositAmount: ethers.BigNumber | string, slippage: number | undefined, maxKeeperFeeInUsd: number | null, options?: any, estimateGas?: boolean): Promise<any>;
481
+ /** redeem UNIT via the Flat Money protocol
482
+ *
483
+ * @param { BigNumber | string } depositAmount Amount of UNIT to withdraw
484
+ * @param { number } slippage slippage, 0.5 represents 0.5%
485
+ * @param { number | null } maxKeeperFeeInUsd 5 represents $5; null will skip the maxKeeperFee check
486
+ * @param {any} options Transaction options
487
+ * @param {boolean} estimateGas Simulate/estimate gas
488
+ * @returns {Promise<any>} Transaction
489
+ */
490
+ redeemUnitViaFlatMoney(withdrawAmount: ethers.BigNumber | string, slippage: number | undefined, maxKeeperFeeInUsd: number | null, options?: any, estimateGas?: boolean): Promise<any>;
491
+ cancelOrderViaFlatMoney(options?: any, estimateGas?: boolean): Promise<any>;
471
492
  }
@@ -0,0 +1,6 @@
1
+ import { Contract, ethers } from "ethers";
2
+ import { Pool } from "../../entities";
3
+ import BigNumber from "bignumber.js";
4
+ export declare const getKeeperFeeContract: (pool: Pool) => Promise<Contract>;
5
+ export declare const getKeeperFee: (pool: Pool, maxKeeperFeeInUsd: number | null) => Promise<ethers.BigNumber>;
6
+ export declare const getKeeperFeeInUsd: (pool: Pool, keeperFee: ethers.BigNumber) => Promise<BigNumber>;
@@ -0,0 +1,9 @@
1
+ import { Pool, ethers } from "../..";
2
+ export declare function getAnnounceStableDepositTxData(depositAmount: ethers.BigNumber | string, minAmountOut: ethers.BigNumber | string, keeperFee: ethers.BigNumber | string): string;
3
+ export declare function getAnnounceStableWithdrawTxData(withdrawAmount: ethers.BigNumber | string, minAmountOut: ethers.BigNumber | string, keeperFee: ethers.BigNumber | string): string;
4
+ export declare function getCancelExistingOrderTxData(account: string): string;
5
+ export declare function mintUnitViaFlatMoney(pool: Pool, depositAmount: ethers.BigNumber | string, slippage: number, // 0.5 means 0.5%
6
+ maxKeeperFeeInUsd: number | null, options?: any, estimateGas?: boolean): Promise<any>;
7
+ export declare function redeemUnitViaFlatMoney(pool: Pool, withdrawAmount: ethers.BigNumber | string, slippage: number, // 0.5 means 0.5%
8
+ maxKeeperFeeInUsd: number | null, options?: any, estimateGas?: boolean): Promise<any>;
9
+ export declare function cancelOrderViaFlatMoney(pool: Pool, options?: any, estimateGas?: boolean): Promise<any>;
@@ -0,0 +1,4 @@
1
+ import { BigNumber } from "ethers";
2
+ import { Pool } from "../../entities";
3
+ export declare const getStableDepositQuote: (pool: Pool, depositAmount: string | BigNumber) => Promise<BigNumber>;
4
+ export declare const getStableWithdrawQuote: (pool: Pool, withdrawAmount: string | BigNumber) => Promise<BigNumber>;
@@ -5,6 +5,7 @@ export declare type TestingRunParams = {
5
5
  network: Network;
6
6
  wallet: ethers.Wallet;
7
7
  provider: ethers.providers.JsonRpcProvider;
8
+ rpcUrl: string;
8
9
  };
9
10
  declare type TestHelperParams = {
10
11
  testingRun: (testingRunParams: TestingRunParams) => void;
@@ -21,7 +22,7 @@ export declare const setTokenAmount: ({ amount, userAddress, tokenAddress, slot,
21
22
  amount: string;
22
23
  userAddress: string;
23
24
  tokenAddress: string;
24
- slot: number;
25
+ slot: number | string;
25
26
  provider: ethers.providers.JsonRpcProvider;
26
27
  }) => Promise<void>;
27
28
  export declare const setUSDCAmount: ({ provider, userAddress, amount, network }: {
@@ -10,4 +10,5 @@ export declare const networkPortMap: {
10
10
  export declare const getWalletData: (network: Network) => {
11
11
  wallet: ethers.Wallet;
12
12
  provider: ethers.providers.JsonRpcProvider;
13
+ rpcUrl: string;
13
14
  };
package/dist/types.d.ts CHANGED
@@ -21,7 +21,8 @@ export declare enum Dapp {
21
21
  VELODROMEV2 = "velodromeV2",
22
22
  LYRA = "lyra",
23
23
  ZEROEX = "0x",
24
- RAMSES = "ramses"
24
+ RAMSES = "ramses",
25
+ AERODROME = "aerodrome"
25
26
  }
26
27
  export declare enum Transaction {
27
28
  SWAP = "swapExactTokensForTokens",