@dhedge/v2-sdk 1.4.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@ var axios = _interopDefault(require('axios'));
9
9
  var lodash = require('lodash');
10
10
  var address = require('@ethersproject/address');
11
11
  require('lodash/set');
12
- var abi$j = require('@ethersproject/abi');
12
+ var abi$m = require('@ethersproject/abi');
13
13
  var BigNumber = _interopDefault(require('bignumber.js'));
14
14
  var web3Utils = require('web3-utils');
15
15
  var ethereumjsUtil = require('ethereumjs-util');
@@ -3840,6 +3840,7 @@ var ManagerLogic = {
3840
3840
  Dapp["SYNTHETIX"] = "synthetix";
3841
3841
  Dapp["AAVEV3"] = "aavev3";
3842
3842
  Dapp["ARRAKIS"] = "arrakis";
3843
+ Dapp["TOROS"] = "toros";
3843
3844
  })(exports.Dapp || (exports.Dapp = {}));
3844
3845
 
3845
3846
  (function (Transaction) {
@@ -3869,7 +3870,7 @@ var _factoryAddress, _Network$POLYGON, _Network$OPTIMISM, _routerAddress, _Netwo
3869
3870
  require("dotenv").config();
3870
3871
 
3871
3872
  var factoryAddress = (_factoryAddress = {}, _factoryAddress[exports.Network.POLYGON] = process.env.STAGING_CONTRACTS ? "0xDd87eCdB10cFF7004276AAbAbd30e7a08F69bb53" : "0xfdc7b8bFe0DD3513Cc669bB8d601Cb83e2F69cB0", _factoryAddress[exports.Network.OPTIMISM] = "0x5e61a079A178f0E5784107a4963baAe0c5a680c6", _factoryAddress);
3872
- 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] = "0x1111111254fb6c44bac0bed2854e76f90643097d", _Network$POLYGON[exports.Dapp.QUICKSWAP] = "0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff", _Network$POLYGON[exports.Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$POLYGON[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$POLYGON[exports.Dapp.ARRAKIS] = "0xbc91a120cCD8F80b819EAF32F0996daC3Fa76a6C", _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] = "0x1111111254760F7ab3F16433eea9304126DCd199", _Network$OPTIMISM), _routerAddress);
3873
+ 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] = "0x1111111254fb6c44bac0bed2854e76f90643097d", _Network$POLYGON[exports.Dapp.QUICKSWAP] = "0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff", _Network$POLYGON[exports.Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$POLYGON[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$POLYGON[exports.Dapp.ARRAKIS] = "0xbc91a120cCD8F80b819EAF32F0996daC3Fa76a6C", _Network$POLYGON[exports.Dapp.TOROS] = "0x9e080df81d9Db50348ef40F630fAE74f5Aea1f68", _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] = "0x1111111254760F7ab3F16433eea9304126DCd199", _Network$OPTIMISM[exports.Dapp.TOROS] = "0x15B7199AA9b9CaE9e611d858ab458aea8D36555B", _Network$OPTIMISM), _routerAddress);
3873
3874
  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);
3874
3875
  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), _stakingAddress[exports.Network.OPTIMISM] = {}, _stakingAddress);
3875
3876
  var nonfungiblePositionManagerAddress = (_nonfungiblePositionM = {}, _nonfungiblePositionM[exports.Network.POLYGON] = "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", _nonfungiblePositionM[exports.Network.OPTIMISM] = "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", _nonfungiblePositionM);
@@ -8083,7 +8084,7 @@ function _multicall() {
8083
8084
  }
8084
8085
 
8085
8086
  multi = new ethers.ethers.Contract(multiCallAddress[network], ["function tryAggregate(bool requireSuccess, tuple(address, bytes)[] memory calls) public view returns (tuple(bool, bytes)[] memory returnData)"], provider);
8086
- itf = new abi$j.Interface(abi);
8087
+ itf = new abi$m.Interface(abi);
8087
8088
  _context3.prev = 4;
8088
8089
  _context3.next = 7;
