@dhedge/v2-sdk 1.8.3 → 1.9.0
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 +7 -0
- package/dist/entities/pool.d.ts +7 -0
- package/dist/services/futures/trade.d.ts +1 -0
- package/dist/test/constants.d.ts +9 -2
- package/dist/test/utils/futures.d.ts +2 -0
- package/dist/types.d.ts +2 -1
- package/dist/v2-sdk.cjs.development.js +115 -36
- 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 +115 -36
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +3 -2
- package/src/config.ts +23 -7
- package/src/entities/pool.ts +18 -1
- package/src/services/futures/trade.ts +6 -0
- package/src/test/aave.test.ts +71 -112
- package/src/test/balancer.test.ts +108 -200
- package/src/test/constants.ts +11 -4
- package/src/test/futures.test.ts +5 -2
- package/src/test/oneInch.test.ts +4 -3
- package/src/test/utils/futures.ts +14 -0
- package/src/test/wallet.ts +1 -1
- package/src/types.ts +2 -1
package/README.md
CHANGED
|
@@ -28,6 +28,13 @@ yarn add @dhedge/v2-sdk
|
|
|
28
28
|
|
|
29
29
|
### Initial setup
|
|
30
30
|
|
|
31
|
+
If you want to use 1Inch to trade pool assets you need to apply for an enterprise endpoint at [1Inch](https://docs.1inch.io/docs/aggregation-protocol/introduction).
|
|
32
|
+
Then you need to copy .env.example file to .env and set your url there.
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
ONEINCH_API_URL=https://my-personal-url.1inch.io/v5.0
|
|
36
|
+
```
|
|
37
|
+
|
|
31
38
|
Initialize the sdk with an [ethers wallet](https://docs.ethers.io/v5/api/signer/#Wallet) and the network.
|
|
32
39
|
|
|
33
40
|
```
|
package/dist/entities/pool.d.ts
CHANGED
|
@@ -347,4 +347,11 @@ export declare class Pool {
|
|
|
347
347
|
* @returns {Promise<any>} Transaction
|
|
348
348
|
*/
|
|
349
349
|
changeFuturesPosition(market: string, changeAmount: BigNumber | string, options?: any): Promise<any>;
|
|
350
|
+
/** Cancels an open oder on Synthetix futures market
|
|
351
|
+
*
|
|
352
|
+
* @param {string} market Address of futures market
|
|
353
|
+
* @param {any} options Transaction options
|
|
354
|
+
* @returns {Promise<any>} Transaction
|
|
355
|
+
*/
|
|
356
|
+
cancelFuturesOrder(market: string, options?: any): Promise<any>;
|
|
350
357
|
}
|
package/dist/test/constants.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare const KWENTA_ETH_PERP_V2 = "0x2b3bb4c683bfc5239b029131eef3b1d2144
|
|
|
16
16
|
export declare const TEST_POOL: {
|
|
17
17
|
polygon: string;
|
|
18
18
|
optimism: string;
|
|
19
|
+
arbitrum: string;
|
|
19
20
|
};
|
|
20
21
|
export declare const CONTRACT_ADDRESS: {
|
|
21
22
|
polygon: {
|
|
@@ -30,8 +31,14 @@ export declare const CONTRACT_ADDRESS: {
|
|
|
30
31
|
SUSD: string;
|
|
31
32
|
WETH: string;
|
|
32
33
|
KWENTA_ETH_PERP_V2: string;
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
};
|
|
35
|
+
arbitrum: {
|
|
36
|
+
USDC: string;
|
|
37
|
+
WETH: string;
|
|
38
|
+
WBTC: string;
|
|
39
|
+
WSTETH: string;
|
|
40
|
+
BALANCER_WSTETH_WETH_POOL: string;
|
|
41
|
+
BALANCER_WSTETH_WETH_GAUGE: string;
|
|
35
42
|
};
|
|
36
43
|
};
|
|
37
44
|
export declare const MAX_AMOUNT: ethers.BigNumber;
|
package/dist/types.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { Deployment } from "@lyrafinance/lyra-js";
|
|
|
2
2
|
import { BigNumber } from "ethers";
|
|
3
3
|
export declare enum Network {
|
|
4
4
|
POLYGON = "polygon",
|
|
5
|
-
OPTIMISM = "optimism"
|
|
5
|
+
OPTIMISM = "optimism",
|
|
6
|
+
ARBITRUM = "arbitrum"
|
|
6
7
|
}
|
|
7
8
|
export declare enum Dapp {
|
|
8
9
|
SUSHISWAP = "sushiswap",
|
|
@@ -3807,6 +3807,7 @@ var ManagerLogic = {
|
|
|
3807
3807
|
(function (Network) {
|
|
3808
3808
|
Network["POLYGON"] = "polygon";
|
|
3809
3809
|
Network["OPTIMISM"] = "optimism";
|
|
3810
|
+
Network["ARBITRUM"] = "arbitrum";
|
|
3810
3811
|
})(exports.Network || (exports.Network = {}));
|
|
3811
3812
|
|
|
3812
3813
|
(function (Dapp) {
|
|
@@ -3846,19 +3847,19 @@ var ManagerLogic = {
|
|
|
3846
3847
|
Transaction["REMOVE_LIQUIDITY_UNSTAKE"] = "removeLiquidityAndUnstake";
|
|
3847
3848
|
})(exports.Transaction || (exports.Transaction = {}));
|
|
3848
3849
|
|
|
3849
|
-
var _factoryAddress, _Network$POLYGON, _Network$OPTIMISM, _routerAddress, _Network$POLYGON2, _dappFactoryAddress, _Network$POLYGON3, _stakingAddress, _Network$POLYGON4, _Network$OPTIMISM2, _aaveAddressProvider, _nonfungiblePositionM, _networkChainIdMap, _balancerSubgraph, _multiCallAddress, _lyraNetworkMap;
|
|
3850
|
+
var _factoryAddress, _Network$POLYGON, _Network$OPTIMISM, _Network$ARBITRUM, _routerAddress, _Network$POLYGON2, _dappFactoryAddress, _Network$POLYGON3, _stakingAddress, _Network$POLYGON4, _Network$OPTIMISM2, _Network$ARBITRUM2, _aaveAddressProvider, _nonfungiblePositionM, _networkChainIdMap, _balancerSubgraph, _multiCallAddress, _lyraNetworkMap;
|
|
3850
3851
|
|
|
3851
3852
|
require("dotenv").config();
|
|
3852
3853
|
|
|
3853
|
-
var factoryAddress = (_factoryAddress = {}, _factoryAddress[exports.Network.POLYGON] = process.env.STAGING_CONTRACTS ? "0xDd87eCdB10cFF7004276AAbAbd30e7a08F69bb53" : "0xfdc7b8bFe0DD3513Cc669bB8d601Cb83e2F69cB0", _factoryAddress[exports.Network.OPTIMISM] = "0x5e61a079A178f0E5784107a4963baAe0c5a680c6", _factoryAddress);
|
|
3854
|
-
var routerAddress = (_routerAddress = {}, _routerAddress[exports.Network.POLYGON] = (_Network$POLYGON = {}, _Network$POLYGON[exports.Dapp.SUSHISWAP] = "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506", _Network$POLYGON[exports.Dapp.AAVE] = "0x8dFf5E27EA6b7AC08EbFdf9eB090F32ee9a30fcf", _Network$POLYGON[exports.Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$POLYGON[exports.Dapp.ONEINCH] = "0x1111111254EEB25477B68fb85Ed929f73A960582", _Network$POLYGON[exports.Dapp.QUICKSWAP] = "0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff", _Network$POLYGON[exports.Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$POLYGON[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$POLYGON[exports.Dapp.ARRAKIS] = "0xc73fb100a995b33f9fa181d420f4c8d74506df66", _Network$POLYGON[exports.Dapp.TOROS] = "0xB2F1498983bf9c9442c35F772e6C1AdE66a8DeDE", _Network$POLYGON), _routerAddress[exports.Network.OPTIMISM] = (_Network$OPTIMISM = {}, _Network$OPTIMISM[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$OPTIMISM[exports.Dapp.SYNTHETIX] = "0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4", _Network$OPTIMISM[exports.Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$OPTIMISM[exports.Dapp.ONEINCH] = "0x1111111254EEB25477B68fb85Ed929f73A960582", _Network$OPTIMISM[exports.Dapp.TOROS] = "0x3988513793bCE39f0167064A9F7fC3617FaF35AB", _Network$OPTIMISM[exports.Dapp.VELODROME] = "0x9c12939390052919aF3155f41Bf4160Fd3666A6f", _Network$OPTIMISM[exports.Dapp.LYRA] = "0xCCE7819d65f348c64B7Beb205BA367b3fE33763B", _Network$OPTIMISM[exports.Dapp.ARRAKIS] = "0x9ce88a56d120300061593eF7AD074A1B710094d5", _Network$OPTIMISM), _routerAddress);
|
|
3855
|
-
var dappFactoryAddress = (_dappFactoryAddress = {}, _dappFactoryAddress[exports.Network.POLYGON] = (_Network$POLYGON2 = {}, _Network$POLYGON2[exports.Dapp.SUSHISWAP] = "0xc35DADB65012eC5796536bD9864eD8773aBc74C4", _Network$POLYGON2[exports.Dapp.QUICKSWAP] = "0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32", _Network$POLYGON2), _dappFactoryAddress[exports.Network.OPTIMISM] = {}, _dappFactoryAddress);
|
|
3856
|
-
var stakingAddress = (_stakingAddress = {}, _stakingAddress[exports.Network.POLYGON] = (_Network$POLYGON3 = {}, _Network$POLYGON3[exports.Dapp.SUSHISWAP] = "0x0769fd68dFb93167989C6f7254cd0D766Fb2841F", _Network$POLYGON3[exports.Dapp.BALANCER] = "0x0F3e0c4218b7b0108a3643cFe9D3ec0d4F57c54e", _Network$POLYGON3[exports.Dapp.AAVE] = "0x357D51124f59836DeD84c8a1730D72B749d8BC23", _Network$POLYGON3[exports.Dapp.AAVEV3] = "0x929EC64c34a17401F460460D4B9390518E5B473e", _Network$POLYGON3), _stakingAddress[exports.Network.OPTIMISM] = {}, _stakingAddress);
|
|
3857
|
-
var aaveAddressProvider = (_aaveAddressProvider = {}, _aaveAddressProvider[exports.Network.POLYGON] = (_Network$POLYGON4 = {}, _Network$POLYGON4[exports.Dapp.AAVE] = "0xd05e3E715d945B59290df0ae8eF85c1BdB684744", _Network$POLYGON4[exports.Dapp.AAVEV3] = "0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb", _Network$POLYGON4), _aaveAddressProvider[exports.Network.OPTIMISM] = (_Network$OPTIMISM2 = {}, _Network$OPTIMISM2[exports.Dapp.AAVEV3] = "0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb", _Network$OPTIMISM2), _aaveAddressProvider);
|
|
3858
|
-
var nonfungiblePositionManagerAddress = (_nonfungiblePositionM = {}, _nonfungiblePositionM[exports.Network.POLYGON] = "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", _nonfungiblePositionM[exports.Network.OPTIMISM] = "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", _nonfungiblePositionM);
|
|
3859
|
-
var networkChainIdMap = (_networkChainIdMap = {}, _networkChainIdMap[exports.Network.POLYGON] = 137, _networkChainIdMap[exports.Network.OPTIMISM] = 10, _networkChainIdMap);
|
|
3860
|
-
var balancerSubgraph = (_balancerSubgraph = {}, _balancerSubgraph[exports.Network.POLYGON] = "https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-polygon-v2", _balancerSubgraph[exports.Network.OPTIMISM] = "", _balancerSubgraph);
|
|
3861
|
-
var multiCallAddress = (_multiCallAddress = {}, _multiCallAddress[exports.Network.POLYGON] = "0x275617327c958bD06b5D6b871E7f491D76113dd8", _multiCallAddress[exports.Network.OPTIMISM] = "", _multiCallAddress);
|
|
3854
|
+
var factoryAddress = (_factoryAddress = {}, _factoryAddress[exports.Network.POLYGON] = process.env.STAGING_CONTRACTS ? "0xDd87eCdB10cFF7004276AAbAbd30e7a08F69bb53" : "0xfdc7b8bFe0DD3513Cc669bB8d601Cb83e2F69cB0", _factoryAddress[exports.Network.OPTIMISM] = "0x5e61a079A178f0E5784107a4963baAe0c5a680c6", _factoryAddress[exports.Network.ARBITRUM] = "0xfffb5fb14606eb3a548c113026355020ddf27535", _factoryAddress);
|
|
3855
|
+
var routerAddress = (_routerAddress = {}, _routerAddress[exports.Network.POLYGON] = (_Network$POLYGON = {}, _Network$POLYGON[exports.Dapp.SUSHISWAP] = "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506", _Network$POLYGON[exports.Dapp.AAVE] = "0x8dFf5E27EA6b7AC08EbFdf9eB090F32ee9a30fcf", _Network$POLYGON[exports.Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$POLYGON[exports.Dapp.ONEINCH] = "0x1111111254EEB25477B68fb85Ed929f73A960582", _Network$POLYGON[exports.Dapp.QUICKSWAP] = "0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff", _Network$POLYGON[exports.Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$POLYGON[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$POLYGON[exports.Dapp.ARRAKIS] = "0xc73fb100a995b33f9fa181d420f4c8d74506df66", _Network$POLYGON[exports.Dapp.TOROS] = "0xB2F1498983bf9c9442c35F772e6C1AdE66a8DeDE", _Network$POLYGON), _routerAddress[exports.Network.OPTIMISM] = (_Network$OPTIMISM = {}, _Network$OPTIMISM[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$OPTIMISM[exports.Dapp.SYNTHETIX] = "0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4", _Network$OPTIMISM[exports.Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$OPTIMISM[exports.Dapp.ONEINCH] = "0x1111111254EEB25477B68fb85Ed929f73A960582", _Network$OPTIMISM[exports.Dapp.TOROS] = "0x3988513793bCE39f0167064A9F7fC3617FaF35AB", _Network$OPTIMISM[exports.Dapp.VELODROME] = "0x9c12939390052919aF3155f41Bf4160Fd3666A6f", _Network$OPTIMISM[exports.Dapp.LYRA] = "0xCCE7819d65f348c64B7Beb205BA367b3fE33763B", _Network$OPTIMISM[exports.Dapp.ARRAKIS] = "0x9ce88a56d120300061593eF7AD074A1B710094d5", _Network$OPTIMISM), _routerAddress[exports.Network.ARBITRUM] = (_Network$ARBITRUM = {}, _Network$ARBITRUM[exports.Dapp.ONEINCH] = "0x1111111254EEB25477B68fb85Ed929f73A960582", _Network$ARBITRUM[exports.Dapp.UNISWAPV3] = "0xe592427a0aece92de3edee1f18e0157c05861564", _Network$ARBITRUM[exports.Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$ARBITRUM[exports.Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$ARBITRUM), _routerAddress);
|
|
3856
|
+
var dappFactoryAddress = (_dappFactoryAddress = {}, _dappFactoryAddress[exports.Network.POLYGON] = (_Network$POLYGON2 = {}, _Network$POLYGON2[exports.Dapp.SUSHISWAP] = "0xc35DADB65012eC5796536bD9864eD8773aBc74C4", _Network$POLYGON2[exports.Dapp.QUICKSWAP] = "0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32", _Network$POLYGON2), _dappFactoryAddress[exports.Network.OPTIMISM] = {}, _dappFactoryAddress[exports.Network.ARBITRUM] = {}, _dappFactoryAddress);
|
|
3857
|
+
var stakingAddress = (_stakingAddress = {}, _stakingAddress[exports.Network.POLYGON] = (_Network$POLYGON3 = {}, _Network$POLYGON3[exports.Dapp.SUSHISWAP] = "0x0769fd68dFb93167989C6f7254cd0D766Fb2841F", _Network$POLYGON3[exports.Dapp.BALANCER] = "0x0F3e0c4218b7b0108a3643cFe9D3ec0d4F57c54e", _Network$POLYGON3[exports.Dapp.AAVE] = "0x357D51124f59836DeD84c8a1730D72B749d8BC23", _Network$POLYGON3[exports.Dapp.AAVEV3] = "0x929EC64c34a17401F460460D4B9390518E5B473e", _Network$POLYGON3), _stakingAddress[exports.Network.OPTIMISM] = {}, _stakingAddress[exports.Network.ARBITRUM] = {}, _stakingAddress);
|
|
3858
|
+
var aaveAddressProvider = (_aaveAddressProvider = {}, _aaveAddressProvider[exports.Network.POLYGON] = (_Network$POLYGON4 = {}, _Network$POLYGON4[exports.Dapp.AAVE] = "0xd05e3E715d945B59290df0ae8eF85c1BdB684744", _Network$POLYGON4[exports.Dapp.AAVEV3] = "0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb", _Network$POLYGON4), _aaveAddressProvider[exports.Network.OPTIMISM] = (_Network$OPTIMISM2 = {}, _Network$OPTIMISM2[exports.Dapp.AAVEV3] = "0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb", _Network$OPTIMISM2), _aaveAddressProvider[exports.Network.ARBITRUM] = (_Network$ARBITRUM2 = {}, _Network$ARBITRUM2[exports.Dapp.AAVEV3] = "0xa97684ead0e402dc232d5a977953df7ecbab3cdb", _Network$ARBITRUM2), _aaveAddressProvider);
|
|
3859
|
+
var nonfungiblePositionManagerAddress = (_nonfungiblePositionM = {}, _nonfungiblePositionM[exports.Network.POLYGON] = "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", _nonfungiblePositionM[exports.Network.OPTIMISM] = "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", _nonfungiblePositionM[exports.Network.ARBITRUM] = "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", _nonfungiblePositionM);
|
|
3860
|
+
var networkChainIdMap = (_networkChainIdMap = {}, _networkChainIdMap[exports.Network.POLYGON] = 137, _networkChainIdMap[exports.Network.OPTIMISM] = 10, _networkChainIdMap[exports.Network.ARBITRUM] = 42161, _networkChainIdMap);
|
|
3861
|
+
var balancerSubgraph = (_balancerSubgraph = {}, _balancerSubgraph[exports.Network.POLYGON] = "https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-polygon-v2", _balancerSubgraph[exports.Network.OPTIMISM] = "", _balancerSubgraph[exports.Network.ARBITRUM] = "", _balancerSubgraph);
|
|
3862
|
+
var multiCallAddress = (_multiCallAddress = {}, _multiCallAddress[exports.Network.POLYGON] = "0x275617327c958bD06b5D6b871E7f491D76113dd8", _multiCallAddress[exports.Network.OPTIMISM] = "", _multiCallAddress[exports.Network.ARBITRUM] = "", _multiCallAddress);
|
|
3862
3863
|
var lyraNetworkMap = (_lyraNetworkMap = {}, _lyraNetworkMap[exports.Network.OPTIMISM] = Lyra.Deployment.Mainnet, _lyraNetworkMap);
|
|
3863
3864
|
var MaxUint128 = "0xffffffffffffffffffffffffffffffff";
|
|
3864
3865
|
var UNISWAPV3_QUOTER_ADDRESS = "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6";
|
|
@@ -19182,6 +19183,28 @@ function _getFuturesChangePositionTxData() {
|
|
|
19182
19183
|
return _getFuturesChangePositionTxData.apply(this, arguments);
|
|
19183
19184
|
}
|
|
19184
19185
|
|
|
19186
|
+
function getFuturesCancelOrderTxData(_x4) {
|
|
19187
|
+
return _getFuturesCancelOrderTxData.apply(this, arguments);
|
|
19188
|
+
}
|
|
19189
|
+
|
|
19190
|
+
function _getFuturesCancelOrderTxData() {
|
|
19191
|
+
_getFuturesCancelOrderTxData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(pool) {
|
|
19192
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
19193
|
+
while (1) {
|
|
19194
|
+
switch (_context2.prev = _context2.next) {
|
|
19195
|
+
case 0:
|
|
19196
|
+
return _context2.abrupt("return", new ethers.ethers.utils.Interface(ISynthetixFuturesMarketV2.abi).encodeFunctionData("cancelOffchainDelayedOrder", [pool.address]));
|
|
19197
|
+
|
|
19198
|
+
case 1:
|
|
19199
|
+
case "end":
|
|
19200
|
+
return _context2.stop();
|
|
19201
|
+
}
|
|
19202
|
+
}
|
|
19203
|
+
}, _callee2);
|
|
19204
|
+
}));
|
|
19205
|
+
return _getFuturesCancelOrderTxData.apply(this, arguments);
|
|
19206
|
+
}
|
|
19207
|
+
|
|
19185
19208
|
var Pool = /*#__PURE__*/function () {
|
|
19186
19209
|
function Pool(network, signer, poolLogic, mangerLogic, utils, factory) {
|
|
19187
19210
|
this.network = network;
|
|
@@ -19585,7 +19608,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
19585
19608
|
}
|
|
19586
19609
|
|
|
19587
19610
|
_context9.t0 = dapp;
|
|
19588
|
-
_context9.next = _context9.t0 === exports.Dapp.ONEINCH ? 5 : _context9.t0 === exports.Dapp.BALANCER ?
|
|
19611
|
+
_context9.next = _context9.t0 === exports.Dapp.ONEINCH ? 5 : _context9.t0 === exports.Dapp.BALANCER ? 17 : _context9.t0 === exports.Dapp.SYNTHETIX ? 21 : _context9.t0 === exports.Dapp.TOROS ? 28 : 32;
|
|
19589
19612
|
break;
|
|
19590
19613
|
|
|
19591
19614
|
case 5:
|
|
@@ -19595,50 +19618,59 @@ var Pool = /*#__PURE__*/function () {
|
|
|
19595
19618
|
|
|
19596
19619
|
case 8:
|
|
19597
19620
|
protocols = _context9.sent;
|
|
19598
|
-
|
|
19599
|
-
|
|
19621
|
+
|
|
19622
|
+
if (process.env.ONEINCH_API_URL) {
|
|
19623
|
+
_context9.next = 11;
|
|
19624
|
+
break;
|
|
19625
|
+
}
|
|
19626
|
+
|
|
19627
|
+
throw new Error("ONEINCH_API_URL not configured in .env file");
|
|
19628
|
+
|
|
19629
|
+
case 11:
|
|
19630
|
+
apiUrl = process.env.ONEINCH_API_URL + "/" + chainId + "/swap?fromTokenAddress=" + assetFrom + "&toTokenAddress=" + assetTo + "&amount=" + amountIn.toString() + "&fromAddress=" + this.address + "&destReceiver=" + this.address + "&slippage=" + slippage.toString() + "&disableEstimate=true" + protocols;
|
|
19631
|
+
_context9.next = 14;
|
|
19600
19632
|
return axios.get(apiUrl);
|
|
19601
19633
|
|
|
19602
|
-
case
|
|
19634
|
+
case 14:
|
|
19603
19635
|
response = _context9.sent;
|
|
19604
19636
|
swapTxData = response.data.tx.data;
|
|
19605
|
-
return _context9.abrupt("break",
|
|
19637
|
+
return _context9.abrupt("break", 47);
|
|
19606
19638
|
|
|
19607
|
-
case
|
|
19608
|
-
_context9.next =
|
|
19639
|
+
case 17:
|
|
19640
|
+
_context9.next = 19;
|
|
19609
19641
|
return this.utils.getBalancerSwapTx(this, assetFrom, assetTo, amountIn, slippage);
|
|
19610
19642
|
|
|
19611
|
-
case
|
|
19643
|
+
case 19:
|
|
19612
19644
|
swapTxData = _context9.sent;
|
|
19613
|
-
return _context9.abrupt("break",
|
|
19645
|
+
return _context9.abrupt("break", 47);
|
|
19614
19646
|
|
|
19615
|
-
case
|
|
19647
|
+
case 21:
|
|
19616
19648
|
iSynthetix = new ethers.ethers.utils.Interface(ISynthetix.abi);
|
|
19617
19649
|
assets = [assetFrom, assetTo].map(function (asset) {
|
|
19618
19650
|
return ethers.ethers.utils.formatBytes32String(asset);
|
|
19619
19651
|
});
|
|
19620
|
-
_context9.next =
|
|
19652
|
+
_context9.next = 25;
|
|
19621
19653
|
return this.factory.owner();
|
|
19622
19654
|
|
|
19623
|
-
case
|
|
19655
|
+
case 25:
|
|
19624
19656
|
daoAddress = _context9.sent;
|
|
19625
19657
|
swapTxData = iSynthetix.encodeFunctionData(exports.Transaction.SWAP_SYNTHS, [assets[0], amountIn, assets[1], daoAddress, SYNTHETIX_TRACKING_CODE]);
|
|
19626
|
-
return _context9.abrupt("break",
|
|
19658
|
+
return _context9.abrupt("break", 47);
|
|
19627
19659
|
|
|
19628
|
-
case
|
|
19629
|
-
_context9.next =
|
|
19660
|
+
case 28:
|
|
19661
|
+
_context9.next = 30;
|
|
19630
19662
|
return getEasySwapperTxData(this, assetFrom, assetTo, ethers.ethers.BigNumber.from(amountIn), slippage);
|
|
19631
19663
|
|
|
19632
|
-
case
|
|
19664
|
+
case 30:
|
|
19633
19665
|
swapTxData = _context9.sent;
|
|
19634
|
-
return _context9.abrupt("break",
|
|
19666
|
+
return _context9.abrupt("break", 47);
|
|
19635
19667
|
|
|
19636
|
-
case
|
|
19668
|
+
case 32:
|
|
19637
19669
|
iUniswapV2Router = new ethers.ethers.utils.Interface(IUniswapV2Router.abi);
|
|
19638
|
-
_context9.next =
|
|
19670
|
+
_context9.next = 35;
|
|
19639
19671
|
return this.utils.getMinAmountOut(dapp, assetFrom, assetTo, amountIn, slippage);
|
|
19640
19672
|
|
|
19641
|
-
case
|
|
19673
|
+
case 35:
|
|
19642
19674
|
minAmountOut = _context9.sent;
|
|
19643
19675
|
_context9.t1 = iUniswapV2Router;
|
|
19644
19676
|
_context9.t2 = exports.Transaction.SWAP;
|
|
@@ -19646,23 +19678,23 @@ var Pool = /*#__PURE__*/function () {
|
|
|
19646
19678
|
_context9.t4 = minAmountOut;
|
|
19647
19679
|
_context9.t5 = [assetFrom, assetTo];
|
|
19648
19680
|
_context9.t6 = this.address;
|
|
19649
|
-
_context9.next =
|
|
19681
|
+
_context9.next = 44;
|
|
19650
19682
|
return getDeadline(this);
|
|
19651
19683
|
|
|
19652
|
-
case
|
|
19684
|
+
case 44:
|
|
19653
19685
|
_context9.t7 = _context9.sent;
|
|
19654
19686
|
_context9.t8 = [_context9.t3, _context9.t4, _context9.t5, _context9.t6, _context9.t7];
|
|
19655
19687
|
swapTxData = _context9.t1.encodeFunctionData.call(_context9.t1, _context9.t2, _context9.t8);
|
|
19656
19688
|
|
|
19657
|
-
case
|
|
19658
|
-
_context9.next =
|
|
19689
|
+
case 47:
|
|
19690
|
+
_context9.next = 49;
|
|
19659
19691
|
return this.poolLogic.execTransaction(routerAddress[this.network][dapp], swapTxData, options);
|
|
19660
19692
|
|
|
19661
|
-
case
|
|
19693
|
+
case 49:
|
|
19662
19694
|
tx = _context9.sent;
|
|
19663
19695
|
return _context9.abrupt("return", tx);
|
|
19664
19696
|
|
|
19665
|
-
case
|
|
19697
|
+
case 51:
|
|
19666
19698
|
case "end":
|
|
19667
19699
|
return _context9.stop();
|
|
19668
19700
|
}
|
|
@@ -21217,6 +21249,53 @@ var Pool = /*#__PURE__*/function () {
|
|
|
21217
21249
|
}
|
|
21218
21250
|
|
|
21219
21251
|
return changeFuturesPosition;
|
|
21252
|
+
}()
|
|
21253
|
+
/** Cancels an open oder on Synthetix futures market
|
|
21254
|
+
*
|
|
21255
|
+
* @param {string} market Address of futures market
|
|
21256
|
+
* @param {any} options Transaction options
|
|
21257
|
+
* @returns {Promise<any>} Transaction
|
|
21258
|
+
*/
|
|
21259
|
+
;
|
|
21260
|
+
|
|
21261
|
+
_proto.cancelFuturesOrder =
|
|
21262
|
+
/*#__PURE__*/
|
|
21263
|
+
function () {
|
|
21264
|
+
var _cancelFuturesOrder = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee38(market, options) {
|
|
21265
|
+
var txData, tx;
|
|
21266
|
+
return runtime_1.wrap(function _callee38$(_context38) {
|
|
21267
|
+
while (1) {
|
|
21268
|
+
switch (_context38.prev = _context38.next) {
|
|
21269
|
+
case 0:
|
|
21270
|
+
if (options === void 0) {
|
|
21271
|
+
options = null;
|
|
21272
|
+
}
|
|
21273
|
+
|
|
21274
|
+
_context38.next = 3;
|
|
21275
|
+
return getFuturesCancelOrderTxData(this);
|
|
21276
|
+
|
|
21277
|
+
case 3:
|
|
21278
|
+
txData = _context38.sent;
|
|
21279
|
+
_context38.next = 6;
|
|
21280
|
+
return this.poolLogic.execTransaction(market, txData, options);
|
|
21281
|
+
|
|
21282
|
+
case 6:
|
|
21283
|
+
tx = _context38.sent;
|
|
21284
|
+
return _context38.abrupt("return", tx);
|
|
21285
|
+
|
|
21286
|
+
case 8:
|
|
21287
|
+
case "end":
|
|
21288
|
+
return _context38.stop();
|
|
21289
|
+
}
|
|
21290
|
+
}
|
|
21291
|
+
}, _callee38, this);
|
|
21292
|
+
}));
|
|
21293
|
+
|
|
21294
|
+
function cancelFuturesOrder(_x151, _x152) {
|
|
21295
|
+
return _cancelFuturesOrder.apply(this, arguments);
|
|
21296
|
+
}
|
|
21297
|
+
|
|
21298
|
+
return cancelFuturesOrder;
|
|
21220
21299
|
}();
|
|
21221
21300
|
|
|
21222
21301
|
return Pool;
|