@dhedge/v2-sdk 1.10.15 → 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/types.d.ts +2 -1
- package/dist/v2-sdk.cjs.development.js +359 -15
- 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 +359 -15
- 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/pendle/index.ts +141 -0
- 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 = [
|
|
@@ -25623,6 +25630,335 @@ function _getOdosSwapTxData() {
|
|
|
25623
25630
|
return _getOdosSwapTxData.apply(this, arguments);
|
|
25624
25631
|
}
|
|
25625
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
|
+
|
|
25626
25962
|
var Pool = /*#__PURE__*/function () {
|
|
25627
25963
|
function Pool(network, signer, poolLogic, mangerLogic, utils, factory, isDhedge) {
|
|
25628
25964
|
if (isDhedge === void 0) {
|
|
@@ -26160,7 +26496,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
26160
26496
|
}
|
|
26161
26497
|
|
|
26162
26498
|
_context10.t0 = dapp;
|
|
26163
|
-
_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;
|
|
26164
26500
|
break;
|
|
26165
26501
|
|
|
26166
26502
|
case 6:
|
|
@@ -26170,7 +26506,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
26170
26506
|
case 8:
|
|
26171
26507
|
_yield$getOneInchSwap = _context10.sent;
|
|
26172
26508
|
swapTxData = _yield$getOneInchSwap.swapTxData;
|
|
26173
|
-
return _context10.abrupt("break",
|
|
26509
|
+
return _context10.abrupt("break", 49);
|
|
26174
26510
|
|
|
26175
26511
|
case 11:
|
|
26176
26512
|
_context10.next = 13;
|
|
@@ -26178,7 +26514,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
26178
26514
|
|
|
26179
26515
|
case 13:
|
|
26180
26516
|
swapTxData = _context10.sent;
|
|
26181
|
-
return _context10.abrupt("break",
|
|
26517
|
+
return _context10.abrupt("break", 49);
|
|
26182
26518
|
|
|
26183
26519
|
case 15:
|
|
26184
26520
|
iSynthetix = new ethers.utils.Interface(ISynthetix.abi);
|
|
@@ -26191,7 +26527,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
26191
26527
|
case 19:
|
|
26192
26528
|
daoAddress = _context10.sent;
|
|
26193
26529
|
swapTxData = iSynthetix.encodeFunctionData(Transaction.SWAP_SYNTHS, [assets[0], amountIn, assets[1], daoAddress, SYNTHETIX_TRACKING_CODE]);
|
|
26194
|
-
return _context10.abrupt("break",
|
|
26530
|
+
return _context10.abrupt("break", 49);
|
|
26195
26531
|
|
|
26196
26532
|
case 22:
|
|
26197
26533
|
_context10.next = 24;
|
|
@@ -26199,7 +26535,7 @@ var Pool = /*#__PURE__*/function () {
|
|
|
26199
26535
|
|
|
26200
26536
|
case 24:
|
|
26201
26537
|
swapTxData = _context10.sent;
|
|
26202
|
-
return _context10.abrupt("break",
|
|
26538
|
+
return _context10.abrupt("break", 49);
|
|
26203
26539
|
|
|
26204
26540
|
case 26:
|
|
26205
26541
|
_context10.next = 28;
|
|
@@ -26207,14 +26543,22 @@ var Pool = /*#__PURE__*/function () {
|
|
|
26207
26543
|
|
|
26208
26544
|
case 28:
|
|
26209
26545
|
swapTxData = _context10.sent;
|
|
26210
|
-
return _context10.abrupt("break",
|
|
26546
|
+
return _context10.abrupt("break", 49);
|
|
26211
26547
|
|
|
26212
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:
|
|
26213
26557
|
iUniswapV2Router = new ethers.utils.Interface(IUniswapV2Router.abi);
|
|
26214
|
-
_context10.next =
|
|
26558
|
+
_context10.next = 37;
|
|
26215
26559
|
return this.utils.getMinAmountOut(dapp, assetFrom, assetTo, amountIn, slippage);
|
|
26216
26560
|
|
|
26217
|
-
case
|
|
26561
|
+
case 37:
|
|
26218
26562
|
minAmountOut = _context10.sent;
|
|
26219
26563
|
_context10.t1 = iUniswapV2Router;
|
|
26220
26564
|
_context10.t2 = Transaction.SWAP;
|
|
@@ -26222,23 +26566,23 @@ var Pool = /*#__PURE__*/function () {
|
|
|
26222
26566
|
_context10.t4 = minAmountOut;
|
|
26223
26567
|
_context10.t5 = [assetFrom, assetTo];
|
|
26224
26568
|
_context10.t6 = this.address;
|
|
26225
|
-
_context10.next =
|
|
26569
|
+
_context10.next = 46;
|
|
26226
26570
|
return getDeadline(this);
|
|
26227
26571
|
|
|
26228
|
-
case
|
|
26572
|
+
case 46:
|
|
26229
26573
|
_context10.t7 = _context10.sent;
|
|
26230
26574
|
_context10.t8 = [_context10.t3, _context10.t4, _context10.t5, _context10.t6, _context10.t7];
|
|
26231
26575
|
swapTxData = _context10.t1.encodeFunctionData.call(_context10.t1, _context10.t2, _context10.t8);
|
|
26232
26576
|
|
|
26233
|
-
case
|
|
26234
|
-
_context10.next =
|
|
26577
|
+
case 49:
|
|
26578
|
+
_context10.next = 51;
|
|
26235
26579
|
return getPoolTxOrGasEstimate(this, [routerAddress[this.network][dapp], swapTxData, options], estimateGas);
|
|
26236
26580
|
|
|
26237
|
-
case
|
|
26581
|
+
case 51:
|
|
26238
26582
|
tx = _context10.sent;
|
|
26239
26583
|
return _context10.abrupt("return", tx);
|
|
26240
26584
|
|
|
26241
|
-
case
|
|
26585
|
+
case 53:
|
|
26242
26586
|
case "end":
|
|
26243
26587
|
return _context10.stop();
|
|
26244
26588
|
}
|