@dhedge/v2-sdk 1.10.14 → 1.10.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/services/pendle/index.d.ts +4 -0
- package/dist/test/constants.d.ts +2 -0
- package/dist/types.d.ts +2 -1
- package/dist/v2-sdk.cjs.development.js +363 -18
- 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 +363 -18
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/pendle/ActionMiscV3.json +122 -0
- package/src/config.ts +15 -4
- package/src/entities/pool.ts +10 -0
- package/src/services/flatmoney/keeperFee.ts +1 -1
- package/src/services/pendle/index.ts +141 -0
- package/src/test/constants.ts +4 -2
- package/src/test/pendle.test.ts +132 -0
- package/src/types.ts +2 -1
package/dist/v2-sdk.esm.js
CHANGED
|
@@ -4278,6 +4278,7 @@ var Dapp;
|
|
|
4278
4278
|
Dapp["COMPOUNDV3"] = "compoundV3";
|
|
4279
4279
|
Dapp["ODOS"] = "odos";
|
|
4280
4280
|
Dapp["SHADOWCL"] = "shadowCL";
|
|
4281
|
+
Dapp["PENDLE"] = "pendle";
|
|
4281
4282
|
})(Dapp || (Dapp = {}));
|
|
4282
4283
|
|
|
4283
4284
|
var Transaction;
|
|
@@ -4309,7 +4310,7 @@ var _factoryAddress, _Network$POLYGON, _Network$OPTIMISM, _Network$ARBITRUM, _Ne
|
|
|
4309
4310
|
require("dotenv").config();
|
|
4310
4311
|
|
|
4311
4312
|
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.SONIC] = "", _factoryAddress);
|
|
4312
|
-
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] = "0x4e3288c9ca110bcc82bf38f09a7b425c095d92bf", _Network$POLYGON), _routerAddress[Network.OPTIMISM] = (_Network$OPTIMISM = {}, _Network$OPTIMISM[Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$OPTIMISM[Dapp.SYNTHETIX] = "0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4", _Network$OPTIMISM[Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$OPTIMISM[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$OPTIMISM[Dapp.TOROS] = "0x2Ed1bd7f66e47113672f3870308b5E867C5bb743", _Network$OPTIMISM[Dapp.VELODROME] = "0x9c12939390052919aF3155f41Bf4160Fd3666A6f", _Network$OPTIMISM[Dapp.VELODROMEV2] = "0xa062ae8a9c5e11aaa026fc2670b0d65ccc8b2858", _Network$OPTIMISM[Dapp.LYRA] = "0xCCE7819d65f348c64B7Beb205BA367b3fE33763B", _Network$OPTIMISM[Dapp.ARRAKIS] = "0x9ce88a56d120300061593eF7AD074A1B710094d5", _Network$OPTIMISM[Dapp.ODOS] = "0xca423977156bb05b13a2ba3b76bc5419e2fe9680", _Network$OPTIMISM), _routerAddress[Network.ARBITRUM] = (_Network$ARBITRUM = {}, _Network$ARBITRUM[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$ARBITRUM[Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$ARBITRUM[Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$ARBITRUM[Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$ARBITRUM[Dapp.RAMSES] = "0xaaa87963efeb6f7e0a2711f397663105acb1805e", _Network$ARBITRUM[Dapp.TOROS] = "0xA5679C4272A056Bb83f039961fae7D99C48529F5", _Network$ARBITRUM[Dapp.ODOS] = "0xa669e7A0d4b3e4Fa48af2dE86BD4CD7126Be4e13", _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] = "0x19cEeAd7105607Cd444F5ad10dd51356436095a1", _Network$BASE), _routerAddress[Network.SONIC] = (_Network$SONIC = {}, _Network$SONIC[Dapp.AAVEV3] = "0x5362dBb1e601abF3a4c14c22ffEdA64042E5eAA3", _Network$SONIC[Dapp.ODOS] = "0xaC041Df48dF9791B0654f1Dbbf2CC8450C5f2e9D", _Network$SONIC), _routerAddress);
|
|
4313
|
+
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] = "0x4e3288c9ca110bcc82bf38f09a7b425c095d92bf", _Network$POLYGON), _routerAddress[Network.OPTIMISM] = (_Network$OPTIMISM = {}, _Network$OPTIMISM[Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$OPTIMISM[Dapp.SYNTHETIX] = "0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4", _Network$OPTIMISM[Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$OPTIMISM[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$OPTIMISM[Dapp.TOROS] = "0x2Ed1bd7f66e47113672f3870308b5E867C5bb743", _Network$OPTIMISM[Dapp.VELODROME] = "0x9c12939390052919aF3155f41Bf4160Fd3666A6f", _Network$OPTIMISM[Dapp.VELODROMEV2] = "0xa062ae8a9c5e11aaa026fc2670b0d65ccc8b2858", _Network$OPTIMISM[Dapp.LYRA] = "0xCCE7819d65f348c64B7Beb205BA367b3fE33763B", _Network$OPTIMISM[Dapp.ARRAKIS] = "0x9ce88a56d120300061593eF7AD074A1B710094d5", _Network$OPTIMISM[Dapp.ODOS] = "0xca423977156bb05b13a2ba3b76bc5419e2fe9680", _Network$OPTIMISM[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$OPTIMISM), _routerAddress[Network.ARBITRUM] = (_Network$ARBITRUM = {}, _Network$ARBITRUM[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$ARBITRUM[Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$ARBITRUM[Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$ARBITRUM[Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$ARBITRUM[Dapp.RAMSES] = "0xaaa87963efeb6f7e0a2711f397663105acb1805e", _Network$ARBITRUM[Dapp.TOROS] = "0xA5679C4272A056Bb83f039961fae7D99C48529F5", _Network$ARBITRUM[Dapp.ODOS] = "0xa669e7A0d4b3e4Fa48af2dE86BD4CD7126Be4e13", _Network$ARBITRUM[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _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] = "0x19cEeAd7105607Cd444F5ad10dd51356436095a1", _Network$BASE[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$BASE), _routerAddress[Network.SONIC] = (_Network$SONIC = {}, _Network$SONIC[Dapp.AAVEV3] = "0x5362dBb1e601abF3a4c14c22ffEdA64042E5eAA3", _Network$SONIC[Dapp.ODOS] = "0xaC041Df48dF9791B0654f1Dbbf2CC8450C5f2e9D", _Network$SONIC[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$SONIC), _routerAddress);
|
|
4313
4314
|
var dappFactoryAddress = (_dappFactoryAddress = {}, _dappFactoryAddress[Network.POLYGON] = (_Network$POLYGON2 = {}, _Network$POLYGON2[Dapp.SUSHISWAP] = "0xc35DADB65012eC5796536bD9864eD8773aBc74C4", _Network$POLYGON2[Dapp.QUICKSWAP] = "0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32", _Network$POLYGON2), _dappFactoryAddress[Network.OPTIMISM] = {}, _dappFactoryAddress[Network.ARBITRUM] = {}, _dappFactoryAddress[Network.BASE] = {}, _dappFactoryAddress[Network.SONIC] = {}, _dappFactoryAddress);
|
|
4314
4315
|
var stakingAddress = (_stakingAddress = {}, _stakingAddress[Network.POLYGON] = (_Network$POLYGON3 = {}, _Network$POLYGON3[Dapp.SUSHISWAP] = "0x0769fd68dFb93167989C6f7254cd0D766Fb2841F", _Network$POLYGON3[Dapp.BALANCER] = "0x0F3e0c4218b7b0108a3643cFe9D3ec0d4F57c54e", _Network$POLYGON3[Dapp.AAVE] = "0x357D51124f59836DeD84c8a1730D72B749d8BC23", _Network$POLYGON3[Dapp.AAVEV3] = "0x929EC64c34a17401F460460D4B9390518E5B473e", _Network$POLYGON3), _stakingAddress[Network.OPTIMISM] = (_Network$OPTIMISM2 = {}, _Network$OPTIMISM2[Dapp.AAVEV3] = "0x929EC64c34a17401F460460D4B9390518E5B473e", _Network$OPTIMISM2[Dapp.COMPOUNDV3] = "0x443ea0340cb75a160f31a440722dec7b5bc3c2e9", _Network$OPTIMISM2), _stakingAddress[Network.ARBITRUM] = (_Network$ARBITRUM2 = {}, _Network$ARBITRUM2[Dapp.COMPOUNDV3] = "0x88730d254a2f7e6ac8388c3198afd694ba9f7fae", _Network$ARBITRUM2[Dapp.PANCAKECL] = "0x5e09ACf80C0296740eC5d6F643005a4ef8DaA694", _Network$ARBITRUM2), _stakingAddress[Network.BASE] = (_Network$BASE2 = {}, _Network$BASE2[Dapp.PANCAKECL] = "0xC6A2Db661D5a5690172d8eB0a7DEA2d3008665A3", _Network$BASE2), _stakingAddress[Network.SONIC] = (_Network$SONIC2 = {}, _Network$SONIC2[Dapp.SHADOWCL] = "0xe879d0E44e6873cf4ab71686055a4f6817685f02", _Network$SONIC2), _stakingAddress);
|
|
4315
4316
|
var aaveAddressProvider = (_aaveAddressProvider = {}, _aaveAddressProvider[Network.POLYGON] = (_Network$POLYGON4 = {}, _Network$POLYGON4[Dapp.AAVE] = "0xd05e3E715d945B59290df0ae8eF85c1BdB684744", _Network$POLYGON4[Dapp.AAVEV3] = "0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb", _Network$POLYGON4), _aaveAddressProvider[Network.OPTIMISM] = (_Network$OPTIMISM3 = {}, _Network$OPTIMISM3[Dapp.AAVEV3] = "0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb", _Network$OPTIMISM3), _aaveAddressProvider[Network.ARBITRUM] = (_Network$ARBITRUM3 = {}, _Network$ARBITRUM3[Dapp.AAVEV3] = "0xa97684ead0e402dc232d5a977953df7ecbab3cdb", _Network$ARBITRUM3), _aaveAddressProvider[Network.BASE] = (_Network$BASE3 = {}, _Network$BASE3[Dapp.AAVEV3] = "0xe20fCBdBfFC4Dd138cE8b2E6FBb6CB49777ad64D", _Network$BASE3), _aaveAddressProvider[Network.SONIC] = (_Network$SONIC3 = {}, _Network$SONIC3[Dapp.AAVEV3] = "0x5C2e738F6E27bCE0F7558051Bf90605dD6176900", _Network$SONIC3), _aaveAddressProvider);
|
|
@@ -4333,6 +4334,12 @@ var flatMoneyContractAddresses = (_flatMoneyContractAdd = {}, _flatMoneyContract
|
|
|
4333
4334
|
FlatcoinVault: "0x86C7b9640302082B0dF78023F930d8612bFcaD3f",
|
|
4334
4335
|
COLLATERAL: "0x68f180fcCe6836688e9084f035309E29Bf0A2095",
|
|
4335
4336
|
StableModule: "0x357CB23571EF7a3d6189b7FAcFC361eA71f7CAB5"
|
|
4337
|
+
}, _flatMoneyContractAdd[Network.ARBITRUM] = {
|
|
4338
|
+
OrderExecution: "0x7e50AD6E467D9FAFC3B4BFd003247cEaA2F17e5b",
|
|
4339
|
+
DelayedOrder: "0x2326BB21B769D81E134C9b305ca156f989249fE7",
|
|
4340
|
+
FlatcoinVault: "0x29fAD9d44C550e5D8081AB35763797B39d75b858",
|
|
4341
|
+
COLLATERAL: "0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f",
|
|
4342
|
+
StableModule: "0xcD3657cB0E851b6a734c4D1e7FC2640Bcd9f6B2d"
|
|
4336
4343
|
}, _flatMoneyContractAdd);
|
|
4337
4344
|
|
|
4338
4345
|
var abi$3 = [
|
|
@@ -11698,7 +11705,7 @@ require("dotenv").config();
|
|
|
11698
11705
|
var networkPortMap = (_networkPortMap = {}, _networkPortMap[Network.POLYGON] = 8542, _networkPortMap[Network.OPTIMISM] = 8544, _networkPortMap[Network.ARBITRUM] = 8540, _networkPortMap[Network.BASE] = 8546, _networkPortMap[Network.SONIC] = 8547, _networkPortMap);
|
|
11699
11706
|
|
|
11700
11707
|
var _TEST_POOL, _CONTRACT_ADDRESS, _USDC_BALANCEOF_SLOT, _WETH_BALANCEOF_SLOT;
|
|
11701
|
-
var TEST_POOL = (_TEST_POOL = {}, _TEST_POOL[Network.POLYGON] = "0x699fd4d6eadb216704c7e355cfa0a12f51813163", _TEST_POOL[Network.OPTIMISM] = "0x12573bfdf764ab9d52aca20e2827497a66829716", _TEST_POOL[Network.ARBITRUM] = "0x0b5f6591c8eb23e5a68102d3d39ebbb464ee5c14", _TEST_POOL[Network.BASE] = "0x4842b42F68524383F609aa46eAfc18c1459cE3cD", _TEST_POOL);
|
|
11708
|
+
var TEST_POOL = (_TEST_POOL = {}, _TEST_POOL[Network.POLYGON] = "0x699fd4d6eadb216704c7e355cfa0a12f51813163", _TEST_POOL[Network.OPTIMISM] = "0x12573bfdf764ab9d52aca20e2827497a66829716", _TEST_POOL[Network.ARBITRUM] = "0x0b5f6591c8eb23e5a68102d3d39ebbb464ee5c14", _TEST_POOL[Network.BASE] = "0x4842b42F68524383F609aa46eAfc18c1459cE3cD", _TEST_POOL[Network.SONIC] = "", _TEST_POOL);
|
|
11702
11709
|
var CONTRACT_ADDRESS = (_CONTRACT_ADDRESS = {}, _CONTRACT_ADDRESS[Network.POLYGON] = {
|
|
11703
11710
|
USDC: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
|
|
11704
11711
|
USDT: "",
|
|
@@ -11796,7 +11803,8 @@ var CONTRACT_ADDRESS = (_CONTRACT_ADDRESS = {}, _CONTRACT_ADDRESS[Network.POLYGO
|
|
|
11796
11803
|
VELODROME_CL_USDC_WETH_GAUGE: "",
|
|
11797
11804
|
VELO: "",
|
|
11798
11805
|
COMPOUNDV3_WETH: "",
|
|
11799
|
-
TOROS: ""
|
|
11806
|
+
TOROS: "",
|
|
11807
|
+
UNIT: ""
|
|
11800
11808
|
}, _CONTRACT_ADDRESS);
|
|
11801
11809
|
var USDC_BALANCEOF_SLOT = (_USDC_BALANCEOF_SLOT = {}, _USDC_BALANCEOF_SLOT[Network.OPTIMISM] = 9, _USDC_BALANCEOF_SLOT[Network.ARBITRUM] = 9, _USDC_BALANCEOF_SLOT[Network.POLYGON] = 0, _USDC_BALANCEOF_SLOT[Network.BASE] = 9, _USDC_BALANCEOF_SLOT[Network.SONIC] = 9, _USDC_BALANCEOF_SLOT);
|
|
11802
11810
|
var WETH_BALANCEOF_SLOT = (_WETH_BALANCEOF_SLOT = {}, _WETH_BALANCEOF_SLOT[Network.OPTIMISM] = 3, _WETH_BALANCEOF_SLOT[Network.ARBITRUM] = 51, _WETH_BALANCEOF_SLOT[Network.POLYGON] = 0, _WETH_BALANCEOF_SLOT[Network.BASE] = 0, _WETH_BALANCEOF_SLOT[Network.SONIC] = 0, _WETH_BALANCEOF_SLOT);
|
|
@@ -24723,7 +24731,7 @@ var getKeeperFee = /*#__PURE__*/function () {
|
|
|
24723
24731
|
case 2:
|
|
24724
24732
|
keeperFeeContract = _context2.sent;
|
|
24725
24733
|
_context2.next = 5;
|
|
24726
|
-
return pool.signer.provider.send("eth_feeHistory", [1, "latest"]);
|
|
24734
|
+
return pool.signer.provider.send("eth_feeHistory", [1, "latest", []]);
|
|
24727
24735
|
|
|
24728
24736
|
case 5:
|
|
24729
24737
|
feeHistory = _context2.sent;
|
|
@@ -25622,6 +25630,335 @@ function _getOdosSwapTxData() {
|
|
|
25622
25630
|
return _getOdosSwapTxData.apply(this, arguments);
|
|
25623
25631
|
}
|
|
25624
25632
|
|
|
25633
|
+
var ActionMiscV3Abi = [
|
|
25634
|
+
{
|
|
25635
|
+
inputs: [
|
|
25636
|
+
{
|
|
25637
|
+
internalType: "address",
|
|
25638
|
+
name: "receiver",
|
|
25639
|
+
type: "address"
|
|
25640
|
+
},
|
|
25641
|
+
{
|
|
25642
|
+
internalType: "address",
|
|
25643
|
+
name: "market",
|
|
25644
|
+
type: "address"
|
|
25645
|
+
},
|
|
25646
|
+
{
|
|
25647
|
+
internalType: "uint256",
|
|
25648
|
+
name: "netPtIn",
|
|
25649
|
+
type: "uint256"
|
|
25650
|
+
},
|
|
25651
|
+
{
|
|
25652
|
+
internalType: "uint256",
|
|
25653
|
+
name: "netLpIn",
|
|
25654
|
+
type: "uint256"
|
|
25655
|
+
},
|
|
25656
|
+
{
|
|
25657
|
+
components: [
|
|
25658
|
+
{
|
|
25659
|
+
internalType: "address",
|
|
25660
|
+
name: "tokenOut",
|
|
25661
|
+
type: "address"
|
|
25662
|
+
},
|
|
25663
|
+
{
|
|
25664
|
+
internalType: "uint256",
|
|
25665
|
+
name: "minTokenOut",
|
|
25666
|
+
type: "uint256"
|
|
25667
|
+
},
|
|
25668
|
+
{
|
|
25669
|
+
internalType: "address",
|
|
25670
|
+
name: "tokenRedeemSy",
|
|
25671
|
+
type: "address"
|
|
25672
|
+
},
|
|
25673
|
+
{
|
|
25674
|
+
internalType: "address",
|
|
25675
|
+
name: "pendleSwap",
|
|
25676
|
+
type: "address"
|
|
25677
|
+
},
|
|
25678
|
+
{
|
|
25679
|
+
components: [
|
|
25680
|
+
{
|
|
25681
|
+
internalType: "enum SwapType",
|
|
25682
|
+
name: "swapType",
|
|
25683
|
+
type: "uint8"
|
|
25684
|
+
},
|
|
25685
|
+
{
|
|
25686
|
+
internalType: "address",
|
|
25687
|
+
name: "extRouter",
|
|
25688
|
+
type: "address"
|
|
25689
|
+
},
|
|
25690
|
+
{
|
|
25691
|
+
internalType: "bytes",
|
|
25692
|
+
name: "extCalldata",
|
|
25693
|
+
type: "bytes"
|
|
25694
|
+
},
|
|
25695
|
+
{
|
|
25696
|
+
internalType: "bool",
|
|
25697
|
+
name: "needScale",
|
|
25698
|
+
type: "bool"
|
|
25699
|
+
}
|
|
25700
|
+
],
|
|
25701
|
+
internalType: "struct SwapData",
|
|
25702
|
+
name: "swapData",
|
|
25703
|
+
type: "tuple"
|
|
25704
|
+
}
|
|
25705
|
+
],
|
|
25706
|
+
internalType: "struct TokenOutput",
|
|
25707
|
+
name: "output",
|
|
25708
|
+
type: "tuple"
|
|
25709
|
+
}
|
|
25710
|
+
],
|
|
25711
|
+
name: "exitPostExpToToken",
|
|
25712
|
+
outputs: [
|
|
25713
|
+
{
|
|
25714
|
+
internalType: "uint256",
|
|
25715
|
+
name: "totalTokenOut",
|
|
25716
|
+
type: "uint256"
|
|
25717
|
+
},
|
|
25718
|
+
{
|
|
25719
|
+
components: [
|
|
25720
|
+
{
|
|
25721
|
+
internalType: "uint256",
|
|
25722
|
+
name: "netPtFromRemove",
|
|
25723
|
+
type: "uint256"
|
|
25724
|
+
},
|
|
25725
|
+
{
|
|
25726
|
+
internalType: "uint256",
|
|
25727
|
+
name: "netSyFromRemove",
|
|
25728
|
+
type: "uint256"
|
|
25729
|
+
},
|
|
25730
|
+
{
|
|
25731
|
+
internalType: "uint256",
|
|
25732
|
+
name: "netPtRedeem",
|
|
25733
|
+
type: "uint256"
|
|
25734
|
+
},
|
|
25735
|
+
{
|
|
25736
|
+
internalType: "uint256",
|
|
25737
|
+
name: "netSyFromRedeem",
|
|
25738
|
+
type: "uint256"
|
|
25739
|
+
},
|
|
25740
|
+
{
|
|
25741
|
+
internalType: "uint256",
|
|
25742
|
+
name: "totalSyOut",
|
|
25743
|
+
type: "uint256"
|
|
25744
|
+
}
|
|
25745
|
+
],
|
|
25746
|
+
internalType: "struct IPActionMiscV3.ExitPostExpReturnParams",
|
|
25747
|
+
name: "params",
|
|
25748
|
+
type: "tuple"
|
|
25749
|
+
}
|
|
25750
|
+
],
|
|
25751
|
+
stateMutability: "nonpayable",
|
|
25752
|
+
type: "function"
|
|
25753
|
+
}
|
|
25754
|
+
];
|
|
25755
|
+
|
|
25756
|
+
var pendleBaseUrl = "https://api-v2.pendle.finance/core/v1";
|
|
25757
|
+
function getPendleSwapTxData(_x, _x2, _x3, _x4, _x5) {
|
|
25758
|
+
return _getPendleSwapTxData.apply(this, arguments);
|
|
25759
|
+
}
|
|
25760
|
+
|
|
25761
|
+
function _getPendleSwapTxData() {
|
|
25762
|
+
_getPendleSwapTxData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(pool, tokenIn, tokenOut, amountIn, slippage) {
|
|
25763
|
+
var expiredMarket, params, market, swapResult;
|
|
25764
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
25765
|
+
while (1) {
|
|
25766
|
+
switch (_context2.prev = _context2.next) {
|
|
25767
|
+
case 0:
|
|
25768
|
+
_context2.next = 2;
|
|
25769
|
+
return checkExitPostExpPT(pool, tokenIn, tokenOut);
|
|
25770
|
+
|
|
25771
|
+
case 2:
|
|
25772
|
+
expiredMarket = _context2.sent;
|
|
25773
|
+
|
|
25774
|
+
if (!expiredMarket) {
|
|
25775
|
+
_context2.next = 5;
|
|
25776
|
+
break;
|
|
25777
|
+
}
|
|
25778
|
+
|
|
25779
|
+
return _context2.abrupt("return", getExitExpPTTxData(pool, tokenOut, amountIn, expiredMarket));
|
|
25780
|
+
|
|
25781
|
+
case 5:
|
|
25782
|
+
params = {
|
|
25783
|
+
receiver: pool.address,
|
|
25784
|
+
tokenIn: tokenIn,
|
|
25785
|
+
tokenOut: tokenOut,
|
|
25786
|
+
amountIn: amountIn.toString(),
|
|
25787
|
+
slippage: slippage
|
|
25788
|
+
};
|
|
25789
|
+
_context2.next = 8;
|
|
25790
|
+
return getMarket(pool, tokenIn, tokenOut);
|
|
25791
|
+
|
|
25792
|
+
case 8:
|
|
25793
|
+
market = _context2.sent;
|
|
25794
|
+
_context2.prev = 9;
|
|
25795
|
+
_context2.next = 12;
|
|
25796
|
+
return axios.get(pendleBaseUrl + "/sdk/" + networkChainIdMap[pool.network] + "/markets/" + market + "/swap", {
|
|
25797
|
+
params: params
|
|
25798
|
+
});
|
|
25799
|
+
|
|
25800
|
+
case 12:
|
|
25801
|
+
swapResult = _context2.sent;
|
|
25802
|
+
return _context2.abrupt("return", swapResult.data.tx.data);
|
|
25803
|
+
|
|
25804
|
+
case 16:
|
|
25805
|
+
_context2.prev = 16;
|
|
25806
|
+
_context2.t0 = _context2["catch"](9);
|
|
25807
|
+
console.error("Error in Pendle API request:", _context2.t0);
|
|
25808
|
+
throw new ApiError("Pendle api request failed");
|
|
25809
|
+
|
|
25810
|
+
case 20:
|
|
25811
|
+
case "end":
|
|
25812
|
+
return _context2.stop();
|
|
25813
|
+
}
|
|
25814
|
+
}
|
|
25815
|
+
}, _callee2, null, [[9, 16]]);
|
|
25816
|
+
}));
|
|
25817
|
+
return _getPendleSwapTxData.apply(this, arguments);
|
|
25818
|
+
}
|
|
25819
|
+
|
|
25820
|
+
var checkUnderlying = function checkUnderlying(market, token, networkId) {
|
|
25821
|
+
if (market.underlyingAsset !== networkId + "-" + token.toLocaleLowerCase()) {
|
|
25822
|
+
throw new Error("Can only trade in or out of the underlying asset");
|
|
25823
|
+
}
|
|
25824
|
+
};
|
|
25825
|
+
|
|
25826
|
+
function getMarket(_x6, _x7, _x8) {
|
|
25827
|
+
return _getMarket.apply(this, arguments);
|
|
25828
|
+
}
|
|
25829
|
+
|
|
25830
|
+
function _getMarket() {
|
|
25831
|
+
_getMarket = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(pool, tokenIn, tokenOut) {
|
|
25832
|
+
var networkId, marketResult, allMarkets, markets;
|
|
25833
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
25834
|
+
while (1) {
|
|
25835
|
+
switch (_context3.prev = _context3.next) {
|
|
25836
|
+
case 0:
|
|
25837
|
+
networkId = networkChainIdMap[pool.network];
|
|
25838
|
+
_context3.prev = 1;
|
|
25839
|
+
_context3.next = 4;
|
|
25840
|
+
return axios.get(pendleBaseUrl + "/" + networkId + "/markets/active");
|
|
25841
|
+
|
|
25842
|
+
case 4:
|
|
25843
|
+
marketResult = _context3.sent;
|
|
25844
|
+
_context3.next = 11;
|
|
25845
|
+
break;
|
|
25846
|
+
|
|
25847
|
+
case 7:
|
|
25848
|
+
_context3.prev = 7;
|
|
25849
|
+
_context3.t0 = _context3["catch"](1);
|
|
25850
|
+
console.error("Error in Pendle API request:", _context3.t0);
|
|
25851
|
+
throw new ApiError("Pendle api request failed");
|
|
25852
|
+
|
|
25853
|
+
case 11:
|
|
25854
|
+
allMarkets = marketResult.data.markets;
|
|
25855
|
+
markets = [tokenIn, tokenOut].map(function (token) {
|
|
25856
|
+
return allMarkets.find(function (market) {
|
|
25857
|
+
return market.pt === networkId + "-" + token.toLocaleLowerCase();
|
|
25858
|
+
});
|
|
25859
|
+
});
|
|
25860
|
+
|
|
25861
|
+
if (!markets[0]) {
|
|
25862
|
+
_context3.next = 18;
|
|
25863
|
+
break;
|
|
25864
|
+
}
|
|
25865
|
+
|
|
25866
|
+
checkUnderlying(markets[0], tokenOut, networkId);
|
|
25867
|
+
return _context3.abrupt("return", markets[0].address);
|
|
25868
|
+
|
|
25869
|
+
case 18:
|
|
25870
|
+
if (!markets[1]) {
|
|
25871
|
+
_context3.next = 23;
|
|
25872
|
+
break;
|
|
25873
|
+
}
|
|
25874
|
+
|
|
25875
|
+
checkUnderlying(markets[1], tokenIn, networkId);
|
|
25876
|
+
return _context3.abrupt("return", markets[1].address);
|
|
25877
|
+
|
|
25878
|
+
case 23:
|
|
25879
|
+
throw new Error("Can only trade PT assets");
|
|
25880
|
+
|
|
25881
|
+
case 24:
|
|
25882
|
+
case "end":
|
|
25883
|
+
return _context3.stop();
|
|
25884
|
+
}
|
|
25885
|
+
}
|
|
25886
|
+
}, _callee3, null, [[1, 7]]);
|
|
25887
|
+
}));
|
|
25888
|
+
return _getMarket.apply(this, arguments);
|
|
25889
|
+
}
|
|
25890
|
+
|
|
25891
|
+
var checkExitPostExpPT = /*#__PURE__*/function () {
|
|
25892
|
+
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(pool, tokenIn, tokenOut) {
|
|
25893
|
+
var networkId, inactiveMarketResult, allInactiveMarkets, markets;
|
|
25894
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
25895
|
+
while (1) {
|
|
25896
|
+
switch (_context.prev = _context.next) {
|
|
25897
|
+
case 0:
|
|
25898
|
+
networkId = networkChainIdMap[pool.network];
|
|
25899
|
+
_context.prev = 1;
|
|
25900
|
+
_context.next = 4;
|
|
25901
|
+
return axios.get(pendleBaseUrl + "/" + networkId + "/markets/inactive");
|
|
25902
|
+
|
|
25903
|
+
case 4:
|
|
25904
|
+
inactiveMarketResult = _context.sent;
|
|
25905
|
+
_context.next = 11;
|
|
25906
|
+
break;
|
|
25907
|
+
|
|
25908
|
+
case 7:
|
|
25909
|
+
_context.prev = 7;
|
|
25910
|
+
_context.t0 = _context["catch"](1);
|
|
25911
|
+
console.error("Error in Pendle API request:", _context.t0);
|
|
25912
|
+
throw new ApiError("Pendle api request failed");
|
|
25913
|
+
|
|
25914
|
+
case 11:
|
|
25915
|
+
allInactiveMarkets = inactiveMarketResult.data.markets;
|
|
25916
|
+
markets = [tokenIn, tokenOut].map(function (token) {
|
|
25917
|
+
return allInactiveMarkets.find(function (market) {
|
|
25918
|
+
return market.pt === networkId + "-" + token.toLocaleLowerCase();
|
|
25919
|
+
});
|
|
25920
|
+
});
|
|
25921
|
+
|
|
25922
|
+
if (!markets[0]) {
|
|
25923
|
+
_context.next = 18;
|
|
25924
|
+
break;
|
|
25925
|
+
}
|
|
25926
|
+
|
|
25927
|
+
checkUnderlying(markets[0], tokenOut, networkId);
|
|
25928
|
+
return _context.abrupt("return", markets[0].address);
|
|
25929
|
+
|
|
25930
|
+
case 18:
|
|
25931
|
+
if (!markets[1]) {
|
|
25932
|
+
_context.next = 22;
|
|
25933
|
+
break;
|
|
25934
|
+
}
|
|
25935
|
+
|
|
25936
|
+
throw new Error("Can not trade to expired PT asset");
|
|
25937
|
+
|
|
25938
|
+
case 22:
|
|
25939
|
+
return _context.abrupt("return", null);
|
|
25940
|
+
|
|
25941
|
+
case 23:
|
|
25942
|
+
case "end":
|
|
25943
|
+
return _context.stop();
|
|
25944
|
+
}
|
|
25945
|
+
}
|
|
25946
|
+
}, _callee, null, [[1, 7]]);
|
|
25947
|
+
}));
|
|
25948
|
+
|
|
25949
|
+
return function checkExitPostExpPT(_x9, _x10, _x11) {
|
|
25950
|
+
return _ref.apply(this, arguments);
|
|
25951
|
+
};
|
|
25952
|
+
}();
|
|
25953
|
+
|
|
25954
|
+
var getExitExpPTTxData = function getExitExpPTTxData(pool, tokenOut, amountIn, market) {
|
|
25955
|
+
var actionMiscV3 = new ethers.utils.Interface(ActionMiscV3Abi);
|
|
25956
|
+
var txData = actionMiscV3.encodeFunctionData("exitPostExpToToken", [pool.address, market, amountIn.toString(), 0, [tokenOut, 0, tokenOut, ethers.constants.AddressZero, // swapData
|
|
25957
|
+
[0, ethers.constants.AddressZero, ethers.constants.HashZero, false // needScale
|
|
25958
|
+
]]]);
|
|
25959
|
+
return txData;
|
|
25960
|
+
};
|
|
25961
|
+
|
|
25625
25962
|
var Pool = /*#__PURE__*/function () {
|
|
25626
25963
|
function Pool(network, signer, poolLogic, mangerLogic, utils, factory, isDhedge) {
|
|
25627
25964
|
if (isDhedge === void 0) {
|
|
@@ -26159,7 +26496,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
26159
26496
|
}
|
|
26160
26497
|
|
|
26161
26498
|
_context10.t0 = dapp;
|
|
26162
|
-
_context10.next = _context10.t0 === Dapp.ONEINCH ? 6 : _context10.t0 === Dapp.BALANCER ? 11 : _context10.t0 === Dapp.SYNTHETIX ? 15 : _context10.t0 === Dapp.TOROS ? 22 : _context10.t0 === Dapp.ODOS ? 26 : 30;
|
|
26499
|
+
_context10.next = _context10.t0 === Dapp.ONEINCH ? 6 : _context10.t0 === Dapp.BALANCER ? 11 : _context10.t0 === Dapp.SYNTHETIX ? 15 : _context10.t0 === Dapp.TOROS ? 22 : _context10.t0 === Dapp.ODOS ? 26 : _context10.t0 === Dapp.PENDLE ? 30 : 34;
|
|
26163
26500
|
break;
|
|
26164
26501
|
|
|
26165
26502
|
case 6:
|
|
@@ -26169,7 +26506,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
26169
26506
|
case 8:
|
|
26170
26507
|
_yield$getOneInchSwap = _context10.sent;
|
|
26171
26508
|
swapTxData = _yield$getOneInchSwap.swapTxData;
|
|
26172
|
-
return _context10.abrupt("break",
|
|
26509
|
+
return _context10.abrupt("break", 49);
|
|
26173
26510
|
|
|
26174
26511
|
case 11:
|
|
26175
26512
|
_context10.next = 13;
|
|
@@ -26177,7 +26514,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
26177
26514
|
|
|
26178
26515
|
case 13:
|
|
26179
26516
|
swapTxData = _context10.sent;
|
|
26180
|
-
return _context10.abrupt("break",
|
|
26517
|
+
return _context10.abrupt("break", 49);
|
|
26181
26518
|
|
|
26182
26519
|
case 15:
|
|
26183
26520
|
iSynthetix = new ethers.utils.Interface(ISynthetix.abi);
|
|
@@ -26190,7 +26527,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
26190
26527
|
case 19:
|
|
26191
26528
|
daoAddress = _context10.sent;
|
|
26192
26529
|
swapTxData = iSynthetix.encodeFunctionData(Transaction.SWAP_SYNTHS, [assets[0], amountIn, assets[1], daoAddress, SYNTHETIX_TRACKING_CODE]);
|
|
26193
|
-
return _context10.abrupt("break",
|
|
26530
|
+
return _context10.abrupt("break", 49);
|
|
26194
26531
|
|
|
26195
26532
|
case 22:
|
|
26196
26533
|
_context10.next = 24;
|
|
@@ -26198,7 +26535,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
26198
26535
|
|
|
26199
26536
|
case 24:
|
|
26200
26537
|
swapTxData = _context10.sent;
|
|
26201
|
-
return _context10.abrupt("break",
|
|
26538
|
+
return _context10.abrupt("break", 49);
|
|
26202
26539
|
|
|
26203
26540
|
case 26:
|
|
26204
26541
|
_context10.next = 28;
|
|
@@ -26206,14 +26543,22 @@ var Pool = /*#__PURE__*/function () {
|
|
|
26206
26543
|
|
|
26207
26544
|
case 28:
|
|
26208
26545
|
swapTxData = _context10.sent;
|
|
26209
|
-
return _context10.abrupt("break",
|
|
26546
|
+
return _context10.abrupt("break", 49);
|
|
26210
26547
|
|
|
26211
26548
|
case 30:
|
|
26549
|
+
_context10.next = 32;
|
|
26550
|
+
return getPendleSwapTxData(this, assetFrom, assetTo, amountIn, slippage);
|
|
26551
|
+
|
|
26552
|
+
case 32:
|
|
26553
|
+
swapTxData = _context10.sent;
|
|
26554
|
+
return _context10.abrupt("break", 49);
|
|
26555
|
+
|
|
26556
|
+
case 34:
|
|
26212
26557
|
iUniswapV2Router = new ethers.utils.Interface(IUniswapV2Router.abi);
|
|
26213
|
-
_context10.next =
|
|
26558
|
+
_context10.next = 37;
|
|
26214
26559
|
return this.utils.getMinAmountOut(dapp, assetFrom, assetTo, amountIn, slippage);
|
|
26215
26560
|
|
|
26216
|
-
case
|
|
26561
|
+
case 37:
|
|
26217
26562
|
minAmountOut = _context10.sent;
|
|
26218
26563
|
_context10.t1 = iUniswapV2Router;
|
|
26219
26564
|
_context10.t2 = Transaction.SWAP;
|
|
@@ -26221,23 +26566,23 @@ var Pool = /*#__PURE__*/function () {
|
|
|
26221
26566
|
_context10.t4 = minAmountOut;
|
|
26222
26567
|
_context10.t5 = [assetFrom, assetTo];
|
|
26223
26568
|
_context10.t6 = this.address;
|
|
26224
|
-
_context10.next =
|
|
26569
|
+
_context10.next = 46;
|
|
26225
26570
|
return getDeadline(this);
|
|
26226
26571
|
|
|
26227
|
-
case
|
|
26572
|
+
case 46:
|
|
26228
26573
|
_context10.t7 = _context10.sent;
|
|
26229
26574
|
_context10.t8 = [_context10.t3, _context10.t4, _context10.t5, _context10.t6, _context10.t7];
|
|
26230
26575
|
swapTxData = _context10.t1.encodeFunctionData.call(_context10.t1, _context10.t2, _context10.t8);
|
|
26231
26576
|
|
|
26232
|
-
case
|
|
26233
|
-
_context10.next =
|
|
26577
|
+
case 49:
|
|
26578
|
+
_context10.next = 51;
|
|
26234
26579
|
return getPoolTxOrGasEstimate(this, [routerAddress[this.network][dapp], swapTxData, options], estimateGas);
|
|
26235
26580
|
|
|
26236
|
-
case
|
|
26581
|
+
case 51:
|
|
26237
26582
|
tx = _context10.sent;
|
|
26238
26583
|
return _context10.abrupt("return", tx);
|
|
26239
26584
|
|
|
26240
|
-
case
|
|
26585
|
+
case 53:
|
|
26241
26586
|
case "end":
|
|
26242
26587
|
return _context10.stop();
|
|
26243
26588
|
}
|