@pendle/core-v2 0.16.3-testnet → 0.16.4-testnet
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/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol/PendleMsgReceiverAppUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/EpochResultManager.sol/EpochResultManager.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.json +2 -2
- package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.dbg.json +1 -1
- package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.json +2 -2
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.json +3 -19
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.dbg.json +1 -1
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.json +2 -2
- package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.json +2 -2
- package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.json +2 -2
- package/build/artifacts/contracts/core/Market/PendleGauge.sol/PendleGauge.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.json +2 -2
- package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.json +2 -2
- package/build/artifacts/contracts/core/RewardManager/RewardManager.sol/RewardManager.dbg.json +1 -1
- package/build/artifacts/contracts/core/RewardManager/RewardManagerAbstract.sol/RewardManagerAbstract.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/SYBase.sol/SYBase.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.json +2 -2
- package/build/artifacts/contracts/core/YieldContracts/InterestManagerYT.sol/InterestManagerYT.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.json +2 -2
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.json +2 -2
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +2 -2
- package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.json +3 -19
- package/build/artifacts/contracts/core/libraries/TokenHelper.sol/TokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.json +20 -20
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.json +23 -23
- package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.json +10 -10
- package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.json +10 -10
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.json +63 -63
- package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingEscrowMainchain.sol/IPVotingEscrowMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.json +2 -2
- package/build/artifacts/contracts/offchain-helpers/ImplicitSwapfeeContract.sol/ImplicitSwapfeeContract.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/ImplicitSwapfeeContract.sol/ImplicitSwapfeeContract.json +2 -2
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.json +2 -2
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +133 -99
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.json +22 -40
- package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.json +2 -2
- package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.json +25 -43
- package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.json +2 -2
- package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.json +12 -30
- package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.json +2 -2
- package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.json +12 -30
- package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.dbg.json +1 -1
- package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.json +2 -2
- package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.json +0 -13
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.json +2 -2
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.json +2 -2
- package/build/artifacts/contracts/router/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.dbg.json +1 -1
- package/contracts/core/BulkSeller/BulkSellerFactory.sol +0 -2
- package/contracts/core/libraries/Errors.sol +1 -2
- package/contracts/core/libraries/TokenHelper.sol +9 -0
- package/contracts/interfaces/IPActionMintRedeem.sol +1 -1
- package/contracts/offchain-helpers/RouterStatic.sol +45 -30
- package/contracts/router/ActionAddRemoveLiq.sol +12 -13
- package/contracts/router/ActionCallback.sol +4 -8
- package/contracts/router/ActionMintRedeem.sol +16 -11
- package/contracts/router/ActionSwapPT.sol +7 -8
- package/contracts/router/ActionSwapPTYT.sol +3 -7
- package/contracts/router/ActionSwapYT.sol +6 -8
- package/contracts/router/PendleRouter.sol +3 -0
- package/contracts/router/base/ActionBaseMintRedeem.sol +29 -33
- package/contracts/router/kyberswap/KyberSwapHelper.sol +8 -4
- package/package.json +1 -1
- package/typechain-types/ActionAddRemoveLiq.ts +10 -29
- package/typechain-types/ActionBaseMintRedeem.ts +0 -19
- package/typechain-types/ActionMintRedeem.ts +14 -33
- package/typechain-types/ActionSwapPT.ts +8 -27
- package/typechain-types/ActionSwapYT.ts +8 -27
- package/typechain-types/IPActionAddRemoveLiq.ts +10 -10
- package/typechain-types/IPActionMintRedeem.ts +14 -14
- package/typechain-types/IPActionSwapPT.ts +8 -8
- package/typechain-types/IPActionSwapYT.ts +8 -8
- package/typechain-types/IPAllAction.ts +22 -22
- package/typechain-types/RouterStatic.ts +148 -91
- package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +22 -47
- package/typechain-types/factories/ActionBaseMintRedeem__factory.ts +0 -13
- package/typechain-types/factories/ActionCallback__factory.ts +1 -1
- package/typechain-types/factories/ActionMintRedeem__factory.ts +25 -50
- package/typechain-types/factories/ActionMisc__factory.ts +1 -1
- package/typechain-types/factories/ActionSwapPTYT__factory.ts +1 -1
- package/typechain-types/factories/ActionSwapPT__factory.ts +12 -37
- package/typechain-types/factories/ActionSwapYT__factory.ts +12 -37
- package/typechain-types/factories/BulkSellerFactory__factory.ts +2 -18
- package/typechain-types/factories/BulkSellerOffchain__factory.ts +1 -1
- package/typechain-types/factories/BulkSeller__factory.ts +1 -1
- package/typechain-types/factories/Errors__factory.ts +2 -18
- package/typechain-types/factories/IPActionAddRemoveLiq__factory.ts +20 -20
- package/typechain-types/factories/IPActionMintRedeem__factory.ts +23 -23
- package/typechain-types/factories/IPActionSwapPT__factory.ts +10 -10
- package/typechain-types/factories/IPActionSwapYT__factory.ts +10 -10
- package/typechain-types/factories/IPAllAction__factory.ts +63 -63
- package/typechain-types/factories/ImplicitSwapfeeContract__factory.ts +1 -1
- package/typechain-types/factories/MarketMathStatic__factory.ts +1 -1
- package/typechain-types/factories/OracleLib__factory.ts +1 -1
- package/typechain-types/factories/PendleFeeDistributorFactory__factory.ts +1 -1
- package/typechain-types/factories/PendleFeeDistributor__factory.ts +1 -1
- package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleMarketFactory__factory.ts +1 -1
- package/typechain-types/factories/PendleMarket__factory.ts +1 -1
- package/typechain-types/factories/PendleMsgReceiveEndpointUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleMsgSendEndpointUpg__factory.ts +1 -1
- package/typechain-types/factories/PendlePrincipalToken__factory.ts +1 -1
- package/typechain-types/factories/PendleQiTokenHelper__factory.ts +1 -1
- package/typechain-types/factories/PendleQiTokenSY__factory.ts +1 -1
- package/typechain-types/factories/PendleRouter__factory.ts +1 -1
- package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleWstEthSY__factory.ts +1 -1
- package/typechain-types/factories/PendleYieldContractFactory__factory.ts +1 -1
- package/typechain-types/factories/PendleYieldToken__factory.ts +1 -1
- package/typechain-types/factories/RouterStatic__factory.ts +74 -40
- package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +1 -1
- package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +1 -1
|
@@ -288,7 +288,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
288
288
|
address market,
|
|
289
289
|
address tokenIn,
|
|
290
290
|
uint256 netTokenDesired,
|
|
291
|
-
|
|
291
|
+
address bulk,
|
|
292
292
|
uint256 netPtDesired
|
|
293
293
|
)
|
|
294
294
|
external
|
|
@@ -303,7 +303,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
303
303
|
getSyMarket(market),
|
|
304
304
|
tokenIn,
|
|
305
305
|
netTokenDesired,
|
|
306
|
-
|
|
306
|
+
bulk
|
|
307
307
|
);
|
|
308
308
|
|
|
309
309
|
uint256 netSyUsed;
|
|
@@ -348,7 +348,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
348
348
|
address market,
|
|
349
349
|
address baseToken,
|
|
350
350
|
uint256 netBaseTokenIn,
|
|
351
|
-
|
|
351
|
+
address bulk
|
|
352
352
|
)
|
|
353
353
|
external
|
|
354
354
|
returns (
|
|
@@ -362,7 +362,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
362
362
|
getSyMarket(market),
|
|
363
363
|
baseToken,
|
|
364
364
|
netBaseTokenIn,
|
|
365
|
-
|
|
365
|
+
bulk
|
|
366
366
|
);
|
|
367
367
|
|
|
368
368
|
return
|
|
@@ -381,7 +381,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
381
381
|
address market,
|
|
382
382
|
uint256 netLpToRemove,
|
|
383
383
|
address tokenOut,
|
|
384
|
-
|
|
384
|
+
address bulk
|
|
385
385
|
) external view returns (uint256 netTokenOut, uint256 netPtOut) {
|
|
386
386
|
uint256 netSyOut;
|
|
387
387
|
|
|
@@ -390,7 +390,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
390
390
|
netLpToRemove
|
|
391
391
|
);
|
|
392
392
|
|
|
393
|
-
netTokenOut = previewRedeemStatic(getSyMarket(market), tokenOut, netSyOut,
|
|
393
|
+
netTokenOut = previewRedeemStatic(getSyMarket(market), tokenOut, netSyOut, bulk);
|
|
394
394
|
}
|
|
395
395
|
|
|
396
396
|
function removeLiquiditySinglePtStatic(address market, uint256 netLpToRemove)
|
|
@@ -425,7 +425,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
425
425
|
address market,
|
|
426
426
|
uint256 netLpToRemove,
|
|
427
427
|
address baseToken,
|
|
428
|
-
|
|
428
|
+
address bulk
|
|
429
429
|
)
|
|
430
430
|
external
|
|
431
431
|
returns (
|
|
@@ -441,7 +441,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
441
441
|
netLpToRemove
|
|
442
442
|
);
|
|
443
443
|
|
|
444
|
-
netBaseTokenOut = previewRedeemStatic(getSyMarket(market), baseToken, netSyOut,
|
|
444
|
+
netBaseTokenOut = previewRedeemStatic(getSyMarket(market), baseToken, netSyOut, bulk);
|
|
445
445
|
}
|
|
446
446
|
|
|
447
447
|
function swapExactPtForSyStatic(address market, uint256 exactPtIn)
|
|
@@ -494,7 +494,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
494
494
|
address market,
|
|
495
495
|
address baseToken,
|
|
496
496
|
uint256 amountBaseToken,
|
|
497
|
-
|
|
497
|
+
address bulk
|
|
498
498
|
)
|
|
499
499
|
external
|
|
500
500
|
returns (
|
|
@@ -507,7 +507,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
507
507
|
getSyMarket(market),
|
|
508
508
|
baseToken,
|
|
509
509
|
amountBaseToken,
|
|
510
|
-
|
|
510
|
+
bulk
|
|
511
511
|
);
|
|
512
512
|
return MarketMathStatic.swapExactSyForPtStatic(market, netSyIn, getDefaultApproxParams());
|
|
513
513
|
}
|
|
@@ -516,7 +516,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
516
516
|
address market,
|
|
517
517
|
uint256 exactPtIn,
|
|
518
518
|
address baseToken,
|
|
519
|
-
|
|
519
|
+
address bulk
|
|
520
520
|
)
|
|
521
521
|
external
|
|
522
522
|
returns (
|
|
@@ -531,7 +531,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
531
531
|
exactPtIn
|
|
532
532
|
);
|
|
533
533
|
|
|
534
|
-
netBaseTokenOut = previewRedeemStatic(getSyMarket(market), baseToken, netSyOut,
|
|
534
|
+
netBaseTokenOut = previewRedeemStatic(getSyMarket(market), baseToken, netSyOut, bulk);
|
|
535
535
|
}
|
|
536
536
|
|
|
537
537
|
function swapSyForExactYtStatic(address market, uint256 exactYtOut)
|
|
@@ -584,7 +584,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
584
584
|
address market,
|
|
585
585
|
uint256 exactYtIn,
|
|
586
586
|
address baseToken,
|
|
587
|
-
|
|
587
|
+
address bulk
|
|
588
588
|
)
|
|
589
589
|
external
|
|
590
590
|
returns (
|
|
@@ -599,14 +599,14 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
599
599
|
exactYtIn
|
|
600
600
|
);
|
|
601
601
|
|
|
602
|
-
netBaseTokenOut = previewRedeemStatic(getSyMarket(market), baseToken, netSyOut,
|
|
602
|
+
netBaseTokenOut = previewRedeemStatic(getSyMarket(market), baseToken, netSyOut, bulk);
|
|
603
603
|
}
|
|
604
604
|
|
|
605
605
|
function swapExactBaseTokenForYtStatic(
|
|
606
606
|
address market,
|
|
607
607
|
address baseToken,
|
|
608
608
|
uint256 amountBaseToken,
|
|
609
|
-
|
|
609
|
+
address bulk
|
|
610
610
|
)
|
|
611
611
|
external
|
|
612
612
|
returns (
|
|
@@ -619,7 +619,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
619
619
|
getSyMarket(market),
|
|
620
620
|
baseToken,
|
|
621
621
|
amountBaseToken,
|
|
622
|
-
|
|
622
|
+
bulk
|
|
623
623
|
);
|
|
624
624
|
|
|
625
625
|
return MarketMathStatic.swapExactSyForYtStatic(market, netSyIn, getDefaultApproxParams());
|
|
@@ -708,10 +708,10 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
708
708
|
address YT,
|
|
709
709
|
address baseToken,
|
|
710
710
|
uint256 amountBaseToken,
|
|
711
|
-
|
|
711
|
+
address bulk
|
|
712
712
|
) external returns (uint256 amountPY) {
|
|
713
713
|
IStandardizedYield SY = IStandardizedYield(IPYieldToken(YT).SY());
|
|
714
|
-
uint256 amountSy = previewDepositStatic(SY, baseToken, amountBaseToken,
|
|
714
|
+
uint256 amountSy = previewDepositStatic(SY, baseToken, amountBaseToken, bulk);
|
|
715
715
|
return mintPYFromSyStatic(YT, amountSy);
|
|
716
716
|
}
|
|
717
717
|
|
|
@@ -719,21 +719,20 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
719
719
|
address YT,
|
|
720
720
|
uint256 amountPYToRedeem,
|
|
721
721
|
address baseToken,
|
|
722
|
-
|
|
722
|
+
address bulk
|
|
723
723
|
) external returns (uint256 amountBaseToken) {
|
|
724
724
|
IStandardizedYield SY = IStandardizedYield(IPYieldToken(YT).SY());
|
|
725
725
|
uint256 amountSy = redeemPYToSyStatic(YT, amountPYToRedeem);
|
|
726
|
-
return previewRedeemStatic(SY, baseToken, amountSy,
|
|
726
|
+
return previewRedeemStatic(SY, baseToken, amountSy, bulk);
|
|
727
727
|
}
|
|
728
728
|
|
|
729
729
|
function previewDepositStatic(
|
|
730
730
|
IStandardizedYield SY,
|
|
731
731
|
address baseToken,
|
|
732
732
|
uint256 amountToken,
|
|
733
|
-
|
|
733
|
+
address bulk
|
|
734
734
|
) public view returns (uint256 amountSy) {
|
|
735
|
-
if (
|
|
736
|
-
address bulk = bulkFactory.get(baseToken, address(SY));
|
|
735
|
+
if (bulk != address(0)) {
|
|
737
736
|
return IPBulkSeller(bulk).calcSwapExactTokenForSy(amountToken);
|
|
738
737
|
} else {
|
|
739
738
|
return SY.previewDeposit(baseToken, amountToken);
|
|
@@ -744,10 +743,9 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
744
743
|
IStandardizedYield SY,
|
|
745
744
|
address baseToken,
|
|
746
745
|
uint256 amountSy,
|
|
747
|
-
|
|
746
|
+
address bulk
|
|
748
747
|
) public view returns (uint256 amountBaseToken) {
|
|
749
|
-
if (
|
|
750
|
-
address bulk = bulkFactory.get(baseToken, address(SY));
|
|
748
|
+
if (bulk != address(0)) {
|
|
751
749
|
return IPBulkSeller(bulk).calcSwapExactSyForToken(amountSy);
|
|
752
750
|
} else {
|
|
753
751
|
return SY.previewRedeem(baseToken, amountSy);
|
|
@@ -799,7 +797,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
799
797
|
function getAmountTokenToMintSy(
|
|
800
798
|
IStandardizedYield SY,
|
|
801
799
|
address tokenIn,
|
|
802
|
-
|
|
800
|
+
address bulk,
|
|
803
801
|
uint256 netSyOut
|
|
804
802
|
) public view returns (uint256 netTokenIn) {
|
|
805
803
|
uint256 pivotAmount = netSyOut;
|
|
@@ -807,7 +805,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
807
805
|
uint256 low = pivotAmount;
|
|
808
806
|
{
|
|
809
807
|
while (true) {
|
|
810
|
-
uint256 lowSyOut = previewDepositStatic(SY, tokenIn, low,
|
|
808
|
+
uint256 lowSyOut = previewDepositStatic(SY, tokenIn, low, bulk);
|
|
811
809
|
if (lowSyOut >= netSyOut) low /= 10;
|
|
812
810
|
else break;
|
|
813
811
|
}
|
|
@@ -816,7 +814,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
816
814
|
uint256 high = pivotAmount;
|
|
817
815
|
{
|
|
818
816
|
while (true) {
|
|
819
|
-
uint256 highSyOut = previewDepositStatic(SY, tokenIn, high,
|
|
817
|
+
uint256 highSyOut = previewDepositStatic(SY, tokenIn, high, bulk);
|
|
820
818
|
if (highSyOut < netSyOut) high *= 10;
|
|
821
819
|
else break;
|
|
822
820
|
}
|
|
@@ -824,7 +822,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
824
822
|
|
|
825
823
|
while (low <= high) {
|
|
826
824
|
uint256 mid = (low + high) / 2;
|
|
827
|
-
uint256 syOut = previewDepositStatic(SY, tokenIn, mid,
|
|
825
|
+
uint256 syOut = previewDepositStatic(SY, tokenIn, mid, bulk);
|
|
828
826
|
|
|
829
827
|
if (syOut >= netSyOut) {
|
|
830
828
|
netTokenIn = mid;
|
|
@@ -841,4 +839,21 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
841
839
|
(IStandardizedYield SY, , ) = IPMarket(market).readTokens();
|
|
842
840
|
return SY;
|
|
843
841
|
}
|
|
842
|
+
|
|
843
|
+
function getBulkSellerInfo(address token, address SY)
|
|
844
|
+
external
|
|
845
|
+
view
|
|
846
|
+
returns (
|
|
847
|
+
address bulk,
|
|
848
|
+
uint256 totalToken,
|
|
849
|
+
uint256 totalSy
|
|
850
|
+
)
|
|
851
|
+
{
|
|
852
|
+
bulk = IPBulkSellerFactory(bulkFactory).get(token, SY);
|
|
853
|
+
if (bulk != address(0)) {
|
|
854
|
+
BulkSellerState memory state = IPBulkSeller(bulk).readState();
|
|
855
|
+
totalToken = state.totalToken;
|
|
856
|
+
totalSy = state.totalSy;
|
|
857
|
+
}
|
|
858
|
+
}
|
|
844
859
|
}
|
|
@@ -12,13 +12,12 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
12
12
|
using MarketMathCore for MarketState;
|
|
13
13
|
using MarketApproxPtInLib for MarketState;
|
|
14
14
|
using MarketApproxPtOutLib for MarketState;
|
|
15
|
-
using SafeERC20 for IERC20;
|
|
16
15
|
using PYIndexLib for IPYieldToken;
|
|
17
16
|
using BulkSellerMathCore for BulkSellerState;
|
|
18
17
|
|
|
19
18
|
/// @dev since this contract will be proxied, it must not contains non-immutable variables
|
|
20
|
-
constructor(address _kyberScalingLib
|
|
21
|
-
ActionBaseMintRedeem(_kyberScalingLib
|
|
19
|
+
constructor(address _kyberScalingLib)
|
|
20
|
+
ActionBaseMintRedeem(_kyberScalingLib) //solhint-disable-next-line no-empty-blocks
|
|
22
21
|
{}
|
|
23
22
|
|
|
24
23
|
function addLiquidityDualSyAndPt(
|
|
@@ -49,8 +48,8 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
49
48
|
if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
|
|
50
49
|
|
|
51
50
|
// execute the addLiquidity
|
|
52
|
-
IERC20(SY)
|
|
53
|
-
IERC20(PT)
|
|
51
|
+
_transferFrom(IERC20(SY), msg.sender, market, netSyUsed);
|
|
52
|
+
_transferFrom(IERC20(PT), msg.sender, market, netPtUsed);
|
|
54
53
|
|
|
55
54
|
(netLpOut, , ) = IPMarket(market).mint(receiver, netSyUsed, netPtUsed);
|
|
56
55
|
|
|
@@ -100,7 +99,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
// SY has been minted and transferred to the market
|
|
103
|
-
IERC20(PT)
|
|
102
|
+
_transferFrom(IERC20(PT), msg.sender, market, netPtUsed);
|
|
104
103
|
(netLpOut, , ) = IPMarket(market).mint(receiver, netSyUsed, netPtUsed);
|
|
105
104
|
|
|
106
105
|
// fail-safe
|
|
@@ -137,7 +136,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
137
136
|
);
|
|
138
137
|
|
|
139
138
|
// execute the swap
|
|
140
|
-
IERC20(PT)
|
|
139
|
+
_transferFrom(IERC20(PT), msg.sender, market, netPtIn);
|
|
141
140
|
|
|
142
141
|
uint256 netSyReceived;
|
|
143
142
|
(netSyReceived, netSyFee) = IPMarket(market).swapExactPtForSy(
|
|
@@ -164,7 +163,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
164
163
|
(IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
165
164
|
|
|
166
165
|
// transfer SY to market
|
|
167
|
-
IERC20(SY)
|
|
166
|
+
_transferFrom(IERC20(SY), msg.sender, market, netSyIn);
|
|
168
167
|
|
|
169
168
|
// mint LP
|
|
170
169
|
(netLpOut, netSyFee) = _addLiquiditySingleSy(
|
|
@@ -218,7 +217,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
218
217
|
uint256 minSyOut,
|
|
219
218
|
uint256 minPtOut
|
|
220
219
|
) external returns (uint256 netSyOut, uint256 netPtOut) {
|
|
221
|
-
IERC20(market)
|
|
220
|
+
_transferFrom(IERC20(market), msg.sender, market, netLpToRemove);
|
|
222
221
|
|
|
223
222
|
(netSyOut, netPtOut) = IPMarket(market).burn(receiver, receiver, netLpToRemove);
|
|
224
223
|
|
|
@@ -245,7 +244,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
245
244
|
(IStandardizedYield SY, , ) = IPMarket(market).readTokens();
|
|
246
245
|
|
|
247
246
|
// burn LP, SY sent to either SY or bulk, PT sent to receiver
|
|
248
|
-
IERC20(market)
|
|
247
|
+
_transferFrom(IERC20(market), msg.sender, market, netLpToRemove);
|
|
249
248
|
|
|
250
249
|
uint256 netSyOut;
|
|
251
250
|
(netSyOut, netPtOut) = IPMarket(market).burn(
|
|
@@ -293,7 +292,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
293
292
|
revert Errors.RouterInsufficientPtOut(ptFromBurn + ptFromSwap, minPtOut);
|
|
294
293
|
|
|
295
294
|
// execute the burn & the swap
|
|
296
|
-
IERC20(market)
|
|
295
|
+
_transferFrom(IERC20(market), msg.sender, market, netLpToRemove);
|
|
297
296
|
|
|
298
297
|
(, ptFromBurn) = IPMarket(market).burn(market, receiver, netLpToRemove);
|
|
299
298
|
(, netSyFee) = IPMarket(market).swapSyForExactPt(receiver, ptFromSwap, EMPTY_BYTES);
|
|
@@ -313,7 +312,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
313
312
|
uint256 minSyOut
|
|
314
313
|
) external returns (uint256 netSyOut, uint256 netSyFee) {
|
|
315
314
|
// transfer LP to market
|
|
316
|
-
IERC20(market)
|
|
315
|
+
_transferFrom(IERC20(market), msg.sender, market, netLpToRemove);
|
|
317
316
|
|
|
318
317
|
// burn LP, SY sent to receiver
|
|
319
318
|
(netSyOut, netSyFee) = _removeLiquiditySingleSy(receiver, market, netLpToRemove, minSyOut);
|
|
@@ -330,7 +329,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
330
329
|
(IStandardizedYield SY, , ) = IPMarket(market).readTokens();
|
|
331
330
|
|
|
332
331
|
// transfer LP to market, burn LP, SY sent to either SY or bulk
|
|
333
|
-
IERC20(market)
|
|
332
|
+
_transferFrom(IERC20(market), msg.sender, market, netLpToRemove);
|
|
334
333
|
|
|
335
334
|
uint256 netSyReceived;
|
|
336
335
|
|
|
@@ -12,13 +12,9 @@ import "./base/CallbackHelper.sol";
|
|
|
12
12
|
|
|
13
13
|
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
|
14
14
|
|
|
15
|
-
contract ActionCallback is IPMarketSwapCallback, CallbackHelper {
|
|
15
|
+
contract ActionCallback is IPMarketSwapCallback, CallbackHelper, TokenHelper {
|
|
16
16
|
using Math for int256;
|
|
17
17
|
using Math for uint256;
|
|
18
|
-
using SafeERC20 for IStandardizedYield;
|
|
19
|
-
using SafeERC20 for IPYieldToken;
|
|
20
|
-
using SafeERC20 for IPPrincipalToken;
|
|
21
|
-
using SafeERC20 for IERC20;
|
|
22
18
|
using PYIndexLib for PYIndex;
|
|
23
19
|
using PYIndexLib for IPYieldToken;
|
|
24
20
|
|
|
@@ -114,7 +110,7 @@ contract ActionCallback is IPMarketSwapCallback, CallbackHelper {
|
|
|
114
110
|
/// mint & transfer
|
|
115
111
|
/// ------------------------------------------------------------
|
|
116
112
|
if (netSyToPull > 0) {
|
|
117
|
-
SY
|
|
113
|
+
_transferFrom(IERC20(SY), vars.payer, address(YT), netSyToPull);
|
|
118
114
|
}
|
|
119
115
|
|
|
120
116
|
uint256 netPyOut = YT.mintPY(market, vars.receiver);
|
|
@@ -175,7 +171,7 @@ contract ActionCallback is IPMarketSwapCallback, CallbackHelper {
|
|
|
175
171
|
|
|
176
172
|
uint256 netSyOwed = syToAccount.abs();
|
|
177
173
|
|
|
178
|
-
|
|
174
|
+
_transferOut(address(PT), address(YT), exactYtIn);
|
|
179
175
|
uint256 netSyToMarket = YT.redeemPY(market);
|
|
180
176
|
|
|
181
177
|
if (netSyToMarket < netSyOwed)
|
|
@@ -184,6 +180,6 @@ contract ActionCallback is IPMarketSwapCallback, CallbackHelper {
|
|
|
184
180
|
uint256 netPtOut = ptToAccount.Uint() - exactYtIn;
|
|
185
181
|
if (netPtOut < minPtOut) revert Errors.RouterInsufficientPtOut(netPtOut, minPtOut);
|
|
186
182
|
|
|
187
|
-
PT
|
|
183
|
+
_transferOut(address(PT), receiver, netPtOut);
|
|
188
184
|
}
|
|
189
185
|
}
|
|
@@ -10,11 +10,10 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
10
10
|
using MarketMathCore for MarketState;
|
|
11
11
|
using Math for uint256;
|
|
12
12
|
using Math for int256;
|
|
13
|
-
using SafeERC20 for IERC20;
|
|
14
13
|
|
|
15
14
|
/// @dev since this contract will be proxied, it must not contains non-immutable variables
|
|
16
|
-
constructor(address _kyberScalingLib
|
|
17
|
-
ActionBaseMintRedeem(_kyberScalingLib
|
|
15
|
+
constructor(address _kyberScalingLib)
|
|
16
|
+
ActionBaseMintRedeem(_kyberScalingLib) //solhint-disable-next-line no-empty-blocks
|
|
18
17
|
{}
|
|
19
18
|
|
|
20
19
|
function mintSyFromToken(
|
|
@@ -46,7 +45,7 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
46
45
|
address SY = IPYieldToken(YT).SY();
|
|
47
46
|
|
|
48
47
|
uint256 netSyToMint = _mintSyFromToken(YT, SY, 0, input);
|
|
49
|
-
netPyOut = _mintPyFromSy(receiver, YT,
|
|
48
|
+
netPyOut = _mintPyFromSy(receiver, YT, netSyToMint, minPyOut, false);
|
|
50
49
|
|
|
51
50
|
emit MintPyFromToken(msg.sender, receiver, YT, input.tokenIn, input.netTokenIn, netPyOut);
|
|
52
51
|
}
|
|
@@ -59,7 +58,7 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
59
58
|
) external returns (uint256 netTokenOut) {
|
|
60
59
|
address SY = IPYieldToken(YT).SY();
|
|
61
60
|
|
|
62
|
-
uint256 netSyToRedeem = _redeemPyToSy(_syOrBulk(SY, output), YT, netPyIn, 1
|
|
61
|
+
uint256 netSyToRedeem = _redeemPyToSy(_syOrBulk(SY, output), YT, netPyIn, 1);
|
|
63
62
|
netTokenOut = _redeemSyToToken(receiver, SY, netSyToRedeem, output, false);
|
|
64
63
|
|
|
65
64
|
emit RedeemPyToToken(msg.sender, receiver, YT, netPyIn, output.tokenOut, netTokenOut);
|
|
@@ -81,7 +80,7 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
81
80
|
uint256 netPyIn,
|
|
82
81
|
uint256 minSyOut
|
|
83
82
|
) external returns (uint256 netSyOut) {
|
|
84
|
-
netSyOut = _redeemPyToSy(receiver, YT, netPyIn, minSyOut
|
|
83
|
+
netSyOut = _redeemPyToSy(receiver, YT, netPyIn, minSyOut);
|
|
85
84
|
emit RedeemPyToSy(msg.sender, receiver, YT, netPyIn, netSyOut);
|
|
86
85
|
}
|
|
87
86
|
|
|
@@ -184,13 +183,14 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
184
183
|
|
|
185
184
|
// guaranteed no ETH, all rewards are ERC20
|
|
186
185
|
for (uint256 i = 0; i < tokensOut.tokens.length; ++i) {
|
|
187
|
-
|
|
186
|
+
_transferFrom(
|
|
187
|
+
IERC20(tokensOut.tokens[i]),
|
|
188
188
|
msg.sender,
|
|
189
189
|
address(this),
|
|
190
190
|
tokensOut.amounts[i]
|
|
191
191
|
);
|
|
192
192
|
}
|
|
193
|
-
_redeemAllSys(sysOut, dataYT.
|
|
193
|
+
_redeemAllSys(sysOut, dataYT.bulks, dataYT.tokenRedeemSys, tokensOut);
|
|
194
194
|
|
|
195
195
|
// now swap all to outputToken
|
|
196
196
|
netTokenOut = _swapAllToOutputToken(tokensOut, dataSwap);
|
|
@@ -221,14 +221,14 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
221
221
|
/// @dev pull SYs from users & redeem them, then add to tokensOut
|
|
222
222
|
function _redeemAllSys(
|
|
223
223
|
RouterTokenAmounts memory sys,
|
|
224
|
-
|
|
224
|
+
address[] calldata bulks,
|
|
225
225
|
address[] calldata tokenRedeemSys,
|
|
226
226
|
RouterTokenAmounts memory tokensOut
|
|
227
227
|
) internal {
|
|
228
228
|
for (uint256 i = 0; i < sys.tokens.length; ++i) {
|
|
229
229
|
if (sys.amounts[i] == 0) continue;
|
|
230
230
|
|
|
231
|
-
TokenOutput memory output = _wrapTokenOutput(tokenRedeemSys[i], 1,
|
|
231
|
+
TokenOutput memory output = _wrapTokenOutput(tokenRedeemSys[i], 1, bulks[i]);
|
|
232
232
|
uint256 amountOut = _redeemSyToToken(
|
|
233
233
|
address(this),
|
|
234
234
|
sys.tokens[i],
|
|
@@ -247,7 +247,12 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
247
247
|
) internal returns (uint256 netTokenOut) {
|
|
248
248
|
for (uint256 i = 0; i < tokens.tokens.length; ++i) {
|
|
249
249
|
if (tokens.amounts[i] == 0) continue;
|
|
250
|
-
_kyberswap(
|
|
250
|
+
_kyberswap(
|
|
251
|
+
tokens.tokens[i],
|
|
252
|
+
tokens.amounts[i],
|
|
253
|
+
dataSwap.kyberRouter,
|
|
254
|
+
dataSwap.kybercalls[i]
|
|
255
|
+
);
|
|
251
256
|
}
|
|
252
257
|
netTokenOut = _selfBalance(dataSwap.outputToken);
|
|
253
258
|
_transferOut(dataSwap.outputToken, msg.sender, netTokenOut);
|
|
@@ -12,12 +12,11 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
12
12
|
using MarketApproxPtOutLib for MarketState;
|
|
13
13
|
using Math for uint256;
|
|
14
14
|
using Math for int256;
|
|
15
|
-
using SafeERC20 for IERC20;
|
|
16
15
|
using PYIndexLib for IPYieldToken;
|
|
17
16
|
|
|
18
17
|
/// @dev since this contract will be proxied, it must not contains non-immutable variables
|
|
19
|
-
constructor(address _kyberScalingLib
|
|
20
|
-
ActionBaseMintRedeem(_kyberScalingLib
|
|
18
|
+
constructor(address _kyberScalingLib)
|
|
19
|
+
ActionBaseMintRedeem(_kyberScalingLib) //solhint-disable-next-line no-empty-blocks
|
|
21
20
|
{}
|
|
22
21
|
|
|
23
22
|
function swapExactPtForSy(
|
|
@@ -27,7 +26,7 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
27
26
|
uint256 minSyOut
|
|
28
27
|
) external returns (uint256 netSyOut, uint256 netSyFee) {
|
|
29
28
|
(, IPPrincipalToken PT, ) = IPMarket(market).readTokens();
|
|
30
|
-
IERC20(
|
|
29
|
+
_transferFrom(IERC20(PT), msg.sender, market, exactPtIn);
|
|
31
30
|
|
|
32
31
|
(netSyOut, netSyFee) = IPMarket(market).swapExactPtForSy(receiver, exactPtIn, EMPTY_BYTES);
|
|
33
32
|
|
|
@@ -59,7 +58,7 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
59
58
|
|
|
60
59
|
if (netPtIn > maxPtIn) revert Errors.RouterExceededLimitPtIn(netPtIn, maxPtIn);
|
|
61
60
|
|
|
62
|
-
IERC20(PT)
|
|
61
|
+
_transferFrom(IERC20(PT), msg.sender, market, netPtIn);
|
|
63
62
|
|
|
64
63
|
uint256 netSyOut;
|
|
65
64
|
(netSyOut, netSyFee) = IPMarket(market).swapExactPtForSy(receiver, netPtIn, EMPTY_BYTES);
|
|
@@ -83,7 +82,7 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
83
82
|
|
|
84
83
|
if (netSyIn > maxSyIn) revert Errors.RouterExceededLimitSyIn(netSyIn, maxSyIn);
|
|
85
84
|
|
|
86
|
-
IERC20(SY)
|
|
85
|
+
_transferFrom(IERC20(SY), msg.sender, market, netSyIn);
|
|
87
86
|
|
|
88
87
|
(, netSyFee) = IPMarket(market).swapSyForExactPt(receiver, exactPtOut, EMPTY_BYTES); // ignore return
|
|
89
88
|
|
|
@@ -100,7 +99,7 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
100
99
|
) external returns (uint256 netPtOut, uint256 netSyFee) {
|
|
101
100
|
(IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
102
101
|
|
|
103
|
-
IERC20(SY)
|
|
102
|
+
_transferFrom(IERC20(SY), msg.sender, market, exactSyIn);
|
|
104
103
|
|
|
105
104
|
(netPtOut, netSyFee) = _swapExactSyForPt(
|
|
106
105
|
receiver,
|
|
@@ -163,7 +162,7 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
163
162
|
) external returns (uint256 netTokenOut, uint256 netSyFee) {
|
|
164
163
|
(IStandardizedYield SY, IPPrincipalToken PT, ) = IPMarket(market).readTokens();
|
|
165
164
|
|
|
166
|
-
IERC20(
|
|
165
|
+
_transferFrom(IERC20(PT), msg.sender, market, exactPtIn);
|
|
167
166
|
|
|
168
167
|
// all output SY is directly transferred to the SY contract
|
|
169
168
|
uint256 netSyReceived;
|
|
@@ -5,17 +5,13 @@ import "../interfaces/IPActionSwapPTYT.sol";
|
|
|
5
5
|
import "../interfaces/IPMarket.sol";
|
|
6
6
|
import "./base/CallbackHelper.sol";
|
|
7
7
|
|
|
8
|
-
contract ActionSwapPTYT is IPActionSwapPTYT, CallbackHelper {
|
|
8
|
+
contract ActionSwapPTYT is IPActionSwapPTYT, CallbackHelper, TokenHelper {
|
|
9
9
|
using MarketMathCore for MarketState;
|
|
10
10
|
using MarketApproxPtInLib for MarketState;
|
|
11
11
|
using MarketApproxPtOutLib for MarketState;
|
|
12
12
|
using Math for uint256;
|
|
13
13
|
using Math for int256;
|
|
14
|
-
using SafeERC20 for IERC20;
|
|
15
14
|
using PYIndexLib for IPYieldToken;
|
|
16
|
-
using SafeERC20 for IStandardizedYield;
|
|
17
|
-
using SafeERC20 for IPYieldToken;
|
|
18
|
-
using SafeERC20 for IPPrincipalToken;
|
|
19
15
|
|
|
20
16
|
/// @dev since this contract will be proxied, it must not contains non-immutable variables
|
|
21
17
|
constructor() //solhint-disable-next-line no-empty-blocks
|
|
@@ -33,7 +29,7 @@ contract ActionSwapPTYT is IPActionSwapPTYT, CallbackHelper {
|
|
|
33
29
|
(, IPPrincipalToken PT, IPYieldToken YT) = IPMarket(market).readTokens();
|
|
34
30
|
MarketState memory state = IPMarket(market).readState();
|
|
35
31
|
|
|
36
|
-
PT
|
|
32
|
+
_transferFrom(IERC20(PT), msg.sender, market, exactPtIn);
|
|
37
33
|
|
|
38
34
|
uint256 totalPtToSwap;
|
|
39
35
|
(netYtOut, totalPtToSwap, netSyFee) = state.approxSwapExactPtForYt(
|
|
@@ -64,7 +60,7 @@ contract ActionSwapPTYT is IPActionSwapPTYT, CallbackHelper {
|
|
|
64
60
|
(, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
65
61
|
MarketState memory state = IPMarket(market).readState();
|
|
66
62
|
|
|
67
|
-
YT
|
|
63
|
+
_transferFrom(IERC20(YT), msg.sender, address(YT), exactYtIn);
|
|
68
64
|
|
|
69
65
|
uint256 totalPtSwapped;
|
|
70
66
|
(netPtOut, totalPtSwapped, netSyFee) = state.approxSwapExactYtForPt(
|
|
@@ -13,13 +13,11 @@ contract ActionSwapYT is IPActionSwapYT, ActionBaseMintRedeem, CallbackHelper {
|
|
|
13
13
|
using MarketMathCore for MarketState;
|
|
14
14
|
using MarketApproxPtInLib for MarketState;
|
|
15
15
|
using MarketApproxPtOutLib for MarketState;
|
|
16
|
-
using SafeERC20 for IStandardizedYield;
|
|
17
|
-
using SafeERC20 for IPYieldToken;
|
|
18
16
|
using PYIndexLib for IPYieldToken;
|
|
19
17
|
|
|
20
18
|
/// @dev since this contract will be proxied, it must not contains non-immutable variables
|
|
21
|
-
constructor(address _kyberScalingLib
|
|
22
|
-
ActionBaseMintRedeem(_kyberScalingLib
|
|
19
|
+
constructor(address _kyberScalingLib)
|
|
20
|
+
ActionBaseMintRedeem(_kyberScalingLib) //solhint-disable-next-line no-empty-blocks
|
|
23
21
|
{}
|
|
24
22
|
|
|
25
23
|
/**
|
|
@@ -41,7 +39,7 @@ contract ActionSwapYT is IPActionSwapYT, ActionBaseMintRedeem, CallbackHelper {
|
|
|
41
39
|
) external returns (uint256 netYtOut, uint256 netSyFee) {
|
|
42
40
|
(IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
43
41
|
|
|
44
|
-
SY
|
|
42
|
+
_transferFrom(IERC20(SY), msg.sender, address(YT), exactSyIn);
|
|
45
43
|
|
|
46
44
|
(netYtOut, netSyFee) = _swapExactSyForYt(
|
|
47
45
|
receiver,
|
|
@@ -73,7 +71,7 @@ contract ActionSwapYT is IPActionSwapYT, ActionBaseMintRedeem, CallbackHelper {
|
|
|
73
71
|
) external returns (uint256 netSyOut, uint256 netSyFee) {
|
|
74
72
|
(IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
75
73
|
|
|
76
|
-
YT
|
|
74
|
+
_transferFrom(IERC20(YT), msg.sender, address(YT), exactYtIn);
|
|
77
75
|
|
|
78
76
|
(netSyOut, netSyFee) = _swapExactYtForSy(receiver, market, SY, YT, exactYtIn, minSyOut);
|
|
79
77
|
|
|
@@ -139,7 +137,7 @@ contract ActionSwapYT is IPActionSwapYT, ActionBaseMintRedeem, CallbackHelper {
|
|
|
139
137
|
|
|
140
138
|
if (netYtIn > maxYtIn) revert Errors.RouterExceededLimitYtIn(netYtIn, maxYtIn);
|
|
141
139
|
|
|
142
|
-
YT
|
|
140
|
+
_transferFrom(IERC20(YT), msg.sender, address(YT), netYtIn);
|
|
143
141
|
|
|
144
142
|
(, netSyFee) = IPMarket(market).swapSyForExactPt(
|
|
145
143
|
address(YT),
|
|
@@ -188,7 +186,7 @@ contract ActionSwapYT is IPActionSwapYT, ActionBaseMintRedeem, CallbackHelper {
|
|
|
188
186
|
) external returns (uint256 netTokenOut, uint256 netSyFee) {
|
|
189
187
|
(IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
190
188
|
|
|
191
|
-
YT
|
|
189
|
+
_transferFrom(IERC20(YT), msg.sender, address(YT), netYtIn);
|
|
192
190
|
|
|
193
191
|
uint256 netSyOut;
|
|
194
192
|
|