@dhedge/v2-sdk 1.10.5 → 1.10.6

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.
@@ -5,9 +5,9 @@ import { Token, Price } from '@uniswap/sdk-core';
5
5
  import { nearestUsableTick, TICK_SPACINGS, encodeSqrtRatioX96, TickMath, priceToClosestTick } from '@uniswap/v3-sdk';
6
6
  import JSBI from 'jsbi';
7
7
  import BigNumber from 'bignumber.js';
8
+ import axios from 'axios';
8
9
  import 'lodash-es/set';
9
10
  import '@ethersproject/abi';
10
- import axios from 'axios';
11
11
  import { Token as Token$1, Pair, TokenAmount, Route, Trade, TradeType, Percent } from '@sushiswap/sdk';
12
12
  import { SwapTypes, SOR } from '@balancer-labs/sor';
13
13
 
@@ -146,6 +146,44 @@ function _assertThisInitialized(self) {
146
146
  return self;
147
147
  }
148
148
 
149
+ function _unsupportedIterableToArray(o, minLen) {
150
+ if (!o) return;
151
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
152
+ var n = Object.prototype.toString.call(o).slice(8, -1);
153
+ if (n === "Object" && o.constructor) n = o.constructor.name;
154
+ if (n === "Map" || n === "Set") return Array.from(o);
155
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
156
+ }
157
+
158
+ function _arrayLikeToArray(arr, len) {
159
+ if (len == null || len > arr.length) len = arr.length;
160
+
161
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
162
+
163
+ return arr2;
164
+ }
165
+
166
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
167
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
168
+ if (it) return (it = it.call(o)).next.bind(it);
169
+
170
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
171
+ if (it) o = it;
172
+ var i = 0;
173
+ return function () {
174
+ if (i >= o.length) return {
175
+ done: true
176
+ };
177
+ return {
178
+ done: false,
179
+ value: o[i++]
180
+ };
181
+ };
182
+ }
183
+
184
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
185
+ }
186
+
149
187
  function createCommonjsModule(fn, module) {
150
188
  return module = { exports: {} }, fn(module, module.exports), module.exports;
151
189
  }
@@ -4249,7 +4287,7 @@ var _factoryAddress, _Network$POLYGON, _Network$OPTIMISM, _Network$ARBITRUM, _Ne
4249
4287
  require("dotenv").config();
4250
4288
 
4251
4289
  var factoryAddress = (_factoryAddress = {}, _factoryAddress[Network.POLYGON] = process.env.STAGING_CONTRACTS ? "0xDd87eCdB10cFF7004276AAbAbd30e7a08F69bb53" : "0xfdc7b8bFe0DD3513Cc669bB8d601Cb83e2F69cB0", _factoryAddress[Network.OPTIMISM] = "0x5e61a079A178f0E5784107a4963baAe0c5a680c6", _factoryAddress[Network.ARBITRUM] = "0xfffb5fb14606eb3a548c113026355020ddf27535", _factoryAddress[Network.BASE] = "0x49Afe3abCf66CF09Fab86cb1139D8811C8afe56F", _factoryAddress);
