@dhedge/v2-sdk 1.9.8 → 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 +34 -0
- package/dist/config.d.ts +7 -1
- package/dist/entities/pool.d.ts +22 -1
- package/dist/services/flatmoney/keeperFee.d.ts +6 -0
- package/dist/services/flatmoney/stableLp.d.ts +9 -0
- package/dist/services/flatmoney/stableModule.d.ts +4 -0
- package/dist/test/utils/testingHelper.d.ts +2 -1
- package/dist/test/wallet.d.ts +1 -0
- package/dist/v2-sdk.cjs.development.js +2895 -1
- 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 +2895 -1
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/flatmoney/DelayedOrder.json +547 -0
- package/src/abi/flatmoney/IFlatcoinVault.json +570 -0
- package/src/abi/flatmoney/KeeperFee.json +364 -0
- package/src/abi/flatmoney/StableModule.json +770 -0
- package/src/config.ts +19 -0
- package/src/entities/pool.ts +67 -0
- package/src/services/flatmoney/keeperFee.ts +84 -0
- package/src/services/flatmoney/stableLp.ts +135 -0
- package/src/services/flatmoney/stableModule.ts +43 -0
- package/src/test/flatmoney.test.ts +164 -0
- package/src/test/utils/testingHelper.ts +4 -3
- package/src/test/wallet.ts +4 -1
package/README.md
CHANGED
|
@@ -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
|
+
}>>>;
|
package/dist/entities/pool.d.ts
CHANGED
|
@@ -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";
|
|
@@ -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 }: {
|