@dhedge/v2-sdk 2.2.0 → 2.2.2
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 +4 -1
- package/dist/config.d.ts +3 -0
- package/dist/entities/pool.d.ts +3 -1
- package/dist/services/dytm/index.d.ts +7 -0
- package/dist/services/ondo/index.d.ts +5 -0
- package/dist/services/toros/completeWithdrawal.d.ts +2 -2
- package/dist/services/toros/easySwapper.d.ts +4 -1
- package/dist/services/toros/initWithdrawal.d.ts +4 -1
- package/dist/types.d.ts +3 -1
- package/dist/v2-sdk.cjs.development.js +708 -119
- 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 +708 -119
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/dytm/IOffice.json +191 -0
- package/src/abi/ondo/IOndoGMSwap.json +30 -0
- package/src/config.ts +21 -2
- package/src/entities/pool.ts +76 -32
- package/src/services/dytm/index.ts +77 -0
- package/src/services/ondo/index.ts +142 -0
- package/src/services/toros/completeWithdrawal.ts +23 -7
- package/src/services/toros/easySwapper.ts +9 -7
- package/src/services/toros/initWithdrawal.ts +10 -6
- package/src/test/dytm.test.ts +241 -0
- package/src/test/ondo.onchain.test.ts +132 -0
- package/src/types.ts +3 -1
package/README.md
CHANGED
|
@@ -124,21 +124,24 @@ await vault.trade(Dapp.KYBERSWAP, "USDC_ADDRESS", "WETH_ADDRESS", "1000000", 0.5
|
|
|
124
124
|
|
|
125
125
|
---
|
|
126
126
|
|
|
127
|
-
If you want to use aggregators such as 1Inch or Odos, copy `.env.example` to `.env` and configure the API keys you need.
|
|
127
|
+
If you want to use aggregators such as 1Inch or Odos, or Ondo GM token swaps, copy `.env.example` to `.env` and configure the API keys you need.
|
|
128
128
|
|
|
129
129
|
```
|
|
130
130
|
ONEINCH_API_KEY=YOUR_API_KEY_FROM_1INCH
|
|
131
131
|
ODOS_API_KEY=YOUR_ODOS_API_KEY
|
|
132
|
+
ONDO_API_KEY=YOUR_ONDO_API_KEY
|
|
132
133
|
```
|
|
133
134
|
|
|
134
135
|
- `ONEINCH_API_KEY` is required for `Dapp.ONEINCH`
|
|
135
136
|
- `ODOS_API_KEY` is required for `Dapp.ODOS`
|
|
136
137
|
- `ODOS_API_KEY` can also be required by `completeTorosWithdrawal(...)` when a Toros withdrawal needs Odos-backed swap data
|
|
138
|
+
- `ONDO_API_KEY` is required for Ondo GM token swaps (`Dapp.ONDO`)
|
|
137
139
|
|
|
138
140
|
To get started:
|
|
139
141
|
|
|
140
142
|
- get a 1inch API key from the [1inch Developer Portal](https://docs.1inch.io/docs/aggregation-protocol/introduction)
|
|
141
143
|
- get an Odos API key via the [Odos developer docs](https://docs.odos.xyz/build/api-docs), and make sure it is valid for the Odos endpoint configured by this SDK
|
|
144
|
+
- get an Ondo API key by contacting [onboarding@ondo.finance](mailto:onboarding@ondo.finance)
|
|
142
145
|
- place the keys in a `.env` file at the project root before calling aggregator-backed methods
|
|
143
146
|
- if a required key is missing, the SDK will fail before transaction submission
|
|
144
147
|
|
package/dist/config.d.ts
CHANGED
package/dist/entities/pool.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Contract, ethers, Wallet, BigNumber, BigNumberish } from "ethers";
|
|
2
2
|
import { Dapp, FundComposition, AssetEnabled, Network, LyraOptionMarket, LyraOptionType, LyraTradeType, LyraPosition, SDKOptions, LimitOrderInfo } from "../types";
|
|
3
3
|
import { Utils } from "./utils";
|
|
4
|
+
import { TrackedAsset } from "../services/toros/completeWithdrawal";
|
|
4
5
|
export declare class Pool {
|
|
5
6
|
readonly poolLogic: Contract;
|
|
6
7
|
readonly managerLogic: Contract;
|
|
@@ -499,9 +500,10 @@ export declare class Pool {
|
|
|
499
500
|
* @param {number} slippage Slippage tolerance in %
|
|
500
501
|
* @param {any} options Transaction options
|
|
501
502
|
* @param {SDKOptions} sdkOptions SDK options including estimateGas
|
|
503
|
+
* @param {any} trackedAssets Tracked assets information (only for tx data generation)
|
|
502
504
|
* @returns {Promise<any>} Transaction
|
|
503
505
|
*/
|
|
504
|
-
completeTorosWithdrawal(destinationToken: string, slippage?: number, options?: any, sdkOptions?: SDKOptions): Promise<any>;
|
|
506
|
+
completeTorosWithdrawal(destinationToken: string, slippage?: number, options?: any, sdkOptions?: SDKOptions, trackedAssets?: TrackedAsset[]): Promise<any>;
|
|
505
507
|
/**
|
|
506
508
|
* Mint PT and YT tokens on Pendle
|
|
507
509
|
* @param {string} assetFrom Asset to mint from (only underlying asset)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import { Pool } from "../../entities";
|
|
3
|
+
export declare function toDebtId(key: ethers.BigNumber): ethers.BigNumber;
|
|
4
|
+
export declare const getDytmDepositTxData: (pool: Pool, asset: string, amount: ethers.BigNumber | string) => string;
|
|
5
|
+
export declare const getDytmBorrowTxData: (pool: Pool, asset: string, amount: ethers.BigNumber | string) => string;
|
|
6
|
+
export declare const getDytmRepayTxData: (pool: Pool, asset: string, amount: ethers.BigNumber | string) => Promise<string>;
|
|
7
|
+
export declare const getDytmWithdrawTxData: (pool: Pool, asset: string, amount: ethers.BigNumber | string) => Promise<string>;
|
|
@@ -3,5 +3,5 @@ export interface TrackedAsset {
|
|
|
3
3
|
token: string;
|
|
4
4
|
balance: ethers.BigNumber;
|
|
5
5
|
}
|
|
6
|
-
export declare const createCompleteWithdrawalTxArguments: (pool: Pool, receiveToken: string, slippage: number) => Promise<any>;
|
|
7
|
-
export declare const getCompleteWithdrawalTxData: (pool: Pool, receiveToken: string, slippage: number, useOnChainSwap: boolean) => Promise<string>;
|
|
6
|
+
export declare const createCompleteWithdrawalTxArguments: (pool: Pool, receiveToken: string, slippage: number, _trackedAssets: TrackedAsset[]) => Promise<any>;
|
|
7
|
+
export declare const getCompleteWithdrawalTxData: (pool: Pool, receiveToken: string, slippage: number, useOnChainSwap: boolean, trackedAssets: TrackedAsset[]) => Promise<string>;
|
|
@@ -19,4 +19,7 @@ export declare function getEasySwapperDepositQuote(pool: Pool, torosAsset: strin
|
|
|
19
19
|
* If `assetFrom` is a Toros pool, this is treated as a withdrawal and routes through
|
|
20
20
|
* `getInitWithdrawalTxData`. Otherwise it builds a `depositWithCustomCooldown` call.
|
|
21
21
|
*/
|
|
22
|
-
export declare function getEasySwapperTxData(pool: Pool, assetFrom: string, assetTo: string, amountIn: ethers.BigNumber, slippage: number): Promise<
|
|
22
|
+
export declare function getEasySwapperTxData(pool: Pool, assetFrom: string, assetTo: string, amountIn: ethers.BigNumber, slippage: number): Promise<{
|
|
23
|
+
swapTxData: string;
|
|
24
|
+
minAmountOut?: any;
|
|
25
|
+
}>;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { Pool } from "../..";
|
|
2
2
|
export declare const createWithdrawTxArguments: (pool: Pool, torosAsset: string, amountIn: string, slippage: number, useOnChainSwap: boolean) => Promise<any>;
|
|
3
|
-
export declare const getInitWithdrawalTxData: (pool: Pool, torosAsset: string, amountIn: string, slippage: number, useOnChainSwap: boolean) => Promise<
|
|
3
|
+
export declare const getInitWithdrawalTxData: (pool: Pool, torosAsset: string, amountIn: string, slippage: number, useOnChainSwap: boolean) => Promise<{
|
|
4
|
+
swapTxData: string;
|
|
5
|
+
minAmountOut?: any;
|
|
6
|
+
}>;
|
package/dist/types.d.ts
CHANGED
|
@@ -34,8 +34,10 @@ export declare enum Dapp {
|
|
|
34
34
|
ODOS = "odos",
|
|
35
35
|
PENDLE = "pendle",
|
|
36
36
|
KYBERSWAP = "kyberswap",
|
|
37
|
+
DYTM = "dytm",
|
|
37
38
|
HYPERLIQUID = "hyperliquid",
|
|
38
|
-
COWSWAP = "cowswap"
|
|
39
|
+
COWSWAP = "cowswap",
|
|
40
|
+
ONDO = "ondo"
|
|
39
41
|
}
|
|
40
42
|
/** Function-name strings used when encoding ABI calls — keep in sync with the
|
|
41
43
|
* matching ABI files in `src/abi/`. */
|