4252
- var routerAddress = (_routerAddress = {}, _routerAddress[Network.POLYGON] = (_Network$POLYGON = {}, _Network$POLYGON[Dapp.SUSHISWAP] = "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506", _Network$POLYGON[Dapp.AAVE] = "0x8dFf5E27EA6b7AC08EbFdf9eB090F32ee9a30fcf", _Network$POLYGON[Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$POLYGON[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$POLYGON[Dapp.QUICKSWAP] = "0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff", _Network$POLYGON[Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$POLYGON[Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$POLYGON[Dapp.ARRAKIS] = "0xc73fb100a995b33f9fa181d420f4c8d74506df66", _Network$POLYGON[Dapp.TOROS] = "0xB2F1498983bf9c9442c35F772e6C1AdE66a8DeDE", _Network$POLYGON[Dapp.ZEROEX] = "0xdef1c0ded9bec7f1a1670819833240f027b25eff", _Network$POLYGON), _routerAddress[Network.OPTIMISM] = (_Network$OPTIMISM = {}, _Network$OPTIMISM[Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$OPTIMISM[Dapp.SYNTHETIX] = "0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4", _Network$OPTIMISM[Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$OPTIMISM[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$OPTIMISM[Dapp.TOROS] = "0x3988513793bCE39f0167064A9F7fC3617FaF35AB", _Network$OPTIMISM[Dapp.VELODROME] = "0x9c12939390052919aF3155f41Bf4160Fd3666A6f", _Network$OPTIMISM[Dapp.VELODROMEV2] = "0xa062ae8a9c5e11aaa026fc2670b0d65ccc8b2858", _Network$OPTIMISM[Dapp.LYRA] = "0xCCE7819d65f348c64B7Beb205BA367b3fE33763B", _Network$OPTIMISM[Dapp.ARRAKIS] = "0x9ce88a56d120300061593eF7AD074A1B710094d5", _Network$OPTIMISM[Dapp.ZEROEX] = "0xdef1abe32c034e558cdd535791643c58a13acc10", _Network$OPTIMISM), _routerAddress[Network.ARBITRUM] = (_Network$ARBITRUM = {}, _Network$ARBITRUM[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$ARBITRUM[Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$ARBITRUM[Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$ARBITRUM[Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$ARBITRUM[Dapp.RAMSES] = "0xaaa87963efeb6f7e0a2711f397663105acb1805e", _Network$ARBITRUM[Dapp.ZEROEX] = "0xdef1c0ded9bec7f1a1670819833240f027b25eff", _Network$ARBITRUM), _routerAddress[Network.BASE] = (_Network$BASE = {}, _Network$BASE[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$BASE[Dapp.ZEROEX] = "0xdef1c0ded9bec7f1a1670819833240f027b25eff", _Network$BASE[Dapp.AERODROME] = "0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43", _Network$BASE[Dapp.AAVEV3] = "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5", _Network$BASE), _routerAddress);
4290
+ var routerAddress = (_routerAddress = {}, _routerAddress[Network.POLYGON] = (_Network$POLYGON = {}, _Network$POLYGON[Dapp.SUSHISWAP] = "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506", _Network$POLYGON[Dapp.AAVE] = "0x8dFf5E27EA6b7AC08EbFdf9eB090F32ee9a30fcf", _Network$POLYGON[Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$POLYGON[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$POLYGON[Dapp.QUICKSWAP] = "0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff", _Network$POLYGON[Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$POLYGON[Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$POLYGON[Dapp.ARRAKIS] = "0xc73fb100a995b33f9fa181d420f4c8d74506df66", _Network$POLYGON[Dapp.TOROS] = "0x45b90480D6F643dE2f128db091A357C3c90399f2", _Network$POLYGON[Dapp.ZEROEX] = "0xdef1c0ded9bec7f1a1670819833240f027b25eff", _Network$POLYGON), _routerAddress[Network.OPTIMISM] = (_Network$OPTIMISM = {}, _Network$OPTIMISM[Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$OPTIMISM[Dapp.SYNTHETIX] = "0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4", _Network$OPTIMISM[Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$OPTIMISM[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$OPTIMISM[Dapp.TOROS] = "0x2Ed1bd7f66e47113672f3870308b5E867C5bb743", _Network$OPTIMISM[Dapp.VELODROME] = "0x9c12939390052919aF3155f41Bf4160Fd3666A6f", _Network$OPTIMISM[Dapp.VELODROMEV2] = "0xa062ae8a9c5e11aaa026fc2670b0d65ccc8b2858", _Network$OPTIMISM[Dapp.LYRA] = "0xCCE7819d65f348c64B7Beb205BA367b3fE33763B", _Network$OPTIMISM[Dapp.ARRAKIS] = "0x9ce88a56d120300061593eF7AD074A1B710094d5", _Network$OPTIMISM[Dapp.ZEROEX] = "0xdef1abe32c034e558cdd535791643c58a13acc10", _Network$OPTIMISM), _routerAddress[Network.ARBITRUM] = (_Network$ARBITRUM = {}, _Network$ARBITRUM[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$ARBITRUM[Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$ARBITRUM[Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$ARBITRUM[Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$ARBITRUM[Dapp.RAMSES] = "0xaaa87963efeb6f7e0a2711f397663105acb1805e", _Network$ARBITRUM[Dapp.ZEROEX] = "0xdef1c0ded9bec7f1a1670819833240f027b25eff", _Network$ARBITRUM[Dapp.TOROS] = "0xA5679C4272A056Bb83f039961fae7D99C48529F5", _Network$ARBITRUM), _routerAddress[Network.BASE] = (_Network$BASE = {}, _Network$BASE[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$BASE[Dapp.ZEROEX] = "0xdef1c0ded9bec7f1a1670819833240f027b25eff", _Network$BASE[Dapp.AERODROME] = "0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43", _Network$BASE[Dapp.AAVEV3] = "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5", _Network$BASE[Dapp.TOROS] = "0xf067575Eb60c7587C11e867907AA7284833704d1", _Network$BASE), _routerAddress);
4253
4291
  var dappFactoryAddress = (_dappFactoryAddress = {}, _dappFactoryAddress[Network.POLYGON] = (_Network$POLYGON2 = {}, _Network$POLYGON2[Dapp.SUSHISWAP] = "0xc35DADB65012eC5796536bD9864eD8773aBc74C4", _Network$POLYGON2[Dapp.QUICKSWAP] = "0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32", _Network$POLYGON2), _dappFactoryAddress[Network.OPTIMISM] = {}, _dappFactoryAddress[Network.ARBITRUM] = {}, _dappFactoryAddress[Network.BASE] = {}, _dappFactoryAddress);
4254
4292
  var stakingAddress = (_stakingAddress = {}, _stakingAddress[Network.POLYGON] = (_Network$POLYGON3 = {}, _Network$POLYGON3[Dapp.SUSHISWAP] = "0x0769fd68dFb93167989C6f7254cd0D766Fb2841F", _Network$POLYGON3[Dapp.BALANCER] = "0x0F3e0c4218b7b0108a3643cFe9D3ec0d4F57c54e", _Network$POLYGON3[Dapp.AAVE] = "0x357D51124f59836DeD84c8a1730D72B749d8BC23", _Network$POLYGON3[Dapp.AAVEV3] = "0x929EC64c34a17401F460460D4B9390518E5B473e", _Network$POLYGON3), _stakingAddress[Network.OPTIMISM] = (_Network$OPTIMISM2 = {}, _Network$OPTIMISM2[Dapp.AAVEV3] = "0x929EC64c34a17401F460460D4B9390518E5B473e", _Network$OPTIMISM2), _stakingAddress[Network.ARBITRUM] = {}, _stakingAddress[Network.BASE] = {}, _stakingAddress);
4255
4293
  var aaveAddressProvider = (_aaveAddressProvider = {}, _aaveAddressProvider[Network.POLYGON] = (_Network$POLYGON4 = {}, _Network$POLYGON4[Dapp.AAVE] = "0xd05e3E715d945B59290df0ae8eF85c1BdB684744", _Network$POLYGON4[Dapp.AAVEV3] = "0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb", _Network$POLYGON4), _aaveAddressProvider[Network.OPTIMISM] = (_Network$OPTIMISM3 = {}, _Network$OPTIMISM3[Dapp.AAVEV3] = "0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb", _Network$OPTIMISM3), _aaveAddressProvider[Network.ARBITRUM] = (_Network$ARBITRUM2 = {}, _Network$ARBITRUM2[Dapp.AAVEV3] = "0xa97684ead0e402dc232d5a977953df7ecbab3cdb", _Network$ARBITRUM2), _aaveAddressProvider[Network.BASE] = (_Network$BASE2 = {}, _Network$BASE2[Dapp.AAVEV3] = "0xe20fCBdBfFC4Dd138cE8b2E6FBb6CB49777ad64D", _Network$BASE2), _aaveAddressProvider);
@@ -10011,100 +10049,75 @@ function _getUniswapV3SwapTxData() {
10011
10049
  return _getUniswapV3SwapTxData.apply(this, arguments);
10012
10050
  }
10013
10051
 
10014
- var abi$h = [
10015
- {
10016
- inputs: [
10017
- {
10018
- internalType: "address",
10019
- name: "",
10020
- type: "address"
10021
- }
10022
- ],
10023
- name: "allowedPools",
10024
- outputs: [
10025
- {
10026
- internalType: "bool",
10027
- name: "",
10028
- type: "bool"
10029
- }
10030
- ],
10031
- stateMutability: "view",
10032
- type: "function"
10033
- },
10034
- {
10035
- inputs: [
10036
- {
10037
- internalType: "address",
10038
- name: "pool",
10039
- type: "address"
10040
- },
10041
- {
10042
- internalType: "contract IERC20Extended",
10043
- name: "depositAsset",
10044
- type: "address"
10045
- },
10046
- {
10047
- internalType: "uint256",
10048
- name: "amount",
10049
- type: "uint256"
10050
- },
10051
- {
10052
- internalType: "contract IERC20Extended",
10053
- name: "poolDepositAsset",
10054
- type: "address"
10055
- },
10056
- {
10057
- internalType: "uint256",
10058
- name: "expectedLiquidityMinted",
10059
- type: "uint256"
10060
- }
10061
- ],
10062
- name: "deposit",
10063
- outputs: [
10064
- {
10065
- internalType: "uint256",
10066
- name: "liquidityMinted",
10067
- type: "uint256"
10068
- }
10069
- ],
10070
- stateMutability: "nonpayable",
10071
- type: "function"
10072
- },
10052
+ var IDhedgeEasySwapper = [
10073
10053
  {
10074
10054
  inputs: [
10075
10055
  {
10076
- internalType: "address",
10077
- name: "pool",
10078
- type: "address"
10079
- },
10080
- {
10081
- internalType: "contract IERC20Extended",
10082
- name: "depositAsset",
10083
- type: "address"
10084
- },
10085
- {
10086
- internalType: "uint256",
10087
- name: "amount",
10088
- type: "uint256"
10089
- },
10090
- {
10091
- internalType: "contract IERC20Extended",
10092
- name: "poolDepositAsset",
10093
- type: "address"
10056
+ components: [
10057
+ {
10058
+ components: [
10059
+ {
10060
+ internalType: "contract IERC20",
10061
+ name: "token",
10062
+ type: "address"
10063
+ },
10064
+ {
10065
+ internalType: "uint256",
10066
+ name: "amount",
10067
+ type: "uint256"
10068
+ },
10069
+ {
10070
+ components: [
10071
+ {
10072
+ internalType: "bytes32",
10073
+ name: "routerKey",
10074
+ type: "bytes32"
10075
+ },
10076
+ {
10077
+ internalType: "bytes",
10078
+ name: "swapData",
10079
+ type: "bytes"
10080
+ }
10081
+ ],
10082
+ internalType: "struct ISwapper.AggregatorData",
10083
+ name: "aggregatorData",
10084
+ type: "tuple"
10085
+ }
10086
+ ],
10087
+ internalType: "struct ISwapper.SrcTokenSwapDetails[]",
10088
+ name: "srcData",
10089
+ type: "tuple[]"
10090
+ },
10091
+ {
10092
+ components: [
10093
+ {
10094
+ internalType: "contract IERC20",
10095
+ name: "destToken",
10096
+ type: "address"
10097
+ },
10098
+ {
10099
+ internalType: "uint256",
10100
+ name: "minDestAmount",
10101
+ type: "uint256"
10102
+ }
10103
+ ],
10104
+ internalType: "struct ISwapper.DestData",
10105
+ name: "destData",
10106
+ type: "tuple"
10107
+ }
10108
+ ],
10109
+ internalType: "struct IWithdrawalVault.MultiInSingleOutData",
10110
+ name: "_swapData",
10111
+ type: "tuple"
10094
10112
  },
10095
10113
  {
10096
10114
  internalType: "uint256",
10097
- name: "expectedLiquidityMinted",
10115
+ name: "_expectedDestTokenAmount",
10098
10116
  type: "uint256"
10099
10117
  }
10100
10118
  ],
10101
- name: "depositWithCustomCooldown",
10119
+ name: "completeWithdrawal",
10102
10120
  outputs: [
10103
- {
10104
- internalType: "uint256",
10105
- name: "liquidityMinted",
10106
- type: "uint256"
10107
- }
10108
10121
  ],
10109
10122
  stateMutability: "nonpayable",
10110
10123
  type: "function"
@@ -10113,1095 +10126,116 @@ var abi$h = [
10113
10126
  inputs: [
10114
10127
  {
10115
10128
  internalType: "address",
10116
- name: "pool",
10129
+ name: "_dHedgeVault",
10117
10130
  type: "address"
10118
10131
  },
10119
- {
10120
- internalType: "contract IERC20Extended",
10121
- name: "poolDepositAsset",
10122
- type: "address"
10123
- },
10124
- {
10125
- internalType: "uint256",
10126
- name: "expectedLiquidityMinted",
10127
- type: "uint256"
10128
- }
10129
- ],
10130
- name: "depositNative",
10131
- outputs: [
10132
- {
10133
- internalType: "uint256",
10134
- name: "liquidityMinted",
10135
- type: "uint256"
10136
- }
10137
- ],
10138
- stateMutability: "payable",
10139
- type: "function"
10140
- },
10141
- {
10142
- inputs: [
10143
10132
  {
10144
10133
  internalType: "address",
10145
- name: "pool",
10146
- type: "address"
10147
- },
10148
- {
10149
- internalType: "contract IERC20Extended",
10150
- name: "poolDepositAsset",
10134
+ name: "_vaultDepositToken",
10151
10135
  type: "address"
10152
10136
  },
10153
10137
  {
10154
10138
  internalType: "uint256",
10155
- name: "expectedLiquidityMinted",
10139
+ name: "_depositAmount",
10156
10140
  type: "uint256"
10157
10141
  }
10158
10142
  ],
10159
- name: "depositNativeWithCustomCooldown",
10143
+ name: "depositQuote",
10160
10144
  outputs: [
10161
10145
  {
10162
10146
  internalType: "uint256",
10163
- name: "liquidityMinted",
10147
+ name: "expectedAmountReceived",
10164
10148
  type: "uint256"
10165
10149
  }
10166
10150
  ],
10167
- stateMutability: "payable",
10151
+ stateMutability: "view",
10168
10152
  type: "function"
10169
10153
  },
10170
10154
  {
10171
10155
  inputs: [
10172
10156
  {
10173
10157
  internalType: "address",
10174
- name: "pool",
10158
+ name: "_dHedgeVault",
10175
10159
  type: "address"
10176
10160
  },
10177
10161
  {
10178
- internalType: "contract IERC20Extended",
10179
- name: "depositAsset",
10162
+ internalType: "contract IERC20",
10163
+ name: "_vaultDepositToken",
10180
10164
  type: "address"
10181
10165
  },
10182
10166
  {
10183
10167
  internalType: "uint256",
10184
- name: "amount",
10168
+ name: "_depositAmount",
10185
10169
  type: "uint256"
10186
10170
  },
10187
- {
10188
- internalType: "contract IERC20Extended",
10189
- name: "poolDepositAsset",
10190
- type: "address"
10191
- },
10192
- {
10193
- internalType: "bool",
10194
- name: "customCooldown",
10195
- type: "bool"
10196
- }
10197
- ],
10198
- name: "depositQuote",
10199
- outputs: [
10200
- {
10201
- internalType: "uint256",
10202
- name: "expectedLiquidityMinted",
10203
- type: "uint256"
10204
- }
10205
- ],
10206
- stateMutability: "view",
10207
- type: "function"
10208
- },
10209
- {
10210
- inputs: [
10211
- ],
10212
- name: "feeDenominator",
10213
- outputs: [
10214
10171
  {
10215
10172
  internalType: "uint256",
10216
- name: "",
10173
+ name: "_expectedAmountReceived",
10217
10174
  type: "uint256"
10218
10175
  }
10219
10176
  ],
10220
- stateMutability: "view",
10221
- type: "function"
10222
- },
10223
- {
10224
- inputs: [
10225
- ],
10226
- name: "feeNumerator",
10177
+ name: "depositWithCustomCooldown",
10227
10178
  outputs: [
10228
- {
10229
- internalType: "uint256",
10230
- name: "",
10231
- type: "uint256"
10232
- }
10233
10179
  ],
10234
- stateMutability: "view",
10180
+ stateMutability: "nonpayable",
10235
10181
  type: "function"
10236
10182
  },
10237
10183
  {
10238
10184
  inputs: [
10239
10185
  {
10240
10186
  internalType: "address",
10241
- name: "pool",
10242
- type: "address"
10243
- },
10244
- {
10245
- internalType: "uint256",
10246
- name: "fundTokenAmount",
10247
- type: "uint256"
10248
- },
10249
- {
10250
- internalType: "contract IERC20Extended",
10251
- name: "withdrawalAsset",
10187
+ name: "_depositor",
10252
10188
  type: "address"
10253
- },
10254
- {
10255
- internalType: "uint256",
10256
- name: "expectedAmountOut",
10257
- type: "uint256"
10258
10189
  }
10259
10190
  ],
10260
- name: "withdraw",
10191
+ name: "getTrackedAssets",
10261
10192
  outputs: [
10262
- ],
10263
- stateMutability: "nonpayable",
10264
- type: "function"
10265
- },
10266
- {
10267
- inputs: [
10268
- {
10269
- internalType: "address",
10270
- name: "pool",
10271
- type: "address"
10272
- },
10273
- {
10274
- internalType: "uint256",
10275
- name: "fundTokenAmount",
10276
- type: "uint256"
10277
- },
10278
10193
  {
10279
- internalType: "uint256",
10280
- name: "expectedAmountOut",
10281
- type: "uint256"
10194
+ components: [
10195
+ {
10196
+ internalType: "address",
10197
+ name: "token",
10198
+ type: "address"
10199
+ },
10200
+ {
10201
+ internalType: "uint256",
10202
+ name: "balance",
10203
+ type: "uint256"
10204
+ }
10205
+ ],
10206
+ internalType: "struct IWithdrawalVault.TrackedAsset[]",
10207
+ name: "trackedAssets_",
10208
+ type: "tuple[]"
10282
10209
  }
10283
10210
  ],
10284
- name: "withdrawNative",
10285
- outputs: [
10286
- ],
10287
- stateMutability: "nonpayable",
10211
+ stateMutability: "view",
10288
10212
  type: "function"
10289
10213
  },
10290
10214
  {
10291
10215
  inputs: [
10292
10216
  {
10293
10217
  internalType: "address",
10294
- name: "pool",
10218
+ name: "_dHedgeVault",
10295
10219
  type: "address"
10296
10220
  },
10297
10221
  {
10298
10222
  internalType: "uint256",
10299
- name: "fundTokenAmount",
10223
+ name: "_amountIn",
10300
10224
  type: "uint256"
10301
10225
  },
10302
- {
10303
- internalType: "contract IERC20Extended",
10304
- name: "intermediateAsset",
10305
- type: "address"
10306
- },
10307
10226
  {
10308
10227
  internalType: "uint256",
10309
- name: "expectedAmountSUSD",
10228
+ name: "_slippageTolerance",
10310
10229
  type: "uint256"
10311
10230
  }
10312
10231
  ],
10313
- name: "withdrawSUSD",
10232
+ name: "initWithdrawal",
10314
10233
  outputs: [
10315
10234
  ],
10316
10235
  stateMutability: "nonpayable",
10317
10236
  type: "function"
10318
10237
  }
10319
10238
  ];
10320
- var IDhedgeEasySwapper = {
10321
- abi: abi$h
10322
- };
10323
-
10324
- var abi$i = [
10325
- {
10326
- inputs: [
10327
- {
10328
- internalType: "string",
10329
- name: "marketId",
10330
- type: "string"
10331
- },
10332
- {
10333
- internalType: "address",
10334
- name: "owner",
10335
- type: "address"
10336
- }
10337
- ],
10338
- stateMutability: "nonpayable",
10339
- type: "constructor"
10340
- },
10341
- {
10342
- anonymous: false,
10343
- inputs: [
10344
- {
10345
- indexed: true,
10346
- internalType: "address",
10347
- name: "oldAddress",
10348
- type: "address"
10349
- },
10350
- {
10351
- indexed: true,
10352
- internalType: "address",
10353
- name: "newAddress",
10354
- type: "address"
10355
- }
10356
- ],
10357
- name: "ACLAdminUpdated",
10358
- type: "event"
10359
- },
10360
- {
10361
- anonymous: false,
10362
- inputs: [
10363
- {
10364
- indexed: true,
10365
- internalType: "address",
10366
- name: "oldAddress",
10367
- type: "address"
10368
- },
10369
- {
10370
- indexed: true,
10371
- internalType: "address",
10372
- name: "newAddress",
10373
- type: "address"
10374
- }
10375
- ],
10376
- name: "ACLManagerUpdated",
10377
- type: "event"
10378
- },
10379
- {
10380
- anonymous: false,
10381
- inputs: [
10382
- {
10383
- indexed: true,
10384
- internalType: "bytes32",
10385
- name: "id",
10386
- type: "bytes32"
10387
- },
10388
- {
10389
- indexed: true,
10390
- internalType: "address",
10391
- name: "oldAddress",
10392
- type: "address"
10393
- },
10394
- {
10395
- indexed: true,
10396
- internalType: "address",
10397
- name: "newAddress",
10398
- type: "address"
10399
- }
10400
- ],
10401
- name: "AddressSet",
10402
- type: "event"
10403
- },
10404
- {
10405
- anonymous: false,
10406
- inputs: [
10407
- {
10408
- indexed: true,
10409
- internalType: "bytes32",
10410
- name: "id",
10411
- type: "bytes32"
10412
- },
10413
- {
10414
- indexed: true,
10415
- internalType: "address",
10416
- name: "proxyAddress",
10417
- type: "address"
10418
- },
10419
- {
10420
- indexed: false,
10421
- internalType: "address",
10422
- name: "oldImplementationAddress",
10423
- type: "address"
10424
- },
10425
- {
10426
- indexed: true,
10427
- internalType: "address",
10428
- name: "newImplementationAddress",
10429
- type: "address"
10430
- }
10431
- ],
10432
- name: "AddressSetAsProxy",
10433
- type: "event"
10434
- },
10435
- {
10436
- anonymous: false,
10437
- inputs: [
10438
- {
10439
- indexed: true,
10440
- internalType: "string",
10441
- name: "oldMarketId",
10442
- type: "string"
10443
- },
10444
- {
10445
- indexed: true,
10446
- internalType: "string",
10447
- name: "newMarketId",
10448
- type: "string"
10449
- }
10450
- ],
10451
- name: "MarketIdSet",
10452
- type: "event"
10453
- },
10454
- {
10455
- anonymous: false,
10456
- inputs: [
10457
- {
10458
- indexed: true,
10459
- internalType: "address",
10460
- name: "previousOwner",
10461
- type: "address"
10462
- },
10463
- {
10464
- indexed: true,
10465
- internalType: "address",
10466
- name: "newOwner",
10467
- type: "address"
10468
- }
10469
- ],
10470
- name: "OwnershipTransferred",
10471
- type: "event"
10472
- },
10473
- {
10474
- anonymous: false,
10475
- inputs: [
10476
- {
10477
- indexed: true,
10478
- internalType: "address",
10479
- name: "oldAddress",
10480
- type: "address"
10481
- },
10482
- {
10483
- indexed: true,
10484
- internalType: "address",
10485
- name: "newAddress",
10486
- type: "address"
10487
- }
10488
- ],
10489
- name: "PoolConfiguratorUpdated",
10490
- type: "event"
10491
- },
10492
- {
10493
- anonymous: false,
10494
- inputs: [
10495
- {
10496
- indexed: true,
10497
- internalType: "address",
10498
- name: "oldAddress",
10499
- type: "address"
10500
- },
10501
- {
10502
- indexed: true,
10503
- internalType: "address",
10504
- name: "newAddress",
10505
- type: "address"
10506
- }
10507
- ],
10508
- name: "PoolDataProviderUpdated",
10509
- type: "event"
10510
- },
10511
- {
10512
- anonymous: false,
10513
- inputs: [
10514
- {
10515
- indexed: true,
10516
- internalType: "address",
10517
- name: "oldAddress",
10518
- type: "address"
10519
- },
10520
- {
10521
- indexed: true,
10522
- internalType: "address",
10523
- name: "newAddress",
10524
- type: "address"
10525
- }
10526
- ],
10527
- name: "PoolUpdated",
10528
- type: "event"
10529
- },
10530
- {
10531
- anonymous: false,
10532
- inputs: [
10533
- {
10534
- indexed: true,
10535
- internalType: "address",
10536
- name: "oldAddress",
10537
- type: "address"
10538
- },
10539
- {
10540
- indexed: true,
10541
- internalType: "address",
10542
- name: "newAddress",
10543
- type: "address"
10544
- }
10545
- ],
10546
- name: "PriceOracleSentinelUpdated",
10547
- type: "event"
10548
- },
10549
- {
10550
- anonymous: false,
10551
- inputs: [
10552
- {
10553
- indexed: true,
10554
- internalType: "address",
10555
- name: "oldAddress",
10556
- type: "address"
10557
- },
10558
- {
10559
- indexed: true,
10560
- internalType: "address",
10561
- name: "newAddress",
10562
- type: "address"
10563
- }
10564
- ],
10565
- name: "PriceOracleUpdated",
10566
- type: "event"
10567
- },
10568
- {
10569
- anonymous: false,
10570
- inputs: [
10571
- {
10572
- indexed: true,
10573
- internalType: "bytes32",
10574
- name: "id",
10575
- type: "bytes32"
10576
- },
10577
- {
10578
- indexed: true,
10579
- internalType: "address",
10580
- name: "proxyAddress",
10581
- type: "address"
10582
- },
10583
- {
10584
- indexed: true,
10585
- internalType: "address",
10586
- name: "implementationAddress",
10587
- type: "address"
10588
- }
10589
- ],
10590
- name: "ProxyCreated",
10591
- type: "event"
10592
- },
10593
- {
10594
- inputs: [
10595
- ],
10596
- name: "getACLAdmin",
10597
- outputs: [
10598
- {
10599
- internalType: "address",
10600
- name: "",
10601
- type: "address"
10602
- }
10603
- ],
10604
- stateMutability: "view",
10605
- type: "function"
10606
- },
10607
- {
10608
- inputs: [
10609
- ],
10610
- name: "getACLManager",
10611
- outputs: [
10612
- {
10613
- internalType: "address",
10614
- name: "",
10615
- type: "address"
10616
- }
10617
- ],
10618
- stateMutability: "view",
10619
- type: "function"
10620
- },
10621
- {
10622
- inputs: [
10623
- {
10624
- internalType: "bytes32",
10625
- name: "id",
10626
- type: "bytes32"
10627
- }
10628
- ],
10629
- name: "getAddress",
10630
- outputs: [
10631
- {
10632
- internalType: "address",
10633
- name: "",
10634
- type: "address"
10635
- }
10636
- ],
10637
- stateMutability: "view",
10638
- type: "function"
10639
- },
10640
- {
10641
- inputs: [
10642
- ],
10643
- name: "getMarketId",
10644
- outputs: [
10645
- {
10646
- internalType: "string",
10647
- name: "",
10648
- type: "string"
10649
- }
10650
- ],
10651
- stateMutability: "view",
10652
- type: "function"
10653
- },
10654
- {
10655
- inputs: [
10656
- ],
10657
- name: "getPool",
10658
- outputs: [
10659
- {
10660
- internalType: "address",
10661
- name: "",
10662
- type: "address"
10663
- }
10664
- ],
10665
- stateMutability: "view",
10666
- type: "function"
10667
- },
10668
- {
10669
- inputs: [
10670
- ],
10671
- name: "getPoolConfigurator",
10672
- outputs: [
10673
- {
10674
- internalType: "address",
10675
- name: "",
10676
- type: "address"
10677
- }
10678
- ],
10679
- stateMutability: "view",
10680
- type: "function"
10681
- },
10682
- {
10683
- inputs: [
10684
- ],
10685
- name: "getPoolDataProvider",
10686
- outputs: [
10687
- {
10688
- internalType: "address",
10689
- name: "",
10690
- type: "address"
10691
- }
10692
- ],
10693
- stateMutability: "view",
10694
- type: "function"
10695
- },
10696
- {
10697
- inputs: [
10698
- ],
10699
- name: "getPriceOracle",
10700
- outputs: [
10701
- {
10702
- internalType: "address",
10703
- name: "",
10704
- type: "address"
10705
- }
10706
- ],
10707
- stateMutability: "view",
10708
- type: "function"
10709
- },
10710
- {
10711
- inputs: [
10712
- ],
10713
- name: "getPriceOracleSentinel",
10714
- outputs: [
10715
- {
10716
- internalType: "address",
10717
- name: "",
10718
- type: "address"
10719
- }
10720
- ],
10721
- stateMutability: "view",
10722
- type: "function"
10723
- },
10724
- {
10725
- inputs: [
10726
- ],
10727
- name: "owner",
10728
- outputs: [
10729
- {
10730
- internalType: "address",
10731
- name: "",
10732
- type: "address"
10733
- }
10734
- ],
10735
- stateMutability: "view",
10736
- type: "function"
10737
- },
10738
- {
10739
- inputs: [
10740
- ],
10741
- name: "renounceOwnership",
10742
- outputs: [
10743
- ],
10744
- stateMutability: "nonpayable",
10745
- type: "function"
10746
- },
10747
- {
10748
- inputs: [
10749
- {
10750
- internalType: "address",
10751
- name: "newAclAdmin",
10752
- type: "address"
10753
- }
10754
- ],
10755
- name: "setACLAdmin",
10756
- outputs: [
10757
- ],
10758
- stateMutability: "nonpayable",
10759
- type: "function"
10760
- },
10761
- {
10762
- inputs: [
10763
- {
10764
- internalType: "address",
10765
- name: "newAclManager",
10766
- type: "address"
10767
- }
10768
- ],
10769
- name: "setACLManager",
10770
- outputs: [
10771
- ],
10772
- stateMutability: "nonpayable",
10773
- type: "function"
10774
- },
10775
- {
10776
- inputs: [
10777
- {
10778
- internalType: "bytes32",
10779
- name: "id",
10780
- type: "bytes32"
10781
- },
10782
- {
10783
- internalType: "address",
10784
- name: "newAddress",
10785
- type: "address"
10786
- }
10787
- ],
10788
- name: "setAddress",
10789
- outputs: [
10790
- ],
10791
- stateMutability: "nonpayable",
10792
- type: "function"
10793
- },
10794
- {
10795
- inputs: [
10796
- {
10797
- internalType: "bytes32",
10798
- name: "id",
10799
- type: "bytes32"
10800
- },
10801
- {
10802
- internalType: "address",
10803
- name: "newImplementationAddress",
10804
- type: "address"
10805
- }
10806
- ],
10807
- name: "setAddressAsProxy",
10808
- outputs: [
10809
- ],
10810
- stateMutability: "nonpayable",
10811
- type: "function"
10812
- },
10813
- {
10814
- inputs: [
10815
- {
10816
- internalType: "string",
10817
- name: "newMarketId",
10818
- type: "string"
10819
- }
10820
- ],
10821
- name: "setMarketId",
10822
- outputs: [
10823
- ],
10824
- stateMutability: "nonpayable",
10825
- type: "function"
10826
- },
10827
- {
10828
- inputs: [
10829
- {
10830
- internalType: "address",
10831
- name: "newPoolConfiguratorImpl",
10832
- type: "address"
10833
- }
10834
- ],
10835
- name: "setPoolConfiguratorImpl",
10836
- outputs: [
10837
- ],
10838
- stateMutability: "nonpayable",
10839
- type: "function"
10840
- },
10841
- {
10842
- inputs: [
10843
- {
10844
- internalType: "address",
10845
- name: "newDataProvider",
10846
- type: "address"
10847
- }
10848
- ],
10849
- name: "setPoolDataProvider",
10850
- outputs: [
10851
- ],
10852
- stateMutability: "nonpayable",
10853
- type: "function"
10854
- },
10855
- {
10856
- inputs: [
10857
- {
10858
- internalType: "address",
10859
- name: "newPoolImpl",
10860
- type: "address"
10861
- }
10862
- ],
10863
- name: "setPoolImpl",
10864
- outputs: [
10865
- ],
10866
- stateMutability: "nonpayable",
10867
- type: "function"
10868
- },
10869
- {
10870
- inputs: [
10871
- {
10872
- internalType: "address",
10873
- name: "newPriceOracle",
10874
- type: "address"
10875
- }
10876
- ],
10877
- name: "setPriceOracle",
10878
- outputs: [
10879
- ],
10880
- stateMutability: "nonpayable",
10881
- type: "function"
10882
- },
10883
- {
10884
- inputs: [
10885
- {
10886
- internalType: "address",
10887
- name: "newPriceOracleSentinel",
10888
- type: "address"
10889
- }
10890
- ],
10891
- name: "setPriceOracleSentinel",
10892
- outputs: [
10893
- ],
10894
- stateMutability: "nonpayable",
10895
- type: "function"
10896
- },
10897
- {
10898
- inputs: [
10899
- {
10900
- internalType: "address",
10901
- name: "newOwner",
10902
- type: "address"
10903
- }
10904
- ],
10905
- name: "transferOwnership",
10906
- outputs: [
10907
- ],
10908
- stateMutability: "nonpayable",
10909
- type: "function"
10910
- }
10911
- ];
10912
- var IAaveV3PoolAddressProvider = {
10913
- abi: abi$i
10914
- };
10915
-
10916
- var abi$j = [
10917
- {
10918
- inputs: [
10919
- {
10920
- internalType: "address[]",
10921
- name: "_assets",
10922
- type: "address[]"
10923
- },
10924
- {
10925
- internalType: "address[]",
10926
- name: "_sources",
10927
- type: "address[]"
10928
- },
10929
- {
10930
- internalType: "address",
10931
- name: "_fallbackOracle",
10932
- type: "address"
10933
- }
10934
- ],
10935
- payable: false,
10936
- stateMutability: "nonpayable",
10937
- type: "constructor"
10938
- },
10939
- {
10940
- anonymous: false,
10941
- inputs: [
10942
- {
10943
- indexed: true,
10944
- internalType: "address",
10945
- name: "asset",
10946
- type: "address"
10947
- },
10948
- {
10949
- indexed: true,
10950
- internalType: "address",
10951
- name: "source",
10952
- type: "address"
10953
- }
10954
- ],
10955
- name: "AssetSourceUpdated",
10956
- type: "event"
10957
- },
10958
- {
10959
- anonymous: false,
10960
- inputs: [
10961
- {
10962
- indexed: true,
10963
- internalType: "address",
10964
- name: "fallbackOracle",
10965
- type: "address"
10966
- }
10967
- ],
10968
- name: "FallbackOracleUpdated",
10969
- type: "event"
10970
- },
10971
- {
10972
- anonymous: false,
10973
- inputs: [
10974
- {
10975
- indexed: true,
10976
- internalType: "address",
10977
- name: "previousOwner",
10978
- type: "address"
10979
- },
10980
- {
10981
- indexed: true,
10982
- internalType: "address",
10983
- name: "newOwner",
10984
- type: "address"
10985
- }
10986
- ],
10987
- name: "OwnershipTransferred",
10988
- type: "event"
10989
- },
10990
- {
10991
- constant: true,
10992
- inputs: [
10993
- ],
10994
- name: "isOwner",
10995
- outputs: [
10996
- {
10997
- internalType: "bool",
10998
- name: "",
10999
- type: "bool"
11000
- }
11001
- ],
11002
- payable: false,
11003
- stateMutability: "view",
11004
- type: "function"
11005
- },
11006
- {
11007
- constant: true,
11008
- inputs: [
11009
- ],
11010
- name: "owner",
11011
- outputs: [
11012
- {
11013
- internalType: "address",
11014
- name: "",
11015
- type: "address"
11016
- }
11017
- ],
11018
- payable: false,
11019
- stateMutability: "view",
11020
- type: "function"
11021
- },
11022
- {
11023
- constant: false,
11024
- inputs: [
11025
- ],
11026
- name: "renounceOwnership",
11027
- outputs: [
11028
- ],
11029
- payable: false,
11030
- stateMutability: "nonpayable",
11031
- type: "function"
11032
- },
11033
- {
11034
- constant: false,
11035
- inputs: [
11036
- {
11037
- internalType: "address",
11038
- name: "newOwner",
11039
- type: "address"
11040
- }
11041
- ],
11042
- name: "transferOwnership",
11043
- outputs: [
11044
- ],
11045
- payable: false,
11046
- stateMutability: "nonpayable",
11047
- type: "function"
11048
- },
11049
- {
11050
- constant: false,
11051
- inputs: [
11052
- {
11053
- internalType: "address[]",
11054
- name: "_assets",
11055
- type: "address[]"
11056
- },
11057
- {
11058
- internalType: "address[]",
11059
- name: "_sources",
11060
- type: "address[]"
11061
- }
11062
- ],
11063
- name: "setAssetSources",
11064
- outputs: [
11065
- ],
11066
- payable: false,
11067
- stateMutability: "nonpayable",
11068
- type: "function"
11069
- },
11070
- {
11071
- constant: false,
11072
- inputs: [
11073
- {
11074
- internalType: "address",
11075
- name: "_fallbackOracle",
11076
- type: "address"
11077
- }
11078
- ],
11079
- name: "setFallbackOracle",
11080
- outputs: [
11081
- ],
11082
- payable: false,
11083
- stateMutability: "nonpayable",
11084
- type: "function"
11085
- },
11086
- {
11087
- constant: true,
11088
- inputs: [
11089
- {
11090
- internalType: "address",
11091
- name: "_asset",
11092
- type: "address"
11093
- }
11094
- ],
11095
- name: "getAssetPrice",
11096
- outputs: [
11097
- {
11098
- internalType: "uint256",
11099
- name: "",
11100
- type: "uint256"
11101
- }
11102
- ],
11103
- payable: false,
11104
- stateMutability: "view",
11105
- type: "function"
11106
- },
11107
- {
11108
- constant: true,
11109
- inputs: [
11110
- {
11111
- internalType: "address[]",
11112
- name: "_assets",
11113
- type: "address[]"
11114
- }
11115
- ],
11116
- name: "getAssetsPrices",
11117
- outputs: [
11118
- {
11119
- internalType: "uint256[]",
11120
- name: "",
11121
- type: "uint256[]"
11122
- }
11123
- ],
11124
- payable: false,
11125
- stateMutability: "view",
11126
- type: "function"
11127
- },
11128
- {
11129
- constant: true,
11130
- inputs: [
11131
- {
11132
- internalType: "address",
11133
- name: "_asset",
11134
- type: "address"
11135
- }
11136
- ],
11137
- name: "getSourceOfAsset",
11138
- outputs: [
11139
- {
11140
- internalType: "address",
11141
- name: "",
11142
- type: "address"
11143
- }
11144
- ],
11145
- payable: false,
11146
- stateMutability: "view",
11147
- type: "function"
11148
- },
11149
- {
11150
- constant: true,
11151
- inputs: [
11152
- ],
11153
- name: "getFallbackOracle",
11154
- outputs: [
11155
- {
11156
- internalType: "address",
11157
- name: "",
11158
- type: "address"
11159
- }
11160
- ],
11161
- payable: false,
11162
- stateMutability: "view",
11163
- type: "function"
11164
- }
11165
- ];
11166
- var IPriceOracle = {
11167
- abi: abi$j
11168
- };
11169
-
11170
- function getChainlinkPriceInUsd(_x, _x2) {
11171
- return _getChainlinkPriceInUsd.apply(this, arguments);
11172
- }
11173
-
11174
- function _getChainlinkPriceInUsd() {
11175
- _getChainlinkPriceInUsd = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(pool, asset) {
11176
- var lendingPoolAddressProvider, priceOracleAddress, priceOracle;
11177
- return runtime_1.wrap(function _callee$(_context) {
11178
- while (1) {
11179
- switch (_context.prev = _context.next) {
11180
- case 0:
11181
- //Workaround as Chainlink doesn't have feed registry on Polygon/Optimism
11182
- //Use oracle from Aave which uses Chainlink
11183
- lendingPoolAddressProvider = new ethers.Contract(aaveAddressProvider[pool.network][Dapp.AAVEV3], IAaveV3PoolAddressProvider.abi, pool.signer);
11184
- _context.next = 3;
11185
- return lendingPoolAddressProvider.getPriceOracle();
11186
-
11187
- case 3:
11188
- priceOracleAddress = _context.sent;
11189
- priceOracle = new ethers.Contract(priceOracleAddress, IPriceOracle.abi, pool.signer);
11190
- _context.next = 7;
11191
- return priceOracle.getAssetPrice(asset);
11192
-
11193
- case 7:
11194
- return _context.abrupt("return", _context.sent);
11195
-
11196
- case 8:
11197
- case "end":
11198
- return _context.stop();
11199
- }
11200
- }
11201
- }, _callee);
11202
- }));
11203
- return _getChainlinkPriceInUsd.apply(this, arguments);
11204
- }
11205
10239
 
11206
10240
  function loadPool(_x, _x2) {
11207
10241
  return _loadPool.apply(this, arguments);
@@ -11249,16 +10283,179 @@ function _isPool() {
11249
10283
  case 3:
11250
10284
  return _context2.abrupt("return", _context2.sent);
11251
10285
 
11252
- case 4:
10286
+ case 4:
10287
+ case "end":
10288
+ return _context2.stop();
10289
+ }
10290
+ }
10291
+ }, _callee2);
10292
+ }));
10293
+ return _isPool.apply(this, arguments);
10294
+ }
10295
+
10296
+ var oneInchBaseUrl = "https://api.1inch.dev/swap/v6.0/";
10297
+ function getOneInchSwapTxData(_x, _x2, _x3, _x4, _x5, _x6) {
10298
+ return _getOneInchSwapTxData.apply(this, arguments);
10299
+ }
10300
+
10301
+ function _getOneInchSwapTxData() {
10302
+ _getOneInchSwapTxData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(pool, assetFrom, assetTo, amountIn, slippage, forEasySwapper) {
10303
+ var chainId, apiUrl, params, response, swapTxData, dstAmount;
10304
+ return runtime_1.wrap(function _callee$(_context) {
10305
+ while (1) {
10306
+ switch (_context.prev = _context.next) {
10307
+ case 0:
10308
+ if (forEasySwapper === void 0) {
10309
+ forEasySwapper = false;
10310
+ }
10311
+
10312
+ if (process.env.ONEINCH_API_KEY) {
10313
+ _context.next = 3;
10314
+ break;
10315
+ }
10316
+
10317
+ throw new Error("ONEINCH_API_KEY not configured in .env file");
10318
+
10319
+ case 3:
10320
+ chainId = networkChainIdMap[pool.network];
10321
+ apiUrl = "" + oneInchBaseUrl + chainId + "/swap";
10322
+ params = {
10323
+ src: assetFrom,
10324
+ dst: assetTo,
10325
+ amount: amountIn.toString(),
10326
+ from: forEasySwapper ? routerAddress[pool.network].toros : pool.address,
10327
+ receiver: forEasySwapper ? routerAddress[pool.network].toros : pool.address,
10328
+ slippage: slippage,
10329
+ disableEstimate: true,
10330
+ usePermit2: false
10331
+ };
10332
+ _context.prev = 6;
10333
+ _context.next = 9;
10334
+ return axios.get(apiUrl, {
10335
+ headers: {
10336
+ Authorization: "Bearer " + process.env.ONEINCH_API_KEY
10337
+ },
10338
+ params: params
10339
+ });
10340
+
10341
+ case 9:
10342
+ response = _context.sent;
10343
+ swapTxData = response.data.tx.data;
10344
+ dstAmount = response.data.dstAmount;
10345
+ return _context.abrupt("return", {
10346
+ swapTxData: swapTxData,
10347
+ dstAmount: dstAmount
10348
+ });
10349
+
10350
+ case 15:
10351
+ _context.prev = 15;
10352
+ _context.t0 = _context["catch"](6);
10353
+ throw new ApiError("Swap api request of 1inch failed");
10354
+
10355
+ case 18:
11253
10356
  case "end":
11254
- return _context2.stop();
10357
+ return _context.stop();
11255
10358
  }
11256
10359
  }
11257
- }, _callee2);
10360
+ }, _callee, null, [[6, 15]]);
11258
10361
  }));
11259
- return _isPool.apply(this, arguments);
10362
+ return _getOneInchSwapTxData.apply(this, arguments);
11260
10363
  }
11261
10364
 
10365
+ var _networkPortMap;
10366
+
10367
+ require("dotenv").config();
10368
+
10369
+ var networkPortMap = (_networkPortMap = {}, _networkPortMap[Network.POLYGON] = 8542, _networkPortMap[Network.OPTIMISM] = 8544, _networkPortMap[Network.ARBITRUM] = 8540, _networkPortMap[Network.BASE] = 8546, _networkPortMap);
10370
+
10371
+ var _TEST_POOL, _CONTRACT_ADDRESS, _USDC_BALANCEOF_SLOT, _WETH_BALANCEOF_SLOT;
10372
+ var TEST_POOL = (_TEST_POOL = {}, _TEST_POOL[Network.POLYGON] = "0x699fd4d6eadb216704c7e355cfa0a12f51813163", _TEST_POOL[Network.OPTIMISM] = "0x12573bfdf764ab9d52aca20e2827497a66829716", _TEST_POOL[Network.ARBITRUM] = "0x0b5f6591c8eb23e5a68102d3d39ebbb464ee5c14", _TEST_POOL[Network.BASE] = "0x4842b42F68524383F609aa46eAfc18c1459cE3cD", _TEST_POOL);
10373
+ var CONTRACT_ADDRESS = (_CONTRACT_ADDRESS = {}, _CONTRACT_ADDRESS[Network.POLYGON] = {
10374
+ USDC: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
10375
+ USDT: "",
10376
+ SUSD: "",
10377
+ SWETH: "",
10378
+ WETH: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
10379
+ WBTC: "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6",
10380
+ ARRAKIS_USDC_WETH_GAUGE: "0x33d1ad9Cd88A509397CD924C2d7613C285602C20",
10381
+ ARRAKIS_USDC_WETH_LP: "0xa173340f1e942c2845bcbce8ebd411022e18eb13",
10382
+ WMATIC: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
10383
+ uniswapV3: {
10384
+ nonfungiblePositionManager: "0xC36442b4a4522E871399CD717aBDD847Ab11FE88"
10385
+ },
10386
+ VELODROME_CL_USDC_WETH_GAUGE: "",
10387
+ VELO: "",
10388
+ COMPOUNDV3_WETH: "",
10389
+ TOROS: ""
10390
+ }, _CONTRACT_ADDRESS[Network.OPTIMISM] = {
10391
+ USDC: "0x0b2c639c533813f4aa9d7837caf62653d097ff85",
10392
+ USDT: "",
10393
+ SWETH: "",
10394
+ SUSD: "0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9",
10395
+ WETH: "0x4200000000000000000000000000000000000006",
10396
+ WBTC: "0x68f180fcCe6836688e9084f035309E29Bf0A2095",
10397
+ KWENTA_ETH_PERP_V2: "0x2b3bb4c683bfc5239b029131eef3b1d214478d93",
10398
+ uniswapV3: {
10399
+ nonfungiblePositionManager: "0xC36442b4a4522E871399CD717aBDD847Ab11FE88"
10400
+ },
10401
+ WMATIC: "",
10402
+ //
10403
+ ARRAKIS_USDC_WETH_GAUGE: "",
10404
+ ARRAKIS_USDC_WETH_LP: "",
10405
+ VELODROME_CL_USDC_WETH_GAUGE: "0xa75127121d28a9BF848F3B70e7Eea26570aa7700",
10406
+ VELO: "0x9560e827aF36c94D2Ac33a39bCE1Fe78631088Db",
10407
+ COMPOUNDV3_WETH: "",
10408
+ TOROS: "0x49bf093277bf4dde49c48c6aa55a3bda3eedef68" //USDmny
10409
+
10410
+ }, _CONTRACT_ADDRESS[Network.ARBITRUM] = {
10411
+ USDC: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
10412
+ USDT: "",
10413
+ SUSD: "",
10414
+ SWETH: "0xbc011A12Da28e8F0f528d9eE5E7039E22F91cf18",
10415
+ WETH: "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
10416
+ WBTC: "0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f",
10417
+ WSTETH: "0x5979d7b546e38e414f7e9822514be443a4800529",
10418
+ BALANCER_WSTETH_WETH_POOL: "0x36bf227d6bac96e2ab1ebb5492ecec69c691943f",
10419
+ BALANCER_WSTETH_WETH_GAUGE: "0x251e51b25afa40f2b6b9f05aaf1bc7eaa0551771",
10420
+ uniswapV3: {
10421
+ nonfungiblePositionManager: "0xC36442b4a4522E871399CD717aBDD847Ab11FE88"
10422
+ },
10423
+ //
10424
+ ARRAKIS_USDC_WETH_GAUGE: "",
10425
+ ARRAKIS_USDC_WETH_LP: "",
10426
+ WMATIC: "",
10427
+ VELODROME_CL_USDC_WETH_GAUGE: "",
10428
+ VELO: "",
10429
+ COMPOUNDV3_WETH: "0x6f7D514bbD4aFf3BcD1140B7344b32f063dEe486",
10430
+ TOROS: ""
10431
+ }, _CONTRACT_ADDRESS[Network.BASE] = {
10432
+ USDC: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
10433
+ USDT: "0xfde4c96c8593536e31f229ea8f37b2ada2699bb2",
10434
+ SUSD: "",
10435
+ WETH: "0x4200000000000000000000000000000000000006",
10436
+ WBTC: "",
10437
+ SWETH: "",
10438
+ uniswapV3: {
10439
+ nonfungiblePositionManager: ""
10440
+ },
10441
+ //
10442
+ ARRAKIS_USDC_WETH_GAUGE: "",
10443
+ ARRAKIS_USDC_WETH_LP: "",
10444
+ WMATIC: "",
10445
+ VELODROME_CL_USDC_WETH_GAUGE: "0xF33a96b5932D9E9B9A0eDA447AbD8C9d48d2e0c8",
10446
+ VELO: "0x940181a94A35A4569E4529A3CDfB74e38FD98631",
10447
+ COMPOUNDV3_WETH: "",
10448
+ TOROS: ""
10449
+ }, _CONTRACT_ADDRESS);
10450
+ var USDC_BALANCEOF_SLOT = (_USDC_BALANCEOF_SLOT = {}, _USDC_BALANCEOF_SLOT[Network.OPTIMISM] = 9, _USDC_BALANCEOF_SLOT[Network.ARBITRUM] = 9, _USDC_BALANCEOF_SLOT[Network.POLYGON] = 0, _USDC_BALANCEOF_SLOT[Network.BASE] = 9, _USDC_BALANCEOF_SLOT);
10451
+ var WETH_BALANCEOF_SLOT = (_WETH_BALANCEOF_SLOT = {}, _WETH_BALANCEOF_SLOT[Network.OPTIMISM] = 3, _WETH_BALANCEOF_SLOT[Network.ARBITRUM] = 51, _WETH_BALANCEOF_SLOT[Network.POLYGON] = 0, _WETH_BALANCEOF_SLOT[Network.BASE] = 0, _WETH_BALANCEOF_SLOT);
10452
+
10453
+ var wait = function wait(seconds) {
10454
+ return new Promise(function (resolve) {
10455
+ return setTimeout(resolve, seconds * 1000);
10456
+ });
10457
+ };
10458
+
11262
10459
  function getPoolDepositAsset(_x, _x2, _x3) {
11263
10460
  return _getPoolDepositAsset.apply(this, arguments);
11264
10461
  }
@@ -11307,52 +10504,20 @@ function _getPoolDepositAsset() {
11307
10504
  return _getPoolDepositAsset.apply(this, arguments);
11308
10505
  }
11309
10506
 
11310
- function getTorosPoolTokenPrice(_x4, _x5) {
11311
- return _getTorosPoolTokenPrice.apply(this, arguments);
11312
- }
11313
-
11314
- function _getTorosPoolTokenPrice() {
11315
- _getTorosPoolTokenPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(pool, poolAddress) {
11316
- var torosPool;
11317
- return runtime_1.wrap(function _callee2$(_context2) {
11318
- while (1) {
11319
- switch (_context2.prev = _context2.next) {
11320
- case 0:
11321
- _context2.next = 2;
11322
- return loadPool(pool, poolAddress);
11323
-
11324
- case 2:
11325
- torosPool = _context2.sent;
11326
- _context2.next = 5;
11327
- return torosPool.poolLogic.tokenPrice();
11328
-
11329
- case 5:
11330
- return _context2.abrupt("return", _context2.sent);
11331
-
11332
- case 6:
11333
- case "end":
11334
- return _context2.stop();
11335
- }
11336
- }
11337
- }, _callee2);
11338
- }));
11339
- return _getTorosPoolTokenPrice.apply(this, arguments);
11340
- }
11341
-
11342
- function getEasySwapperDepositQuote(_x6, _x7, _x8, _x9, _x10) {
10507
+ function getEasySwapperDepositQuote(_x6, _x7, _x8, _x9) {
11343
10508
  return _getEasySwapperDepositQuote.apply(this, arguments);
11344
10509
  }
11345
10510
 
11346
10511
  function _getEasySwapperDepositQuote() {
11347
- _getEasySwapperDepositQuote = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(pool, torosAsset, investAsset, depositAsset, amountIn) {
10512
+ _getEasySwapperDepositQuote = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(pool, torosAsset, investAsset, amountIn) {
11348
10513
  var easySwapper;
11349
10514
  return runtime_1.wrap(function _callee3$(_context3) {
11350
10515
  while (1) {
11351
10516
  switch (_context3.prev = _context3.next) {
11352
10517
  case 0:
11353
- easySwapper = new ethers.Contract(routerAddress[pool.network][Dapp.TOROS], IDhedgeEasySwapper.abi, pool.signer);
10518
+ easySwapper = new ethers.Contract(routerAddress[pool.network][Dapp.TOROS], IDhedgeEasySwapper, pool.signer);
11354
10519
  _context3.next = 3;
11355
- return easySwapper.depositQuote(torosAsset, investAsset, amountIn, depositAsset, true);
10520
+ return easySwapper.depositQuote(torosAsset, investAsset, amountIn);
11356
10521
 
11357
10522
  case 3:
11358
10523
  return _context3.abrupt("return", _context3.sent);
@@ -11367,46 +10532,14 @@ function _getEasySwapperDepositQuote() {
11367
10532
  return _getEasySwapperDepositQuote.apply(this, arguments);
11368
10533
  }
11369
10534
 
11370
- function getEasySwapperWithdrawalQuote(_x11, _x12, _x13, _x14) {
11371
- return _getEasySwapperWithdrawalQuote.apply(this, arguments);
11372
- }
11373
-
11374
- function _getEasySwapperWithdrawalQuote() {
11375
- _getEasySwapperWithdrawalQuote = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(pool, torosAsset, investAsset, amountIn) {
11376
- var _yield$Promise$all, torosTokenPrice, assetPrice, assetDecimals;
11377
-
11378
- return runtime_1.wrap(function _callee4$(_context4) {
11379
- while (1) {
11380
- switch (_context4.prev = _context4.next) {
11381
- case 0:
11382
- _context4.next = 2;
11383
- return Promise.all([getTorosPoolTokenPrice(pool, torosAsset), getChainlinkPriceInUsd(pool, investAsset), pool.utils.getDecimals(investAsset)]);
11384
-
11385
- case 2:
11386
- _yield$Promise$all = _context4.sent;
11387
- torosTokenPrice = _yield$Promise$all[0];
11388
- assetPrice = _yield$Promise$all[1];
11389
- assetDecimals = _yield$Promise$all[2];
11390
- return _context4.abrupt("return", amountIn.mul(torosTokenPrice).div(assetPrice).div(1e10).div(Math.pow(10, 18 - assetDecimals)));
11391
-
11392
- case 7:
11393
- case "end":
11394
- return _context4.stop();
11395
- }
11396
- }
11397
- }, _callee4);
11398
- }));
11399
- return _getEasySwapperWithdrawalQuote.apply(this, arguments);
11400
- }
11401
-
11402
- function getEasySwapperTxData(_x15, _x16, _x17, _x18, _x19) {
10535
+ function getEasySwapperTxData(_x14, _x15, _x16, _x17, _x18) {
11403
10536
  return _getEasySwapperTxData.apply(this, arguments);
11404
10537
  }
11405
10538
 
11406
10539
  function _getEasySwapperTxData() {
11407
10540
  _getEasySwapperTxData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(pool, assetFrom, assetTo, amountIn, slippage // eslint-disable-next-line @typescript-eslint/no-explicit-any
11408
10541
  ) {
11409
- var isWithdrawal, _ref, torosAsset, investAsset, iDhedgeEasySwapper, minAmountOut, depositAsset, _minAmountOut;
10542
+ var isWithdrawal, _ref, torosAsset, investAsset, iDhedgeEasySwapper, depositAsset, minAmountOut;
11410
10543
 
11411
10544
  return runtime_1.wrap(function _callee5$(_context5) {
11412
10545
  while (1) {
@@ -11418,43 +10551,46 @@ function _getEasySwapperTxData() {
11418
10551
  case 2:
11419
10552
  isWithdrawal = _context5.sent;
11420
10553
  _ref = isWithdrawal ? [assetFrom, assetTo] : [assetTo, assetFrom], torosAsset = _ref[0], investAsset = _ref[1];
11421
- iDhedgeEasySwapper = new ethers.utils.Interface(IDhedgeEasySwapper.abi);
10554
+ iDhedgeEasySwapper = new ethers.utils.Interface(IDhedgeEasySwapper);
11422
10555
 
11423
10556
  if (!isWithdrawal) {
11424
- _context5.next = 12;
10557
+ _context5.next = 9;
11425
10558
  break;
11426
10559
  }
11427
10560
 
11428
- _context5.next = 8;
11429
- return getEasySwapperWithdrawalQuote(pool, torosAsset, investAsset, amountIn);
11430
-
11431
- case 8:
11432
- minAmountOut = _context5.sent;
11433
- return _context5.abrupt("return", iDhedgeEasySwapper.encodeFunctionData("withdraw", [torosAsset, amountIn, investAsset, minAmountOut.mul(10000 - slippage * 100).div(10000)]));
10561
+ return _context5.abrupt("return", iDhedgeEasySwapper.encodeFunctionData("initWithdrawal", [torosAsset, amountIn, slippage * 100]));
11434
10562
 
11435
- case 12:
11436
- _context5.next = 14;
10563
+ case 9:
10564
+ _context5.next = 11;
11437
10565
  return getPoolDepositAsset(pool, torosAsset, investAsset);
11438
10566
 
11439
- case 14:
10567
+ case 11:
11440
10568
  depositAsset = _context5.sent;
11441
10569
 
11442
10570
  if (depositAsset) {
11443
- _context5.next = 17;
10571
+ _context5.next = 14;
11444
10572
  break;
11445
10573
  }
11446
10574
 
11447
10575
  throw new Error("no deposit assets");
11448
10576
 
11449
- case 17:
11450
- _context5.next = 19;
11451
- return getEasySwapperDepositQuote(pool, torosAsset, investAsset, depositAsset, amountIn);
10577
+ case 14:
10578
+ if (!(depositAsset.toLowerCase() !== investAsset.toLowerCase())) {
10579
+ _context5.next = 16;
10580
+ break;
10581
+ }
11452
10582
 
11453
- case 19:
11454
- _minAmountOut = _context5.sent;
11455
- return _context5.abrupt("return", iDhedgeEasySwapper.encodeFunctionData("depositWithCustomCooldown", [torosAsset, investAsset, amountIn, depositAsset, _minAmountOut.mul(10000 - slippage * 100).div(10000)]));
10583
+ throw new Error("can only trade deposit asset");
11456
10584
 
11457
- case 21:
10585
+ case 16:
10586
+ _context5.next = 18;
10587
+ return getEasySwapperDepositQuote(pool, torosAsset, investAsset, amountIn);
10588
+
10589
+ case 18:
10590
+ minAmountOut = _context5.sent;
10591
+ return _context5.abrupt("return", iDhedgeEasySwapper.encodeFunctionData("depositWithCustomCooldown", [torosAsset, depositAsset, amountIn, minAmountOut.mul(10000 - slippage * 100).div(10000)]));
10592
+
10593
+ case 20:
11458
10594
  case "end":
11459
10595
  return _context5.stop();
11460
10596
  }
@@ -11464,7 +10600,83 @@ function _getEasySwapperTxData() {
11464
10600
  return _getEasySwapperTxData.apply(this, arguments);
11465
10601
  }
11466
10602
 
11467
- var abi$k = [
10603
+ function getCompleteWithdrawalTxData(_x19, _x20, _x21) {
10604
+ return _getCompleteWithdrawalTxData.apply(this, arguments);
10605
+ }
10606
+
10607
+ function _getCompleteWithdrawalTxData() {
10608
+ _getCompleteWithdrawalTxData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(pool, destToken, slippage // eslint-disable-next-line @typescript-eslint/no-explicit-any
10609
+ ) {
10610
+ var easySwapper, trackedAssets, trackedAssetsExcludingDestToken, srcData, minDestAmount, _iterator, _step, _step$value, token, balance, _yield$getOneInchSwap, swapTxData, dstAmount;
10611
+
10612
+ return runtime_1.wrap(function _callee6$(_context6) {
10613
+ while (1) {
10614
+ switch (_context6.prev = _context6.next) {
10615
+ case 0:
10616
+ easySwapper = new ethers.Contract(routerAddress[pool.network][Dapp.TOROS], IDhedgeEasySwapper, pool.signer);
10617
+ _context6.next = 3;
10618
+ return easySwapper.getTrackedAssets(pool.address);
10619
+
10620
+ case 3:
10621
+ trackedAssets = _context6.sent;
10622
+ trackedAssetsExcludingDestToken = trackedAssets.filter(function (_ref2) {
10623
+ var token = _ref2.token;
10624
+ return token.toLowerCase() !== destToken.toLowerCase();
10625
+ });
10626
+ srcData = [];
10627
+ minDestAmount = ethers.BigNumber.from(0);
10628
+ _iterator = _createForOfIteratorHelperLoose(trackedAssetsExcludingDestToken);
10629
+
10630
+ case 8:
10631
+ if ((_step = _iterator()).done) {
10632
+ _context6.next = 21;
10633
+ break;
10634
+ }
10635
+
10636
+ _step$value = _step.value, token = _step$value.token, balance = _step$value.balance;
10637
+ _context6.next = 12;
10638
+ return getOneInchSwapTxData(pool, token, destToken, balance, slippage, true);
10639
+
10640
+ case 12:
10641
+ _yield$getOneInchSwap = _context6.sent;
10642
+ swapTxData = _yield$getOneInchSwap.swapTxData;
10643
+ dstAmount = _yield$getOneInchSwap.dstAmount;
10644
+ srcData.push({
10645
+ token: token,
10646
+ amount: balance,
10647
+ aggregatorData: {
10648
+ routerKey: ethers.utils.formatBytes32String("ONE_INCH"),
10649
+ swapData: swapTxData
10650
+ }
10651
+ });
10652
+ minDestAmount = minDestAmount.add(dstAmount);
10653
+ _context6.next = 19;
10654
+ return wait(2);
10655
+
10656
+ case 19:
10657
+ _context6.next = 8;
10658
+ break;
10659
+
10660
+ case 21:
10661
+ return _context6.abrupt("return", easySwapper["interface"].encodeFunctionData("completeWithdrawal", [{
10662
+ srcData: srcData,
10663
+ destData: {
10664
+ destToken: destToken,
10665
+ minDestAmount: minDestAmount
10666
+ }
10667
+ }, minDestAmount.mul(10000 - slippage * 100).div(10000)]));
10668
+
10669
+ case 22:
10670
+ case "end":
10671
+ return _context6.stop();
10672
+ }
10673
+ }
10674
+ }, _callee6);
10675
+ }));
10676
+ return _getCompleteWithdrawalTxData.apply(this, arguments);
10677
+ }
10678
+
10679
+ var abi$h = [
11468
10680
  {
11469
10681
  inputs: [
11470
10682
  {
@@ -12391,10 +11603,10 @@ var abi$k = [
12391
11603
  }
12392
11604
  ];
12393
11605
  var IAaveV3Incentives = {
12394
- abi: abi$k
11606
+ abi: abi$h
12395
11607
  };
12396
11608
 
12397
- var abi$l = [
11609
+ var abi$i = [
12398
11610
  {
12399
11611
  inputs: [
12400
11612
  {
@@ -14143,7 +13355,7 @@ var abi$l = [
14143
13355
  }
14144
13356
  ];
14145
13357
  var ILendingPoolV3 = {
14146
- abi: abi$l
13358
+ abi: abi$i
14147
13359
  };
14148
13360
 
14149
13361
  function getAaveAssetsForUnderlying(_x, _x2, _x3) {
@@ -14214,7 +13426,7 @@ function _getAaveV3ClaimTxData() {
14214
13426
  return _getAaveV3ClaimTxData.apply(this, arguments);
14215
13427
  }
14216
13428
 
14217
- var abi$m = [
13429
+ var abi$j = [
14218
13430
  {
14219
13431
  inputs: [
14220
13432
  {
@@ -15196,7 +14408,7 @@ var abi$m = [
15196
14408
  }
15197
14409
  ];
15198
14410
  var IVelodromeRouter = {
15199
- abi: abi$m
14411
+ abi: abi$j
15200
14412
  };
15201
14413
 
15202
14414
  function getVelodromeAddLiquidityTxData(_x, _x2, _x3, _x4, _x5, _x6) {
@@ -15303,7 +14515,7 @@ function _getVelodromeClOwner() {
15303
14515
  return _getVelodromeClOwner.apply(this, arguments);
15304
14516
  }
15305
14517
 
15306
- var abi$n = [
14518
+ var abi$k = [
15307
14519
  {
15308
14520
  inputs: [
15309
14521
  {
@@ -16345,10 +15557,10 @@ var abi$n = [
16345
15557
  }
16346
15558
  ];
16347
15559
  var IVelodromeGaugeV1 = {
16348
- abi: abi$n
15560
+ abi: abi$k
16349
15561
  };
16350
15562
 
16351
- var abi$o = [
15563
+ var abi$l = [
16352
15564
  {
16353
15565
  inputs: [
16354
15566
  {
@@ -16548,10 +15760,10 @@ var abi$o = [
16548
15760
  }
16549
15761
  ];
16550
15762
  var IVelodromeGaugeV2 = {
16551
- abi: abi$o
15763
+ abi: abi$l
16552
15764
  };
16553
15765
 
16554
- var abi$p = [
15766
+ var abi$m = [
16555
15767
  {
16556
15768
  inputs: [
16557
15769
  {
@@ -16722,7 +15934,7 @@ var abi$p = [
16722
15934
  }
16723
15935
  ];
16724
15936
  var IVelodromeCLGauge = {
16725
- abi: abi$p
15937
+ abi: abi$m
16726
15938
  };
16727
15939
 
16728
15940
  function call(_x, _x2, _x3, _x4) {
@@ -17008,7 +16220,7 @@ function _getStrike() {
17008
16220
  return _getStrike.apply(this, arguments);
17009
16221
  }
17010
16222
 
17011
- var abi$q = [
16223
+ var abi$n = [
17012
16224
  {
17013
16225
  inputs: [
17014
16226
  {
@@ -18360,7 +17572,7 @@ var abi$q = [
18360
17572
  }
18361
17573
  ];
18362
17574
  var IOptionMarketWrapper = {
18363
- abi: abi$q
17575
+ abi: abi$n
18364
17576
  };
18365
17577
 
18366
17578
  function getLyraTradeOptionType(isCall, isLong, isCoveredCall) {
@@ -18377,7 +17589,7 @@ function isLong(optionType) {
18377
17589
  return optionType === 0 || optionType === 1;
18378
17590
  }
18379
17591
 
18380
- var abi$r = [
17592
+ var abi$o = [
18381
17593
  {
18382
17594
  inputs: [
18383
17595
  {
@@ -20711,7 +19923,7 @@ var abi$r = [
20711
19923
  }
20712
19924
  ];
20713
19925
  var IOptionToken = {
20714
- abi: abi$r
19926
+ abi: abi$o
20715
19927
  };
20716
19928
 
20717
19929
  function getOptionPositions(_x, _x2) {
@@ -20849,7 +20061,7 @@ function _getLyraOptionTxData() {
20849
20061
  return _getLyraOptionTxData.apply(this, arguments);
20850
20062
  }
20851
20063
 
20852
- var abi$s = [
20064
+ var abi$p = [
20853
20065
  {
20854
20066
  inputs: [
20855
20067
  {
@@ -21394,7 +20606,7 @@ var abi$s = [
21394
20606
  }
21395
20607
  ];
21396
20608
  var ISynthetixFuturesMarketV2 = {
21397
- abi: abi$s
20609
+ abi: abi$p
21398
20610
  };
21399
20611
 
21400
20612
  function getFuturesChangeMarginTxData(amount) {
@@ -21545,67 +20757,7 @@ var getZeroExTradeTxData = /*#__PURE__*/function () {
21545
20757
  };
21546
20758
  }();
21547
20759
 
21548
- var oneInchBaseUrl = "https://api.1inch.dev/swap/v6.0/";
21549
- function getOneInchSwapTxData(_x, _x2, _x3, _x4, _x5) {
21550
- return _getOneInchSwapTxData.apply(this, arguments);
21551
- }
21552
-
21553
- function _getOneInchSwapTxData() {
21554
- _getOneInchSwapTxData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(pool, assetFrom, assetTo, amountIn, slippage) {
21555
- var chainId, apiUrl, params, response;
21556
- return runtime_1.wrap(function _callee$(_context) {
21557
- while (1) {
21558
- switch (_context.prev = _context.next) {
21559
- case 0:
21560
- if (process.env.ONEINCH_API_KEY) {
21561
- _context.next = 2;
21562
- break;
21563
- }
21564
-
21565
- throw new Error("ONEINCH_API_KEY not configured in .env file");
21566
-
21567
- case 2:
21568
- chainId = networkChainIdMap[pool.network];
21569
- apiUrl = "" + oneInchBaseUrl + chainId + "/swap";
21570
- params = {
21571
- src: assetFrom,
21572
- dst: assetTo,
21573
- amount: amountIn.toString(),
21574
- from: pool.address,
21575
- origin: pool.signer.address,
21576
- slippage: slippage,
21577
- disableEstimate: true,
21578
- usePermit2: false
21579
- };
21580
- _context.prev = 5;
21581
- _context.next = 8;
21582
- return axios.get(apiUrl, {
21583
- headers: {
21584
- Authorization: "Bearer " + process.env.ONEINCH_API_KEY
21585
- },
21586
- params: params
21587
- });
21588
-
21589
- case 8:
21590
- response = _context.sent;
21591
- return _context.abrupt("return", response.data.tx.data);
21592
-
21593
- case 12:
21594
- _context.prev = 12;
21595
- _context.t0 = _context["catch"](5);
21596
- throw new ApiError("Swap api request of 1inch failed");
21597
-
21598
- case 15:
21599
- case "end":
21600
- return _context.stop();
21601
- }
21602
- }
21603
- }, _callee, null, [[5, 12]]);
21604
- }));
21605
- return _getOneInchSwapTxData.apply(this, arguments);
21606
- }
21607
-
21608
- var abi$t = [
20760
+ var abi$q = [
21609
20761
  {
21610
20762
  inputs: [
21611
20763
  {
@@ -21706,7 +20858,7 @@ var abi$t = [
21706
20858
  }
21707
20859
  ];
21708
20860
  var IXRam = {
21709
- abi: abi$t
20861
+ abi: abi$q
21710
20862
  };
21711
20863
 
21712
20864
  /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -25041,7 +24193,8 @@ var Pool = /*#__PURE__*/function () {
25041
24193
  /*#__PURE__*/
25042
24194
  function () {
25043
24195
  var _trade = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(dapp, assetFrom, assetTo, amountIn, slippage, options, estimateGas) {
25044
- var swapTxData, iSynthetix, assets, daoAddress, iUniswapV2Router, minAmountOut, tx;
24196
+ var swapTxData, _yield$getOneInchSwap, iSynthetix, assets, daoAddress, iUniswapV2Router, minAmountOut, tx;
24197
+
25045
24198
  return runtime_1.wrap(function _callee10$(_context10) {
25046
24199
  while (1) {
25047
24200
  switch (_context10.prev = _context10.next) {
@@ -25059,7 +24212,7 @@ var Pool = /*#__PURE__*/function () {
25059
24212
  }
25060
24213
 
25061
24214
  _context10.t0 = dapp;
25062
- _context10.next = _context10.t0 === Dapp.ZEROEX ? 6 : _context10.t0 === Dapp.ONEINCH ? 10 : _context10.t0 === Dapp.BALANCER ? 14 : _context10.t0 === Dapp.SYNTHETIX ? 18 : _context10.t0 === Dapp.TOROS ? 25 : 29;
24215
+ _context10.next = _context10.t0 === Dapp.ZEROEX ? 6 : _context10.t0 === Dapp.ONEINCH ? 10 : _context10.t0 === Dapp.BALANCER ? 15 : _context10.t0 === Dapp.SYNTHETIX ? 19 : _context10.t0 === Dapp.TOROS ? 26 : 30;
25063
24216
  break;
25064
24217
 
25065
24218
  case 6:
@@ -25068,51 +24221,52 @@ var Pool = /*#__PURE__*/function () {
25068
24221
 
25069
24222
  case 8:
25070
24223
  swapTxData = _context10.sent;
25071
- return _context10.abrupt("break", 44);
24224
+ return _context10.abrupt("break", 45);
25072
24225
 
25073
24226
  case 10:
25074
24227
  _context10.next = 12;
25075
24228
  return getOneInchSwapTxData(this, assetFrom, assetTo, amountIn, slippage);
25076
24229
 
25077
24230
  case 12:
25078
- swapTxData = _context10.sent;
25079
- return _context10.abrupt("break", 44);
24231
+ _yield$getOneInchSwap = _context10.sent;
24232
+ swapTxData = _yield$getOneInchSwap.swapTxData;
24233
+ return _context10.abrupt("break", 45);
25080
24234
 
25081
- case 14:
25082
- _context10.next = 16;
24235
+ case 15:
24236
+ _context10.next = 17;
25083
24237
  return this.utils.getBalancerSwapTx(this, assetFrom, assetTo, amountIn, slippage);
25084
24238
 
25085
- case 16:
24239
+ case 17:
25086
24240
  swapTxData = _context10.sent;
25087
- return _context10.abrupt("break", 44);
24241
+ return _context10.abrupt("break", 45);
25088
24242
 
25089
- case 18:
24243
+ case 19:
25090
24244
  iSynthetix = new ethers.utils.Interface(ISynthetix.abi);
25091
24245
  assets = [assetFrom, assetTo].map(function (asset) {
25092
24246
  return ethers.utils.formatBytes32String(asset);
25093
24247
  });
25094
- _context10.next = 22;
24248
+ _context10.next = 23;
25095
24249
  return this.factory.owner();
25096
24250
 
25097
- case 22:
24251
+ case 23:
25098
24252
  daoAddress = _context10.sent;
25099
24253
  swapTxData = iSynthetix.encodeFunctionData(Transaction.SWAP_SYNTHS, [assets[0], amountIn, assets[1], daoAddress, SYNTHETIX_TRACKING_CODE]);
25100
- return _context10.abrupt("break", 44);
24254
+ return _context10.abrupt("break", 45);
25101
24255
 
25102
- case 25:
25103
- _context10.next = 27;
24256
+ case 26:
24257
+ _context10.next = 28;
25104
24258
  return getEasySwapperTxData(this, assetFrom, assetTo, ethers.BigNumber.from(amountIn), slippage);
25105
24259
 
25106
- case 27:
24260
+ case 28:
25107
24261
  swapTxData = _context10.sent;
25108
- return _context10.abrupt("break", 44);
24262
+ return _context10.abrupt("break", 45);
25109
24263
 
25110
- case 29:
24264
+ case 30:
25111
24265
  iUniswapV2Router = new ethers.utils.Interface(IUniswapV2Router.abi);
25112
- _context10.next = 32;
24266
+ _context10.next = 33;
25113
24267
  return this.utils.getMinAmountOut(dapp, assetFrom, assetTo, amountIn, slippage);
25114
24268
 
25115
- case 32:
24269
+ case 33:
25116
24270
  minAmountOut = _context10.sent;
25117
24271
  _context10.t1 = iUniswapV2Router;
25118
24272
  _context10.t2 = Transaction.SWAP;
@@ -25120,23 +24274,23 @@ var Pool = /*#__PURE__*/function () {
25120
24274
  _context10.t4 = minAmountOut;
25121
24275
  _context10.t5 = [assetFrom, assetTo];
25122
24276
  _context10.t6 = this.address;
25123
- _context10.next = 41;
24277
+ _context10.next = 42;
25124
24278
  return getDeadline(this);
25125
24279
 
25126
- case 41:
24280
+ case 42:
25127
24281
  _context10.t7 = _context10.sent;
25128
24282
  _context10.t8 = [_context10.t3, _context10.t4, _context10.t5, _context10.t6, _context10.t7];
25129
24283
  swapTxData = _context10.t1.encodeFunctionData.call(_context10.t1, _context10.t2, _context10.t8);
25130
24284
 
25131
- case 44:
25132
- _context10.next = 46;
24285
+ case 45:
24286
+ _context10.next = 47;
25133
24287
  return getPoolTxOrGasEstimate(this, [routerAddress[this.network][dapp], swapTxData, options], estimateGas);
25134
24288
 
25135
- case 46:
24289
+ case 47:
25136
24290
  tx = _context10.sent;
25137
24291
  return _context10.abrupt("return", tx);
25138
24292
 
25139
- case 48:
24293
+ case 49:
25140
24294
  case "end":
25141
24295
  return _context10.stop();
25142
24296
  }
@@ -27687,12 +26841,69 @@ var Pool = /*#__PURE__*/function () {
27687
26841
  }
27688
26842
 
27689
26843
  return cancelOrderViaFlatMoney$1;
26844
+ }()
26845
+ /**
26846
+ * Complete a Toros withdrawal to a single asset
26847
+ * @param {string} destinationToken Address of destination asset
26848
+ * @param {number} slippage Slippage tolerance in %
26849
+ * @param {any} options Transaction options
26850
+ * @param {boolean} estimateGas Simulate/estimate gas
26851
+ * @returns {Promise<any>} Transaction
26852
+ */
26853
+ ;
26854
+
26855
+ _proto.completeTorosWithdrawal =
26856
+ /*#__PURE__*/
26857
+ function () {
26858
+ var _completeTorosWithdrawal = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee54(destinationToken, slippage, options, estimateGas) {
26859
+ var txData, tx;
26860
+ return runtime_1.wrap(function _callee54$(_context54) {
26861
+ while (1) {
26862
+ switch (_context54.prev = _context54.next) {
26863
+ case 0:
26864
+ if (slippage === void 0) {
26865
+ slippage = 0.5;
26866
+ }
26867
+
26868
+ if (options === void 0) {
26869
+ options = null;
26870
+ }
26871
+
26872
+ if (estimateGas === void 0) {
26873
+ estimateGas = false;
26874
+ }
26875
+
26876
+ _context54.next = 5;
26877
+ return getCompleteWithdrawalTxData(this, destinationToken, slippage);
26878
+
26879
+ case 5:
26880
+ txData = _context54.sent;
26881
+ _context54.next = 8;
26882
+ return getPoolTxOrGasEstimate(this, [routerAddress[this.network].toros, txData, options], estimateGas);
26883
+
26884
+ case 8:
26885
+ tx = _context54.sent;
26886
+ return _context54.abrupt("return", tx);
26887
+
26888
+ case 10:
26889
+ case "end":
26890
+ return _context54.stop();
26891
+ }
26892
+ }
26893
+ }, _callee54, this);
26894
+ }));
26895
+
26896
+ function completeTorosWithdrawal(_x260, _x261, _x262, _x263) {
26897
+ return _completeTorosWithdrawal.apply(this, arguments);
26898
+ }
26899
+
26900
+ return completeTorosWithdrawal;
27690
26901
  }();
27691
26902
 
27692
26903
  return Pool;
27693
26904
  }();
27694
26905
 
27695
- var abi$u = [
26906
+ var abi$r = [
27696
26907
  {
27697
26908
  inputs: [
27698
26909
  {
@@ -27916,10 +27127,10 @@ var abi$u = [
27916
27127
  }
27917
27128
  ];
27918
27129
  var UniswapV2Factory = {
27919
- abi: abi$u
27130
+ abi: abi$r
27920
27131
  };
27921
27132
 
27922
- var abi$v = [
27133
+ var abi$s = [
27923
27134
  {
27924
27135
  anonymous: false,
27925
27136
  inputs: [
@@ -28663,7 +27874,7 @@ var evm = {
28663
27874
  }
28664
27875
  };
28665
27876
  var UniswapV2Pair = {
28666
- abi: abi$v,
27877
+ abi: abi$s,
28667
27878
  evm: evm,
28668
27879
  "interface": [
28669
27880
  {
@@ -29394,7 +28605,7 @@ var UniswapV2Pair = {
29394
28605
  ]
29395
28606
  };
29396
28607
 
29397
- var abi$w = [
28608
+ var abi$t = [
29398
28609
  {
29399
28610
  inputs: [
29400
28611
  {
@@ -30589,7 +29800,7 @@ var abi$w = [
30589
29800
  }
30590
29801
  ];
30591
29802
  var IBalancerV2Vault = {
30592
- abi: abi$w
29803
+ abi: abi$t
30593
29804
  };
30594
29805
 
30595
29806
  var Utils = /*#__PURE__*/function () {