@dhedge/v2-sdk 1.10.10 → 1.10.12
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/dist/config.d.ts +2 -1
- package/dist/entities/dhedge.d.ts +1 -1
- package/dist/entities/pool.d.ts +2 -1
- package/dist/services/flatmoney/stableLp.d.ts +1 -0
- package/dist/test/constants.d.ts +4 -0
- package/dist/types.d.ts +0 -1
- package/dist/v2-sdk.cjs.development.js +311 -172
- 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 +311 -172
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/abi/flatmoney/v2/IOrderExecutionModule.json +96 -0
- package/src/config.ts +10 -6
- package/src/entities/dhedge.ts +5 -4
- package/src/entities/pool.ts +4 -12
- package/src/services/flatmoney/keeperFee.ts +12 -4
- package/src/services/flatmoney/stableLp.ts +30 -8
- package/src/test/constants.ts +6 -1
- package/src/test/flatmoney.test.ts +30 -11
- package/src/types.ts +0 -1
- package/src/utils/contract.ts +19 -7
- package/dist/services/zeroEx/zeroExTrade.d.ts +0 -3
- package/src/services/zeroEx/zeroExTrade.ts +0 -52
- package/src/test/zeroEx.test.ts +0 -95
|
@@ -53,6 +53,24 @@ function _asyncToGenerator(fn) {
|
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
function _extends() {
|
|
57
|
+
_extends = Object.assign || function (target) {
|
|
58
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
59
|
+
var source = arguments[i];
|
|
60
|
+
|
|
61
|
+
for (var key in source) {
|
|
62
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
63
|
+
target[key] = source[key];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return target;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return _extends.apply(this, arguments);
|
|
72
|
+
}
|
|
73
|
+
|
|
56
74
|
function _inheritsLoose(subClass, superClass) {
|
|
57
75
|
subClass.prototype = Object.create(superClass.prototype);
|
|
58
76
|
subClass.prototype.constructor = subClass;
|
|
@@ -4253,7 +4271,6 @@ var ManagerLogic = {
|
|
|
4253
4271
|
Dapp["VELODROMEV2"] = "velodromeV2";
|
|
4254
4272
|
Dapp["VELODROMECL"] = "velodromeCL";
|
|
4255
4273
|
Dapp["LYRA"] = "lyra";
|
|
4256
|
-
Dapp["ZEROEX"] = "0x";
|
|
4257
4274
|
Dapp["RAMSES"] = "ramses";
|
|
4258
4275
|
Dapp["AERODROME"] = "aerodrome";
|
|
4259
4276
|
Dapp["AERODROMECL"] = "aerodromeCL";
|
|
@@ -4290,7 +4307,7 @@ var _factoryAddress, _Network$POLYGON, _Network$OPTIMISM, _Network$ARBITRUM, _Ne
|
|
|
4290
4307
|
require("dotenv").config();
|
|
4291
4308
|
|
|
4292
4309
|
var factoryAddress = (_factoryAddress = {}, _factoryAddress[exports.Network.POLYGON] = process.env.STAGING_CONTRACTS ? "0xDd87eCdB10cFF7004276AAbAbd30e7a08F69bb53" : "0xfdc7b8bFe0DD3513Cc669bB8d601Cb83e2F69cB0", _factoryAddress[exports.Network.OPTIMISM] = "0x5e61a079A178f0E5784107a4963baAe0c5a680c6", _factoryAddress[exports.Network.ARBITRUM] = "0xfffb5fb14606eb3a548c113026355020ddf27535", _factoryAddress[exports.Network.BASE] = "0x49Afe3abCf66CF09Fab86cb1139D8811C8afe56F", _factoryAddress);
|
|
4293
|
-
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] = "0x111111125421ca6dc452d289314280a0f8842a65", _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] = "0x45b90480D6F643dE2f128db091A357C3c90399f2", _Network$POLYGON[exports.Dapp.
|
|
4310
|
+
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] = "0x111111125421ca6dc452d289314280a0f8842a65", _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] = "0x45b90480D6F643dE2f128db091A357C3c90399f2", _Network$POLYGON[exports.Dapp.ODOS] = "0x4e3288c9ca110bcc82bf38f09a7b425c095d92bf", _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] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$OPTIMISM[exports.Dapp.TOROS] = "0x2Ed1bd7f66e47113672f3870308b5E867C5bb743", _Network$OPTIMISM[exports.Dapp.VELODROME] = "0x9c12939390052919aF3155f41Bf4160Fd3666A6f", _Network$OPTIMISM[exports.Dapp.VELODROMEV2] = "0xa062ae8a9c5e11aaa026fc2670b0d65ccc8b2858", _Network$OPTIMISM[exports.Dapp.LYRA] = "0xCCE7819d65f348c64B7Beb205BA367b3fE33763B", _Network$OPTIMISM[exports.Dapp.ARRAKIS] = "0x9ce88a56d120300061593eF7AD074A1B710094d5", _Network$OPTIMISM[exports.Dapp.ODOS] = "0xca423977156bb05b13a2ba3b76bc5419e2fe9680", _Network$OPTIMISM), _routerAddress[exports.Network.ARBITRUM] = (_Network$ARBITRUM = {}, _Network$ARBITRUM[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$ARBITRUM[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$ARBITRUM[exports.Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$ARBITRUM[exports.Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$ARBITRUM[exports.Dapp.RAMSES] = "0xaaa87963efeb6f7e0a2711f397663105acb1805e", _Network$ARBITRUM[exports.Dapp.TOROS] = "0xA5679C4272A056Bb83f039961fae7D99C48529F5", _Network$ARBITRUM[exports.Dapp.ODOS] = "0xa669e7A0d4b3e4Fa48af2dE86BD4CD7126Be4e13", _Network$ARBITRUM), _routerAddress[exports.Network.BASE] = (_Network$BASE = {}, _Network$BASE[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$BASE[exports.Dapp.AERODROME] = "0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43", _Network$BASE[exports.Dapp.AAVEV3] = "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5", _Network$BASE[exports.Dapp.TOROS] = "0xf067575Eb60c7587C11e867907AA7284833704d1", _Network$BASE[exports.Dapp.ODOS] = "0x19cEeAd7105607Cd444F5ad10dd51356436095a1", _Network$BASE), _routerAddress);
|
|
4294
4311
|
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[exports.Network.BASE] = {}, _dappFactoryAddress);
|
|
4295
4312
|
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] = (_Network$OPTIMISM2 = {}, _Network$OPTIMISM2[exports.Dapp.AAVEV3] = "0x929EC64c34a17401F460460D4B9390518E5B473e", _Network$OPTIMISM2[exports.Dapp.COMPOUNDV3] = "0x443ea0340cb75a160f31a440722dec7b5bc3c2e9", _Network$OPTIMISM2), _stakingAddress[exports.Network.ARBITRUM] = (_Network$ARBITRUM2 = {}, _Network$ARBITRUM2[exports.Dapp.COMPOUNDV3] = "0x88730d254a2f7e6ac8388c3198afd694ba9f7fae", _Network$ARBITRUM2[exports.Dapp.PANCAKECL] = "0x5e09ACf80C0296740eC5d6F643005a4ef8DaA694", _Network$ARBITRUM2), _stakingAddress[exports.Network.BASE] = (_Network$BASE2 = {}, _Network$BASE2[exports.Dapp.PANCAKECL] = "0xC6A2Db661D5a5690172d8eB0a7DEA2d3008665A3", _Network$BASE2), _stakingAddress);
|
|
4296
4313
|
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$OPTIMISM3 = {}, _Network$OPTIMISM3[exports.Dapp.AAVEV3] = "0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb", _Network$OPTIMISM3), _aaveAddressProvider[exports.Network.ARBITRUM] = (_Network$ARBITRUM3 = {}, _Network$ARBITRUM3[exports.Dapp.AAVEV3] = "0xa97684ead0e402dc232d5a977953df7ecbab3cdb", _Network$ARBITRUM3), _aaveAddressProvider[exports.Network.BASE] = (_Network$BASE3 = {}, _Network$BASE3[exports.Dapp.AAVEV3] = "0xe20fCBdBfFC4Dd138cE8b2E6FBb6CB49777ad64D", _Network$BASE3), _aaveAddressProvider);
|
|
@@ -4306,7 +4323,14 @@ var flatMoneyContractAddresses = (_flatMoneyContractAdd = {}, _flatMoneyContract
|
|
|
4306
4323
|
DelayedOrder: "0x6D857e9D24a7566bB72a3FB0847A3E0e4E1c2879",
|
|
4307
4324
|
FlatcoinVault: "0x95Fa1ddc9a78273f795e67AbE8f1Cd2Cd39831fF",
|
|
4308
4325
|
StableModule: "0xb95fB324b8A2fAF8ec4f76e3dF46C718402736e2",
|
|
4309
|
-
|
|
4326
|
+
COLLATERAL: "0xb6fe221fe9eef5aba221c348ba20a1bf5e73624c" // RETH
|
|
4327
|
+
|
|
4328
|
+
}, _flatMoneyContractAdd[exports.Network.OPTIMISM] = {
|
|
4329
|
+
OrderExecution: "0x7805CB7fb2C2e70FDdF92949065D9Ee1Fc2F72a8",
|
|
4330
|
+
DelayedOrder: "0xd917A0C9B21Bb71DF1209d2c211Ad83004F01554",
|
|
4331
|
+
FlatcoinVault: "0x86C7b9640302082B0dF78023F930d8612bFcaD3f",
|
|
4332
|
+
COLLATERAL: "0x68f180fcCe6836688e9084f035309E29Bf0A2095",
|
|
4333
|
+
StableModule: "0x357CB23571EF7a3d6189b7FAcFC361eA71f7CAB5"
|
|
4310
4334
|
}, _flatMoneyContractAdd);
|
|
4311
4335
|
|
|
4312
4336
|
var abi$3 = [
|
|
@@ -10482,7 +10506,8 @@ var CONTRACT_ADDRESS = (_CONTRACT_ADDRESS = {}, _CONTRACT_ADDRESS[exports.Networ
|
|
|
10482
10506
|
VELODROME_CL_USDC_WETH_GAUGE: "",
|
|
10483
10507
|
VELO: "",
|
|
10484
10508
|
COMPOUNDV3_WETH: "",
|
|
10485
|
-
TOROS: ""
|
|
10509
|
+
TOROS: "",
|
|
10510
|
+
UNIT: ""
|
|
10486
10511
|
}, _CONTRACT_ADDRESS[exports.Network.OPTIMISM] = {
|
|
10487
10512
|
USDC: "0x0b2c639c533813f4aa9d7837caf62653d097ff85",
|
|
10488
10513
|
USDT: "",
|
|
@@ -10494,6 +10519,7 @@ var CONTRACT_ADDRESS = (_CONTRACT_ADDRESS = {}, _CONTRACT_ADDRESS[exports.Networ
|
|
|
10494
10519
|
uniswapV3: {
|
|
10495
10520
|
nonfungiblePositionManager: "0xC36442b4a4522E871399CD717aBDD847Ab11FE88"
|
|
10496
10521
|
},
|
|
10522
|
+
UNIT: "0x357CB23571EF7a3d6189b7FAcFC361eA71f7CAB5",
|
|
10497
10523
|
WMATIC: "",
|
|
10498
10524
|
//
|
|
10499
10525
|
ARRAKIS_USDC_WETH_GAUGE: "",
|
|
@@ -10516,6 +10542,7 @@ var CONTRACT_ADDRESS = (_CONTRACT_ADDRESS = {}, _CONTRACT_ADDRESS[exports.Networ
|
|
|
10516
10542
|
uniswapV3: {
|
|
10517
10543
|
nonfungiblePositionManager: "0xC36442b4a4522E871399CD717aBDD847Ab11FE88"
|
|
10518
10544
|
},
|
|
10545
|
+
UNIT: "",
|
|
10519
10546
|
//
|
|
10520
10547
|
ARRAKIS_USDC_WETH_GAUGE: "",
|
|
10521
10548
|
ARRAKIS_USDC_WETH_LP: "",
|
|
@@ -10531,6 +10558,7 @@ var CONTRACT_ADDRESS = (_CONTRACT_ADDRESS = {}, _CONTRACT_ADDRESS[exports.Networ
|
|
|
10531
10558
|
WETH: "0x4200000000000000000000000000000000000006",
|
|
10532
10559
|
WBTC: "",
|
|
10533
10560
|
SWETH: "",
|
|
10561
|
+
UNIT: "0xb95fB324b8A2fAF8ec4f76e3dF46C718402736e2",
|
|
10534
10562
|
uniswapV3: {
|
|
10535
10563
|
nonfungiblePositionManager: ""
|
|
10536
10564
|
},
|
|
@@ -16073,25 +16101,59 @@ var getPoolTxOrGasEstimate = /*#__PURE__*/function () {
|
|
|
16073
16101
|
while (1) {
|
|
16074
16102
|
switch (_context2.prev = _context2.next) {
|
|
16075
16103
|
case 0:
|
|
16104
|
+
if (!pool.isDhedge) {
|
|
16105
|
+
_context2.next = 12;
|
|
16106
|
+
break;
|
|
16107
|
+
}
|
|
16108
|
+
|
|
16076
16109
|
if (!estimateGas) {
|
|
16077
|
-
_context2.next =
|
|
16110
|
+
_context2.next = 7;
|
|
16078
16111
|
break;
|
|
16079
16112
|
}
|
|
16080
16113
|
|
|
16081
|
-
_context2.next =
|
|
16114
|
+
_context2.next = 4;
|
|
16082
16115
|
return pool.poolLogic.estimateGas.execTransaction(args[0], args[1], args[2]);
|
|
16083
16116
|
|
|
16084
|
-
case
|
|
16117
|
+
case 4:
|
|
16085
16118
|
return _context2.abrupt("return", _context2.sent);
|
|
16086
16119
|
|
|
16087
|
-
case
|
|
16088
|
-
_context2.next =
|
|
16120
|
+
case 7:
|
|
16121
|
+
_context2.next = 9;
|
|
16089
16122
|
return pool.poolLogic.execTransaction(args[0], args[1], args[2]);
|
|
16090
16123
|
|
|
16091
|
-
case
|
|
16124
|
+
case 9:
|
|
16092
16125
|
return _context2.abrupt("return", _context2.sent);
|
|
16093
16126
|
|
|
16094
|
-
case
|
|
16127
|
+
case 10:
|
|
16128
|
+
_context2.next = 21;
|
|
16129
|
+
break;
|
|
16130
|
+
|
|
16131
|
+
case 12:
|
|
16132
|
+
if (!estimateGas) {
|
|
16133
|
+
_context2.next = 18;
|
|
16134
|
+
break;
|
|
16135
|
+
}
|
|
16136
|
+
|
|
16137
|
+
_context2.next = 15;
|
|
16138
|
+
return pool.signer.estimateGas({
|
|
16139
|
+
to: args[0],
|
|
16140
|
+
data: args[1]
|
|
16141
|
+
});
|
|
16142
|
+
|
|
16143
|
+
case 15:
|
|
16144
|
+
return _context2.abrupt("return", _context2.sent);
|
|
16145
|
+
|
|
16146
|
+
case 18:
|
|
16147
|
+
_context2.next = 20;
|
|
16148
|
+
return pool.signer.sendTransaction(_extends({
|
|
16149
|
+
to: args[0],
|
|
16150
|
+
data: args[1]
|
|
16151
|
+
}, args[2]));
|
|
16152
|
+
|
|
16153
|
+
case 20:
|
|
16154
|
+
return _context2.abrupt("return", _context2.sent);
|
|
16155
|
+
|
|
16156
|
+
case 21:
|
|
16095
16157
|
case "end":
|
|
16096
16158
|
return _context2.stop();
|
|
16097
16159
|
}
|
|
@@ -20765,94 +20827,6 @@ function _getFuturesCancelOrderTxData() {
|
|
|
20765
20827
|
return _getFuturesCancelOrderTxData.apply(this, arguments);
|
|
20766
20828
|
}
|
|
20767
20829
|
|
|
20768
|
-
// see https://stackoverflow.com/a/41102306
|
|
20769
|
-
var CAN_SET_PROTOTYPE = ("setPrototypeOf" in Object);
|
|
20770
|
-
var ApiError = /*#__PURE__*/function (_Error) {
|
|
20771
|
-
_inheritsLoose(ApiError, _Error);
|
|
20772
|
-
|
|
20773
|
-
function ApiError(message) {
|
|
20774
|
-
var _this;
|
|
20775
|
-
|
|
20776
|
-
_this = _Error.call(this, message != null ? message : "Api request failed") || this;
|
|
20777
|
-
_this.name = _this.constructor.name;
|
|
20778
|
-
if (CAN_SET_PROTOTYPE) Object.setPrototypeOf(_assertThisInitialized(_this), (this instanceof ApiError ? this.constructor : void 0).prototype);
|
|
20779
|
-
return _this;
|
|
20780
|
-
}
|
|
20781
|
-
|
|
20782
|
-
return ApiError;
|
|
20783
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
20784
|
-
|
|
20785
|
-
// in 0x, e.g. 0.03 for 3% slippage allowed
|
|
20786
|
-
// 1inch slippage 0.5% represented by 0.5
|
|
20787
|
-
// 0x slippage 0.5% represented by 0.005
|
|
20788
|
-
|
|
20789
|
-
var getZeroExSlippage = function getZeroExSlippage(slippage) {
|
|
20790
|
-
return Number(slippage) / 100;
|
|
20791
|
-
};
|
|
20792
|
-
|
|
20793
|
-
var getZeroExTradeTxData = /*#__PURE__*/function () {
|
|
20794
|
-
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(network, assetFrom, assetTo, amountIn, slippage, takerAddress) {
|
|
20795
|
-
var slippagePercentage, params, response;
|
|
20796
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
20797
|
-
while (1) {
|
|
20798
|
-
switch (_context.prev = _context.next) {
|
|
20799
|
-
case 0:
|
|
20800
|
-
if (slippage === void 0) {
|
|
20801
|
-
slippage = 0.5;
|
|
20802
|
-
}
|
|
20803
|
-
|
|
20804
|
-
if (process.env.ZEROEX_API_KEY) {
|
|
20805
|
-
_context.next = 3;
|
|
20806
|
-
break;
|
|
20807
|
-
}
|
|
20808
|
-
|
|
20809
|
-
throw new Error("ZEROEX_API_KEY not configured in .env file");
|
|
20810
|
-
|
|
20811
|
-
case 3:
|
|
20812
|
-
_context.prev = 3;
|
|
20813
|
-
slippagePercentage = getZeroExSlippage(slippage);
|
|
20814
|
-
params = {
|
|
20815
|
-
buyToken: assetTo,
|
|
20816
|
-
sellToken: assetFrom,
|
|
20817
|
-
sellAmount: amountIn.toString(),
|
|
20818
|
-
// necessary to skip quote validation is that in which the takerAddress refers to a smart contract
|
|
20819
|
-
skipValidation: true,
|
|
20820
|
-
// Used to enable RFQ-T liquidity
|
|
20821
|
-
intentOnFilling: true,
|
|
20822
|
-
takerAddress: takerAddress,
|
|
20823
|
-
slippagePercentage: slippagePercentage // excludedSourcesParam
|
|
20824
|
-
|
|
20825
|
-
};
|
|
20826
|
-
_context.next = 8;
|
|
20827
|
-
return axios.get("https://" + network + ".api.0x.org/swap/v1/quote", {
|
|
20828
|
-
params: params,
|
|
20829
|
-
headers: {
|
|
20830
|
-
"0x-api-key": process.env.ZEROEX_API_KEY
|
|
20831
|
-
}
|
|
20832
|
-
});
|
|
20833
|
-
|
|
20834
|
-
case 8:
|
|
20835
|
-
response = _context.sent;
|
|
20836
|
-
return _context.abrupt("return", response.data.data);
|
|
20837
|
-
|
|
20838
|
-
case 12:
|
|
20839
|
-
_context.prev = 12;
|
|
20840
|
-
_context.t0 = _context["catch"](3);
|
|
20841
|
-
throw new ApiError("Swap api request of 0x failed");
|
|
20842
|
-
|
|
20843
|
-
case 15:
|
|
20844
|
-
case "end":
|
|
20845
|
-
return _context.stop();
|
|
20846
|
-
}
|
|
20847
|
-
}
|
|
20848
|
-
}, _callee, null, [[3, 12]]);
|
|
20849
|
-
}));
|
|
20850
|
-
|
|
20851
|
-
return function getZeroExTradeTxData(_x, _x2, _x3, _x4, _x5, _x6) {
|
|
20852
|
-
return _ref.apply(this, arguments);
|
|
20853
|
-
};
|
|
20854
|
-
}();
|
|
20855
|
-
|
|
20856
20830
|
var abi$q = [
|
|
20857
20831
|
{
|
|
20858
20832
|
inputs: [
|
|
@@ -21535,6 +21509,108 @@ var DelayedOrderAbi = [
|
|
|
21535
21509
|
}
|
|
21536
21510
|
];
|
|
21537
21511
|
|
|
21512
|
+
var IOrderExecutionModuleAbi = [
|
|
21513
|
+
{
|
|
21514
|
+
type: "function",
|
|
21515
|
+
name: "cancelExistingOrder",
|
|
21516
|
+
inputs: [
|
|
21517
|
+
{
|
|
21518
|
+
name: "account",
|
|
21519
|
+
type: "address",
|
|
21520
|
+
internalType: "address"
|
|
21521
|
+
}
|
|
21522
|
+
],
|
|
21523
|
+
outputs: [
|
|
21524
|
+
],
|
|
21525
|
+
stateMutability: "nonpayable"
|
|
21526
|
+
},
|
|
21527
|
+
{
|
|
21528
|
+
type: "function",
|
|
21529
|
+
name: "cancelOrderByModule",
|
|
21530
|
+
inputs: [
|
|
21531
|
+
{
|
|
21532
|
+
name: "account",
|
|
21533
|
+
type: "address",
|
|
21534
|
+
internalType: "address"
|
|
21535
|
+
}
|
|
21536
|
+
],
|
|
21537
|
+
outputs: [
|
|
21538
|
+
],
|
|
21539
|
+
stateMutability: "nonpayable"
|
|
21540
|
+
},
|
|
21541
|
+
{
|
|
21542
|
+
type: "function",
|
|
21543
|
+
name: "executeLimitOrder",
|
|
21544
|
+
inputs: [
|
|
21545
|
+
{
|
|
21546
|
+
name: "tokenId",
|
|
21547
|
+
type: "uint256",
|
|
21548
|
+
internalType: "uint256"
|
|
21549
|
+
},
|
|
21550
|
+
{
|
|
21551
|
+
name: "priceUpdateData",
|
|
21552
|
+
type: "bytes[]",
|
|
21553
|
+
internalType: "bytes[]"
|
|
21554
|
+
}
|
|
21555
|
+
],
|
|
21556
|
+
outputs: [
|
|
21557
|
+
],
|
|
21558
|
+
stateMutability: "payable"
|
|
21559
|
+
},
|
|
21560
|
+
{
|
|
21561
|
+
type: "function",
|
|
21562
|
+
name: "executeOrder",
|
|
21563
|
+
inputs: [
|
|
21564
|
+
{
|
|
21565
|
+
name: "account",
|
|
21566
|
+
type: "address",
|
|
21567
|
+
internalType: "address"
|
|
21568
|
+
},
|
|
21569
|
+
{
|
|
21570
|
+
name: "priceUpdateData",
|
|
21571
|
+
type: "bytes[]",
|
|
21572
|
+
internalType: "bytes[]"
|
|
21573
|
+
}
|
|
21574
|
+
],
|
|
21575
|
+
outputs: [
|
|
21576
|
+
],
|
|
21577
|
+
stateMutability: "payable"
|
|
21578
|
+
},
|
|
21579
|
+
{
|
|
21580
|
+
type: "function",
|
|
21581
|
+
name: "hasOrderExpired",
|
|
21582
|
+
inputs: [
|
|
21583
|
+
{
|
|
21584
|
+
name: "account",
|
|
21585
|
+
type: "address",
|
|
21586
|
+
internalType: "address"
|
|
21587
|
+
}
|
|
21588
|
+
],
|
|
21589
|
+
outputs: [
|
|
21590
|
+
{
|
|
21591
|
+
name: "expired",
|
|
21592
|
+
type: "bool",
|
|
21593
|
+
internalType: "bool"
|
|
21594
|
+
}
|
|
21595
|
+
],
|
|
21596
|
+
stateMutability: "view"
|
|
21597
|
+
},
|
|
21598
|
+
{
|
|
21599
|
+
type: "function",
|
|
21600
|
+
name: "maxExecutabilityAge",
|
|
21601
|
+
inputs: [
|
|
21602
|
+
],
|
|
21603
|
+
outputs: [
|
|
21604
|
+
{
|
|
21605
|
+
name: "maxExecutabilityAge",
|
|
21606
|
+
type: "uint64",
|
|
21607
|
+
internalType: "uint64"
|
|
21608
|
+
}
|
|
21609
|
+
],
|
|
21610
|
+
stateMutability: "view"
|
|
21611
|
+
}
|
|
21612
|
+
];
|
|
21613
|
+
|
|
21538
21614
|
var StableModuleAbi = [
|
|
21539
21615
|
{
|
|
21540
21616
|
inputs: [
|
|
@@ -23409,7 +23485,7 @@ var getKeeperFeeContract = /*#__PURE__*/function () {
|
|
|
23409
23485
|
}();
|
|
23410
23486
|
var getKeeperFee = /*#__PURE__*/function () {
|
|
23411
23487
|
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(pool, maxKeeperFeeInUsd) {
|
|
23412
|
-
var keeperFeeContract, gasPrice, keeperfee, keeperFeeInUsd;
|
|
23488
|
+
var keeperFeeContract, feeHistory, gasPrice, keeperfee, keeperFeeInUsd;
|
|
23413
23489
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
23414
23490
|
while (1) {
|
|
23415
23491
|
switch (_context2.prev = _context2.next) {
|
|
@@ -23420,49 +23496,50 @@ var getKeeperFee = /*#__PURE__*/function () {
|
|
|
23420
23496
|
case 2:
|
|
23421
23497
|
keeperFeeContract = _context2.sent;
|
|
23422
23498
|
_context2.next = 5;
|
|
23423
|
-
return pool.signer.provider.
|
|
23499
|
+
return pool.signer.provider.send("eth_feeHistory", [1, "latest"]);
|
|
23424
23500
|
|
|
23425
23501
|
case 5:
|
|
23426
|
-
|
|
23502
|
+
feeHistory = _context2.sent;
|
|
23503
|
+
gasPrice = Number(feeHistory.baseFeePerGas[0]);
|
|
23427
23504
|
|
|
23428
23505
|
if (!gasPrice) {
|
|
23429
|
-
_context2.next =
|
|
23506
|
+
_context2.next = 13;
|
|
23430
23507
|
break;
|
|
23431
23508
|
}
|
|
23432
23509
|
|
|
23433
|
-
_context2.next =
|
|
23434
|
-
return keeperFeeContract["getKeeperFee(uint256)"](new BigNumber(gasPrice.toString()).times(1.
|
|
23510
|
+
_context2.next = 10;
|
|
23511
|
+
return keeperFeeContract["getKeeperFee(uint256)"](new BigNumber(gasPrice.toString()).times(1.5).toFixed(0));
|
|
23435
23512
|
|
|
23436
|
-
case
|
|
23513
|
+
case 10:
|
|
23437
23514
|
keeperfee = _context2.sent;
|
|
23438
|
-
_context2.next =
|
|
23515
|
+
_context2.next = 16;
|
|
23439
23516
|
break;
|
|
23440
23517
|
|
|
23441
|
-
case
|
|
23442
|
-
_context2.next =
|
|
23518
|
+
case 13:
|
|
23519
|
+
_context2.next = 15;
|
|
23443
23520
|
return keeperFeeContract["getKeeperFee()"]();
|
|
23444
23521
|
|
|
23445
|
-
case
|
|
23522
|
+
case 15:
|
|
23446
23523
|
keeperfee = _context2.sent;
|
|
23447
23524
|
|
|
23448
|
-
case
|
|
23449
|
-
_context2.next =
|
|
23525
|
+
case 16:
|
|
23526
|
+
_context2.next = 18;
|
|
23450
23527
|
return getKeeperFeeInUsd(pool, keeperfee);
|
|
23451
23528
|
|
|
23452
|
-
case
|
|
23529
|
+
case 18:
|
|
23453
23530
|
keeperFeeInUsd = _context2.sent;
|
|
23454
23531
|
|
|
23455
23532
|
if (!(Number.isFinite(maxKeeperFeeInUsd) && keeperFeeInUsd.gt(ethers.ethers.BigNumber.from(maxKeeperFeeInUsd).toString()))) {
|
|
23456
|
-
_context2.next =
|
|
23533
|
+
_context2.next = 21;
|
|
23457
23534
|
break;
|
|
23458
23535
|
}
|
|
23459
23536
|
|
|
23460
23537
|
throw new Error("mintUnitViaFlatMoney: keeperFee too large");
|
|
23461
23538
|
|
|
23462
|
-
case
|
|
23539
|
+
case 21:
|
|
23463
23540
|
return _context2.abrupt("return", keeperfee);
|
|
23464
23541
|
|
|
23465
|
-
case
|
|
23542
|
+
case 22:
|
|
23466
23543
|
case "end":
|
|
23467
23544
|
return _context2.stop();
|
|
23468
23545
|
}
|
|
@@ -23476,7 +23553,7 @@ var getKeeperFee = /*#__PURE__*/function () {
|
|
|
23476
23553
|
}();
|
|
23477
23554
|
var getKeeperFeeInUsd = /*#__PURE__*/function () {
|
|
23478
23555
|
var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(pool, keeperFee) {
|
|
23479
|
-
var flatMoneyContracts, fundComposition, filteredFc, rateD1;
|
|
23556
|
+
var flatMoneyContracts, fundComposition, filteredFc, rateD1, assetDecimal;
|
|
23480
23557
|
return runtime_1.wrap(function _callee3$(_context3) {
|
|
23481
23558
|
while (1) {
|
|
23482
23559
|
switch (_context3.prev = _context3.next) {
|
|
@@ -23497,7 +23574,7 @@ var getKeeperFeeInUsd = /*#__PURE__*/function () {
|
|
|
23497
23574
|
case 5:
|
|
23498
23575
|
fundComposition = _context3.sent;
|
|
23499
23576
|
filteredFc = fundComposition.filter(function (fc) {
|
|
23500
|
-
return fc.asset.toLocaleLowerCase() === flatMoneyContracts.
|
|
23577
|
+
return fc.asset.toLocaleLowerCase() === flatMoneyContracts.COLLATERAL.toLocaleLowerCase();
|
|
23501
23578
|
});
|
|
23502
23579
|
|
|
23503
23580
|
if (filteredFc[0]) {
|
|
@@ -23509,9 +23586,14 @@ var getKeeperFeeInUsd = /*#__PURE__*/function () {
|
|
|
23509
23586
|
|
|
23510
23587
|
case 9:
|
|
23511
23588
|
rateD1 = new BigNumber(filteredFc[0].rate.toString()).div(1e18);
|
|
23512
|
-
|
|
23589
|
+
_context3.next = 12;
|
|
23590
|
+
return pool.utils.getDecimals(flatMoneyContracts.COLLATERAL);
|
|
23513
23591
|
|
|
23514
|
-
case
|
|
23592
|
+
case 12:
|
|
23593
|
+
assetDecimal = _context3.sent;
|
|
23594
|
+
return _context3.abrupt("return", rateD1.times(keeperFee.toString()).div(Math.pow(10, assetDecimal)));
|
|
23595
|
+
|
|
23596
|
+
case 14:
|
|
23515
23597
|
case "end":
|
|
23516
23598
|
return _context3.stop();
|
|
23517
23599
|
}
|
|
@@ -23533,6 +23615,9 @@ function getAnnounceStableWithdrawTxData(withdrawAmount, minAmountOut, keeperFee
|
|
|
23533
23615
|
function getCancelExistingOrderTxData(account) {
|
|
23534
23616
|
return new ethers.ethers.utils.Interface(DelayedOrderAbi).encodeFunctionData("cancelExistingOrder", [account]);
|
|
23535
23617
|
}
|
|
23618
|
+
function getCancelExistingOrderTxDataForV2(account) {
|
|
23619
|
+
return new ethers.ethers.utils.Interface(IOrderExecutionModuleAbi).encodeFunctionData("cancelExistingOrder", [account]);
|
|
23620
|
+
}
|
|
23536
23621
|
function mintUnitViaFlatMoney(_x, _x2, _x3, _x4, _x5, _x6) {
|
|
23537
23622
|
return _mintUnitViaFlatMoney.apply(this, arguments);
|
|
23538
23623
|
}
|
|
@@ -23568,7 +23653,7 @@ function _mintUnitViaFlatMoney() {
|
|
|
23568
23653
|
|
|
23569
23654
|
case 7:
|
|
23570
23655
|
keeperfee = _context.sent;
|
|
23571
|
-
// in
|
|
23656
|
+
// in COLLATERAL
|
|
23572
23657
|
adjustedDepositAmount = new BigNumber(depositAmount.toString()).minus(keeperfee.toString() // keeper fee deducted from amountIn
|
|
23573
23658
|
);
|
|
23574
23659
|
_context.next = 11;
|
|
@@ -23669,7 +23754,7 @@ function cancelOrderViaFlatMoney(_x13, _x14, _x15) {
|
|
|
23669
23754
|
|
|
23670
23755
|
function _cancelOrderViaFlatMoney() {
|
|
23671
23756
|
_cancelOrderViaFlatMoney = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(pool, options, estimateGas) {
|
|
23672
|
-
var flatMoneyContracts, cancelOrderTxData, tx;
|
|
23757
|
+
var flatMoneyContracts, toAddress, cancelOrderTxData, tx;
|
|
23673
23758
|
return runtime_1.wrap(function _callee3$(_context3) {
|
|
23674
23759
|
while (1) {
|
|
23675
23760
|
switch (_context3.prev = _context3.next) {
|
|
@@ -23692,19 +23777,46 @@ function _cancelOrderViaFlatMoney() {
|
|
|
23692
23777
|
throw new Error("cancelOrderViaFlatMoney: network not supported");
|
|
23693
23778
|
|
|
23694
23779
|
case 5:
|
|
23695
|
-
|
|
23696
|
-
|
|
23780
|
+
// flat money v2
|
|
23781
|
+
// use OrderExecution module to cancel order
|
|
23782
|
+
toAddress = flatMoneyContracts.DelayedOrder;
|
|
23783
|
+
cancelOrderTxData = getCancelExistingOrderTxData(pool.address);
|
|
23697
23784
|
|
|
23698
|
-
|
|
23785
|
+
if (!flatMoneyContracts.OrderExecution) {
|
|
23786
|
+
_context3.next = 12;
|
|
23787
|
+
break;
|
|
23788
|
+
}
|
|
23789
|
+
|
|
23790
|
+
toAddress = flatMoneyContracts.OrderExecution;
|
|
23791
|
+
_context3.next = 11;
|
|
23792
|
+
return getCancelExistingOrderTxDataForV2(pool.address);
|
|
23793
|
+
|
|
23794
|
+
case 11:
|
|
23699
23795
|
cancelOrderTxData = _context3.sent;
|
|
23700
|
-
_context3.next = 10;
|
|
23701
|
-
return getPoolTxOrGasEstimate(pool, [flatMoneyContracts.DelayedOrder, cancelOrderTxData, options], estimateGas);
|
|
23702
23796
|
|
|
23703
|
-
case
|
|
23797
|
+
case 12:
|
|
23798
|
+
if (!estimateGas) {
|
|
23799
|
+
_context3.next = 16;
|
|
23800
|
+
break;
|
|
23801
|
+
}
|
|
23802
|
+
|
|
23803
|
+
return _context3.abrupt("return", pool.signer.estimateGas({
|
|
23804
|
+
to: toAddress,
|
|
23805
|
+
data: cancelOrderTxData
|
|
23806
|
+
}));
|
|
23807
|
+
|
|
23808
|
+
case 16:
|
|
23809
|
+
_context3.next = 18;
|
|
23810
|
+
return pool.signer.sendTransaction(_extends({
|
|
23811
|
+
to: toAddress,
|
|
23812
|
+
data: cancelOrderTxData
|
|
23813
|
+
}, options));
|
|
23814
|
+
|
|
23815
|
+
case 18:
|
|
23704
23816
|
tx = _context3.sent;
|
|
23705
23817
|
return _context3.abrupt("return", tx);
|
|
23706
23818
|
|
|
23707
|
-
case
|
|
23819
|
+
case 20:
|
|
23708
23820
|
case "end":
|
|
23709
23821
|
return _context3.stop();
|
|
23710
23822
|
}
|
|
@@ -24284,7 +24396,11 @@ function _getOdosSwapTxData() {
|
|
|
24284
24396
|
}
|
|
24285
24397
|
|
|
24286
24398
|
var Pool = /*#__PURE__*/function () {
|
|
24287
|
-
function Pool(network, signer, poolLogic, mangerLogic, utils, factory) {
|
|
24399
|
+
function Pool(network, signer, poolLogic, mangerLogic, utils, factory, isDhedge) {
|
|
24400
|
+
if (isDhedge === void 0) {
|
|
24401
|
+
isDhedge = true;
|
|
24402
|
+
}
|
|
24403
|
+
|
|
24288
24404
|
this.network = network;
|
|
24289
24405
|
this.poolLogic = poolLogic;
|
|
24290
24406
|
this.address = poolLogic.address;
|
|
@@ -24292,6 +24408,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
24292
24408
|
this.signer = signer;
|
|
24293
24409
|
this.utils = utils;
|
|
24294
24410
|
this.factory = factory;
|
|
24411
|
+
this.isDhedge = isDhedge;
|
|
24295
24412
|
}
|
|
24296
24413
|
/**
|
|
24297
24414
|
* Return the assets with balances and deposit info of a pool
|
|
@@ -24815,69 +24932,61 @@ var Pool = /*#__PURE__*/function () {
|
|
|
24815
24932
|
}
|
|
24816
24933
|
|
|
24817
24934
|
_context10.t0 = dapp;
|
|
24818
|
-
_context10.next = _context10.t0 === exports.Dapp.
|
|
24935
|
+
_context10.next = _context10.t0 === exports.Dapp.ONEINCH ? 6 : _context10.t0 === exports.Dapp.BALANCER ? 11 : _context10.t0 === exports.Dapp.SYNTHETIX ? 15 : _context10.t0 === exports.Dapp.TOROS ? 22 : _context10.t0 === exports.Dapp.ODOS ? 26 : 30;
|
|
24819
24936
|
break;
|
|
24820
24937
|
|
|
24821
24938
|
case 6:
|
|
24822
24939
|
_context10.next = 8;
|
|
24823
|
-
return getZeroExTradeTxData(this.network, assetFrom, assetTo, amountIn, slippage, this.address);
|
|
24824
|
-
|
|
24825
|
-
case 8:
|
|
24826
|
-
swapTxData = _context10.sent;
|
|
24827
|
-
return _context10.abrupt("break", 49);
|
|
24828
|
-
|
|
24829
|
-
case 10:
|
|
24830
|
-
_context10.next = 12;
|
|
24831
24940
|
return getOneInchSwapTxData(this, assetFrom, assetTo, amountIn, slippage);
|
|
24832
24941
|
|
|
24833
|
-
case
|
|
24942
|
+
case 8:
|
|
24834
24943
|
_yield$getOneInchSwap = _context10.sent;
|
|
24835
24944
|
swapTxData = _yield$getOneInchSwap.swapTxData;
|
|
24836
|
-
return _context10.abrupt("break",
|
|
24945
|
+
return _context10.abrupt("break", 45);
|
|
24837
24946
|
|
|
24838
|
-
case
|
|
24839
|
-
_context10.next =
|
|
24947
|
+
case 11:
|
|
24948
|
+
_context10.next = 13;
|
|
24840
24949
|
return this.utils.getBalancerSwapTx(this, assetFrom, assetTo, amountIn, slippage);
|
|
24841
24950
|
|
|
24842
|
-
case
|
|
24951
|
+
case 13:
|
|
24843
24952
|
swapTxData = _context10.sent;
|
|
24844
|
-
return _context10.abrupt("break",
|
|
24953
|
+
return _context10.abrupt("break", 45);
|
|
24845
24954
|
|
|
24846
|
-
case
|
|
24955
|
+
case 15:
|
|
24847
24956
|
iSynthetix = new ethers.ethers.utils.Interface(ISynthetix.abi);
|
|
24848
24957
|
assets = [assetFrom, assetTo].map(function (asset) {
|
|
24849
24958
|
return ethers.ethers.utils.formatBytes32String(asset);
|
|
24850
24959
|
});
|
|
24851
|
-
_context10.next =
|
|
24960
|
+
_context10.next = 19;
|
|
24852
24961
|
return this.factory.owner();
|
|
24853
24962
|
|
|
24854
|
-
case
|
|
24963
|
+
case 19:
|
|
24855
24964
|
daoAddress = _context10.sent;
|
|
24856
24965
|
swapTxData = iSynthetix.encodeFunctionData(exports.Transaction.SWAP_SYNTHS, [assets[0], amountIn, assets[1], daoAddress, SYNTHETIX_TRACKING_CODE]);
|
|
24857
|
-
return _context10.abrupt("break",
|
|
24966
|
+
return _context10.abrupt("break", 45);
|
|
24858
24967
|
|
|
24859
|
-
case
|
|
24860
|
-
_context10.next =
|
|
24968
|
+
case 22:
|
|
24969
|
+
_context10.next = 24;
|
|
24861
24970
|
return getEasySwapperTxData(this, assetFrom, assetTo, ethers.ethers.BigNumber.from(amountIn), slippage);
|
|
24862
24971
|
|
|
24863
|
-
case
|
|
24972
|
+
case 24:
|
|
24864
24973
|
swapTxData = _context10.sent;
|
|
24865
|
-
return _context10.abrupt("break",
|
|
24974
|
+
return _context10.abrupt("break", 45);
|
|
24866
24975
|
|
|
24867
|
-
case
|
|
24868
|
-
_context10.next =
|
|
24976
|
+
case 26:
|
|
24977
|
+
_context10.next = 28;
|
|
24869
24978
|
return getOdosSwapTxData(this, assetFrom, assetTo, amountIn, slippage);
|
|
24870
24979
|
|
|
24871
|
-
case
|
|
24980
|
+
case 28:
|
|
24872
24981
|
swapTxData = _context10.sent;
|
|
24873
|
-
return _context10.abrupt("break",
|
|
24982
|
+
return _context10.abrupt("break", 45);
|
|
24874
24983
|
|
|
24875
|
-
case
|
|
24984
|
+
case 30:
|
|
24876
24985
|
iUniswapV2Router = new ethers.ethers.utils.Interface(IUniswapV2Router.abi);
|
|
24877
|
-
_context10.next =
|
|
24986
|
+
_context10.next = 33;
|
|
24878
24987
|
return this.utils.getMinAmountOut(dapp, assetFrom, assetTo, amountIn, slippage);
|
|
24879
24988
|
|
|
24880
|
-
case
|
|
24989
|
+
case 33:
|
|
24881
24990
|
minAmountOut = _context10.sent;
|
|
24882
24991
|
_context10.t1 = iUniswapV2Router;
|
|
24883
24992
|
_context10.t2 = exports.Transaction.SWAP;
|
|
@@ -24885,23 +24994,23 @@ var Pool = /*#__PURE__*/function () {
|
|
|
24885
24994
|
_context10.t4 = minAmountOut;
|
|
24886
24995
|
_context10.t5 = [assetFrom, assetTo];
|
|
24887
24996
|
_context10.t6 = this.address;
|
|
24888
|
-
_context10.next =
|
|
24997
|
+
_context10.next = 42;
|
|
24889
24998
|
return getDeadline(this);
|
|
24890
24999
|
|
|
24891
|
-
case
|
|
25000
|
+
case 42:
|
|
24892
25001
|
_context10.t7 = _context10.sent;
|
|
24893
25002
|
_context10.t8 = [_context10.t3, _context10.t4, _context10.t5, _context10.t6, _context10.t7];
|
|
24894
25003
|
swapTxData = _context10.t1.encodeFunctionData.call(_context10.t1, _context10.t2, _context10.t8);
|
|
24895
25004
|
|
|
24896
|
-
case
|
|
24897
|
-
_context10.next =
|
|
25005
|
+
case 45:
|
|
25006
|
+
_context10.next = 47;
|
|
24898
25007
|
return getPoolTxOrGasEstimate(this, [routerAddress[this.network][dapp], swapTxData, options], estimateGas);
|
|
24899
25008
|
|
|
24900
|
-
case
|
|
25009
|
+
case 47:
|
|
24901
25010
|
tx = _context10.sent;
|
|
24902
25011
|
return _context10.abrupt("return", tx);
|
|
24903
25012
|
|
|
24904
|
-
case
|
|
25013
|
+
case 49:
|
|
24905
25014
|
case "end":
|
|
24906
25015
|
return _context10.stop();
|
|
24907
25016
|
}
|
|
@@ -31105,22 +31214,35 @@ var Dhedge = /*#__PURE__*/function () {
|
|
|
31105
31214
|
_proto.loadPool =
|
|
31106
31215
|
/*#__PURE__*/
|
|
31107
31216
|
function () {
|
|
31108
|
-
var _loadPool = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(address) {
|
|
31217
|
+
var _loadPool = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(address, isDhedge) {
|
|
31109
31218
|
var poolLogic, managerLogicAddress, managerLogic;
|
|
31110
31219
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
31111
31220
|
while (1) {
|
|
31112
31221
|
switch (_context2.prev = _context2.next) {
|
|
31113
31222
|
case 0:
|
|
31223
|
+
if (isDhedge === void 0) {
|
|
31224
|
+
isDhedge = true;
|
|
31225
|
+
}
|
|
31226
|
+
|
|
31114
31227
|
poolLogic = new ethers.Contract(address, PoolLogic.abi, this.signer);
|
|
31115
|
-
|
|
31228
|
+
managerLogicAddress = address;
|
|
31229
|
+
|
|
31230
|
+
if (!isDhedge) {
|
|
31231
|
+
_context2.next = 7;
|
|
31232
|
+
break;
|
|
31233
|
+
}
|
|
31234
|
+
|
|
31235
|
+
_context2.next = 6;
|
|
31116
31236
|
return poolLogic.poolManagerLogic();
|
|
31117
31237
|
|
|
31118
|
-
case
|
|
31238
|
+
case 6:
|
|
31119
31239
|
managerLogicAddress = _context2.sent;
|
|
31240
|
+
|
|
31241
|
+
case 7:
|
|
31120
31242
|
managerLogic = new ethers.Contract(managerLogicAddress, ManagerLogic.abi, this.signer);
|
|
31121
|
-
return _context2.abrupt("return", new Pool(this.network, this.signer, poolLogic, managerLogic, this.utils, this.factory));
|
|
31243
|
+
return _context2.abrupt("return", new Pool(this.network, this.signer, poolLogic, managerLogic, this.utils, this.factory, isDhedge));
|
|
31122
31244
|
|
|
31123
|
-
case
|
|
31245
|
+
case 9:
|
|
31124
31246
|
case "end":
|
|
31125
31247
|
return _context2.stop();
|
|
31126
31248
|
}
|
|
@@ -31128,7 +31250,7 @@ var Dhedge = /*#__PURE__*/function () {
|
|
|
31128
31250
|
}, _callee2, this);
|
|
31129
31251
|
}));
|
|
31130
31252
|
|
|
31131
|
-
function loadPool(_x7) {
|
|
31253
|
+
function loadPool(_x7, _x8) {
|
|
31132
31254
|
return _loadPool.apply(this, arguments);
|
|
31133
31255
|
}
|
|
31134
31256
|
|
|
@@ -31148,6 +31270,23 @@ var Dhedge = /*#__PURE__*/function () {
|
|
|
31148
31270
|
return Dhedge;
|
|
31149
31271
|
}();
|
|
31150
31272
|
|
|
31273
|
+
// see https://stackoverflow.com/a/41102306
|
|
31274
|
+
var CAN_SET_PROTOTYPE = ("setPrototypeOf" in Object);
|
|
31275
|
+
var ApiError = /*#__PURE__*/function (_Error) {
|
|
31276
|
+
_inheritsLoose(ApiError, _Error);
|
|
31277
|
+
|
|
31278
|
+
function ApiError(message) {
|
|
31279
|
+
var _this;
|
|
31280
|
+
|
|
31281
|
+
_this = _Error.call(this, message != null ? message : "Api request failed") || this;
|
|
31282
|
+
_this.name = _this.constructor.name;
|
|
31283
|
+
if (CAN_SET_PROTOTYPE) Object.setPrototypeOf(_assertThisInitialized(_this), (this instanceof ApiError ? this.constructor : void 0).prototype);
|
|
31284
|
+
return _this;
|
|
31285
|
+
}
|
|
31286
|
+
|
|
31287
|
+
return ApiError;
|
|
31288
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
31289
|
+
|
|
31151
31290
|
Object.defineProperty(exports, 'ethers', {
|
|
31152
31291
|
enumerable: true,
|
|
31153
31292
|
get: function () {
|