8089
8090
  return multi.tryAggregate( // if false, allows individual calls to fail without causing entire multicall to fail
@@ -9323,6 +9324,1639 @@ function _getUniswapV3SwapTxData() {
9323
9324
  return _getUniswapV3SwapTxData.apply(this, arguments);
9324
9325
  }
9325
9326
 
9327
+ var abi$g = [
9328
+ {
9329
+ inputs: [
9330
+ {
9331
+ internalType: "address payable",
9332
+ name: "_feeSink",
9333
+ type: "address"
9334
+ },
9335
+ {
9336
+ components: [
9337
+ {
9338
+ internalType: "contract IUniswapV2RouterSwapOnly",
9339
+ name: "swapRouter",
9340
+ type: "address"
9341
+ },
9342
+ {
9343
+ internalType: "contract IUniswapV2Router",
9344
+ name: "assetType2Router",
9345
+ type: "address"
9346
+ },
9347
+ {
9348
+ internalType: "contract IUniswapV2Router",
9349
+ name: "assetType5Router",
9350
+ type: "address"
9351
+ },
9352
+ {
9353
+ components: [
9354
+ {
9355
+ internalType: "contract ISynthetix",
9356
+ name: "snxProxy",
9357
+ type: "address"
9358
+ },
9359
+ {
9360
+ internalType: "contract IERC20",
9361
+ name: "swapSUSDToAsset",
9362
+ type: "address"
9363
+ },
9364
+ {
9365
+ internalType: "contract ISynthAddressProxy",
9366
+ name: "sUSDProxy",
9367
+ type: "address"
9368
+ }
9369
+ ],
9370
+ internalType: "struct EasySwapperStructs.SynthetixProps",
9371
+ name: "synthetixProps",
9372
+ type: "tuple"
9373
+ },
9374
+ {
9375
+ internalType: "contract IERC20",
9376
+ name: "weth",
9377
+ type: "address"
9378
+ }
9379
+ ],
9380
+ internalType: "struct EasySwapperStructs.WithdrawProps",
9381
+ name: "_withdrawProps",
9382
+ type: "tuple"
9383
+ }
9384
+ ],
9385
+ stateMutability: "nonpayable",
9386
+ type: "constructor"
9387
+ },
9388
+ {
9389
+ anonymous: false,
9390
+ inputs: [
9391
+ {
9392
+ indexed: false,
9393
+ internalType: "address",
9394
+ name: "pool",
9395
+ type: "address"
9396
+ },
9397
+ {
9398
+ indexed: false,
9399
+ internalType: "address",
9400
+ name: "depositor",
9401
+ type: "address"
9402
+ },
9403
+ {
9404
+ indexed: false,
9405
+ internalType: "address",
9406
+ name: "depositAsset",
9407
+ type: "address"
9408
+ },
9409
+ {
9410
+ indexed: false,
9411
+ internalType: "uint256",
9412
+ name: "amount",
9413
+ type: "uint256"
9414
+ },
9415
+ {
9416
+ indexed: false,
9417
+ internalType: "address",
9418
+ name: "poolDepositAsset",
9419
+ type: "address"
9420
+ },
9421
+ {
9422
+ indexed: false,
9423
+ internalType: "uint256",
9424
+ name: "liquidityMinted",
9425
+ type: "uint256"
9426
+ }
9427
+ ],
9428
+ name: "Deposit",
9429
+ type: "event"
9430
+ },
9431
+ {
9432
+ anonymous: false,
9433
+ inputs: [
9434
+ {
9435
+ indexed: true,
9436
+ internalType: "address",
9437
+ name: "previousOwner",
9438
+ type: "address"
9439
+ },
9440
+ {
9441
+ indexed: true,
9442
+ internalType: "address",
9443
+ name: "newOwner",
9444
+ type: "address"
9445
+ }
9446
+ ],
9447
+ name: "OwnershipTransferred",
9448
+ type: "event"
9449
+ },
9450
+ {
9451
+ inputs: [
9452
+ {
9453
+ internalType: "address",
9454
+ name: "",
9455
+ type: "address"
9456
+ }
9457
+ ],
9458
+ name: "allowedPools",
9459
+ outputs: [
9460
+ {
9461
+ internalType: "bool",
9462
+ name: "",
9463
+ type: "bool"
9464
+ }
9465
+ ],
9466
+ stateMutability: "view",
9467
+ type: "function"
9468
+ },
9469
+ {
9470
+ inputs: [
9471
+ {
9472
+ internalType: "address",
9473
+ name: "pool",
9474
+ type: "address"
9475
+ },
9476
+ {
9477
+ internalType: "contract IERC20",
9478
+ name: "depositAsset",
9479
+ type: "address"
9480
+ },
9481
+ {
9482
+ internalType: "uint256",
9483
+ name: "amount",
9484
+ type: "uint256"
9485
+ },
9486
+ {
9487
+ internalType: "contract IERC20",
9488
+ name: "poolDepositAsset",
9489
+ type: "address"
9490
+ },
9491
+ {
9492
+ internalType: "uint256",
9493
+ name: "expectedLiquidityMinted",
9494
+ type: "uint256"
9495
+ }
9496
+ ],
9497
+ name: "deposit",
9498
+ outputs: [
9499
+ {
9500
+ internalType: "uint256",
9501
+ name: "liquidityMinted",
9502
+ type: "uint256"
9503
+ }
9504
+ ],
9505
+ stateMutability: "nonpayable",
9506
+ type: "function"
9507
+ },
9508
+ {
9509
+ inputs: [
9510
+ {
9511
+ internalType: "address",
9512
+ name: "pool",
9513
+ type: "address"
9514
+ },
9515
+ {
9516
+ internalType: "contract IERC20",
9517
+ name: "depositAsset",
9518
+ type: "address"
9519
+ },
9520
+ {
9521
+ internalType: "uint256",
9522
+ name: "amount",
9523
+ type: "uint256"
9524
+ },
9525
+ {
9526
+ internalType: "contract IERC20",
9527
+ name: "poolDepositAsset",
9528
+ type: "address"
9529
+ }
9530
+ ],
9531
+ name: "depositQuote",
9532
+ outputs: [
9533
+ {
9534
+ internalType: "uint256",
9535
+ name: "expectedLiquidityMinted",
9536
+ type: "uint256"
9537
+ }
9538
+ ],
9539
+ stateMutability: "view",
9540
+ type: "function"
9541
+ },
9542
+ {
9543
+ inputs: [
9544
+ ],
9545
+ name: "feeDenominator",
9546
+ outputs: [
9547
+ {
9548
+ internalType: "uint256",
9549
+ name: "",
9550
+ type: "uint256"
9551
+ }
9552
+ ],
9553
+ stateMutability: "view",
9554
+ type: "function"
9555
+ },
9556
+ {
9557
+ inputs: [
9558
+ ],
9559
+ name: "feeNumerator",
9560
+ outputs: [
9561
+ {
9562
+ internalType: "uint256",
9563
+ name: "",
9564
+ type: "uint256"
9565
+ }
9566
+ ],
9567
+ stateMutability: "view",
9568
+ type: "function"
9569
+ },
9570
+ {
9571
+ inputs: [
9572
+ ],
9573
+ name: "feeSink",
9574
+ outputs: [
9575
+ {
9576
+ internalType: "address payable",
9577
+ name: "",
9578
+ type: "address"
9579
+ }
9580
+ ],
9581
+ stateMutability: "view",
9582
+ type: "function"
9583
+ },
9584
+ {
9585
+ inputs: [
9586
+ ],
9587
+ name: "owner",
9588
+ outputs: [
9589
+ {
9590
+ internalType: "address",
9591
+ name: "",
9592
+ type: "address"
9593
+ }
9594
+ ],
9595
+ stateMutability: "view",
9596
+ type: "function"
9597
+ },
9598
+ {
9599
+ inputs: [
9600
+ ],
9601
+ name: "renounceOwnership",
9602
+ outputs: [
9603
+ ],
9604
+ stateMutability: "nonpayable",
9605
+ type: "function"
9606
+ },
9607
+ {
9608
+ inputs: [
9609
+ {
9610
+ internalType: "uint256",
9611
+ name: "numerator",
9612
+ type: "uint256"
9613
+ },
9614
+ {
9615
+ internalType: "uint256",
9616
+ name: "denominator",
9617
+ type: "uint256"
9618
+ }
9619
+ ],
9620
+ name: "setFee",
9621
+ outputs: [
9622
+ ],
9623
+ stateMutability: "nonpayable",
9624
+ type: "function"
9625
+ },
9626
+ {
9627
+ inputs: [
9628
+ {
9629
+ internalType: "address payable",
9630
+ name: "sink",
9631
+ type: "address"
9632
+ }
9633
+ ],
9634
+ name: "setFeeSink",
9635
+ outputs: [
9636
+ ],
9637
+ stateMutability: "nonpayable",
9638
+ type: "function"
9639
+ },
9640
+ {
9641
+ inputs: [
9642
+ {
9643
+ internalType: "address",
9644
+ name: "pool",
9645
+ type: "address"
9646
+ },
9647
+ {
9648
+ internalType: "bool",
9649
+ name: "allowed",
9650
+ type: "bool"
9651
+ }
9652
+ ],
9653
+ name: "setPoolAllowed",
9654
+ outputs: [
9655
+ ],
9656
+ stateMutability: "nonpayable",
9657
+ type: "function"
9658
+ },
9659
+ {
9660
+ inputs: [
9661
+ {
9662
+ internalType: "contract IUniswapV2RouterSwapOnly",
9663
+ name: "_swapRouter",
9664
+ type: "address"
9665
+ }
9666
+ ],
9667
+ name: "setSwapRouter",
9668
+ outputs: [
9669
+ ],
9670
+ stateMutability: "nonpayable",
9671
+ type: "function"
9672
+ },
9673
+ {
9674
+ inputs: [
9675
+ {
9676
+ internalType: "address",
9677
+ name: "newOwner",
9678
+ type: "address"
9679
+ }
9680
+ ],
9681
+ name: "transferOwnership",
9682
+ outputs: [
9683
+ ],
9684
+ stateMutability: "nonpayable",
9685
+ type: "function"
9686
+ },
9687
+ {
9688
+ inputs: [
9689
+ ],
9690
+ name: "weth",
9691
+ outputs: [
9692
+ {
9693
+ internalType: "contract IERC20",
9694
+ name: "",
9695
+ type: "address"
9696
+ }
9697
+ ],
9698
+ stateMutability: "view",
9699
+ type: "function"
9700
+ },
9701
+ {
9702
+ inputs: [
9703
+ {
9704
+ internalType: "address",
9705
+ name: "pool",
9706
+ type: "address"
9707
+ },
9708
+ {
9709
+ internalType: "uint256",
9710
+ name: "fundTokenAmount",
9711
+ type: "uint256"
9712
+ },
9713
+ {
9714
+ internalType: "contract IERC20",
9715
+ name: "withdrawalAsset",
9716
+ type: "address"
9717
+ },
9718
+ {
9719
+ internalType: "uint256",
9720
+ name: "expectedAmountOut",
9721
+ type: "uint256"
9722
+ }
9723
+ ],
9724
+ name: "withdraw",
9725
+ outputs: [
9726
+ ],
9727
+ stateMutability: "nonpayable",
9728
+ type: "function"
9729
+ },
9730
+ {
9731
+ inputs: [
9732
+ ],
9733
+ name: "withdrawProps",
9734
+ outputs: [
9735
+ {
9736
+ internalType: "contract IUniswapV2RouterSwapOnly",
9737
+ name: "swapRouter",
9738
+ type: "address"
9739
+ },
9740
+ {
9741
+ internalType: "contract IUniswapV2Router",
9742
+ name: "assetType2Router",
9743
+ type: "address"
9744
+ },
9745
+ {
9746
+ internalType: "contract IUniswapV2Router",
9747
+ name: "assetType5Router",
9748
+ type: "address"
9749
+ },
9750
+ {
9751
+ components: [
9752
+ {
9753
+ internalType: "contract ISynthetix",
9754
+ name: "snxProxy",
9755
+ type: "address"
9756
+ },
9757
+ {
9758
+ internalType: "contract IERC20",
9759
+ name: "swapSUSDToAsset",
9760
+ type: "address"
9761
+ },
9762
+ {
9763
+ internalType: "contract ISynthAddressProxy",
9764
+ name: "sUSDProxy",
9765
+ type: "address"
9766
+ }
9767
+ ],
9768
+ internalType: "struct EasySwapperStructs.SynthetixProps",
9769
+ name: "synthetixProps",
9770
+ type: "tuple"
9771
+ },
9772
+ {
9773
+ internalType: "contract IERC20",
9774
+ name: "weth",
9775
+ type: "address"
9776
+ }
9777
+ ],
9778
+ stateMutability: "view",
9779
+ type: "function"
9780
+ }
9781
+ ];
9782
+ var IDhedgeEasySwapper = {
9783
+ abi: abi$g
9784
+ };
9785
+
9786
+ var abi$h = [
9787
+ {
9788
+ inputs: [
9789
+ {
9790
+ internalType: "string",
9791
+ name: "marketId",
9792
+ type: "string"
9793
+ },
9794
+ {
9795
+ internalType: "address",
9796
+ name: "owner",
9797
+ type: "address"
9798
+ }
9799
+ ],
9800
+ stateMutability: "nonpayable",
9801
+ type: "constructor"
9802
+ },
9803
+ {
9804
+ anonymous: false,
9805
+ inputs: [
9806
+ {
9807
+ indexed: true,
9808
+ internalType: "address",
9809
+ name: "oldAddress",
9810
+ type: "address"
9811
+ },
9812
+ {
9813
+ indexed: true,
9814
+ internalType: "address",
9815
+ name: "newAddress",
9816
+ type: "address"
9817
+ }
9818
+ ],
9819
+ name: "ACLAdminUpdated",
9820
+ type: "event"
9821
+ },
9822
+ {
9823
+ anonymous: false,
9824
+ inputs: [
9825
+ {
9826
+ indexed: true,
9827
+ internalType: "address",
9828
+ name: "oldAddress",
9829
+ type: "address"
9830
+ },
9831
+ {
9832
+ indexed: true,
9833
+ internalType: "address",
9834
+ name: "newAddress",
9835
+ type: "address"
9836
+ }
9837
+ ],
9838
+ name: "ACLManagerUpdated",
9839
+ type: "event"
9840
+ },
9841
+ {
9842
+ anonymous: false,
9843
+ inputs: [
9844
+ {
9845
+ indexed: true,
9846
+ internalType: "bytes32",
9847
+ name: "id",
9848
+ type: "bytes32"
9849
+ },
9850
+ {
9851
+ indexed: true,
9852
+ internalType: "address",
9853
+ name: "oldAddress",
9854
+ type: "address"
9855
+ },
9856
+ {
9857
+ indexed: true,
9858
+ internalType: "address",
9859
+ name: "newAddress",
9860
+ type: "address"
9861
+ }
9862
+ ],
9863
+ name: "AddressSet",
9864
+ type: "event"
9865
+ },
9866
+ {
9867
+ anonymous: false,
9868
+ inputs: [
9869
+ {
9870
+ indexed: true,
9871
+ internalType: "bytes32",
9872
+ name: "id",
9873
+ type: "bytes32"
9874
+ },
9875
+ {
9876
+ indexed: true,
9877
+ internalType: "address",
9878
+ name: "proxyAddress",
9879
+ type: "address"
9880
+ },
9881
+ {
9882
+ indexed: false,
9883
+ internalType: "address",
9884
+ name: "oldImplementationAddress",
9885
+ type: "address"
9886
+ },
9887
+ {
9888
+ indexed: true,
9889
+ internalType: "address",
9890
+ name: "newImplementationAddress",
9891
+ type: "address"
9892
+ }
9893
+ ],
9894
+ name: "AddressSetAsProxy",
9895
+ type: "event"
9896
+ },
9897
+ {
9898
+ anonymous: false,
9899
+ inputs: [
9900
+ {
9901
+ indexed: true,
9902
+ internalType: "string",
9903
+ name: "oldMarketId",
9904
+ type: "string"
9905
+ },
9906
+ {
9907
+ indexed: true,
9908
+ internalType: "string",
9909
+ name: "newMarketId",
9910
+ type: "string"
9911
+ }
9912
+ ],
9913
+ name: "MarketIdSet",
9914
+ type: "event"
9915
+ },
9916
+ {
9917
+ anonymous: false,
9918
+ inputs: [
9919
+ {
9920
+ indexed: true,
9921
+ internalType: "address",
9922
+ name: "previousOwner",
9923
+ type: "address"
9924
+ },
9925
+ {
9926
+ indexed: true,
9927
+ internalType: "address",
9928
+ name: "newOwner",
9929
+ type: "address"
9930
+ }
9931
+ ],
9932
+ name: "OwnershipTransferred",
9933
+ type: "event"
9934
+ },
9935
+ {
9936
+ anonymous: false,
9937
+ inputs: [
9938
+ {
9939
+ indexed: true,
9940
+ internalType: "address",
9941
+ name: "oldAddress",
9942
+ type: "address"
9943
+ },
9944
+ {
9945
+ indexed: true,
9946
+ internalType: "address",
9947
+ name: "newAddress",
9948
+ type: "address"
9949
+ }
9950
+ ],
9951
+ name: "PoolConfiguratorUpdated",
9952
+ type: "event"
9953
+ },
9954
+ {
9955
+ anonymous: false,
9956
+ inputs: [
9957
+ {
9958
+ indexed: true,
9959
+ internalType: "address",
9960
+ name: "oldAddress",
9961
+ type: "address"
9962
+ },
9963
+ {
9964
+ indexed: true,
9965
+ internalType: "address",
9966
+ name: "newAddress",
9967
+ type: "address"
9968
+ }
9969
+ ],
9970
+ name: "PoolDataProviderUpdated",
9971
+ type: "event"
9972
+ },
9973
+ {
9974
+ anonymous: false,
9975
+ inputs: [
9976
+ {
9977
+ indexed: true,
9978
+ internalType: "address",
9979
+ name: "oldAddress",
9980
+ type: "address"
9981
+ },
9982
+ {
9983
+ indexed: true,
9984
+ internalType: "address",
9985
+ name: "newAddress",
9986
+ type: "address"
9987
+ }
9988
+ ],
9989
+ name: "PoolUpdated",
9990
+ type: "event"
9991
+ },
9992
+ {
9993
+ anonymous: false,
9994
+ inputs: [
9995
+ {
9996
+ indexed: true,
9997
+ internalType: "address",
9998
+ name: "oldAddress",
9999
+ type: "address"
10000
+ },
10001
+ {
10002
+ indexed: true,
10003
+ internalType: "address",
10004
+ name: "newAddress",
10005
+ type: "address"
10006
+ }
10007
+ ],
10008
+ name: "PriceOracleSentinelUpdated",
10009
+ type: "event"
10010
+ },
10011
+ {
10012
+ anonymous: false,
10013
+ inputs: [
10014
+ {
10015
+ indexed: true,
10016
+ internalType: "address",
10017
+ name: "oldAddress",
10018
+ type: "address"
10019
+ },
10020
+ {
10021
+ indexed: true,
10022
+ internalType: "address",
10023
+ name: "newAddress",
10024
+ type: "address"
10025
+ }
10026
+ ],
10027
+ name: "PriceOracleUpdated",
10028
+ type: "event"
10029
+ },
10030
+ {
10031
+ anonymous: false,
10032
+ inputs: [
10033
+ {
10034
+ indexed: true,
10035
+ internalType: "bytes32",
10036
+ name: "id",
10037
+ type: "bytes32"
10038
+ },
10039
+ {
10040
+ indexed: true,
10041
+ internalType: "address",
10042
+ name: "proxyAddress",
10043
+ type: "address"
10044
+ },
10045
+ {
10046
+ indexed: true,
10047
+ internalType: "address",
10048
+ name: "implementationAddress",
10049
+ type: "address"
10050
+ }
10051
+ ],
10052
+ name: "ProxyCreated",
10053
+ type: "event"
10054
+ },
10055
+ {
10056
+ inputs: [
10057
+ ],
10058
+ name: "getACLAdmin",
10059
+ outputs: [
10060
+ {
10061
+ internalType: "address",
10062
+ name: "",
10063
+ type: "address"
10064
+ }
10065
+ ],
10066
+ stateMutability: "view",
10067
+ type: "function"
10068
+ },
10069
+ {
10070
+ inputs: [
10071
+ ],
10072
+ name: "getACLManager",
10073
+ outputs: [
10074
+ {
10075
+ internalType: "address",
10076
+ name: "",
10077
+ type: "address"
10078
+ }
10079
+ ],
10080
+ stateMutability: "view",
10081
+ type: "function"
10082
+ },
10083
+ {
10084
+ inputs: [
10085
+ {
10086
+ internalType: "bytes32",
10087
+ name: "id",
10088
+ type: "bytes32"
10089
+ }
10090
+ ],
10091
+ name: "getAddress",
10092
+ outputs: [
10093
+ {
10094
+ internalType: "address",
10095
+ name: "",
10096
+ type: "address"
10097
+ }
10098
+ ],
10099
+ stateMutability: "view",
10100
+ type: "function"
10101
+ },
10102
+ {
10103
+ inputs: [
10104
+ ],
10105
+ name: "getMarketId",
10106
+ outputs: [
10107
+ {
10108
+ internalType: "string",
10109
+ name: "",
10110
+ type: "string"
10111
+ }
10112
+ ],
10113
+ stateMutability: "view",
10114
+ type: "function"
10115
+ },
10116
+ {
10117
+ inputs: [
10118
+ ],
10119
+ name: "getPool",
10120
+ outputs: [
10121
+ {
10122
+ internalType: "address",
10123
+ name: "",
10124
+ type: "address"
10125
+ }
10126
+ ],
10127
+ stateMutability: "view",
10128
+ type: "function"
10129
+ },
10130
+ {
10131
+ inputs: [
10132
+ ],
10133
+ name: "getPoolConfigurator",
10134
+ outputs: [
10135
+ {
10136
+ internalType: "address",
10137
+ name: "",
10138
+ type: "address"
10139
+ }
10140
+ ],
10141
+ stateMutability: "view",
10142
+ type: "function"
10143
+ },
10144
+ {
10145
+ inputs: [
10146
+ ],
10147
+ name: "getPoolDataProvider",
10148
+ outputs: [
10149
+ {
10150
+ internalType: "address",
10151
+ name: "",
10152
+ type: "address"
10153
+ }
10154
+ ],
10155
+ stateMutability: "view",
10156
+ type: "function"
10157
+ },
10158
+ {
10159
+ inputs: [
10160
+ ],
10161
+ name: "getPriceOracle",
10162
+ outputs: [
10163
+ {
10164
+ internalType: "address",
10165
+ name: "",
10166
+ type: "address"
10167
+ }
10168
+ ],
10169
+ stateMutability: "view",
10170
+ type: "function"
10171
+ },
10172
+ {
10173
+ inputs: [
10174
+ ],
10175
+ name: "getPriceOracleSentinel",
10176
+ outputs: [
10177
+ {
10178
+ internalType: "address",
10179
+ name: "",
10180
+ type: "address"
10181
+ }
10182
+ ],
10183
+ stateMutability: "view",
10184
+ type: "function"
10185
+ },
10186
+ {
10187
+ inputs: [
10188
+ ],
10189
+ name: "owner",
10190
+ outputs: [
10191
+ {
10192
+ internalType: "address",
10193
+ name: "",
10194
+ type: "address"
10195
+ }
10196
+ ],
10197
+ stateMutability: "view",
10198
+ type: "function"
10199
+ },
10200
+ {
10201
+ inputs: [
10202
+ ],
10203
+ name: "renounceOwnership",
10204
+ outputs: [
10205
+ ],
10206
+ stateMutability: "nonpayable",
10207
+ type: "function"
10208
+ },
10209
+ {
10210
+ inputs: [
10211
+ {
10212
+ internalType: "address",
10213
+ name: "newAclAdmin",
10214
+ type: "address"
10215
+ }
10216
+ ],
10217
+ name: "setACLAdmin",
10218
+ outputs: [
10219
+ ],
10220
+ stateMutability: "nonpayable",
10221
+ type: "function"
10222
+ },
10223
+ {
10224
+ inputs: [
10225
+ {
10226
+ internalType: "address",
10227
+ name: "newAclManager",
10228
+ type: "address"
10229
+ }
10230
+ ],
10231
+ name: "setACLManager",
10232
+ outputs: [
10233
+ ],
10234
+ stateMutability: "nonpayable",
10235
+ type: "function"
10236
+ },
10237
+ {
10238
+ inputs: [
10239
+ {
10240
+ internalType: "bytes32",
10241
+ name: "id",
10242
+ type: "bytes32"
10243
+ },
10244
+ {
10245
+ internalType: "address",
10246
+ name: "newAddress",
10247
+ type: "address"
10248
+ }
10249
+ ],
10250
+ name: "setAddress",
10251
+ outputs: [
10252
+ ],
10253
+ stateMutability: "nonpayable",
10254
+ type: "function"
10255
+ },
10256
+ {
10257
+ inputs: [
10258
+ {
10259
+ internalType: "bytes32",
10260
+ name: "id",
10261
+ type: "bytes32"
10262
+ },
10263
+ {
10264
+ internalType: "address",
10265
+ name: "newImplementationAddress",
10266
+ type: "address"
10267
+ }
10268
+ ],
10269
+ name: "setAddressAsProxy",
10270
+ outputs: [
10271
+ ],
10272
+ stateMutability: "nonpayable",
10273
+ type: "function"
10274
+ },
10275
+ {
10276
+ inputs: [
10277
+ {
10278
+ internalType: "string",
10279
+ name: "newMarketId",
10280
+ type: "string"
10281
+ }
10282
+ ],
10283
+ name: "setMarketId",
10284
+ outputs: [
10285
+ ],
10286
+ stateMutability: "nonpayable",
10287
+ type: "function"
10288
+ },
10289
+ {
10290
+ inputs: [
10291
+ {
10292
+ internalType: "address",
10293
+ name: "newPoolConfiguratorImpl",
10294
+ type: "address"
10295
+ }
10296
+ ],
10297
+ name: "setPoolConfiguratorImpl",
10298
+ outputs: [
10299
+ ],
10300
+ stateMutability: "nonpayable",
10301
+ type: "function"
10302
+ },
10303
+ {
10304
+ inputs: [
10305
+ {
10306
+ internalType: "address",
10307
+ name: "newDataProvider",
10308
+ type: "address"
10309
+ }
10310
+ ],
10311
+ name: "setPoolDataProvider",
10312
+ outputs: [
10313
+ ],
10314
+ stateMutability: "nonpayable",
10315
+ type: "function"
10316
+ },
10317
+ {
10318
+ inputs: [
10319
+ {
10320
+ internalType: "address",
10321
+ name: "newPoolImpl",
10322
+ type: "address"
10323
+ }
10324
+ ],
10325
+ name: "setPoolImpl",
10326
+ outputs: [
10327
+ ],
10328
+ stateMutability: "nonpayable",
10329
+ type: "function"
10330
+ },
10331
+ {
10332
+ inputs: [
10333
+ {
10334
+ internalType: "address",
10335
+ name: "newPriceOracle",
10336
+ type: "address"
10337
+ }
10338
+ ],
10339
+ name: "setPriceOracle",
10340
+ outputs: [
10341
+ ],
10342
+ stateMutability: "nonpayable",
10343
+ type: "function"
10344
+ },
10345
+ {
10346
+ inputs: [
10347
+ {
10348
+ internalType: "address",
10349
+ name: "newPriceOracleSentinel",
10350
+ type: "address"
10351
+ }
10352
+ ],
10353
+ name: "setPriceOracleSentinel",
10354
+ outputs: [
10355
+ ],
10356
+ stateMutability: "nonpayable",
10357
+ type: "function"
10358
+ },
10359
+ {
10360
+ inputs: [
10361
+ {
10362
+ internalType: "address",
10363
+ name: "newOwner",
10364
+ type: "address"
10365
+ }
10366
+ ],
10367
+ name: "transferOwnership",
10368
+ outputs: [
10369
+ ],
10370
+ stateMutability: "nonpayable",
10371
+ type: "function"
10372
+ }
10373
+ ];
10374
+ var IAaveV3PoolAddressProvider = {
10375
+ abi: abi$h
10376
+ };
10377
+
10378
+ var abi$i = [
10379
+ {
10380
+ inputs: [
10381
+ {
10382
+ internalType: "address[]",
10383
+ name: "_assets",
10384
+ type: "address[]"
10385
+ },
10386
+ {
10387
+ internalType: "address[]",
10388
+ name: "_sources",
10389
+ type: "address[]"
10390
+ },
10391
+ {
10392
+ internalType: "address",
10393
+ name: "_fallbackOracle",
10394
+ type: "address"
10395
+ }
10396
+ ],
10397
+ payable: false,
10398
+ stateMutability: "nonpayable",
10399
+ type: "constructor"
10400
+ },
10401
+ {
10402
+ anonymous: false,
10403
+ inputs: [
10404
+ {
10405
+ indexed: true,
10406
+ internalType: "address",
10407
+ name: "asset",
10408
+ type: "address"
10409
+ },
10410
+ {
10411
+ indexed: true,
10412
+ internalType: "address",
10413
+ name: "source",
10414
+ type: "address"
10415
+ }
10416
+ ],
10417
+ name: "AssetSourceUpdated",
10418
+ type: "event"
10419
+ },
10420
+ {
10421
+ anonymous: false,
10422
+ inputs: [
10423
+ {
10424
+ indexed: true,
10425
+ internalType: "address",
10426
+ name: "fallbackOracle",
10427
+ type: "address"
10428
+ }
10429
+ ],
10430
+ name: "FallbackOracleUpdated",
10431
+ type: "event"
10432
+ },
10433
+ {
10434
+ anonymous: false,
10435
+ inputs: [
10436
+ {
10437
+ indexed: true,
10438
+ internalType: "address",
10439
+ name: "previousOwner",
10440
+ type: "address"
10441
+ },
10442
+ {
10443
+ indexed: true,
10444
+ internalType: "address",
10445
+ name: "newOwner",
10446
+ type: "address"
10447
+ }
10448
+ ],
10449
+ name: "OwnershipTransferred",
10450
+ type: "event"
10451
+ },
10452
+ {
10453
+ constant: true,
10454
+ inputs: [
10455
+ ],
10456
+ name: "isOwner",
10457
+ outputs: [
10458
+ {
10459
+ internalType: "bool",
10460
+ name: "",
10461
+ type: "bool"
10462
+ }
10463
+ ],
10464
+ payable: false,
10465
+ stateMutability: "view",
10466
+ type: "function"
10467
+ },
10468
+ {
10469
+ constant: true,
10470
+ inputs: [
10471
+ ],
10472
+ name: "owner",
10473
+ outputs: [
10474
+ {
10475
+ internalType: "address",
10476
+ name: "",
10477
+ type: "address"
10478
+ }
10479
+ ],
10480
+ payable: false,
10481
+ stateMutability: "view",
10482
+ type: "function"
10483
+ },
10484
+ {
10485
+ constant: false,
10486
+ inputs: [
10487
+ ],
10488
+ name: "renounceOwnership",
10489
+ outputs: [
10490
+ ],
10491
+ payable: false,
10492
+ stateMutability: "nonpayable",
10493
+ type: "function"
10494
+ },
10495
+ {
10496
+ constant: false,
10497
+ inputs: [
10498
+ {
10499
+ internalType: "address",
10500
+ name: "newOwner",
10501
+ type: "address"
10502
+ }
10503
+ ],
10504
+ name: "transferOwnership",
10505
+ outputs: [
10506
+ ],
10507
+ payable: false,
10508
+ stateMutability: "nonpayable",
10509
+ type: "function"
10510
+ },
10511
+ {
10512
+ constant: false,
10513
+ inputs: [
10514
+ {
10515
+ internalType: "address[]",
10516
+ name: "_assets",
10517
+ type: "address[]"
10518
+ },
10519
+ {
10520
+ internalType: "address[]",
10521
+ name: "_sources",
10522
+ type: "address[]"
10523
+ }
10524
+ ],
10525
+ name: "setAssetSources",
10526
+ outputs: [
10527
+ ],
10528
+ payable: false,
10529
+ stateMutability: "nonpayable",
10530
+ type: "function"
10531
+ },
10532
+ {
10533
+ constant: false,
10534
+ inputs: [
10535
+ {
10536
+ internalType: "address",
10537
+ name: "_fallbackOracle",
10538
+ type: "address"
10539
+ }
10540
+ ],
10541
+ name: "setFallbackOracle",
10542
+ outputs: [
10543
+ ],
10544
+ payable: false,
10545
+ stateMutability: "nonpayable",
10546
+ type: "function"
10547
+ },
10548
+ {
10549
+ constant: true,
10550
+ inputs: [
10551
+ {
10552
+ internalType: "address",
10553
+ name: "_asset",
10554
+ type: "address"
10555
+ }
10556
+ ],
10557
+ name: "getAssetPrice",
10558
+ outputs: [
10559
+ {
10560
+ internalType: "uint256",
10561
+ name: "",
10562
+ type: "uint256"
10563
+ }
10564
+ ],
10565
+ payable: false,
10566
+ stateMutability: "view",
10567
+ type: "function"
10568
+ },
10569
+ {
10570
+ constant: true,
10571
+ inputs: [
10572
+ {
10573
+ internalType: "address[]",
10574
+ name: "_assets",
10575
+ type: "address[]"
10576
+ }
10577
+ ],
10578
+ name: "getAssetsPrices",
10579
+ outputs: [
10580
+ {
10581
+ internalType: "uint256[]",
10582
+ name: "",
10583
+ type: "uint256[]"
10584
+ }
10585
+ ],
10586
+ payable: false,
10587
+ stateMutability: "view",
10588
+ type: "function"
10589
+ },
10590
+ {
10591
+ constant: true,
10592
+ inputs: [
10593
+ {
10594
+ internalType: "address",
10595
+ name: "_asset",
10596
+ type: "address"
10597
+ }
10598
+ ],
10599
+ name: "getSourceOfAsset",
10600
+ outputs: [
10601
+ {
10602
+ internalType: "address",
10603
+ name: "",
10604
+ type: "address"
10605
+ }
10606
+ ],
10607
+ payable: false,
10608
+ stateMutability: "view",
10609
+ type: "function"
10610
+ },
10611
+ {
10612
+ constant: true,
10613
+ inputs: [
10614
+ ],
10615
+ name: "getFallbackOracle",
10616
+ outputs: [
10617
+ {
10618
+ internalType: "address",
10619
+ name: "",
10620
+ type: "address"
10621
+ }
10622
+ ],
10623
+ payable: false,
10624
+ stateMutability: "view",
10625
+ type: "function"
10626
+ }
10627
+ ];
10628
+ var IPriceOracle = {
10629
+ abi: abi$i
10630
+ };
10631
+
10632
+ function getChainlinkPriceInUsd(_x, _x2) {
10633
+ return _getChainlinkPriceInUsd.apply(this, arguments);
10634
+ }
10635
+
10636
+ function _getChainlinkPriceInUsd() {
10637
+ _getChainlinkPriceInUsd = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(pool, asset) {
10638
+ var lendingPoolAddressProvider, priceOracleAddress, priceOracle;
10639
+ return runtime_1.wrap(function _callee$(_context) {
10640
+ while (1) {
10641
+ switch (_context.prev = _context.next) {
10642
+ case 0:
10643
+ //Workaround as Chainlink doesn't have feed registry on Polygon/Optimism
10644
+ //Use oracle from Aave which uses Chainlink
10645
+ lendingPoolAddressProvider = new ethers.ethers.Contract("0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb", IAaveV3PoolAddressProvider.abi, pool.signer);
10646
+ _context.next = 3;
10647
+ return lendingPoolAddressProvider.getPriceOracle();
10648
+
10649
+ case 3:
10650
+ priceOracleAddress = _context.sent;
10651
+ priceOracle = new ethers.ethers.Contract(priceOracleAddress, IPriceOracle.abi, pool.signer);
10652
+ _context.next = 7;
10653
+ return priceOracle.getAssetPrice(asset);
10654
+
10655
+ case 7:
10656
+ return _context.abrupt("return", _context.sent);
10657
+
10658
+ case 8:
10659
+ case "end":
10660
+ return _context.stop();
10661
+ }
10662
+ }
10663
+ }, _callee);
10664
+ }));
10665
+ return _getChainlinkPriceInUsd.apply(this, arguments);
10666
+ }
10667
+
10668
+ function loadPool(_x, _x2) {
10669
+ return _loadPool.apply(this, arguments);
10670
+ }
10671
+
10672
+ function _loadPool() {
10673
+ _loadPool = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(pool, poolAddress) {
10674
+ var dhedge;
10675
+ return runtime_1.wrap(function _callee$(_context) {
10676
+ while (1) {
10677
+ switch (_context.prev = _context.next) {
10678
+ case 0:
10679
+ dhedge = new Dhedge(pool.signer, pool.network);
10680
+ _context.next = 3;
10681
+ return dhedge.loadPool(poolAddress);
10682
+
10683
+ case 3:
10684
+ return _context.abrupt("return", _context.sent);
10685
+
10686
+ case 4:
10687
+ case "end":
10688
+ return _context.stop();
10689
+ }
10690
+ }
10691
+ }, _callee);
10692
+ }));
10693
+ return _loadPool.apply(this, arguments);
10694
+ }
10695
+
10696
+ function isPool(_x3, _x4) {
10697
+ return _isPool.apply(this, arguments);
10698
+ }
10699
+
10700
+ function _isPool() {
10701
+ _isPool = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(pool, poolAddress) {
10702
+ var dhedge;
10703
+ return runtime_1.wrap(function _callee2$(_context2) {
10704
+ while (1) {
10705
+ switch (_context2.prev = _context2.next) {
10706
+ case 0:
10707
+ dhedge = new Dhedge(pool.signer, pool.network);
10708
+ _context2.next = 3;
10709
+ return dhedge.validatePool(poolAddress);
10710
+
10711
+ case 3:
10712
+ return _context2.abrupt("return", _context2.sent);
10713
+
10714
+ case 4:
10715
+ case "end":
10716
+ return _context2.stop();
10717
+ }
10718
+ }
10719
+ }, _callee2);
10720
+ }));
10721
+ return _isPool.apply(this, arguments);
10722
+ }
10723
+
10724
+ function getPoolDepositAsset(_x, _x2) {
10725
+ return _getPoolDepositAsset.apply(this, arguments);
10726
+ }
10727
+
10728
+ function _getPoolDepositAsset() {
10729
+ _getPoolDepositAsset = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(pool, poolAddress) {
10730
+ var _composition$find;
10731
+
10732
+ var torosPool, composition;
10733
+ return runtime_1.wrap(function _callee$(_context) {
10734
+ while (1) {
10735
+ switch (_context.prev = _context.next) {
10736
+ case 0:
10737
+ _context.next = 2;
10738
+ return loadPool(pool, poolAddress);
10739
+
10740
+ case 2:
10741
+ torosPool = _context.sent;
10742
+ _context.next = 5;
10743
+ return torosPool.getComposition();
10744
+
10745
+ case 5:
10746
+ composition = _context.sent;
10747
+ return _context.abrupt("return", (_composition$find = composition.find(function (e) {
10748
+ return e.isDeposit;
10749
+ })) == null ? void 0 : _composition$find.asset);
10750
+
10751
+ case 7:
10752
+ case "end":
10753
+ return _context.stop();
10754
+ }
10755
+ }
10756
+ }, _callee);
10757
+ }));
10758
+ return _getPoolDepositAsset.apply(this, arguments);
10759
+ }
10760
+
10761
+ function getTorosPoolTokenPrice(_x3, _x4) {
10762
+ return _getTorosPoolTokenPrice.apply(this, arguments);
10763
+ }
10764
+
10765
+ function _getTorosPoolTokenPrice() {
10766
+ _getTorosPoolTokenPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(pool, poolAddress) {
10767
+ var torosPool;
10768
+ return runtime_1.wrap(function _callee2$(_context2) {
10769
+ while (1) {
10770
+ switch (_context2.prev = _context2.next) {
10771
+ case 0:
10772
+ _context2.next = 2;
10773
+ return loadPool(pool, poolAddress);
10774
+
10775
+ case 2:
10776
+ torosPool = _context2.sent;
10777
+ _context2.next = 5;
10778
+ return torosPool.poolLogic.tokenPrice();
10779
+
10780
+ case 5:
10781
+ return _context2.abrupt("return", _context2.sent);
10782
+
10783
+ case 6:
10784
+ case "end":
10785
+ return _context2.stop();
10786
+ }
10787
+ }
10788
+ }, _callee2);
10789
+ }));
10790
+ return _getTorosPoolTokenPrice.apply(this, arguments);
10791
+ }
10792
+
10793
+ function getEasySwapperDepositQuote(_x5, _x6, _x7, _x8, _x9) {
10794
+ return _getEasySwapperDepositQuote.apply(this, arguments);
10795
+ }
10796
+
10797
+ function _getEasySwapperDepositQuote() {
10798
+ _getEasySwapperDepositQuote = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(pool, torosAsset, investAsset, depositAsset, amountIn) {
10799
+ var easySwapper;
10800
+ return runtime_1.wrap(function _callee3$(_context3) {
10801
+ while (1) {
10802
+ switch (_context3.prev = _context3.next) {
10803
+ case 0:
10804
+ easySwapper = new ethers.ethers.Contract(routerAddress[pool.network][exports.Dapp.TOROS], IDhedgeEasySwapper.abi, pool.signer);
10805
+ _context3.next = 3;
10806
+ return easySwapper.depositQuote(torosAsset, investAsset, amountIn, depositAsset);
10807
+
10808
+ case 3:
10809
+ return _context3.abrupt("return", _context3.sent);
10810
+
10811
+ case 4:
10812
+ case "end":
10813
+ return _context3.stop();
10814
+ }
10815
+ }
10816
+ }, _callee3);
10817
+ }));
10818
+ return _getEasySwapperDepositQuote.apply(this, arguments);
10819
+ }
10820
+
10821
+ function getEasySwapperWithdrawalQuote(_x10, _x11, _x12, _x13) {
10822
+ return _getEasySwapperWithdrawalQuote.apply(this, arguments);
10823
+ }
10824
+
10825
+ function _getEasySwapperWithdrawalQuote() {
10826
+ _getEasySwapperWithdrawalQuote = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(pool, torosAsset, investAsset, amountIn) {
10827
+ var _yield$Promise$all, torosTokenPrice, assetPrice, assetDecimals;
10828
+
10829
+ return runtime_1.wrap(function _callee4$(_context4) {
10830
+ while (1) {
10831
+ switch (_context4.prev = _context4.next) {
10832
+ case 0:
10833
+ _context4.next = 2;
10834
+ return Promise.all([getTorosPoolTokenPrice(pool, torosAsset), getChainlinkPriceInUsd(pool, investAsset), pool.utils.getDecimals(investAsset)]);
10835
+
10836
+ case 2:
10837
+ _yield$Promise$all = _context4.sent;
10838
+ torosTokenPrice = _yield$Promise$all[0];
10839
+ assetPrice = _yield$Promise$all[1];
10840
+ assetDecimals = _yield$Promise$all[2];
10841
+ return _context4.abrupt("return", amountIn.mul(torosTokenPrice).div(assetPrice).div(1e10).div(Math.pow(10, 18 - assetDecimals)));
10842
+
10843
+ case 7:
10844
+ case "end":
10845
+ return _context4.stop();
10846
+ }
10847
+ }
10848
+ }, _callee4);
10849
+ }));
10850
+ return _getEasySwapperWithdrawalQuote.apply(this, arguments);
10851
+ }
10852
+
10853
+ function getEasySwapperTxData(_x14, _x15, _x16, _x17, _x18) {
10854
+ return _getEasySwapperTxData.apply(this, arguments);
10855
+ }
10856
+
10857
+ function _getEasySwapperTxData() {
10858
+ _getEasySwapperTxData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(pool, assetFrom, assetTo, amountIn, slippage // eslint-disable-next-line @typescript-eslint/no-explicit-any
10859
+ ) {
10860
+ var isWithdrawal, _ref, torosAsset, investAsset, iDhedgeEasySwapper, minAmountOut, depositAsset, _minAmountOut;
10861
+
10862
+ return runtime_1.wrap(function _callee5$(_context5) {
10863
+ while (1) {
10864
+ switch (_context5.prev = _context5.next) {
10865
+ case 0:
10866
+ _context5.next = 2;
10867
+ return isPool(pool, assetFrom);
10868
+
10869
+ case 2:
10870
+ isWithdrawal = _context5.sent;
10871
+ _ref = isWithdrawal ? [assetFrom, assetTo] : [assetTo, assetFrom], torosAsset = _ref[0], investAsset = _ref[1];
10872
+ iDhedgeEasySwapper = new ethers.ethers.utils.Interface(IDhedgeEasySwapper.abi);
10873
+
10874
+ if (!isWithdrawal) {
10875
+ _context5.next = 12;
10876
+ break;
10877
+ }
10878
+
10879
+ _context5.next = 8;
10880
+ return getEasySwapperWithdrawalQuote(pool, torosAsset, investAsset, amountIn);
10881
+
10882
+ case 8:
10883
+ minAmountOut = _context5.sent;
10884
+ return _context5.abrupt("return", iDhedgeEasySwapper.encodeFunctionData("withdraw", [torosAsset, amountIn, investAsset, minAmountOut.mul(10000 - slippage * 100).div(10000)]));
10885
+
10886
+ case 12:
10887
+ _context5.next = 14;
10888
+ return getPoolDepositAsset(pool, torosAsset);
10889
+
10890
+ case 14:
10891
+ depositAsset = _context5.sent;
10892
+
10893
+ if (depositAsset) {
10894
+ _context5.next = 17;
10895
+ break;
10896
+ }
10897
+
10898
+ throw new Error("no deposit assets");
10899
+
10900
+ case 17:
10901
+ _context5.next = 19;
10902
+ return getEasySwapperDepositQuote(pool, torosAsset, investAsset, depositAsset, amountIn);
10903
+
10904
+ case 19:
10905
+ _minAmountOut = _context5.sent;
10906
+ return _context5.abrupt("return", iDhedgeEasySwapper.encodeFunctionData("deposit", [torosAsset, investAsset, amountIn, depositAsset, _minAmountOut.mul(10000 - slippage * 100).div(10000)]));
10907
+
10908
+ case 21:
10909
+ case "end":
10910
+ return _context5.stop();
10911
+ }
10912
+ }
10913
+ }, _callee5);
10914
+ }));
10915
+ return _getEasySwapperTxData.apply(this, arguments);
10916
+ }
10917
+
10918
+ var excludedProtocols = ["OPTIMISM_PMM6"]; //Clipper
10919
+
10920
+ function getOneInchProtocols(_x) {
10921
+ return _getOneInchProtocols.apply(this, arguments);
10922
+ }
10923
+
10924
+ function _getOneInchProtocols() {
10925
+ _getOneInchProtocols = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(chainId) {
10926
+ var response, protocols, filteredProtocols;
10927
+ return runtime_1.wrap(function _callee$(_context) {
10928
+ while (1) {
10929
+ switch (_context.prev = _context.next) {
10930
+ case 0:
10931
+ _context.prev = 0;
10932
+ _context.next = 3;
10933
+ return axios.get("https://api.1inch.io/v4.0/" + chainId + "/liquidity-sources");
10934
+
10935
+ case 3:
10936
+ response = _context.sent;
10937
+ protocols = response.data.protocols.map(function (e) {
10938
+ return e.id;
10939
+ });
10940
+ filteredProtocols = protocols.filter(function (e) {
10941
+ return !excludedProtocols.includes(e);
10942
+ });
10943
+ return _context.abrupt("return", "&protocols=" + filteredProtocols.join(","));
10944
+
10945
+ case 9:
10946
+ _context.prev = 9;
10947
+ _context.t0 = _context["catch"](0);
10948
+ return _context.abrupt("return", "");
10949
+
10950
+ case 12:
10951
+ case "end":
10952
+ return _context.stop();
10953
+ }
10954
+ }
10955
+ }, _callee, null, [[0, 9]]);
10956
+ }));
10957
+ return _getOneInchProtocols.apply(this, arguments);
10958
+ }
10959
+
9326
10960
  var Pool = /*#__PURE__*/function () {
9327
10961
  function Pool(network, signer, poolLogic, mangerLogic, utils, factory) {
9328
10962
  this.network = network;
@@ -9712,7 +11346,7 @@ var Pool = /*#__PURE__*/function () {
9712
11346
  /*#__PURE__*/
9713
11347
  function () {
9714
11348
  var _trade = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(dapp, assetFrom, assetTo, amountIn, slippage, options) {
9715
- var swapTxData, chainId, apiUrl, response, iSynthetix, assets, daoAddress, iUniswapV2Router, minAmountOut, tx;
11349
+ var swapTxData, chainId, protocols, apiUrl, response, iSynthetix, assets, daoAddress, iUniswapV2Router, minAmountOut, tx;
9716
11350
  return runtime_1.wrap(function _callee9$(_context9) {
9717
11351
  while (1) {
9718
11352
  switch (_context9.prev = _context9.next) {
@@ -9725,73 +11359,73 @@ var Pool = /*#__PURE__*/function () {
9725
11359
  options = null;
9726
11360
  }
9727
11361
 
9728
- if (!(dapp === exports.Dapp.ONEINCH)) {
9729
- _context9.next = 11;
9730
- break;
9731
- }
11362
+ _context9.t0 = dapp;
11363
+ _context9.next = _context9.t0 === exports.Dapp.ONEINCH ? 5 : _context9.t0 === exports.Dapp.BALANCER ? 15 : _context9.t0 === exports.Dapp.SYNTHETIX ? 19 : _context9.t0 === exports.Dapp.TOROS ? 26 : 30;
11364
+ break;
9732
11365
 
11366
+ case 5:
9733
11367
  chainId = networkChainIdMap[this.network];
9734
- apiUrl = "https://api.1inch.exchange/v4.0/" + chainId + "/swap?fromTokenAddress=" + assetFrom + "&toTokenAddress=" + assetTo + "&amount=" + amountIn.toString() + "&fromAddress=" + this.address + "&destReceiver=" + this.address + "&slippage=" + slippage.toString() + "&disableEstimate=true";
9735
- _context9.next = 7;
11368
+ _context9.next = 8;
11369
+ return getOneInchProtocols(chainId);
11370
+
11371
+ case 8:
11372
+ protocols = _context9.sent;
11373
+ apiUrl = "https://api.1inch.exchange/v4.0/" + chainId + "/swap?fromTokenAddress=" + assetFrom + "&toTokenAddress=" + assetTo + "&amount=" + amountIn.toString() + "&fromAddress=" + this.address + "&destReceiver=" + this.address + "&slippage=" + slippage.toString() + "&disableEstimate=true" + protocols;
11374
+ _context9.next = 12;
9736
11375
  return axios.get(apiUrl);
9737
11376
 
9738
- case 7:
11377
+ case 12:
9739
11378
  response = _context9.sent;
9740
11379
  swapTxData = response.data.tx.data;
9741
- _context9.next = 31;
9742
- break;
9743
-
9744
- case 11:
9745
- if (!(dapp === exports.Dapp.BALANCER)) {
9746
- _context9.next = 17;
9747
- break;
9748
- }
11380
+ return _context9.abrupt("break", 35);
9749
11381
 
9750
- _context9.next = 14;
11382
+ case 15:
11383
+ _context9.next = 17;
9751
11384
  return this.utils.getBalancerSwapTx(this, assetFrom, assetTo, amountIn, slippage);
9752
11385
 
9753
- case 14:
9754
- swapTxData = _context9.sent;
9755
- _context9.next = 31;
9756
- break;
9757
-
9758
11386
  case 17:
9759
- if (!(dapp === exports.Dapp.SYNTHETIX)) {
9760
- _context9.next = 26;
9761
- break;
9762
- }
11387
+ swapTxData = _context9.sent;
11388
+ return _context9.abrupt("break", 35);
9763
11389
 
11390
+ case 19:
9764
11391
  iSynthetix = new ethers.ethers.utils.Interface(ISynthetix.abi);
9765
11392
  assets = [assetFrom, assetTo].map(function (asset) {
9766
11393
  return ethers.ethers.utils.formatBytes32String(asset);
9767
11394
  });
9768
- _context9.next = 22;
11395
+ _context9.next = 23;
9769
11396
  return this.factory.owner();
9770
11397
 
9771
- case 22:
11398
+ case 23:
9772
11399
  daoAddress = _context9.sent;
9773
11400
  swapTxData = iSynthetix.encodeFunctionData(exports.Transaction.SWAP_SYNTHS, [assets[0], amountIn, assets[1], daoAddress, SYNTHETIX_TRACKING_CODE]);
9774
- _context9.next = 31;
9775
- break;
11401
+ return _context9.abrupt("break", 35);
9776
11402
 
9777
11403
  case 26:
11404
+ _context9.next = 28;
11405
+ return getEasySwapperTxData(this, assetFrom, assetTo, ethers.ethers.BigNumber.from(amountIn), slippage);
11406
+
11407
+ case 28:
11408
+ swapTxData = _context9.sent;
11409
+ return _context9.abrupt("break", 35);
11410
+
11411
+ case 30:
9778
11412
  iUniswapV2Router = new ethers.ethers.utils.Interface(IUniswapV2Router.abi);
9779
- _context9.next = 29;
11413
+ _context9.next = 33;
9780
11414
  return this.utils.getMinAmountOut(dapp, assetFrom, assetTo, amountIn, slippage);
9781
11415
 
9782
- case 29:
11416
+ case 33:
9783
11417
  minAmountOut = _context9.sent;
9784
11418
  swapTxData = iUniswapV2Router.encodeFunctionData(exports.Transaction.SWAP, [amountIn, minAmountOut, [assetFrom, assetTo], this.address, deadline]);
9785
11419
 
9786
- case 31:
9787
- _context9.next = 33;
11420
+ case 35:
11421
+ _context9.next = 37;
9788
11422
  return this.poolLogic.execTransaction(routerAddress[this.network][dapp], swapTxData, options);
9789
11423
 
9790
- case 33:
11424
+ case 37:
9791
11425
  tx = _context9.sent;
9792
11426
  return _context9.abrupt("return", tx);
9793
11427
 
9794
- case 35:
11428
+ case 39:
9795
11429
  case "end":
9796
11430
  return _context9.stop();
9797
11431
  }
@@ -10670,7 +12304,7 @@ var Pool = /*#__PURE__*/function () {
10670
12304
  options = null;
10671
12305
  }
10672
12306
 
10673
- if (!((!minPrice || !maxPrice) && (!minTick || !maxTick))) {
12307
+ if (!((minPrice === null || maxPrice === null) && (minTick === null || maxTick === null))) {
10674
12308
  _context27.next = 3;
10675
12309
  break;
10676
12310
  }
@@ -10745,7 +12379,7 @@ var Pool = /*#__PURE__*/function () {
10745
12379
  return getUniswapV3Liquidity(tokenId, this);
10746
12380
 
10747
12381
  case 7:
10748
- liquidity = _context28.sent.mul(amount).div(100);
12382
+ liquidity = _context28.sent.mul(Math.round(amount * 1e4)).div(1e6);
10749
12383
  decreaseLiquidityTxData = abi.encodeFunctionData(exports.Transaction.DECREASE_LIQUIDITY, [[tokenId, liquidity, 0, 0, deadline]]);
10750
12384
  collectTxData = abi.encodeFunctionData(exports.Transaction.COLLECT, [[tokenId, this.address, MaxUint128, MaxUint128]]);
10751
12385
  multicallParams = [decreaseLiquidityTxData, collectTxData];
@@ -10771,7 +12405,7 @@ var Pool = /*#__PURE__*/function () {
10771
12405
  return this.utils.getBalance(tokenId, this.address);
10772
12406
 
10773
12407
  case 20:
10774
- _liquidity = _context28.sent.mul(amount).div(100);
12408
+ _liquidity = _context28.sent.mul(Math.round(amount * 1e4)).div(1e6);
10775
12409
  txData = _abi.encodeFunctionData(exports.Transaction.REMOVE_LIQUIDITY_UNSTAKE, [tokenId, _liquidity, 0, 0, this.address]);
10776
12410
  _context28.next = 25;
10777
12411
  break;
@@ -11004,7 +12638,7 @@ var Pool = /*#__PURE__*/function () {
11004
12638
  return Pool;
11005
12639
  }();
11006
12640
 
11007
- var abi$g = [
12641
+ var abi$j = [
11008
12642
  {
11009
12643
  inputs: [
11010
12644
  {
@@ -11228,10 +12862,10 @@ var abi$g = [
11228
12862
  }
11229
12863
  ];
11230
12864
  var UniswapV2Factory = {
11231
- abi: abi$g
12865
+ abi: abi$j
11232
12866
  };
11233
12867
 
11234
- var abi$h = [
12868
+ var abi$k = [
11235
12869
  {
11236
12870
  anonymous: false,
11237
12871
  inputs: [
@@ -11975,7 +13609,7 @@ var evm = {
11975
13609
  }
11976
13610
  };
11977
13611
  var UniswapV2Pair = {
11978
- abi: abi$h,
13612
+ abi: abi$k,
11979
13613
  evm: evm,
11980
13614
  "interface": [
11981
13615
  {
@@ -12706,7 +14340,7 @@ var UniswapV2Pair = {
12706
14340
  ]
12707
14341
  };
12708
14342
 
12709
- var abi$i = [
14343
+ var abi$l = [
12710
14344
  {
12711
14345
  inputs: [
12712
14346
  {
@@ -13901,7 +15535,7 @@ var abi$i = [
13901
15535
  }
13902
15536
  ];
13903
15537
  var IBalancerV2Vault = {
13904
- abi: abi$i
15538
+ abi: abi$l
13905
15539
  };
13906
15540
 
13907
15541
  var Utils = /*#__PURE__*/function () {
@@ -14417,17 +16051,16 @@ var Dhedge = /*#__PURE__*/function () {
14417
16051
  while (1) {
14418
16052
  switch (_context2.prev = _context2.next) {
14419
16053
  case 0:
14420
- this.validatePool(address);
14421
16054
  poolLogic = new ethers.Contract(address, PoolLogic.abi, this.signer);
14422
- _context2.next = 4;
16055
+ _context2.next = 3;
14423
16056
  return poolLogic.poolManagerLogic();
14424
16057
 
14425
- case 4:
16058
+ case 3:
14426
16059
  managerLogicAddress = _context2.sent;
14427
16060
  managerLogic = new ethers.Contract(managerLogicAddress, ManagerLogic.abi, this.signer);
14428
16061
  return _context2.abrupt("return", new Pool(this.network, this.signer, poolLogic, managerLogic, this.utils, this.factory));
14429
16062
 
14430
- case 7:
16063
+ case 6:
14431
16064
  case "end":
14432
16065
  return _context2.stop();
14433
16066
  }
@@ -14448,42 +16081,9 @@ var Dhedge = /*#__PURE__*/function () {
14448
16081
  */
14449
16082
  ;
14450
16083
 
14451
- _proto.validatePool =
14452
- /*#__PURE__*/
14453
- function () {
14454
- var _validatePool = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(address) {
14455
- var isPool;
14456
- return runtime_1.wrap(function _callee3$(_context3) {
14457
- while (1) {
14458
- switch (_context3.prev = _context3.next) {
14459
- case 0:
14460
- _context3.next = 2;
14461
- return this.factory.isPool(address);
14462
-
14463
- case 2:
14464
- isPool = _context3.sent;
14465
-
14466
- if (isPool) {
14467
- _context3.next = 5;
14468
- break;
14469
- }
14470
-
14471
- throw new Error("Given address not a pool");
14472
-
14473
- case 5:
14474
- case "end":
14475
- return _context3.stop();
14476
- }
14477
- }
14478
- }, _callee3, this);
14479
- }));
14480
-
14481
- function validatePool(_x8) {
14482
- return _validatePool.apply(this, arguments);
14483
- }
14484
-
14485
- return validatePool;
14486
- }();
16084
+ _proto.validatePool = function validatePool(address) {
16085
+ return this.factory.isPool(address);
16086
+ };
14487
16087
 
14488
16088
  return Dhedge;
14489
16089
  }();