@dhedge/v2-sdk 2.2.0 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/config.d.ts +3 -0
- package/dist/entities/pool.d.ts +3 -1
- package/dist/services/dytm/index.d.ts +7 -0
- package/dist/services/ondo/index.d.ts +5 -0
- package/dist/services/toros/completeWithdrawal.d.ts +2 -2
- package/dist/services/toros/easySwapper.d.ts +4 -1
- package/dist/services/toros/initWithdrawal.d.ts +4 -1
- package/dist/types.d.ts +3 -1
- package/dist/v2-sdk.cjs.development.js +708 -119
- package/dist/v2-sdk.cjs.development.js.map +1 -1
- package/dist/v2-sdk.cjs.production.min.js +1 -1
- package/dist/v2-sdk.cjs.production.min.js.map +1 -1
- package/dist/v2-sdk.esm.js +708 -119
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/dytm/IOffice.json +191 -0
- package/src/abi/ondo/IOndoGMSwap.json +30 -0
- package/src/config.ts +21 -2
- package/src/entities/pool.ts +76 -32
- package/src/services/dytm/index.ts +77 -0
- package/src/services/ondo/index.ts +142 -0
- package/src/services/toros/completeWithdrawal.ts +23 -7
- package/src/services/toros/easySwapper.ts +9 -7
- package/src/services/toros/initWithdrawal.ts +10 -6
- package/src/test/dytm.test.ts +241 -0
- package/src/test/ondo.onchain.test.ts +132 -0
- package/src/types.ts +3 -1
package/dist/v2-sdk.esm.js
CHANGED
|
@@ -4591,8 +4591,10 @@ var Dapp;
|
|
|
4591
4591
|
Dapp["ODOS"] = "odos";
|
|
4592
4592
|
Dapp["PENDLE"] = "pendle";
|
|
4593
4593
|
Dapp["KYBERSWAP"] = "kyberswap";
|
|
4594
|
+
Dapp["DYTM"] = "dytm";
|
|
4594
4595
|
Dapp["HYPERLIQUID"] = "hyperliquid";
|
|
4595
4596
|
Dapp["COWSWAP"] = "cowswap";
|
|
4597
|
+
Dapp["ONDO"] = "ondo";
|
|
4596
4598
|
})(Dapp || (Dapp = {}));
|
|
4597
4599
|
/** Function-name strings used when encoding ABI calls — keep in sync with the
|
|
4598
4600
|
* matching ABI files in `src/abi/`. */
|
|
@@ -4621,7 +4623,7 @@ var Transaction;
|
|
|
4621
4623
|
Transaction["REMOVE_LIQUIDITY_UNSTAKE"] = "removeLiquidityAndUnstake";
|
|
4622
4624
|
})(Transaction || (Transaction = {}));
|
|
4623
4625
|
|
|
4624
|
-
var _factoryAddress, _Network$POLYGON, _Network$OPTIMISM, _Network$ARBITRUM, _Network$BASE, _Network$ETHEREUM, _Network$PLASMA, _Network$HYPERLIQUID, _routerAddress, _gpv2SettlementAddres, _Network$POLYGON2, _dappFactoryAddress, _Network$POLYGON3, _Network$OPTIMISM2, _Network$ARBITRUM2, _Network$BASE2, _stakingAddress, _Network$POLYGON4, _Network$OPTIMISM3, _Network$ARBITRUM3, _Network$BASE3, _Network$ETHEREUM2, _Network$PLASMA2, _aaveAddressProvider, _Network$POLYGON5, _Network$OPTIMISM4, _Network$ARBITRUM4, _Network$BASE4, _nonfungiblePositionM, _networkChainIdMap, _balancerSubgraph, _multiCallAddress, _lyraNetworkMap, _flatMoneyContractAdd, _limitOrderAddress, _OdosSwapFeeRecipient;
|
|
4626
|
+
var _factoryAddress, _Network$POLYGON, _Network$OPTIMISM, _Network$ARBITRUM, _Network$BASE, _Network$ETHEREUM, _Network$PLASMA, _Network$HYPERLIQUID, _routerAddress, _gpv2SettlementAddres, _Network$POLYGON2, _dappFactoryAddress, _Network$POLYGON3, _Network$OPTIMISM2, _Network$ARBITRUM2, _Network$BASE2, _stakingAddress, _Network$POLYGON4, _Network$OPTIMISM3, _Network$ARBITRUM3, _Network$BASE3, _Network$ETHEREUM2, _Network$PLASMA2, _aaveAddressProvider, _Network$POLYGON5, _Network$OPTIMISM4, _Network$ARBITRUM4, _Network$BASE4, _nonfungiblePositionM, _networkChainIdMap, _balancerSubgraph, _multiCallAddress, _lyraNetworkMap, _flatMoneyContractAdd, _limitOrderAddress, _OdosSwapFeeRecipient, _dytmContractAddresse;
|
|
4625
4627
|
|
|
4626
4628
|
require("dotenv").config();
|
|
4627
4629
|
/** dHEDGE PoolFactory proxy address per network — used by `Dhedge.createPool` and pool lookups. */
|
|
@@ -4630,7 +4632,7 @@ require("dotenv").config();
|
|
|
4630
4632
|
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[Network.ETHEREUM] = "0x96D33bCF84DdE326014248E2896F79bbb9c13D6d", _factoryAddress[Network.PLASMA] = "0xAec4975Fc8ad911464D2948D771488b30F6eEE87", _factoryAddress[Network.HYPERLIQUID] = "0xe91505e2ab653dd128c71e9690eeefd28cc5b333", _factoryAddress);
|
|
4631
4633
|
/** Router/spender address for each (network, Dapp). Target of `pool.approve`/`pool.trade`. */
|
|
4632
4634
|
|
|
4633
|
-
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.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$POLYGON[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$POLYGON[Dapp.COWSWAP] = "0x893223Be4e941fAA8A8DB93D0C097fCac37801ce", _Network$POLYGON), _routerAddress[Network.OPTIMISM] = (_Network$OPTIMISM = {}, _Network$OPTIMISM[Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _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.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$OPTIMISM[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$OPTIMISM[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _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.TOROS] = "0xA5679C4272A056Bb83f039961fae7D99C48529F5", _Network$ARBITRUM[Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$ARBITRUM[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$ARBITRUM[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$ARBITRUM), _routerAddress[Network.BASE] = (_Network$BASE = {}, _Network$BASE[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$BASE[Dapp.AERODROME] = "0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43", _Network$BASE[Dapp.AAVEV3] = "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5", _Network$BASE[Dapp.TOROS] = "0xf067575Eb60c7587C11e867907AA7284833704d1", _Network$BASE[Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$BASE[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$BASE[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$BASE), _routerAddress[Network.ETHEREUM] = (_Network$ETHEREUM = {}, _Network$ETHEREUM[Dapp.AAVEV3] = "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2", _Network$ETHEREUM[Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$ETHEREUM[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$ETHEREUM[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$ETHEREUM[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$ETHEREUM), _routerAddress[Network.PLASMA] = (_Network$PLASMA = {}, _Network$PLASMA[Dapp.AAVEV3] = "0x925a2A7214Ed92428B5b1B090F80b25700095e12", _Network$PLASMA[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$PLASMA[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$PLASMA), _routerAddress[Network.HYPERLIQUID] = (_Network$HYPERLIQUID = {}, _Network$HYPERLIQUID[Dapp.HYPERLIQUID] = "0x6b9e773128f453f5c2c60935ee2de2cbc5390a24", _Network$HYPERLIQUID), _routerAddress);
|
|
4635
|
+
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.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$POLYGON[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$POLYGON[Dapp.COWSWAP] = "0x893223Be4e941fAA8A8DB93D0C097fCac37801ce", _Network$POLYGON), _routerAddress[Network.OPTIMISM] = (_Network$OPTIMISM = {}, _Network$OPTIMISM[Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _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.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$OPTIMISM[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$OPTIMISM[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _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.TOROS] = "0xA5679C4272A056Bb83f039961fae7D99C48529F5", _Network$ARBITRUM[Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$ARBITRUM[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$ARBITRUM[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$ARBITRUM[Dapp.DYTM] = "0x0fF1CEE337d7af25eEF4c1a7A2CaF83f98d80001", _Network$ARBITRUM), _routerAddress[Network.BASE] = (_Network$BASE = {}, _Network$BASE[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$BASE[Dapp.AERODROME] = "0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43", _Network$BASE[Dapp.AAVEV3] = "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5", _Network$BASE[Dapp.TOROS] = "0xf067575Eb60c7587C11e867907AA7284833704d1", _Network$BASE[Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$BASE[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$BASE[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$BASE), _routerAddress[Network.ETHEREUM] = (_Network$ETHEREUM = {}, _Network$ETHEREUM[Dapp.AAVEV3] = "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2", _Network$ETHEREUM[Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$ETHEREUM[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$ETHEREUM[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$ETHEREUM[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$ETHEREUM[Dapp.ONDO] = "0xde41399145F23936b03dD1474eC16c1519c0DC2a", _Network$ETHEREUM[Dapp.DYTM] = "0x0ff1ce991105DD1a8e26bC8a974Fd0154398Df0f", _Network$ETHEREUM), _routerAddress[Network.PLASMA] = (_Network$PLASMA = {}, _Network$PLASMA[Dapp.AAVEV3] = "0x925a2A7214Ed92428B5b1B090F80b25700095e12", _Network$PLASMA[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$PLASMA[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$PLASMA), _routerAddress[Network.HYPERLIQUID] = (_Network$HYPERLIQUID = {}, _Network$HYPERLIQUID[Dapp.HYPERLIQUID] = "0x6b9e773128f453f5c2c60935ee2de2cbc5390a24", _Network$HYPERLIQUID), _routerAddress);
|
|
4634
4636
|
/** CoW Protocol GPv2Settlement address per network (where pre-signed orders are submitted). */
|
|
4635
4637
|
|
|
4636
4638
|
var gpv2SettlementAddress = (_gpv2SettlementAddres = {}, _gpv2SettlementAddres[Network.POLYGON] = "0x9008D19f58AAbD9eD0D60971565AA8510560ab41", _gpv2SettlementAddres);
|
|
@@ -4684,6 +4686,11 @@ var flatMoneyContractAddresses = (_flatMoneyContractAdd = {}, _flatMoneyContract
|
|
|
4684
4686
|
|
|
4685
4687
|
var limitOrderAddress = (_limitOrderAddress = {}, _limitOrderAddress[Network.POLYGON] = "0xB71410736d2C8F2DAf30dA9D332dA10534d2624d", _limitOrderAddress[Network.OPTIMISM] = "0x3bFE2a472d2964Ea4070725b7Fb0A868b3f08b63", _limitOrderAddress[Network.ARBITRUM] = "0x26a687e8244f1866E9Aa2D400c8b9957Aa8e6Ad4", _limitOrderAddress[Network.BASE] = "0xFcBEc28c43E356693971a24bf3F2Fd7D965E2ebA", _limitOrderAddress[Network.ETHEREUM] = "0x95B19De479bc693721cab39Da98FfECE062f5Ea4", _limitOrderAddress[Network.PLASMA] = "", _limitOrderAddress[Network.HYPERLIQUID] = "", _limitOrderAddress);
|
|
4686
4688
|
var OdosSwapFeeRecipient = (_OdosSwapFeeRecipient = {}, _OdosSwapFeeRecipient[Network.POLYGON] = "0x090e7fbD87A673eE3D0B6ccACf0e1d94fB90DA59", _OdosSwapFeeRecipient[Network.OPTIMISM] = "0x813123A13d01d3F07d434673Fdc89cBBA523f14d", _OdosSwapFeeRecipient[Network.ARBITRUM] = "0xfbD2B4216f422DC1eEe1Cff4Fb64B726F099dEF5", _OdosSwapFeeRecipient[Network.BASE] = "0x5619AD05b0253a7e647Bd2E4C01c7f40CEaB0879", _OdosSwapFeeRecipient[Network.ETHEREUM] = "0xfbD2B4216f422DC1eEe1Cff4Fb64B726F099dEF5", _OdosSwapFeeRecipient[Network.PLASMA] = "", _OdosSwapFeeRecipient[Network.HYPERLIQUID] = "", _OdosSwapFeeRecipient);
|
|
4689
|
+
var dytmContractAddresses = (_dytmContractAddresse = {}, _dytmContractAddresse[Network.ARBITRUM] = {
|
|
4690
|
+
Periphery: "0x1FBe7Bb394BE505C08e9ee419Dd166c71004e51B"
|
|
4691
|
+
}, _dytmContractAddresse[Network.ETHEREUM] = {
|
|
4692
|
+
Periphery: "0xbc632a1A4bD878D7e7D14ea6CfE0DDe3Fc291D1a"
|
|
4693
|
+
}, _dytmContractAddresse);
|
|
4687
4694
|
|
|
4688
4695
|
var abi$3 = [
|
|
4689
4696
|
{
|
|
@@ -12215,7 +12222,11 @@ var getInitWithdrawalTxData = /*#__PURE__*/function () {
|
|
|
12215
12222
|
case 2:
|
|
12216
12223
|
complexAssetsData = _context7.sent;
|
|
12217
12224
|
iEasySwapperV2 = new ethers.utils.Interface(IEasySwapperV2);
|
|
12218
|
-
return _context7.abrupt("return",
|
|
12225
|
+
return _context7.abrupt("return", {
|
|
12226
|
+
swapTxData: iEasySwapperV2.encodeFunctionData("initWithdrawal", [torosAsset, amountIn, complexAssetsData]),
|
|
12227
|
+
minAmountOut: null // not be used when building multicall tx data
|
|
12228
|
+
|
|
12229
|
+
});
|
|
12219
12230
|
|
|
12220
12231
|
case 5:
|
|
12221
12232
|
case "end":
|
|
@@ -12331,7 +12342,7 @@ function getEasySwapperTxData(_x10, _x11, _x12, _x13, _x14) {
|
|
|
12331
12342
|
function _getEasySwapperTxData() {
|
|
12332
12343
|
_getEasySwapperTxData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(pool, assetFrom, assetTo, amountIn, slippage // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12333
12344
|
) {
|
|
12334
|
-
var isWithdrawal, _ref, torosAsset, investAsset, iEasySwapperV2, depositAsset, minAmountOut;
|
|
12345
|
+
var isWithdrawal, _ref, torosAsset, investAsset, iEasySwapperV2, depositAsset, minAmountOut, _minAmountOut;
|
|
12335
12346
|
|
|
12336
12347
|
return runtime_1.wrap(function _callee4$(_context4) {
|
|
12337
12348
|
while (1) {
|
|
@@ -12380,9 +12391,13 @@ function _getEasySwapperTxData() {
|
|
|
12380
12391
|
|
|
12381
12392
|
case 18:
|
|
12382
12393
|
minAmountOut = _context4.sent;
|
|
12383
|
-
|
|
12394
|
+
_minAmountOut = minAmountOut.mul(10000 - slippage * 100).div(10000);
|
|
12395
|
+
return _context4.abrupt("return", {
|
|
12396
|
+
swapTxData: iEasySwapperV2.encodeFunctionData("depositWithCustomCooldown", [torosAsset, depositAsset, amountIn, _minAmountOut]),
|
|
12397
|
+
minAmountOut: _minAmountOut
|
|
12398
|
+
});
|
|
12384
12399
|
|
|
12385
|
-
case
|
|
12400
|
+
case 21:
|
|
12386
12401
|
case "end":
|
|
12387
12402
|
return _context4.stop();
|
|
12388
12403
|
}
|
|
@@ -27893,24 +27908,32 @@ var getSwapWithdrawData = /*#__PURE__*/function () {
|
|
|
27893
27908
|
}();
|
|
27894
27909
|
|
|
27895
27910
|
var createCompleteWithdrawalTxArguments = /*#__PURE__*/function () {
|
|
27896
|
-
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(pool, receiveToken, slippage) {
|
|
27897
|
-
var easySwapper, trackedAssets, swapTrackedAssets, assetHandlerAddress, assetHandler, receiveTokenPriceD18, receiveTokenErc20, receiveTokenDecimals, tAssetInfos, swapDestMinDestAmount, withdrawalVaultAddress, balanceOfReceiveToken, estimatedMinReceiveAmount, swapData;
|
|
27911
|
+
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(pool, receiveToken, slippage, _trackedAssets) {
|
|
27912
|
+
var easySwapper, trackedAssets, swapTrackedAssets, assetHandlerAddress, assetHandler, receiveTokenPriceD18, receiveTokenErc20, receiveTokenDecimals, tAssetInfos, swapDestMinDestAmount, withdrawalVaultAddress, balanceOfReceiveToken, trackedAsset, estimatedMinReceiveAmount, swapData;
|
|
27898
27913
|
return runtime_1.wrap(function _callee3$(_context5) {
|
|
27899
27914
|
while (1) {
|
|
27900
27915
|
switch (_context5.prev = _context5.next) {
|
|
27901
27916
|
case 0:
|
|
27902
27917
|
easySwapper = new ethers.Contract(routerAddress[pool.network][Dapp.TOROS], IEasySwapperV2, pool.signer);
|
|
27903
|
-
|
|
27918
|
+
trackedAssets = _trackedAssets;
|
|
27919
|
+
|
|
27920
|
+
if (!(trackedAssets.length === 0)) {
|
|
27921
|
+
_context5.next = 6;
|
|
27922
|
+
break;
|
|
27923
|
+
}
|
|
27924
|
+
|
|
27925
|
+
_context5.next = 5;
|
|
27904
27926
|
return easySwapper.getTrackedAssets(pool.address);
|
|
27905
27927
|
|
|
27906
|
-
case
|
|
27928
|
+
case 5:
|
|
27907
27929
|
trackedAssets = _context5.sent;
|
|
27908
27930
|
|
|
27931
|
+
case 6:
|
|
27909
27932
|
if (!(trackedAssets.length === 0 || trackedAssets.every(function (_ref3) {
|
|
27910
27933
|
var token = _ref3.token;
|
|
27911
27934
|
return token.toLowerCase() === receiveToken.toLowerCase();
|
|
27912
27935
|
}))) {
|
|
27913
|
-
_context5.next =
|
|
27936
|
+
_context5.next = 8;
|
|
27914
27937
|
break;
|
|
27915
27938
|
}
|
|
27916
27939
|
|
|
@@ -27920,35 +27943,35 @@ var createCompleteWithdrawalTxArguments = /*#__PURE__*/function () {
|
|
|
27920
27943
|
estimatedMinReceiveAmount: null
|
|
27921
27944
|
});
|
|
27922
27945
|
|
|
27923
|
-
case
|
|
27946
|
+
case 8:
|
|
27924
27947
|
swapTrackedAssets = trackedAssets.filter(function (_ref4) {
|
|
27925
27948
|
var token = _ref4.token;
|
|
27926
27949
|
return token.toLowerCase() !== receiveToken.toLowerCase();
|
|
27927
27950
|
});
|
|
27928
|
-
_context5.next =
|
|
27951
|
+
_context5.next = 11;
|
|
27929
27952
|
return pool.factory.callStatic.getAssetHandler();
|
|
27930
27953
|
|
|
27931
|
-
case
|
|
27954
|
+
case 11:
|
|
27932
27955
|
assetHandlerAddress = _context5.sent;
|
|
27933
27956
|
assetHandler = new ethers.Contract(assetHandlerAddress, AssetHandlerAbi.abi, pool.signer);
|
|
27934
27957
|
_context5.t0 = BigNumber;
|
|
27935
|
-
_context5.next =
|
|
27958
|
+
_context5.next = 16;
|
|
27936
27959
|
return assetHandler.getUSDPrice(receiveToken);
|
|
27937
27960
|
|
|
27938
|
-
case
|
|
27961
|
+
case 16:
|
|
27939
27962
|
_context5.t1 = _context5.sent.toString();
|
|
27940
27963
|
receiveTokenPriceD18 = new _context5.t0(_context5.t1);
|
|
27941
|
-
_context5.next =
|
|
27964
|
+
_context5.next = 20;
|
|
27942
27965
|
return new ethers.Contract(receiveToken, IERC20.abi, pool.signer);
|
|
27943
27966
|
|
|
27944
|
-
case
|
|
27967
|
+
case 20:
|
|
27945
27968
|
receiveTokenErc20 = _context5.sent;
|
|
27946
|
-
_context5.next =
|
|
27969
|
+
_context5.next = 23;
|
|
27947
27970
|
return receiveTokenErc20.decimals();
|
|
27948
27971
|
|
|
27949
|
-
case
|
|
27972
|
+
case 23:
|
|
27950
27973
|
receiveTokenDecimals = _context5.sent;
|
|
27951
|
-
_context5.next =
|
|
27974
|
+
_context5.next = 26;
|
|
27952
27975
|
return Promise.all(swapTrackedAssets.map( /*#__PURE__*/function () {
|
|
27953
27976
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(swapTAsset) {
|
|
27954
27977
|
var swapTAssetPriceD18, swapTAssetTokenErc20, swapTAssetDecimals, tokenBalanceBN, estimatedValueToSwapD0, adjustedSlippage, estimatedMinReceiveAmount;
|
|
@@ -28000,34 +28023,47 @@ var createCompleteWithdrawalTxArguments = /*#__PURE__*/function () {
|
|
|
28000
28023
|
}, _callee2);
|
|
28001
28024
|
}));
|
|
28002
28025
|
|
|
28003
|
-
return function (
|
|
28026
|
+
return function (_x9) {
|
|
28004
28027
|
return _ref5.apply(this, arguments);
|
|
28005
28028
|
};
|
|
28006
28029
|
}()));
|
|
28007
28030
|
|
|
28008
|
-
case
|
|
28031
|
+
case 26:
|
|
28009
28032
|
tAssetInfos = _context5.sent;
|
|
28010
28033
|
swapDestMinDestAmount = tAssetInfos.reduce(function (acc, _ref6) {
|
|
28011
28034
|
var estimatedMinReceiveAmount = _ref6.estimatedMinReceiveAmount;
|
|
28012
28035
|
return acc.plus(estimatedMinReceiveAmount);
|
|
28013
28036
|
}, new BigNumber(0));
|
|
28014
|
-
_context5.next =
|
|
28037
|
+
_context5.next = 30;
|
|
28015
28038
|
return easySwapper.withdrawalContracts(pool.address);
|
|
28016
28039
|
|
|
28017
|
-
case
|
|
28040
|
+
case 30:
|
|
28018
28041
|
withdrawalVaultAddress = _context5.sent;
|
|
28019
|
-
_context5.next =
|
|
28042
|
+
_context5.next = 33;
|
|
28020
28043
|
return receiveTokenErc20.balanceOf(withdrawalVaultAddress);
|
|
28021
28044
|
|
|
28022
|
-
case
|
|
28045
|
+
case 33:
|
|
28023
28046
|
balanceOfReceiveToken = _context5.sent;
|
|
28024
|
-
|
|
28047
|
+
|
|
28048
|
+
if (trackedAssets.length !== 0) {
|
|
28049
|
+
// finds the receiveTokenErc20's balance inside trackedAssets
|
|
28050
|
+
trackedAsset = trackedAssets.find(function (_ref7) {
|
|
28051
|
+
var token = _ref7.token;
|
|
28052
|
+
return token.toLowerCase() === receiveToken.toLowerCase();
|
|
28053
|
+
});
|
|
28054
|
+
|
|
28055
|
+
if (trackedAsset) {
|
|
28056
|
+
balanceOfReceiveToken = balanceOfReceiveToken.add(trackedAsset.balance);
|
|
28057
|
+
}
|
|
28058
|
+
} // complete withdraw _expectedDestTokenAmount
|
|
28059
|
+
|
|
28060
|
+
|
|
28025
28061
|
estimatedMinReceiveAmount = swapDestMinDestAmount.plus(balanceOfReceiveToken.toString());
|
|
28026
|
-
_context5.next =
|
|
28027
|
-
return getSwapWithdrawData(pool, tAssetInfos.map(function (
|
|
28028
|
-
var token =
|
|
28029
|
-
balance =
|
|
28030
|
-
slippage =
|
|
28062
|
+
_context5.next = 38;
|
|
28063
|
+
return getSwapWithdrawData(pool, tAssetInfos.map(function (_ref8) {
|
|
28064
|
+
var token = _ref8.token,
|
|
28065
|
+
balance = _ref8.balance,
|
|
28066
|
+
slippage = _ref8.slippage;
|
|
28031
28067
|
return {
|
|
28032
28068
|
token: token,
|
|
28033
28069
|
balance: balance,
|
|
@@ -28035,7 +28071,7 @@ var createCompleteWithdrawalTxArguments = /*#__PURE__*/function () {
|
|
|
28035
28071
|
};
|
|
28036
28072
|
}), receiveToken, swapDestMinDestAmount);
|
|
28037
28073
|
|
|
28038
|
-
case
|
|
28074
|
+
case 38:
|
|
28039
28075
|
swapData = _context5.sent;
|
|
28040
28076
|
return _context5.abrupt("return", {
|
|
28041
28077
|
isSwapNeeded: true,
|
|
@@ -28043,7 +28079,7 @@ var createCompleteWithdrawalTxArguments = /*#__PURE__*/function () {
|
|
|
28043
28079
|
estimatedMinReceiveAmount: estimatedMinReceiveAmount.toFixed(0)
|
|
28044
28080
|
});
|
|
28045
28081
|
|
|
28046
|
-
case
|
|
28082
|
+
case 40:
|
|
28047
28083
|
case "end":
|
|
28048
28084
|
return _context5.stop();
|
|
28049
28085
|
}
|
|
@@ -28051,19 +28087,19 @@ var createCompleteWithdrawalTxArguments = /*#__PURE__*/function () {
|
|
|
28051
28087
|
}, _callee3);
|
|
28052
28088
|
}));
|
|
28053
28089
|
|
|
28054
|
-
return function createCompleteWithdrawalTxArguments(_x5, _x6, _x7) {
|
|
28090
|
+
return function createCompleteWithdrawalTxArguments(_x5, _x6, _x7, _x8) {
|
|
28055
28091
|
return _ref2.apply(this, arguments);
|
|
28056
28092
|
};
|
|
28057
28093
|
}();
|
|
28058
28094
|
var getCompleteWithdrawalTxData = /*#__PURE__*/function () {
|
|
28059
|
-
var
|
|
28095
|
+
var _ref9 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(pool, receiveToken, slippage, useOnChainSwap, trackedAssets) {
|
|
28060
28096
|
var completeWithdrawTxArguments, isSwapNeeded, isOffchainSwap, iEasySwapperV2;
|
|
28061
28097
|
return runtime_1.wrap(function _callee4$(_context6) {
|
|
28062
28098
|
while (1) {
|
|
28063
28099
|
switch (_context6.prev = _context6.next) {
|
|
28064
28100
|
case 0:
|
|
28065
28101
|
_context6.next = 2;
|
|
28066
|
-
return createCompleteWithdrawalTxArguments(pool, receiveToken, slippage);
|
|
28102
|
+
return createCompleteWithdrawalTxArguments(pool, receiveToken, slippage, trackedAssets);
|
|
28067
28103
|
|
|
28068
28104
|
case 2:
|
|
28069
28105
|
completeWithdrawTxArguments = _context6.sent;
|
|
@@ -28089,8 +28125,275 @@ var getCompleteWithdrawalTxData = /*#__PURE__*/function () {
|
|
|
28089
28125
|
}, _callee4);
|
|
28090
28126
|
}));
|
|
28091
28127
|
|
|
28092
|
-
return function getCompleteWithdrawalTxData(
|
|
28093
|
-
return
|
|
28128
|
+
return function getCompleteWithdrawalTxData(_x10, _x11, _x12, _x13, _x14) {
|
|
28129
|
+
return _ref9.apply(this, arguments);
|
|
28130
|
+
};
|
|
28131
|
+
}();
|
|
28132
|
+
|
|
28133
|
+
var IOffice = [
|
|
28134
|
+
{
|
|
28135
|
+
inputs: [
|
|
28136
|
+
{
|
|
28137
|
+
components: [
|
|
28138
|
+
{
|
|
28139
|
+
internalType: "AccountId",
|
|
28140
|
+
name: "account",
|
|
28141
|
+
type: "uint256"
|
|
28142
|
+
},
|
|
28143
|
+
{
|
|
28144
|
+
internalType: "ReserveKey",
|
|
28145
|
+
name: "key",
|
|
28146
|
+
type: "uint248"
|
|
28147
|
+
},
|
|
28148
|
+
{
|
|
28149
|
+
internalType: "address",
|
|
28150
|
+
name: "receiver",
|
|
28151
|
+
type: "address"
|
|
28152
|
+
},
|
|
28153
|
+
{
|
|
28154
|
+
internalType: "uint256",
|
|
28155
|
+
name: "assets",
|
|
28156
|
+
type: "uint256"
|
|
28157
|
+
},
|
|
28158
|
+
{
|
|
28159
|
+
internalType: "bytes",
|
|
28160
|
+
name: "extraData",
|
|
28161
|
+
type: "bytes"
|
|
28162
|
+
}
|
|
28163
|
+
],
|
|
28164
|
+
internalType: "struct BorrowParams",
|
|
28165
|
+
name: "params",
|
|
28166
|
+
type: "tuple"
|
|
28167
|
+
}
|
|
28168
|
+
],
|
|
28169
|
+
name: "borrow",
|
|
28170
|
+
outputs: [
|
|
28171
|
+
{
|
|
28172
|
+
internalType: "uint256",
|
|
28173
|
+
name: "debtShares",
|
|
28174
|
+
type: "uint256"
|
|
28175
|
+
}
|
|
28176
|
+
],
|
|
28177
|
+
stateMutability: "nonpayable",
|
|
28178
|
+
type: "function"
|
|
28179
|
+
},
|
|
28180
|
+
{
|
|
28181
|
+
inputs: [
|
|
28182
|
+
{
|
|
28183
|
+
components: [
|
|
28184
|
+
{
|
|
28185
|
+
internalType: "AccountId",
|
|
28186
|
+
name: "account",
|
|
28187
|
+
type: "uint256"
|
|
28188
|
+
},
|
|
28189
|
+
{
|
|
28190
|
+
internalType: "ReserveKey",
|
|
28191
|
+
name: "key",
|
|
28192
|
+
type: "uint248"
|
|
28193
|
+
},
|
|
28194
|
+
{
|
|
28195
|
+
internalType: "enum TokenType",
|
|
28196
|
+
name: "withCollateralType",
|
|
28197
|
+
type: "uint8"
|
|
28198
|
+
},
|
|
28199
|
+
{
|
|
28200
|
+
internalType: "uint256",
|
|
28201
|
+
name: "assets",
|
|
28202
|
+
type: "uint256"
|
|
28203
|
+
},
|
|
28204
|
+
{
|
|
28205
|
+
internalType: "uint256",
|
|
28206
|
+
name: "shares",
|
|
28207
|
+
type: "uint256"
|
|
28208
|
+
},
|
|
28209
|
+
{
|
|
28210
|
+
internalType: "bytes",
|
|
28211
|
+
name: "extraData",
|
|
28212
|
+
type: "bytes"
|
|
28213
|
+
}
|
|
28214
|
+
],
|
|
28215
|
+
internalType: "struct RepayParams",
|
|
28216
|
+
name: "params",
|
|
28217
|
+
type: "tuple"
|
|
28218
|
+
}
|
|
28219
|
+
],
|
|
28220
|
+
name: "repay",
|
|
28221
|
+
outputs: [
|
|
28222
|
+
{
|
|
28223
|
+
internalType: "uint256",
|
|
28224
|
+
name: "assetsRepaid",
|
|
28225
|
+
type: "uint256"
|
|
28226
|
+
}
|
|
28227
|
+
],
|
|
28228
|
+
stateMutability: "nonpayable",
|
|
28229
|
+
type: "function"
|
|
28230
|
+
},
|
|
28231
|
+
{
|
|
28232
|
+
inputs: [
|
|
28233
|
+
{
|
|
28234
|
+
components: [
|
|
28235
|
+
{
|
|
28236
|
+
internalType: "AccountId",
|
|
28237
|
+
name: "account",
|
|
28238
|
+
type: "uint256"
|
|
28239
|
+
},
|
|
28240
|
+
{
|
|
28241
|
+
internalType: "uint256",
|
|
28242
|
+
name: "tokenId",
|
|
28243
|
+
type: "uint256"
|
|
28244
|
+
},
|
|
28245
|
+
{
|
|
28246
|
+
internalType: "uint256",
|
|
28247
|
+
name: "assets",
|
|
28248
|
+
type: "uint256"
|
|
28249
|
+
},
|
|
28250
|
+
{
|
|
28251
|
+
internalType: "bytes",
|
|
28252
|
+
name: "extraData",
|
|
28253
|
+
type: "bytes"
|
|
28254
|
+
}
|
|
28255
|
+
],
|
|
28256
|
+
internalType: "struct SupplyParams",
|
|
28257
|
+
name: "params",
|
|
28258
|
+
type: "tuple"
|
|
28259
|
+
}
|
|
28260
|
+
],
|
|
28261
|
+
name: "supply",
|
|
28262
|
+
outputs: [
|
|
28263
|
+
{
|
|
28264
|
+
internalType: "uint256",
|
|
28265
|
+
name: "shares",
|
|
28266
|
+
type: "uint256"
|
|
28267
|
+
}
|
|
28268
|
+
],
|
|
28269
|
+
stateMutability: "nonpayable",
|
|
28270
|
+
type: "function"
|
|
28271
|
+
},
|
|
28272
|
+
{
|
|
28273
|
+
inputs: [
|
|
28274
|
+
{
|
|
28275
|
+
components: [
|
|
28276
|
+
{
|
|
28277
|
+
internalType: "AccountId",
|
|
28278
|
+
name: "account",
|
|
28279
|
+
type: "uint256"
|
|
28280
|
+
},
|
|
28281
|
+
{
|
|
28282
|
+
internalType: "uint256",
|
|
28283
|
+
name: "tokenId",
|
|
28284
|
+
type: "uint256"
|
|
28285
|
+
},
|
|
28286
|
+
{
|
|
28287
|
+
internalType: "address",
|
|
28288
|
+
name: "receiver",
|
|
28289
|
+
type: "address"
|
|
28290
|
+
},
|
|
28291
|
+
{
|
|
28292
|
+
internalType: "uint256",
|
|
28293
|
+
name: "assets",
|
|
28294
|
+
type: "uint256"
|
|
28295
|
+
},
|
|
28296
|
+
{
|
|
28297
|
+
internalType: "uint256",
|
|
28298
|
+
name: "shares",
|
|
28299
|
+
type: "uint256"
|
|
28300
|
+
},
|
|
28301
|
+
{
|
|
28302
|
+
internalType: "bytes",
|
|
28303
|
+
name: "extraData",
|
|
28304
|
+
type: "bytes"
|
|
28305
|
+
}
|
|
28306
|
+
],
|
|
28307
|
+
internalType: "struct WithdrawParams",
|
|
28308
|
+
name: "params",
|
|
28309
|
+
type: "tuple"
|
|
28310
|
+
}
|
|
28311
|
+
],
|
|
28312
|
+
name: "withdraw",
|
|
28313
|
+
outputs: [
|
|
28314
|
+
{
|
|
28315
|
+
internalType: "uint256",
|
|
28316
|
+
name: "assets",
|
|
28317
|
+
type: "uint256"
|
|
28318
|
+
}
|
|
28319
|
+
],
|
|
28320
|
+
stateMutability: "nonpayable",
|
|
28321
|
+
type: "function"
|
|
28322
|
+
}
|
|
28323
|
+
];
|
|
28324
|
+
|
|
28325
|
+
var iOffice = /*#__PURE__*/new ethers.utils.Interface(IOffice);
|
|
28326
|
+
var getDytmDepositTxData = function getDytmDepositTxData(pool, asset, amount) {
|
|
28327
|
+
return iOffice.encodeFunctionData("supply", [{
|
|
28328
|
+
account: ethers.BigNumber.from(pool.address),
|
|
28329
|
+
tokenId: asset,
|
|
28330
|
+
assets: amount,
|
|
28331
|
+
extraData: "0x"
|
|
28332
|
+
}]);
|
|
28333
|
+
};
|
|
28334
|
+
var getDytmBorrowTxData = function getDytmBorrowTxData(pool, asset, amount) {
|
|
28335
|
+
return iOffice.encodeFunctionData("borrow", [{
|
|
28336
|
+
account: ethers.BigNumber.from(pool.address),
|
|
28337
|
+
key: asset,
|
|
28338
|
+
receiver: pool.address,
|
|
28339
|
+
assets: amount,
|
|
28340
|
+
extraData: "0x"
|
|
28341
|
+
}]);
|
|
28342
|
+
};
|
|
28343
|
+
var getDytmRepayTxData = /*#__PURE__*/function () {
|
|
28344
|
+
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(pool, asset, amount) {
|
|
28345
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
28346
|
+
while (1) {
|
|
28347
|
+
switch (_context.prev = _context.next) {
|
|
28348
|
+
case 0:
|
|
28349
|
+
return _context.abrupt("return", iOffice.encodeFunctionData("repay", [{
|
|
28350
|
+
account: ethers.BigNumber.from(pool.address),
|
|
28351
|
+
key: asset,
|
|
28352
|
+
withCollateralType: "0",
|
|
28353
|
+
assets: amount,
|
|
28354
|
+
shares: "0",
|
|
28355
|
+
extraData: "0x"
|
|
28356
|
+
}]));
|
|
28357
|
+
|
|
28358
|
+
case 1:
|
|
28359
|
+
case "end":
|
|
28360
|
+
return _context.stop();
|
|
28361
|
+
}
|
|
28362
|
+
}
|
|
28363
|
+
}, _callee);
|
|
28364
|
+
}));
|
|
28365
|
+
|
|
28366
|
+
return function getDytmRepayTxData(_x, _x2, _x3) {
|
|
28367
|
+
return _ref.apply(this, arguments);
|
|
28368
|
+
};
|
|
28369
|
+
}();
|
|
28370
|
+
var getDytmWithdrawTxData = /*#__PURE__*/function () {
|
|
28371
|
+
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(pool, asset, amount) {
|
|
28372
|
+
var isMaxAmount;
|
|
28373
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
28374
|
+
while (1) {
|
|
28375
|
+
switch (_context2.prev = _context2.next) {
|
|
28376
|
+
case 0:
|
|
28377
|
+
isMaxAmount = ethers.BigNumber.from(amount).eq(ethers.constants.MaxUint256);
|
|
28378
|
+
return _context2.abrupt("return", iOffice.encodeFunctionData("withdraw", [{
|
|
28379
|
+
account: ethers.BigNumber.from(pool.address),
|
|
28380
|
+
tokenId: asset,
|
|
28381
|
+
assets: isMaxAmount ? 0 : amount,
|
|
28382
|
+
shares: isMaxAmount ? amount : 0,
|
|
28383
|
+
receiver: pool.address,
|
|
28384
|
+
extraData: "0x"
|
|
28385
|
+
}]));
|
|
28386
|
+
|
|
28387
|
+
case 2:
|
|
28388
|
+
case "end":
|
|
28389
|
+
return _context2.stop();
|
|
28390
|
+
}
|
|
28391
|
+
}
|
|
28392
|
+
}, _callee2);
|
|
28393
|
+
}));
|
|
28394
|
+
|
|
28395
|
+
return function getDytmWithdrawTxData(_x4, _x5, _x6) {
|
|
28396
|
+
return _ref2.apply(this, arguments);
|
|
28094
28397
|
};
|
|
28095
28398
|
}();
|
|
28096
28399
|
|
|
@@ -28540,6 +28843,233 @@ function _getCowSwapTxData() {
|
|
|
28540
28843
|
return _getCowSwapTxData.apply(this, arguments);
|
|
28541
28844
|
}
|
|
28542
28845
|
|
|
28846
|
+
var IOndoGMSwap = [
|
|
28847
|
+
{
|
|
28848
|
+
inputs: [
|
|
28849
|
+
{
|
|
28850
|
+
name: "tokenIn",
|
|
28851
|
+
type: "address"
|
|
28852
|
+
},
|
|
28853
|
+
{
|
|
28854
|
+
name: "amountIn",
|
|
28855
|
+
type: "uint256"
|
|
28856
|
+
},
|
|
28857
|
+
{
|
|
28858
|
+
name: "tokenOut",
|
|
28859
|
+
type: "address"
|
|
28860
|
+
},
|
|
28861
|
+
{
|
|
28862
|
+
name: "amountOutMinimum",
|
|
28863
|
+
type: "uint256"
|
|
28864
|
+
},
|
|
28865
|
+
{
|
|
28866
|
+
name: "attestationSignature",
|
|
28867
|
+
type: "bytes"
|
|
28868
|
+
},
|
|
28869
|
+
{
|
|
28870
|
+
components: [
|
|
28871
|
+
{
|
|
28872
|
+
name: "chainId",
|
|
28873
|
+
type: "uint256"
|
|
28874
|
+
},
|
|
28875
|
+
{
|
|
28876
|
+
name: "attestationId",
|
|
28877
|
+
type: "uint256"
|
|
28878
|
+
},
|
|
28879
|
+
{
|
|
28880
|
+
name: "userId",
|
|
28881
|
+
type: "bytes32"
|
|
28882
|
+
},
|
|
28883
|
+
{
|
|
28884
|
+
name: "asset",
|
|
28885
|
+
type: "address"
|
|
28886
|
+
},
|
|
28887
|
+
{
|
|
28888
|
+
name: "price",
|
|
28889
|
+
type: "uint256"
|
|
28890
|
+
},
|
|
28891
|
+
{
|
|
28892
|
+
name: "quantity",
|
|
28893
|
+
type: "uint256"
|
|
28894
|
+
},
|
|
28895
|
+
{
|
|
28896
|
+
name: "expiration",
|
|
28897
|
+
type: "uint256"
|
|
28898
|
+
},
|
|
28899
|
+
{
|
|
28900
|
+
name: "side",
|
|
28901
|
+
type: "uint8"
|
|
28902
|
+
},
|
|
28903
|
+
{
|
|
28904
|
+
name: "additionalData",
|
|
28905
|
+
type: "bytes32"
|
|
28906
|
+
}
|
|
28907
|
+
],
|
|
28908
|
+
name: "quote",
|
|
28909
|
+
type: "tuple"
|
|
28910
|
+
}
|
|
28911
|
+
],
|
|
28912
|
+
name: "swapExactInWithAttestation",
|
|
28913
|
+
outputs: [
|
|
28914
|
+
],
|
|
28915
|
+
stateMutability: "nonpayable",
|
|
28916
|
+
type: "function"
|
|
28917
|
+
}
|
|
28918
|
+
];
|
|
28919
|
+
|
|
28920
|
+
var ONDO_API_URL = "https://api.gm.ondo.finance/v1/attestations"; // Ethereum mainnet USDC — Ondo is Ethereum-only
|
|
28921
|
+
|
|
28922
|
+
var USDC_ETHEREUM = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48";
|
|
28923
|
+
var iface$1 = /*#__PURE__*/new ethers.utils.Interface(IOndoGMSwap); // Ondo returns userId as a left-aligned 32-byte hex (significant bytes first,
|
|
28924
|
+
// e.g. 0x474d...0000), so right-pad to preserve byte order and fix it to 32 bytes.
|
|
28925
|
+
|
|
28926
|
+
function toBytes32(s) {
|
|
28927
|
+
var hex = s.startsWith("0x") ? s.slice(2) : s;
|
|
28928
|
+
return "0x" + hex.padEnd(64, "0").slice(0, 64);
|
|
28929
|
+
}
|
|
28930
|
+
|
|
28931
|
+
function postOndoAttestation(_x, _x2, _x3, _x4) {
|
|
28932
|
+
return _postOndoAttestation.apply(this, arguments);
|
|
28933
|
+
}
|
|
28934
|
+
|
|
28935
|
+
function _postOndoAttestation() {
|
|
28936
|
+
_postOndoAttestation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(symbol, side, amount, apiKey) {
|
|
28937
|
+
var _yield$axios$post, data, _error$response$data, _ref, code, message;
|
|
28938
|
+
|
|
28939
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
28940
|
+
while (1) {
|
|
28941
|
+
switch (_context.prev = _context.next) {
|
|
28942
|
+
case 0:
|
|
28943
|
+
_context.prev = 0;
|
|
28944
|
+
_context.next = 3;
|
|
28945
|
+
return axios.post(ONDO_API_URL, _extends({
|
|
28946
|
+
chainId: "ethereum-1",
|
|
28947
|
+
symbol: symbol,
|
|
28948
|
+
side: side
|
|
28949
|
+
}, amount, {
|
|
28950
|
+
duration: "short"
|
|
28951
|
+
}), {
|
|
28952
|
+
headers: {
|
|
28953
|
+
"x-api-key": apiKey
|
|
28954
|
+
}
|
|
28955
|
+
});
|
|
28956
|
+
|
|
28957
|
+
case 3:
|
|
28958
|
+
_yield$axios$post = _context.sent;
|
|
28959
|
+
data = _yield$axios$post.data;
|
|
28960
|
+
return _context.abrupt("return", data);
|
|
28961
|
+
|
|
28962
|
+
case 8:
|
|
28963
|
+
_context.prev = 8;
|
|
28964
|
+
_context.t0 = _context["catch"](0);
|
|
28965
|
+
|
|
28966
|
+
if (!(axios.isAxiosError(_context.t0) && _context.t0.response)) {
|
|
28967
|
+
_context.next = 13;
|
|
28968
|
+
break;
|
|
28969
|
+
}
|
|
28970
|
+
|
|
28971
|
+
_ref = (_error$response$data = _context.t0.response.data) != null ? _error$response$data : {}, code = _ref.code, message = _ref.message;
|
|
28972
|
+
throw new ApiError(("Ondo attestation request failed (" + _context.t0.response.status + "): " + (code != null ? code : "") + " " + (message != null ? message : JSON.stringify(_context.t0.response.data))).trim());
|
|
28973
|
+
|
|
28974
|
+
case 13:
|
|
28975
|
+
throw new ApiError("Ondo attestation request failed: " + (_context.t0 instanceof Error ? _context.t0.message : String(_context.t0)));
|
|
28976
|
+
|
|
28977
|
+
case 14:
|
|
28978
|
+
case "end":
|
|
28979
|
+
return _context.stop();
|
|
28980
|
+
}
|
|
28981
|
+
}
|
|
28982
|
+
}, _callee, null, [[0, 8]]);
|
|
28983
|
+
}));
|
|
28984
|
+
return _postOndoAttestation.apply(this, arguments);
|
|
28985
|
+
}
|
|
28986
|
+
|
|
28987
|
+
function getOndoSwapTxData(_x5, _x6, _x7, _x8, _x9) {
|
|
28988
|
+
return _getOndoSwapTxData.apply(this, arguments);
|
|
28989
|
+
}
|
|
28990
|
+
|
|
28991
|
+
function _getOndoSwapTxData() {
|
|
28992
|
+
_getOndoSwapTxData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(pool, tokenIn, tokenOut, amountIn, slippage) {
|
|
28993
|
+
var apiKey, amount, isMint, gmToken, slippageBps, tokenContract, symbol, attestationAmount, attestation, signature, additionalData, quantity, priceD18, minAmountOut, usdcOut, quote, swapTxData;
|
|
28994
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
28995
|
+
while (1) {
|
|
28996
|
+
switch (_context2.prev = _context2.next) {
|
|
28997
|
+
case 0:
|
|
28998
|
+
apiKey = process.env.ONDO_API_KEY;
|
|
28999
|
+
|
|
29000
|
+
if (apiKey) {
|
|
29001
|
+
_context2.next = 3;
|
|
29002
|
+
break;
|
|
29003
|
+
}
|
|
29004
|
+
|
|
29005
|
+
throw new Error("ONDO_API_KEY environment variable is not set");
|
|
29006
|
+
|
|
29007
|
+
case 3:
|
|
29008
|
+
amount = new BigNumber(amountIn);
|
|
29009
|
+
isMint = tokenIn.toLowerCase() === USDC_ETHEREUM.toLowerCase();
|
|
29010
|
+
gmToken = isMint ? tokenOut : tokenIn;
|
|
29011
|
+
slippageBps = Math.round(slippage * 100);
|
|
29012
|
+
tokenContract = new ethers.Contract(gmToken, ["function symbol() view returns (string)"], pool.signer);
|
|
29013
|
+
_context2.next = 10;
|
|
29014
|
+
return tokenContract.symbol();
|
|
29015
|
+
|
|
29016
|
+
case 10:
|
|
29017
|
+
symbol = _context2.sent;
|
|
29018
|
+
// For mint: notionalValue is the USD amount to subscribe. USDonManager values
|
|
29019
|
+
// USDC at par (1 USDC = 1 USDon), so pass the USDC amount as-is (6dp -> decimal).
|
|
29020
|
+
// Discounting by a USDC market price would strand the gap as USDon in the swapper
|
|
29021
|
+
// (and revert via ExcessiveAmountIn once it exceeds the 1 USDC tolerance).
|
|
29022
|
+
// For redeem: pass the GM token amount directly as tokenAmount.
|
|
29023
|
+
attestationAmount = isMint ? {
|
|
29024
|
+
notionalValue: amount.div(1e6).toFixed(18)
|
|
29025
|
+
} : {
|
|
29026
|
+
tokenAmount: amount.div(1e18).toFixed(18)
|
|
29027
|
+
};
|
|
29028
|
+
_context2.next = 14;
|
|
29029
|
+
return postOndoAttestation(symbol, isMint ? "buy" : "sell", attestationAmount, apiKey);
|
|
29030
|
+
|
|
29031
|
+
case 14:
|
|
29032
|
+
attestation = _context2.sent;
|
|
29033
|
+
signature = "0x" + Buffer.from(attestation.signature, "base64").toString("hex");
|
|
29034
|
+
additionalData = ethers.utils.hexZeroPad("0x" + Buffer.from(attestation.additionalData, "base64").toString("hex"), 32);
|
|
29035
|
+
quantity = new BigNumber(attestation.tokenAmount);
|
|
29036
|
+
priceD18 = new BigNumber(attestation.price);
|
|
29037
|
+
|
|
29038
|
+
if (isMint) {
|
|
29039
|
+
minAmountOut = quantity.times(10000 - slippageBps).div(10000);
|
|
29040
|
+
} else {
|
|
29041
|
+
// USDC out (6 dec) = quantity_D18 * price_D18 / 1e30
|
|
29042
|
+
usdcOut = quantity.times(priceD18).div(1e30);
|
|
29043
|
+
minAmountOut = usdcOut.times(10000 - slippageBps).div(10000);
|
|
29044
|
+
}
|
|
29045
|
+
|
|
29046
|
+
quote = {
|
|
29047
|
+
chainId: 1,
|
|
29048
|
+
attestationId: attestation.attestationId,
|
|
29049
|
+
userId: toBytes32(attestation.userId),
|
|
29050
|
+
asset: attestation.assetAddress,
|
|
29051
|
+
price: priceD18.toFixed(0),
|
|
29052
|
+
quantity: quantity.toFixed(0),
|
|
29053
|
+
expiration: attestation.expiration,
|
|
29054
|
+
side: Number(attestation.side),
|
|
29055
|
+
additionalData: additionalData
|
|
29056
|
+
};
|
|
29057
|
+
swapTxData = iface$1.encodeFunctionData("swapExactInWithAttestation", [tokenIn, amount.toFixed(0), tokenOut, minAmountOut.toFixed(0), signature, quote]);
|
|
29058
|
+
return _context2.abrupt("return", {
|
|
29059
|
+
swapTxData: swapTxData,
|
|
29060
|
+
minAmountOut: minAmountOut.toFixed(0)
|
|
29061
|
+
});
|
|
29062
|
+
|
|
29063
|
+
case 23:
|
|
29064
|
+
case "end":
|
|
29065
|
+
return _context2.stop();
|
|
29066
|
+
}
|
|
29067
|
+
}
|
|
29068
|
+
}, _callee2);
|
|
29069
|
+
}));
|
|
29070
|
+
return _getOndoSwapTxData.apply(this, arguments);
|
|
29071
|
+
}
|
|
29072
|
+
|
|
28543
29073
|
var ICoreDepositWalletAbi = [
|
|
28544
29074
|
{
|
|
28545
29075
|
inputs: [
|
|
@@ -29664,7 +30194,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
29664
30194
|
/*#__PURE__*/
|
|
29665
30195
|
function () {
|
|
29666
30196
|
var _trade = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(dapp, assetFrom, assetTo, amountIn, slippage, options, sdkOptions) {
|
|
29667
|
-
var swapTxData, minAmountOut, _yield$getOneInchSwap, _yield$getOdosSwapTxD, _yield$getPendleSwapT, _yield$getKyberSwapTx, cowSwapEstimateGas, _yield$getCowSwapTxDa, encodedTypedData, preSignTxData, cowMinOut, validatorContract, submitTx, submitReceipt, iUniswapV2Router, calculatedMinAmountOut, tx;
|
|
30197
|
+
var swapTxData, minAmountOut, _yield$getOneInchSwap, _yield$getEasySwapper, _yield$getOdosSwapTxD, _yield$getPendleSwapT, _yield$getKyberSwapTx, _yield$getOndoSwapTxD, cowSwapEstimateGas, _yield$getCowSwapTxDa, encodedTypedData, preSignTxData, cowMinOut, validatorContract, submitTx, submitReceipt, iUniswapV2Router, calculatedMinAmountOut, tx;
|
|
29668
30198
|
|
|
29669
30199
|
return runtime_1.wrap(function _callee10$(_context10) {
|
|
29670
30200
|
while (1) {
|
|
@@ -29686,7 +30216,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
29686
30216
|
|
|
29687
30217
|
minAmountOut = null;
|
|
29688
30218
|
_context10.t0 = dapp;
|
|
29689
|
-
_context10.next = _context10.t0 === Dapp.ONEINCH ? 7 : _context10.t0 === Dapp.BALANCER ? 13 : _context10.t0 === Dapp.TOROS ? 17 : _context10.t0 === Dapp.ODOS ?
|
|
30219
|
+
_context10.next = _context10.t0 === Dapp.ONEINCH ? 7 : _context10.t0 === Dapp.BALANCER ? 13 : _context10.t0 === Dapp.TOROS ? 17 : _context10.t0 === Dapp.ODOS ? 23 : _context10.t0 === Dapp.PENDLE ? 29 : _context10.t0 === Dapp.KYBERSWAP ? 35 : _context10.t0 === Dapp.ONDO ? 41 : _context10.t0 === Dapp.COWSWAP ? 47 : 66;
|
|
29690
30220
|
break;
|
|
29691
30221
|
|
|
29692
30222
|
case 7:
|
|
@@ -29697,7 +30227,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
29697
30227
|
_yield$getOneInchSwap = _context10.sent;
|
|
29698
30228
|
swapTxData = _yield$getOneInchSwap.swapTxData;
|
|
29699
30229
|
minAmountOut = _yield$getOneInchSwap.dstAmount;
|
|
29700
|
-
return _context10.abrupt("break",
|
|
30230
|
+
return _context10.abrupt("break", 81);
|
|
29701
30231
|
|
|
29702
30232
|
case 13:
|
|
29703
30233
|
_context10.next = 15;
|
|
@@ -29705,96 +30235,108 @@ var Pool = /*#__PURE__*/function () {
|
|
|
29705
30235
|
|
|
29706
30236
|
case 15:
|
|
29707
30237
|
swapTxData = _context10.sent;
|
|
29708
|
-
return _context10.abrupt("break",
|
|
30238
|
+
return _context10.abrupt("break", 81);
|
|
29709
30239
|
|
|
29710
30240
|
case 17:
|
|
29711
30241
|
_context10.next = 19;
|
|
29712
30242
|
return getEasySwapperTxData(this, assetFrom, assetTo, ethers.BigNumber.from(amountIn), slippage);
|
|
29713
30243
|
|
|
29714
30244
|
case 19:
|
|
29715
|
-
|
|
29716
|
-
|
|
30245
|
+
_yield$getEasySwapper = _context10.sent;
|
|
30246
|
+
swapTxData = _yield$getEasySwapper.swapTxData;
|
|
30247
|
+
minAmountOut = _yield$getEasySwapper.minAmountOut;
|
|
30248
|
+
return _context10.abrupt("break", 81);
|
|
29717
30249
|
|
|
29718
|
-
case
|
|
29719
|
-
_context10.next =
|
|
30250
|
+
case 23:
|
|
30251
|
+
_context10.next = 25;
|
|
29720
30252
|
return getOdosSwapTxData(this, assetFrom, assetTo, amountIn, slippage);
|
|
29721
30253
|
|
|
29722
|
-
case
|
|
30254
|
+
case 25:
|
|
29723
30255
|
_yield$getOdosSwapTxD = _context10.sent;
|
|
29724
30256
|
swapTxData = _yield$getOdosSwapTxD.swapTxData;
|
|
29725
30257
|
minAmountOut = _yield$getOdosSwapTxD.minAmountOut;
|
|
29726
|
-
return _context10.abrupt("break",
|
|
30258
|
+
return _context10.abrupt("break", 81);
|
|
29727
30259
|
|
|
29728
|
-
case
|
|
29729
|
-
_context10.next =
|
|
30260
|
+
case 29:
|
|
30261
|
+
_context10.next = 31;
|
|
29730
30262
|
return getPendleSwapTxData(this, assetFrom, assetTo, amountIn, slippage);
|
|
29731
30263
|
|
|
29732
|
-
case
|
|
30264
|
+
case 31:
|
|
29733
30265
|
_yield$getPendleSwapT = _context10.sent;
|
|
29734
30266
|
swapTxData = _yield$getPendleSwapT.swapTxData;
|
|
29735
30267
|
minAmountOut = _yield$getPendleSwapT.minAmountOut;
|
|
29736
|
-
return _context10.abrupt("break",
|
|
30268
|
+
return _context10.abrupt("break", 81);
|
|
29737
30269
|
|
|
29738
|
-
case
|
|
29739
|
-
_context10.next =
|
|
30270
|
+
case 35:
|
|
30271
|
+
_context10.next = 37;
|
|
29740
30272
|
return getKyberSwapTxData(this, assetFrom, assetTo, amountIn, slippage);
|
|
29741
30273
|
|
|
29742
|
-
case
|
|
30274
|
+
case 37:
|
|
29743
30275
|
_yield$getKyberSwapTx = _context10.sent;
|
|
29744
30276
|
swapTxData = _yield$getKyberSwapTx.swapTxData;
|
|
29745
30277
|
minAmountOut = _yield$getKyberSwapTx.minAmountOut;
|
|
29746
|
-
return _context10.abrupt("break",
|
|
30278
|
+
return _context10.abrupt("break", 81);
|
|
29747
30279
|
|
|
29748
|
-
case
|
|
30280
|
+
case 41:
|
|
30281
|
+
_context10.next = 43;
|
|
30282
|
+
return getOndoSwapTxData(this, assetFrom, assetTo, amountIn.toString(), slippage);
|
|
30283
|
+
|
|
30284
|
+
case 43:
|
|
30285
|
+
_yield$getOndoSwapTxD = _context10.sent;
|
|
30286
|
+
swapTxData = _yield$getOndoSwapTxD.swapTxData;
|
|
30287
|
+
minAmountOut = _yield$getOndoSwapTxD.minAmountOut;
|
|
30288
|
+
return _context10.abrupt("break", 81);
|
|
30289
|
+
|
|
30290
|
+
case 47:
|
|
29749
30291
|
cowSwapEstimateGas = isSdkOptionsBoolean(sdkOptions) ? sdkOptions : sdkOptions.estimateGas;
|
|
29750
30292
|
|
|
29751
30293
|
if (!(cowSwapEstimateGas || !isSdkOptionsBoolean(sdkOptions) && sdkOptions.onlyGetTxData)) {
|
|
29752
|
-
_context10.next =
|
|
30294
|
+
_context10.next = 50;
|
|
29753
30295
|
break;
|
|
29754
30296
|
}
|
|
29755
30297
|
|
|
29756
30298
|
throw new Error("CowSwap requires two sequential transactions (submit + preSign) and does not support estimateGas or onlyGetTxData");
|
|
29757
30299
|
|
|
29758
|
-
case
|
|
29759
|
-
_context10.next =
|
|
30300
|
+
case 50:
|
|
30301
|
+
_context10.next = 52;
|
|
29760
30302
|
return getCowSwapTxData(this, assetFrom, assetTo, amountIn, slippage);
|
|
29761
30303
|
|
|
29762
|
-
case
|
|
30304
|
+
case 52:
|
|
29763
30305
|
_yield$getCowSwapTxDa = _context10.sent;
|
|
29764
30306
|
encodedTypedData = _yield$getCowSwapTxDa.encodedTypedData;
|
|
29765
30307
|
preSignTxData = _yield$getCowSwapTxDa.preSignTxData;
|
|
29766
30308
|
cowMinOut = _yield$getCowSwapTxDa.minAmountOut;
|
|
29767
30309
|
// Tx 1: manager calls submit() directly on TypedStructuredDataValidator (not via pool.execTransaction)
|
|
29768
30310
|
validatorContract = new Contract(routerAddress[this.network][dapp], ["function submit(address _poolLogic, uint8 _dataType, bytes memory _structuredData) external"], this.signer);
|
|
29769
|
-
_context10.next =
|
|
30311
|
+
_context10.next = 59;
|
|
29770
30312
|
return validatorContract.submit.apply(validatorContract, [this.address, 1
|
|
29771
30313
|
/* COWSWAP_ORDER */
|
|
29772
30314
|
, encodedTypedData].concat(options ? [options] : []));
|
|
29773
30315
|
|
|
29774
|
-
case
|
|
30316
|
+
case 59:
|
|
29775
30317
|
submitTx = _context10.sent;
|
|
29776
|
-
_context10.next =
|
|
30318
|
+
_context10.next = 62;
|
|
29777
30319
|
return submitTx.wait(3);
|
|
29778
30320
|
|
|
29779
|
-
case
|
|
30321
|
+
case 62:
|
|
29780
30322
|
submitReceipt = _context10.sent;
|
|
29781
30323
|
|
|
29782
30324
|
if (!(submitReceipt.status === 0)) {
|
|
29783
|
-
_context10.next =
|
|
30325
|
+
_context10.next = 65;
|
|
29784
30326
|
break;
|
|
29785
30327
|
}
|
|
29786
30328
|
|
|
29787
30329
|
return _context10.abrupt("return", submitReceipt);
|
|
29788
30330
|
|
|
29789
|
-
case
|
|
30331
|
+
case 65:
|
|
29790
30332
|
return _context10.abrupt("return", getPoolTxOrGasEstimate(this, [gpv2SettlementAddress[this.network], preSignTxData, options, cowMinOut], sdkOptions));
|
|
29791
30333
|
|
|
29792
|
-
case
|
|
30334
|
+
case 66:
|
|
29793
30335
|
iUniswapV2Router = new ethers.utils.Interface(IUniswapV2Router.abi);
|
|
29794
|
-
_context10.next =
|
|
30336
|
+
_context10.next = 69;
|
|
29795
30337
|
return this.utils.getMinAmountOut(dapp, assetFrom, assetTo, amountIn, slippage);
|
|
29796
30338
|
|
|
29797
|
-
case
|
|
30339
|
+
case 69:
|
|
29798
30340
|
calculatedMinAmountOut = _context10.sent;
|
|
29799
30341
|
_context10.t1 = iUniswapV2Router;
|
|
29800
30342
|
_context10.t2 = Transaction.SWAP;
|
|
@@ -29802,23 +30344,23 @@ var Pool = /*#__PURE__*/function () {
|
|
|
29802
30344
|
_context10.t4 = calculatedMinAmountOut;
|
|
29803
30345
|
_context10.t5 = [assetFrom, assetTo];
|
|
29804
30346
|
_context10.t6 = this.address;
|
|
29805
|
-
_context10.next =
|
|
30347
|
+
_context10.next = 78;
|
|
29806
30348
|
return getDeadline(this);
|
|
29807
30349
|
|
|
29808
|
-
case
|
|
30350
|
+
case 78:
|
|
29809
30351
|
_context10.t7 = _context10.sent;
|
|
29810
30352
|
_context10.t8 = [_context10.t3, _context10.t4, _context10.t5, _context10.t6, _context10.t7];
|
|
29811
30353
|
swapTxData = _context10.t1.encodeFunctionData.call(_context10.t1, _context10.t2, _context10.t8);
|
|
29812
30354
|
|
|
29813
|
-
case
|
|
29814
|
-
_context10.next =
|
|
30355
|
+
case 81:
|
|
30356
|
+
_context10.next = 83;
|
|
29815
30357
|
return getPoolTxOrGasEstimate(this, [routerAddress[this.network][dapp], swapTxData, options, minAmountOut], sdkOptions);
|
|
29816
30358
|
|
|
29817
|
-
case
|
|
30359
|
+
case 83:
|
|
29818
30360
|
tx = _context10.sent;
|
|
29819
30361
|
return _context10.abrupt("return", tx);
|
|
29820
30362
|
|
|
29821
|
-
case
|
|
30363
|
+
case 85:
|
|
29822
30364
|
case "end":
|
|
29823
30365
|
return _context10.stop();
|
|
29824
30366
|
}
|
|
@@ -30235,7 +30777,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
30235
30777
|
/*#__PURE__*/
|
|
30236
30778
|
function () {
|
|
30237
30779
|
var _lend = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee17(dapp, asset, amount, referralCode, options, sdkOptions) {
|
|
30238
|
-
var
|
|
30780
|
+
var depositTxData, iLendingPool, tx;
|
|
30239
30781
|
return runtime_1.wrap(function _callee17$(_context17) {
|
|
30240
30782
|
while (1) {
|
|
30241
30783
|
switch (_context17.prev = _context17.next) {
|
|
@@ -30254,16 +30796,21 @@ var Pool = /*#__PURE__*/function () {
|
|
|
30254
30796
|
};
|
|
30255
30797
|
}
|
|
30256
30798
|
|
|
30257
|
-
|
|
30258
|
-
|
|
30259
|
-
|
|
30799
|
+
if (dapp === Dapp.DYTM) {
|
|
30800
|
+
depositTxData = getDytmDepositTxData(this, asset, amount);
|
|
30801
|
+
} else {
|
|
30802
|
+
iLendingPool = new ethers.utils.Interface(ILendingPool.abi);
|
|
30803
|
+
depositTxData = iLendingPool.encodeFunctionData(Transaction.DEPOSIT, [asset, amount, this.address, referralCode]);
|
|
30804
|
+
}
|
|
30805
|
+
|
|
30806
|
+
_context17.next = 6;
|
|
30260
30807
|
return getPoolTxOrGasEstimate(this, [routerAddress[this.network][dapp], depositTxData, options], sdkOptions);
|
|
30261
30808
|
|
|
30262
|
-
case
|
|
30809
|
+
case 6:
|
|
30263
30810
|
tx = _context17.sent;
|
|
30264
30811
|
return _context17.abrupt("return", tx);
|
|
30265
30812
|
|
|
30266
|
-
case
|
|
30813
|
+
case 8:
|
|
30267
30814
|
case "end":
|
|
30268
30815
|
return _context17.stop();
|
|
30269
30816
|
}
|
|
@@ -30348,7 +30895,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
30348
30895
|
/*#__PURE__*/
|
|
30349
30896
|
function () {
|
|
30350
30897
|
var _withdrawDeposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee19(dapp, asset, amount, options, sdkOptions) {
|
|
30351
|
-
var
|
|
30898
|
+
var withdrawTxData, iLendingPool, tx;
|
|
30352
30899
|
return runtime_1.wrap(function _callee19$(_context19) {
|
|
30353
30900
|
while (1) {
|
|
30354
30901
|
switch (_context19.prev = _context19.next) {
|
|
@@ -30363,16 +30910,32 @@ var Pool = /*#__PURE__*/function () {
|
|
|
30363
30910
|
};
|
|
30364
30911
|
}
|
|
30365
30912
|
|
|
30913
|
+
if (!(dapp === Dapp.DYTM)) {
|
|
30914
|
+
_context19.next = 8;
|
|
30915
|
+
break;
|
|
30916
|
+
}
|
|
30917
|
+
|
|
30918
|
+
_context19.next = 5;
|
|
30919
|
+
return getDytmWithdrawTxData(this, asset, amount);
|
|
30920
|
+
|
|
30921
|
+
case 5:
|
|
30922
|
+
withdrawTxData = _context19.sent;
|
|
30923
|
+
_context19.next = 10;
|
|
30924
|
+
break;
|
|
30925
|
+
|
|
30926
|
+
case 8:
|
|
30366
30927
|
iLendingPool = new ethers.utils.Interface(ILendingPool.abi);
|
|
30367
30928
|
withdrawTxData = iLendingPool.encodeFunctionData(Transaction.WITHDRAW, [asset, amount, this.address]);
|
|
30368
|
-
|
|
30929
|
+
|
|
30930
|
+
case 10:
|
|
30931
|
+
_context19.next = 12;
|
|
30369
30932
|
return getPoolTxOrGasEstimate(this, [routerAddress[this.network][dapp], withdrawTxData, options], sdkOptions);
|
|
30370
30933
|
|
|
30371
|
-
case
|
|
30934
|
+
case 12:
|
|
30372
30935
|
tx = _context19.sent;
|
|
30373
30936
|
return _context19.abrupt("return", tx);
|
|
30374
30937
|
|
|
30375
|
-
case
|
|
30938
|
+
case 14:
|
|
30376
30939
|
case "end":
|
|
30377
30940
|
return _context19.stop();
|
|
30378
30941
|
}
|
|
@@ -30458,7 +31021,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
30458
31021
|
/*#__PURE__*/
|
|
30459
31022
|
function () {
|
|
30460
31023
|
var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee21(dapp, asset, amount, referralCode, options, sdkOptions) {
|
|
30461
|
-
var
|
|
31024
|
+
var borrowTxData, iLendingPool, tx;
|
|
30462
31025
|
return runtime_1.wrap(function _callee21$(_context21) {
|
|
30463
31026
|
while (1) {
|
|
30464
31027
|
switch (_context21.prev = _context21.next) {
|
|
@@ -30477,16 +31040,21 @@ var Pool = /*#__PURE__*/function () {
|
|
|
30477
31040
|
};
|
|
30478
31041
|
}
|
|
30479
31042
|
|
|
30480
|
-
|
|
30481
|
-
|
|
30482
|
-
|
|
31043
|
+
if (dapp === Dapp.DYTM) {
|
|
31044
|
+
borrowTxData = getDytmBorrowTxData(this, asset, amount);
|
|
31045
|
+
} else {
|
|
31046
|
+
iLendingPool = new ethers.utils.Interface(ILendingPool.abi);
|
|
31047
|
+
borrowTxData = iLendingPool.encodeFunctionData(Transaction.BORROW, [asset, amount, 2, referralCode, this.address]);
|
|
31048
|
+
}
|
|
31049
|
+
|
|
31050
|
+
_context21.next = 6;
|
|
30483
31051
|
return getPoolTxOrGasEstimate(this, [routerAddress[this.network][dapp], borrowTxData, options], sdkOptions);
|
|
30484
31052
|
|
|
30485
|
-
case
|
|
31053
|
+
case 6:
|
|
30486
31054
|
tx = _context21.sent;
|
|
30487
31055
|
return _context21.abrupt("return", tx);
|
|
30488
31056
|
|
|
30489
|
-
case
|
|
31057
|
+
case 8:
|
|
30490
31058
|
case "end":
|
|
30491
31059
|
return _context21.stop();
|
|
30492
31060
|
}
|
|
@@ -30515,7 +31083,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
30515
31083
|
/*#__PURE__*/
|
|
30516
31084
|
function () {
|
|
30517
31085
|
var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee22(dapp, asset, amount, options, sdkOptions) {
|
|
30518
|
-
var
|
|
31086
|
+
var repayTxData, iLendingPool, tx;
|
|
30519
31087
|
return runtime_1.wrap(function _callee22$(_context22) {
|
|
30520
31088
|
while (1) {
|
|
30521
31089
|
switch (_context22.prev = _context22.next) {
|
|
@@ -30530,16 +31098,32 @@ var Pool = /*#__PURE__*/function () {
|
|
|
30530
31098
|
};
|
|
30531
31099
|
}
|
|
30532
31100
|
|
|
31101
|
+
if (!(dapp === Dapp.DYTM)) {
|
|
31102
|
+
_context22.next = 8;
|
|
31103
|
+
break;
|
|
31104
|
+
}
|
|
31105
|
+
|
|
31106
|
+
_context22.next = 5;
|
|
31107
|
+
return getDytmRepayTxData(this, asset, amount);
|
|
31108
|
+
|
|
31109
|
+
case 5:
|
|
31110
|
+
repayTxData = _context22.sent;
|
|
31111
|
+
_context22.next = 10;
|
|
31112
|
+
break;
|
|
31113
|
+
|
|
31114
|
+
case 8:
|
|
30533
31115
|
iLendingPool = new ethers.utils.Interface(ILendingPool.abi);
|
|
30534
31116
|
repayTxData = iLendingPool.encodeFunctionData(Transaction.REPAY, [asset, amount, 2, this.address]);
|
|
30535
|
-
|
|
31117
|
+
|
|
31118
|
+
case 10:
|
|
31119
|
+
_context22.next = 12;
|
|
30536
31120
|
return getPoolTxOrGasEstimate(this, [routerAddress[this.network][dapp], repayTxData, options], sdkOptions);
|
|
30537
31121
|
|
|
30538
|
-
case
|
|
31122
|
+
case 12:
|
|
30539
31123
|
tx = _context22.sent;
|
|
30540
31124
|
return _context22.abrupt("return", tx);
|
|
30541
31125
|
|
|
30542
|
-
case
|
|
31126
|
+
case 14:
|
|
30543
31127
|
case "end":
|
|
30544
31128
|
return _context22.stop();
|
|
30545
31129
|
}
|
|
@@ -32310,6 +32894,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
32310
32894
|
* @param {number} slippage Slippage tolerance in %
|
|
32311
32895
|
* @param {any} options Transaction options
|
|
32312
32896
|
* @param {SDKOptions} sdkOptions SDK options including estimateGas
|
|
32897
|
+
* @param {any} trackedAssets Tracked assets information (only for tx data generation)
|
|
32313
32898
|
* @returns {Promise<any>} Transaction
|
|
32314
32899
|
*/
|
|
32315
32900
|
;
|
|
@@ -32317,7 +32902,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
32317
32902
|
_proto.completeTorosWithdrawal =
|
|
32318
32903
|
/*#__PURE__*/
|
|
32319
32904
|
function () {
|
|
32320
|
-
var _completeTorosWithdrawal = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee50(destinationToken, slippage, options, sdkOptions) {
|
|
32905
|
+
var _completeTorosWithdrawal = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee50(destinationToken, slippage, options, sdkOptions, trackedAssets) {
|
|
32321
32906
|
var txData, tx;
|
|
32322
32907
|
return runtime_1.wrap(function _callee50$(_context50) {
|
|
32323
32908
|
while (1) {
|
|
@@ -32337,19 +32922,23 @@ var Pool = /*#__PURE__*/function () {
|
|
|
32337
32922
|
};
|
|
32338
32923
|
}
|
|
32339
32924
|
|
|
32340
|
-
|
|
32341
|
-
|
|
32925
|
+
if (trackedAssets === void 0) {
|
|
32926
|
+
trackedAssets = [];
|
|
32927
|
+
}
|
|
32342
32928
|
|
|
32343
|
-
|
|
32929
|
+
_context50.next = 6;
|
|
32930
|
+
return getCompleteWithdrawalTxData(this, destinationToken, slippage * 100, false, trackedAssets);
|
|
32931
|
+
|
|
32932
|
+
case 6:
|
|
32344
32933
|
txData = _context50.sent;
|
|
32345
|
-
_context50.next =
|
|
32934
|
+
_context50.next = 9;
|
|
32346
32935
|
return getPoolTxOrGasEstimate(this, [routerAddress[this.network].toros, txData, options], sdkOptions);
|
|
32347
32936
|
|
|
32348
|
-
case
|
|
32937
|
+
case 9:
|
|
32349
32938
|
tx = _context50.sent;
|
|
32350
32939
|
return _context50.abrupt("return", tx);
|
|
32351
32940
|
|
|
32352
|
-
case
|
|
32941
|
+
case 11:
|
|
32353
32942
|
case "end":
|
|
32354
32943
|
return _context50.stop();
|
|
32355
32944
|
}
|
|
@@ -32357,7 +32946,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
32357
32946
|
}, _callee50, this);
|
|
32358
32947
|
}));
|
|
32359
32948
|
|
|
32360
|
-
function completeTorosWithdrawal(_x238, _x239, _x240, _x241) {
|
|
32949
|
+
function completeTorosWithdrawal(_x238, _x239, _x240, _x241, _x242) {
|
|
32361
32950
|
return _completeTorosWithdrawal.apply(this, arguments);
|
|
32362
32951
|
}
|
|
32363
32952
|
|
|
@@ -32421,7 +33010,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
32421
33010
|
}, _callee51, this);
|
|
32422
33011
|
}));
|
|
32423
33012
|
|
|
32424
|
-
function mintPendle(
|
|
33013
|
+
function mintPendle(_x243, _x244, _x245, _x246, _x247, _x248) {
|
|
32425
33014
|
return _mintPendle.apply(this, arguments);
|
|
32426
33015
|
}
|
|
32427
33016
|
|
|
@@ -32478,7 +33067,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
32478
33067
|
}, _callee52, this);
|
|
32479
33068
|
}));
|
|
32480
33069
|
|
|
32481
|
-
function depositHyperliquid(
|
|
33070
|
+
function depositHyperliquid(_x249, _x250, _x251, _x252) {
|
|
32482
33071
|
return _depositHyperliquid.apply(this, arguments);
|
|
32483
33072
|
}
|
|
32484
33073
|
|
|
@@ -32531,7 +33120,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
32531
33120
|
}, _callee53, this);
|
|
32532
33121
|
}));
|
|
32533
33122
|
|
|
32534
|
-
function perpToSpotHyperliquid(
|
|
33123
|
+
function perpToSpotHyperliquid(_x253, _x254, _x255, _x256) {
|
|
32535
33124
|
return _perpToSpotHyperliquid.apply(this, arguments);
|
|
32536
33125
|
}
|
|
32537
33126
|
|
|
@@ -32583,7 +33172,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
32583
33172
|
}, _callee54, this);
|
|
32584
33173
|
}));
|
|
32585
33174
|
|
|
32586
|
-
function spotToPerpHyperliquid(
|
|
33175
|
+
function spotToPerpHyperliquid(_x257, _x258, _x259, _x260) {
|
|
32587
33176
|
return _spotToPerpHyperliquid.apply(this, arguments);
|
|
32588
33177
|
}
|
|
32589
33178
|
|
|
@@ -32633,7 +33222,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
32633
33222
|
}, _callee55, this);
|
|
32634
33223
|
}));
|
|
32635
33224
|
|
|
32636
|
-
function withdrawHyperliquid(
|
|
33225
|
+
function withdrawHyperliquid(_x261, _x262, _x263) {
|
|
32637
33226
|
return _withdrawHyperliquid.apply(this, arguments);
|
|
32638
33227
|
}
|
|
32639
33228
|
|
|
@@ -32700,7 +33289,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
32700
33289
|
}, _callee56, this);
|
|
32701
33290
|
}));
|
|
32702
33291
|
|
|
32703
|
-
function openMarketOrderHyperliquid(
|
|
33292
|
+
function openMarketOrderHyperliquid(_x264, _x265, _x266, _x267, _x268, _x269) {
|
|
32704
33293
|
return _openMarketOrderHyperliquid.apply(this, arguments);
|
|
32705
33294
|
}
|
|
32706
33295
|
|
|
@@ -32769,7 +33358,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
32769
33358
|
}, _callee57, this);
|
|
32770
33359
|
}));
|
|
32771
33360
|
|
|
32772
|
-
function closePositionHyperliquid(
|
|
33361
|
+
function closePositionHyperliquid(_x270, _x271, _x272, _x273, _x274) {
|
|
32773
33362
|
return _closePositionHyperliquid.apply(this, arguments);
|
|
32774
33363
|
}
|
|
32775
33364
|
|
|
@@ -32818,7 +33407,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
32818
33407
|
}, _callee58, this);
|
|
32819
33408
|
}));
|
|
32820
33409
|
|
|
32821
|
-
function approveTorosLimitOrder(
|
|
33410
|
+
function approveTorosLimitOrder(_x275, _x276, _x277, _x278) {
|
|
32822
33411
|
return _approveTorosLimitOrder.apply(this, arguments);
|
|
32823
33412
|
}
|
|
32824
33413
|
|
|
@@ -32887,7 +33476,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
32887
33476
|
}, _callee59, this);
|
|
32888
33477
|
}));
|
|
32889
33478
|
|
|
32890
|
-
function createTorosLimitOrder(
|
|
33479
|
+
function createTorosLimitOrder(_x279, _x280, _x281, _x282, _x283, _x284, _x285) {
|
|
32891
33480
|
return _createTorosLimitOrder.apply(this, arguments);
|
|
32892
33481
|
}
|
|
32893
33482
|
|
|
@@ -32956,7 +33545,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
32956
33545
|
}, _callee60, this);
|
|
32957
33546
|
}));
|
|
32958
33547
|
|
|
32959
|
-
function modifyTorosLimitOrder(
|
|
33548
|
+
function modifyTorosLimitOrder(_x286, _x287, _x288, _x289, _x290, _x291, _x292) {
|
|
32960
33549
|
return _modifyTorosLimitOrder.apply(this, arguments);
|
|
32961
33550
|
}
|
|
32962
33551
|
|
|
@@ -33011,7 +33600,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
33011
33600
|
}, _callee61, this);
|
|
33012
33601
|
}));
|
|
33013
33602
|
|
|
33014
|
-
function deleteTorosLimitOrder(
|
|
33603
|
+
function deleteTorosLimitOrder(_x293, _x294, _x295) {
|
|
33015
33604
|
return _deleteTorosLimitOrder.apply(this, arguments);
|
|
33016
33605
|
}
|
|
33017
33606
|
|
|
@@ -33043,7 +33632,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
33043
33632
|
}, _callee62, this);
|
|
33044
33633
|
}));
|
|
33045
33634
|
|
|
33046
|
-
function getTorosLimitOrder$1(
|
|
33635
|
+
function getTorosLimitOrder$1(_x296, _x297) {
|
|
33047
33636
|
return _getTorosLimitOrder2.apply(this, arguments);
|
|
33048
33637
|
}
|
|
33049
33638
|
|
|
@@ -33075,7 +33664,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
33075
33664
|
}, _callee63, this);
|
|
33076
33665
|
}));
|
|
33077
33666
|
|
|
33078
|
-
function hasActiveTorosLimitOrder$1(
|
|
33667
|
+
function hasActiveTorosLimitOrder$1(_x298, _x299) {
|
|
33079
33668
|
return _hasActiveTorosLimitOrder2.apply(this, arguments);
|
|
33080
33669
|
}
|
|
33081
33670
|
|