@pendle/core-v2 0.7.1-beta-2 → 0.8.0-beta
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/SuperComposableYield/SCY-implementations/AaveV3/PendleAaveV3SCY.sol/PendleAaveV3SCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/PendleAaveV3SCY.sol/PendleAaveV3SCY.json +33 -17
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/WadRayMath.sol/WadRayMath.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/WadRayMath.sol/WadRayMath.json +2 -2
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.json +2 -2
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenSCY.sol/PendleQiTokenSCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenSCY.sol/PendleQiTokenSCY.json +33 -17
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleERC4626SCY.sol/PendleERC4626SCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleERC4626SCY.sol/PendleERC4626SCY.json +33 -17
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleWstEthSCY.sol/PendleWstEthSCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleWstEthSCY.sol/PendleWstEthSCY.json +33 -17
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleYearnVaultScy.sol/PendleYearnVaultSCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleYearnVaultScy.sol/PendleYearnVaultSCY.json +33 -17
- package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBase.sol/SCYBase.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBase.sol/SCYBase.json +31 -15
- package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBaseWithRewards.sol/SCYBaseWithRewards.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBaseWithRewards.sol/SCYBaseWithRewards.json +31 -15
- package/build/artifacts/contracts/core/LiquidityMining/CelerAbstracts/CelerReceiverUpg.sol/CelerReceiverUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/CelerAbstracts/CelerSenderUpg.sol/CelerSenderUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerMainchain.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerMainchain.sol/PendleGaugeControllerMainchainUpg.json +2 -2
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerSidechain.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerSidechain.sol/PendleGaugeControllerSidechainUpg.json +2 -2
- package/build/artifacts/contracts/core/LiquidityMining/PendleGauge.sol/PendleGauge.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/PendleGauge.sol/PendleGauge.json +0 -26
- package/build/artifacts/contracts/core/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.json +2 -2
- package/build/artifacts/contracts/core/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.json +2 -2
- package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.json +2 -2
- package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.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 +125 -111
- 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/PendleERC20.sol/PendleERC20.dbg.json +1 -1
- package/build/artifacts/contracts/core/PendleERC20.sol/PendleERC20.json +2 -2
- package/build/artifacts/contracts/core/PendleERC20Permit.sol/PendleERC20Permit.dbg.json +1 -1
- package/build/artifacts/contracts/core/PendleERC20Permit.sol/PendleERC20Permit.json +2 -2
- package/build/artifacts/contracts/core/PendleRouter.sol/PendleRouter.dbg.json +1 -1
- package/build/artifacts/contracts/core/PendleRouter.sol/PendleRouter.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 +77 -2
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.json +51 -20
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +72 -93
- package/build/artifacts/contracts/core/actions/ActionCallback.sol/ActionCallback.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionCallback.sol/ActionCallback.json +2 -2
- package/build/artifacts/contracts/core/actions/ActionCore.sol/ActionCore.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionCore.sol/ActionCore.json +3 -3
- package/build/artifacts/contracts/core/actions/ActionYT.sol/ActionYT.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionYT.sol/ActionYT.json +2 -2
- package/build/artifacts/contracts/core/actions/base/ActionSCYAndPTBase.sol/ActionSCYAndPTBase.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/base/ActionSCYAndPYBase.sol/ActionSCYAndPYBase.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/base/ActionSCYAndYTBase.sol/ActionSCYAndYTBase.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/base/CallbackHelper.sol/CallbackHelper.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IAToken.sol/IAToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IAavePool.sol/IAavePool.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IAaveRewardsController.sol/IAaveRewardsController.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IBenQiComptroller.sol/IBenQiComptroller.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IBenQiInterestRateModel.sol/IBenQiInterestRateModel.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ICelerMessageBus.sol/ICelerMessageBus.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ICelerMessageReceiverApp.sol/ICelerMessageReceiverApp.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IERC4626.sol/IERC4626.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IJoePair.sol/IJoePair.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IJoeRouter01.sol/IJoeRouter01.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IJoeRouter02.sol/IJoeRouter02.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionCore.sol/IPActionCore.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionCore.sol/IPActionCore.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionYT.sol/IPActionYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.json +1 -1
- package/build/artifacts/contracts/interfaces/IPGaugeController.sol/IPGaugeController.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPGaugeControllerMainchain.sol/IPGaugeControllerMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPGovernanceManager.sol/IPGovernanceManager.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPInterestManagerYT.sol/IPInterestManagerYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.json +48 -83
- package/build/artifacts/contracts/interfaces/IPMarketFactory.sol/IPMarketFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarketSwapCallback.sol/IPMarketSwapCallback.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPPermissionsV2Upg.sol/IPermissionsV2Upg.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPPrincipalToken.sol/IPPrincipalToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPRouterStatic.sol/IPRouterStatic.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVeToken.sol/IPVeToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingEscrow.sol/IPVotingEscrow.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldContractFactory.sol/IPYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldContractFactory.sol/IPYieldContractFactory.json +30 -4
- package/build/artifacts/contracts/interfaces/IPYieldToken.sol/IPYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldToken.sol/IPYieldToken.json +8 -92
- package/build/artifacts/contracts/interfaces/IQiAvax.sol/IQiAvax.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IQiErc20.sol/IQiErc20.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IQiToken.sol/IQiToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IREDACTEDStaking.sol/IREDACTEDStaking.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IRewardManager.sol/IRewardManager.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ISuperComposableYield.sol/ISuperComposableYield.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ISuperComposableYield.sol/ISuperComposableYield.json +31 -2
- package/build/artifacts/contracts/interfaces/IWETH.sol/IWETH.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IWXBTRFLY.sol/IWXBTRFLY.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IWstETH.sol/IWstETH.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IYearnVault.sol/IYearnVault.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/RewardManager.sol/RewardManager.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/RewardManagerAbstract.sol/RewardManagerAbstract.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/SCY/SCYIndex.sol/SCYIndexLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/SCY/SCYIndex.sol/SCYIndexLib.json +2 -2
- package/build/artifacts/contracts/libraries/SCY/SCYUtils.sol/SCYUtils.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/SCY/SCYUtils.sol/SCYUtils.json +2 -2
- package/build/artifacts/contracts/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/VeBalanceLib.sol/VeBalanceLib.json +2 -2
- package/build/artifacts/contracts/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/VeHistoryLib.sol/Checkpoints.json +2 -2
- package/build/artifacts/contracts/libraries/helpers/ArrayLib.sol/ArrayLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/helpers/ArrayLib.sol/ArrayLib.json +2 -2
- package/build/artifacts/contracts/libraries/helpers/ExpiryUtilsLib.sol/ExpiryUtils.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/helpers/ExpiryUtilsLib.sol/ExpiryUtils.json +2 -2
- package/build/artifacts/contracts/libraries/helpers/MiniHelpers.sol/MiniHelpers.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/helpers/MiniHelpers.sol/MiniHelpers.json +2 -2
- package/build/artifacts/contracts/libraries/helpers/SSTORE2Deployer.sol/SSTORE2Deployer.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/helpers/SSTORE2Deployer.sol/SSTORE2Deployer.json +2 -2
- package/build/artifacts/contracts/libraries/helpers/TokenHelper.sol/TokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/LogExpMath.sol/LogExpMath.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/LogExpMath.sol/LogExpMath.json +2 -2
- package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxLib.json +2 -2
- package/build/artifacts/contracts/libraries/math/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/MarketMathCore.sol/MarketMathCore.json +2 -2
- package/build/artifacts/contracts/libraries/math/Math.sol/Math.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/Math.sol/Math.json +2 -2
- package/build/artifacts/contracts/libraries/math/WeekMath.sol/WeekMath.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/WeekMath.sol/WeekMath.json +2 -2
- package/build/artifacts/contracts/libraries/solmate/SSTORE2.sol/SSTORE2.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/solmate/SSTORE2.sol/SSTORE2.json +2 -2
- package/build/artifacts/contracts/libraries/traderjoe/JoeLibrary.sol/JoeLibrary.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/traderjoe/JoeLibrary.sol/JoeLibrary.json +2 -2
- package/build/artifacts/contracts/libraries/traderjoe/PendleJoeSwapHelperUpg.sol/PendleJoeSwapHelperUpg.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +2 -2
- package/build/artifacts/contracts/periphery/PendleGovernanceManager.sol/PendleGovernanceManager.dbg.json +1 -1
- package/build/artifacts/contracts/periphery/PendleGovernanceManager.sol/PendleGovernanceManager.json +2 -2
- package/build/artifacts/contracts/periphery/PermissionsV2Upg.sol/PermissionsV2Upg.dbg.json +1 -1
- package/contracts/SuperComposableYield/SCY-implementations/AaveV3/PendleAaveV3SCY.sol +16 -12
- package/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenHelper.sol +3 -3
- package/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenSCY.sol +20 -0
- package/contracts/SuperComposableYield/SCY-implementations/PendleERC4626SCY.sol +20 -0
- package/contracts/SuperComposableYield/SCY-implementations/PendleWstEthSCY.sol +20 -0
- package/contracts/SuperComposableYield/SCY-implementations/PendleYearnVaultScy.sol +29 -2
- package/contracts/SuperComposableYield/base-implementations/SCYBase.sol +63 -41
- package/contracts/SuperComposableYield/base-implementations/SCYBaseWithRewards.sol +0 -7
- package/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol +1 -1
- package/contracts/core/LiquidityMining/PendleGauge.sol +24 -8
- package/contracts/core/LiquidityMining/VotingController/PendleVotingControllerUpg.sol +47 -96
- package/contracts/core/LiquidityMining/VotingController/VotingControllerStorageUpg.sol +86 -73
- package/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol +17 -16
- package/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol +1 -1
- package/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol +3 -4
- package/contracts/core/Market/PendleMarket.sol +32 -62
- package/contracts/core/PendleRouter.sol +1 -1
- package/contracts/core/YieldContracts/InterestManagerYT.sol +11 -8
- package/contracts/core/YieldContracts/PendlePrincipalToken.sol +3 -3
- package/contracts/core/YieldContracts/PendleYieldContractFactory.sol +18 -12
- package/contracts/core/YieldContracts/PendleYieldToken.sol +167 -140
- package/contracts/core/actions/ActionCallback.sol +11 -10
- package/contracts/core/actions/ActionCore.sol +84 -22
- package/contracts/core/actions/ActionYT.sol +33 -15
- package/contracts/core/actions/base/ActionSCYAndPTBase.sol +4 -15
- package/contracts/core/actions/base/ActionSCYAndPYBase.sol +20 -50
- package/contracts/core/actions/base/ActionSCYAndYTBase.sol +2 -12
- package/contracts/interfaces/IPActionCore.sol +72 -1
- package/contracts/interfaces/IPActionYT.sol +15 -0
- package/contracts/interfaces/IPMarket.sol +7 -26
- package/contracts/interfaces/IPVeToken.sol +0 -2
- package/contracts/interfaces/IPVotingEscrow.sol +1 -1
- package/contracts/interfaces/IPYieldContractFactory.sol +6 -2
- package/contracts/interfaces/IPYieldToken.sol +21 -11
- package/contracts/interfaces/ISuperComposableYield.sol +22 -28
- package/contracts/interfaces/IYearnVault.sol +8 -0
- package/contracts/libraries/RewardManager.sol +9 -6
- package/contracts/libraries/RewardManagerAbstract.sol +6 -8
- package/contracts/libraries/SCY/SCYIndex.sol +10 -0
- package/contracts/libraries/VeBalanceLib.sol +0 -1
- package/contracts/libraries/helpers/ArrayLib.sol +11 -0
- package/contracts/libraries/helpers/TokenHelper.sol +6 -5
- package/contracts/libraries/math/MarketApproxLib.sol +91 -36
- package/contracts/libraries/math/Math.sol +2 -4
- package/contracts/offchain-helpers/RouterStatic.sol +2 -2
- package/deployments/43113-core.json +11 -11
- package/deployments/43113-markets/benqi-market-0xF3150c14F776c50C9D397054d38979c7B77FC41D.json +7 -0
- package/deployments/80001-core.json +10 -10
- package/deployments/80001-markets/benqi-market-0x150b6eb90Bf636eC0c4328d13d1e1d4adDBAF904.json +7 -0
- package/package.json +2 -2
- package/typechain-types/ActionCore.ts +8 -8
- package/typechain-types/CelerReceiver.ts +267 -0
- package/typechain-types/CelerSender.ts +164 -0
- package/typechain-types/IPActionCore.ts +8 -8
- package/typechain-types/IPAllAction.ts +8 -8
- package/typechain-types/IPMarket.ts +66 -109
- package/typechain-types/IPVotingEscrowController.ts +154 -0
- package/typechain-types/IPYieldContractFactory.ts +34 -0
- package/typechain-types/IPYieldToken.ts +12 -112
- package/typechain-types/ISuperComposableYield.ts +54 -10
- package/typechain-types/PendleAaveV3SCY.ts +54 -29
- package/typechain-types/PendleBtrflyScy.ts +56 -58
- package/typechain-types/PendleERC4626SCY.ts +54 -29
- package/typechain-types/PendleGauge.ts +0 -32
- package/typechain-types/PendleGaugeController.ts +282 -0
- package/typechain-types/PendleGaugeControllerMainchain.ts +346 -0
- package/typechain-types/PendleGaugeControllerSidechain.ts +460 -0
- package/typechain-types/PendleJoeLpSCY.ts +56 -58
- package/typechain-types/PendleMarket.ts +169 -140
- package/typechain-types/PendlePrincipalToken.ts +104 -0
- package/typechain-types/PendleQiTokenSCY.ts +54 -29
- package/typechain-types/PendleVotingController.ts +865 -0
- package/typechain-types/PendleWstEthSCY.ts +54 -29
- package/typechain-types/PendleYearnVaultSCY.ts +54 -29
- package/typechain-types/PendleYieldContractFactory.ts +66 -19
- package/typechain-types/PendleYieldToken.ts +122 -158
- package/typechain-types/SCYBase.ts +54 -29
- package/typechain-types/SCYBaseWithRewards.ts +54 -29
- package/typechain-types/VotingControllerStorage.ts +410 -0
- package/typechain-types/VotingEscrowController.ts +154 -0
- package/typechain-types/VotingEscrowToken.ts +335 -0
- package/typechain-types/factories/ActionCallback__factory.ts +1 -1
- package/typechain-types/factories/ActionCore__factory.ts +2 -2
- package/typechain-types/factories/ActionYT__factory.ts +1 -1
- package/typechain-types/factories/CelerReceiver__factory.ts +140 -0
- package/typechain-types/factories/CelerSender__factory.ts +67 -0
- package/typechain-types/factories/ERC20__factory.ts +1 -1
- package/typechain-types/factories/IPActionCore__factory.ts +1 -1
- package/typechain-types/factories/IPAllAction__factory.ts +1 -1
- package/typechain-types/factories/IPMarket__factory.ts +48 -83
- package/typechain-types/factories/IPVotingEscrowController__factory.ts +80 -0
- package/typechain-types/factories/IPYieldContractFactory__factory.ts +30 -4
- package/typechain-types/factories/IPYieldToken__factory.ts +6 -90
- package/typechain-types/factories/ISuperComposableYield__factory.ts +31 -2
- package/typechain-types/factories/PendleAaveV3SCY__factory.ts +32 -16
- package/typechain-types/factories/PendleBtrflyScy__factory.ts +52 -28
- package/typechain-types/factories/PendleERC20Permit__factory.ts +1 -1
- package/typechain-types/factories/PendleERC20__factory.ts +1 -1
- package/typechain-types/factories/PendleERC4626SCY__factory.ts +32 -16
- package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleGaugeControllerMainchain__factory.ts +269 -0
- package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleGaugeControllerSidechain__factory.ts +328 -0
- package/typechain-types/factories/PendleGaugeController__factory.ts +149 -0
- package/typechain-types/factories/PendleGauge__factory.ts +0 -26
- package/typechain-types/factories/PendleGovernanceManager__factory.ts +1 -1
- package/typechain-types/factories/PendleJoeLpSCY__factory.ts +34 -28
- package/typechain-types/factories/PendleMarketFactory__factory.ts +1 -1
- package/typechain-types/factories/PendleMarket__factory.ts +124 -110
- package/typechain-types/factories/PendlePrincipalToken__factory.ts +76 -1
- package/typechain-types/factories/PendleQiTokenHelper__factory.ts +1 -1
- package/typechain-types/factories/PendleQiTokenSCY__factory.ts +32 -16
- package/typechain-types/factories/PendleRouter__factory.ts +1 -1
- package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleVotingController__factory.ts +584 -0
- package/typechain-types/factories/PendleWstEthSCY__factory.ts +32 -16
- package/typechain-types/factories/PendleYearnVaultSCY__factory.ts +32 -16
- package/typechain-types/factories/PendleYieldContractFactory__factory.ts +54 -19
- package/typechain-types/factories/PendleYieldToken__factory.ts +70 -91
- package/typechain-types/factories/RouterStatic__factory.ts +1 -1
- package/typechain-types/factories/SCYBaseWithRewards__factory.ts +31 -15
- package/typechain-types/factories/SCYBase__factory.ts +31 -15
- package/typechain-types/factories/VotingControllerStorage__factory.ts +298 -0
- package/typechain-types/factories/VotingEscrowController__factory.ts +80 -0
- package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +1 -1
- package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +1 -1
- package/typechain-types/factories/VotingEscrowToken__factory.ts +225 -0
- package/typechain-types/hardhat.d.ts +0 -27
- package/typechain-types/index.ts +0 -6
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleBtrflySCY.sol/PendleBtrflyScy.dbg.json +0 -4
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleBtrflySCY.sol/PendleBtrflyScy.json +0 -635
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleJoeLpSCY.sol/PendleJoeLpSCY.dbg.json +0 -4
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleJoeLpSCY.sol/PendleJoeLpSCY.json +0 -653
- package/build/artifacts/contracts/interfaces/IPMarketAddRemoveCallback.sol/IPMarketAddRemoveCallback.dbg.json +0 -4
- package/build/artifacts/contracts/interfaces/IPMarketAddRemoveCallback.sol/IPMarketAddRemoveCallback.json +0 -67
- package/build/artifacts/contracts/libraries/solmate/Bytes32AddressLib.sol/Bytes32AddressLib.dbg.json +0 -4
- package/build/artifacts/contracts/libraries/solmate/Bytes32AddressLib.sol/Bytes32AddressLib.json +0 -10
- package/contracts/SuperComposableYield/SCY-implementations/PendleBtrflySCY.sol +0 -123
- package/contracts/SuperComposableYield/SCY-implementations/PendleJoeLpSCY.sol +0 -245
- package/contracts/interfaces/IPMarketAddRemoveCallback.sol +0 -18
- package/contracts/libraries/solmate/Bytes32AddressLib.sol +0 -14
- package/deployments/43113-markets/benqi-market.json +0 -7
- package/deployments/80001-markets/benqi-market.json +0 -7
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"_format": "hh-sol-artifact-1",
|
|
3
|
-
"contractName": "IPMarketAddRemoveCallback",
|
|
4
|
-
"sourceName": "contracts/interfaces/IPMarketAddRemoveCallback.sol",
|
|
5
|
-
"abi": [
|
|
6
|
-
{
|
|
7
|
-
"inputs": [
|
|
8
|
-
{
|
|
9
|
-
"internalType": "uint256",
|
|
10
|
-
"name": "lpToAccount",
|
|
11
|
-
"type": "uint256"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"internalType": "uint256",
|
|
15
|
-
"name": "scyUsed",
|
|
16
|
-
"type": "uint256"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"internalType": "uint256",
|
|
20
|
-
"name": "ptUsed",
|
|
21
|
-
"type": "uint256"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"internalType": "bytes",
|
|
25
|
-
"name": "data",
|
|
26
|
-
"type": "bytes"
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
"name": "addLiquidityCallback",
|
|
30
|
-
"outputs": [],
|
|
31
|
-
"stateMutability": "nonpayable",
|
|
32
|
-
"type": "function"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"inputs": [
|
|
36
|
-
{
|
|
37
|
-
"internalType": "uint256",
|
|
38
|
-
"name": "lpOwed",
|
|
39
|
-
"type": "uint256"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"internalType": "uint256",
|
|
43
|
-
"name": "scyToAccount",
|
|
44
|
-
"type": "uint256"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"internalType": "uint256",
|
|
48
|
-
"name": "ptToAccount",
|
|
49
|
-
"type": "uint256"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"internalType": "bytes",
|
|
53
|
-
"name": "data",
|
|
54
|
-
"type": "bytes"
|
|
55
|
-
}
|
|
56
|
-
],
|
|
57
|
-
"name": "removeLiquidityCallback",
|
|
58
|
-
"outputs": [],
|
|
59
|
-
"stateMutability": "nonpayable",
|
|
60
|
-
"type": "function"
|
|
61
|
-
}
|
|
62
|
-
],
|
|
63
|
-
"bytecode": "0x",
|
|
64
|
-
"deployedBytecode": "0x",
|
|
65
|
-
"linkReferences": {},
|
|
66
|
-
"deployedLinkReferences": {}
|
|
67
|
-
}
|
package/build/artifacts/contracts/libraries/solmate/Bytes32AddressLib.sol/Bytes32AddressLib.json
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"_format": "hh-sol-artifact-1",
|
|
3
|
-
"contractName": "Bytes32AddressLib",
|
|
4
|
-
"sourceName": "contracts/libraries/solmate/Bytes32AddressLib.sol",
|
|
5
|
-
"abi": [],
|
|
6
|
-
"bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220bd83a6ed0f6a6cb1411148557218ce05367c955a2b8660f2b004f54ebed2915f64736f6c634300080f0033",
|
|
7
|
-
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220bd83a6ed0f6a6cb1411148557218ce05367c955a2b8660f2b004f54ebed2915f64736f6c634300080f0033",
|
|
8
|
-
"linkReferences": {},
|
|
9
|
-
"deployedLinkReferences": {}
|
|
10
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
-
pragma solidity 0.8.15;
|
|
3
|
-
|
|
4
|
-
import "../base-implementations/SCYBase.sol";
|
|
5
|
-
import "../../interfaces/IWXBTRFLY.sol";
|
|
6
|
-
import "../../interfaces/IREDACTEDStaking.sol";
|
|
7
|
-
|
|
8
|
-
contract PendleBtrflyScy is SCYBase {
|
|
9
|
-
address public immutable BTRFLY;
|
|
10
|
-
address public immutable xBTRFLY;
|
|
11
|
-
address public immutable wxBTRFLY;
|
|
12
|
-
|
|
13
|
-
constructor(
|
|
14
|
-
string memory _name,
|
|
15
|
-
string memory _symbol,
|
|
16
|
-
address _wxBTRFLY
|
|
17
|
-
) SCYBase(_name, _symbol, _wxBTRFLY) {
|
|
18
|
-
require(_wxBTRFLY != address(0), "zero address");
|
|
19
|
-
wxBTRFLY = _wxBTRFLY;
|
|
20
|
-
BTRFLY = IWXBTRFLY(wxBTRFLY).BTRFLY();
|
|
21
|
-
xBTRFLY = IWXBTRFLY(wxBTRFLY).xBTRFLY();
|
|
22
|
-
|
|
23
|
-
_safeApprove(BTRFLY, wxBTRFLY, type(uint256).max);
|
|
24
|
-
_safeApprove(xBTRFLY, wxBTRFLY, type(uint256).max);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/*///////////////////////////////////////////////////////////////
|
|
28
|
-
DEPOSIT/REDEEM USING BASE TOKENS
|
|
29
|
-
//////////////////////////////////////////////////////////////*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @dev See {SCYBase-_deposit}
|
|
33
|
-
*
|
|
34
|
-
* The underlying yield token is wxBTRFLY. If the base token is not said token, the contract
|
|
35
|
-
* first wraps from `tokenIn` to wxBRTRFLY. Then the corresponding amount of shares is returned.
|
|
36
|
-
*
|
|
37
|
-
* The exchange rate of wxBTRFLY to shares is 1:1
|
|
38
|
-
*/
|
|
39
|
-
function _deposit(address tokenIn, uint256 amountDeposited)
|
|
40
|
-
internal
|
|
41
|
-
virtual
|
|
42
|
-
override
|
|
43
|
-
returns (uint256 amountSharesOut)
|
|
44
|
-
{
|
|
45
|
-
if (tokenIn == wxBTRFLY) {
|
|
46
|
-
amountSharesOut = amountDeposited;
|
|
47
|
-
} else if (tokenIn == xBTRFLY) {
|
|
48
|
-
// wrapFromxBTRFLY returns amountWXBTRFLYout
|
|
49
|
-
amountSharesOut = IWXBTRFLY(wxBTRFLY).wrapFromxBTRFLY(amountDeposited);
|
|
50
|
-
} else {
|
|
51
|
-
// must be BTRFLY
|
|
52
|
-
// wrapFromBTRFLY returns amountWXBTRFLYout
|
|
53
|
-
amountSharesOut = IWXBTRFLY(wxBTRFLY).wrapFromBTRFLY(amountDeposited);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* @dev See {SCYBase-_redeem}
|
|
59
|
-
*
|
|
60
|
-
* The shares are redeemed into the same amount of wxBTRFLY. If `tokenOut` is not wxBTRFLY
|
|
61
|
-
* the function unwraps said amount of wxBTRFLY into `tokenOut` for redemption.
|
|
62
|
-
*/
|
|
63
|
-
function _redeem(address tokenOut, uint256 amountSharesToRedeem)
|
|
64
|
-
internal
|
|
65
|
-
virtual
|
|
66
|
-
override
|
|
67
|
-
returns (uint256 amountTokenOut)
|
|
68
|
-
{
|
|
69
|
-
if (tokenOut == wxBTRFLY) {
|
|
70
|
-
amountTokenOut = amountSharesToRedeem;
|
|
71
|
-
} else if (tokenOut == xBTRFLY) {
|
|
72
|
-
amountTokenOut = IWXBTRFLY(wxBTRFLY).unwrapToxBTRFLY(amountSharesToRedeem);
|
|
73
|
-
} else {
|
|
74
|
-
// must be BTRFLY
|
|
75
|
-
amountTokenOut = IWXBTRFLY(wxBTRFLY).unwrapToBTRFLY(amountSharesToRedeem);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/*///////////////////////////////////////////////////////////////
|
|
80
|
-
EXCHANGE-RATE
|
|
81
|
-
//////////////////////////////////////////////////////////////*/
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* @notice Calculates and updates the exchange rate of shares to underlying asset token
|
|
85
|
-
* @dev It is the conversion rate of wxBTRFLY to BTRFLY
|
|
86
|
-
*/
|
|
87
|
-
function exchangeRate() public view virtual override returns (uint256) {
|
|
88
|
-
return IWXBTRFLY(wxBTRFLY).xBTRFLYValue(Math.ONE);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/*///////////////////////////////////////////////////////////////
|
|
92
|
-
MISC FUNCTIONS FOR METADATA
|
|
93
|
-
//////////////////////////////////////////////////////////////*/
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* @dev See {ISuperComposableYield-getBaseTokens}
|
|
97
|
-
*/
|
|
98
|
-
function getBaseTokens() public view virtual override returns (address[] memory res) {
|
|
99
|
-
res = new address[](3);
|
|
100
|
-
res[0] = BTRFLY;
|
|
101
|
-
res[1] = xBTRFLY;
|
|
102
|
-
res[2] = wxBTRFLY;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* @dev See {ISuperComposableYield-isValidBaseToken}
|
|
107
|
-
*/
|
|
108
|
-
function isValidBaseToken(address token) public view virtual override returns (bool) {
|
|
109
|
-
return token == BTRFLY || token == xBTRFLY || token == wxBTRFLY;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function assetInfo()
|
|
113
|
-
external
|
|
114
|
-
view
|
|
115
|
-
returns (
|
|
116
|
-
AssetType assetType,
|
|
117
|
-
address assetAddress,
|
|
118
|
-
uint8 assetDecimals
|
|
119
|
-
)
|
|
120
|
-
{
|
|
121
|
-
return (AssetType.TOKEN, BTRFLY, IERC20Metadata(BTRFLY).decimals());
|
|
122
|
-
}
|
|
123
|
-
}
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
-
pragma solidity 0.8.15;
|
|
3
|
-
|
|
4
|
-
import "../../interfaces/IJoePair.sol";
|
|
5
|
-
import "../../interfaces/IJoeRouter02.sol";
|
|
6
|
-
import "../base-implementations/SCYBase.sol";
|
|
7
|
-
import "../../libraries/math/LogExpMath.sol";
|
|
8
|
-
|
|
9
|
-
contract PendleJoeLpSCY is SCYBase {
|
|
10
|
-
using Math for uint256;
|
|
11
|
-
|
|
12
|
-
address public immutable joeRouter;
|
|
13
|
-
address public immutable joePair;
|
|
14
|
-
address public immutable token0;
|
|
15
|
-
address public immutable token1;
|
|
16
|
-
|
|
17
|
-
constructor(
|
|
18
|
-
string memory _name,
|
|
19
|
-
string memory _symbol,
|
|
20
|
-
address _joeRouter,
|
|
21
|
-
address _joePair
|
|
22
|
-
) SCYBase(_name, _symbol, _joePair) {
|
|
23
|
-
require(_joeRouter != address(0), "zero address");
|
|
24
|
-
joeRouter = _joeRouter;
|
|
25
|
-
joePair = _joePair;
|
|
26
|
-
token0 = IJoePair(joePair).token0();
|
|
27
|
-
token1 = IJoePair(joePair).token1();
|
|
28
|
-
_safeApprove(token0, joeRouter, type(uint256).max);
|
|
29
|
-
_safeApprove(token1, joeRouter, type(uint256).max);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/*///////////////////////////////////////////////////////////////
|
|
33
|
-
DEPOSIT/REDEEM USING BASE TOKENS
|
|
34
|
-
//////////////////////////////////////////////////////////////*/
|
|
35
|
-
|
|
36
|
-
function _deposit(address tokenIn, uint256 amount)
|
|
37
|
-
internal
|
|
38
|
-
override
|
|
39
|
-
returns (uint256 amountSharesOut)
|
|
40
|
-
{
|
|
41
|
-
if (tokenIn == joePair) {
|
|
42
|
-
amountSharesOut = amount;
|
|
43
|
-
} else {
|
|
44
|
-
amountSharesOut = _performZapIn(tokenIn, amount);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function _redeem(address tokenOut, uint256 amountSharesToRedeem)
|
|
49
|
-
internal
|
|
50
|
-
override
|
|
51
|
-
returns (uint256 amountBaseOut)
|
|
52
|
-
{
|
|
53
|
-
if (tokenOut == joePair) {
|
|
54
|
-
amountBaseOut = amountSharesToRedeem;
|
|
55
|
-
} else {
|
|
56
|
-
amountBaseOut = _performZapOut(tokenOut, amountSharesToRedeem);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/*///////////////////////////////////////////////////////////////
|
|
61
|
-
EXCHANGE-RATE
|
|
62
|
-
//////////////////////////////////////////////////////////////*/
|
|
63
|
-
|
|
64
|
-
function exchangeRate() public view override returns (uint256) {
|
|
65
|
-
(uint256 reserve0, uint256 reserve1, ) = IJoePair(joePair).getReserves();
|
|
66
|
-
|
|
67
|
-
// K = sqrt(reserve0 * reserve1) = pow(reserve0*reserve1, 0.5)
|
|
68
|
-
uint256 currentK = LogExpMath.pow(reserve0 * reserve1, uint256(LogExpMath.ONE_18 / 2));
|
|
69
|
-
uint256 totalSupply = IJoePair(joePair).totalSupply();
|
|
70
|
-
return currentK.divDown(totalSupply);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/*///////////////////////////////////////////////////////////////
|
|
74
|
-
MISC FUNCTIONS FOR METADATA
|
|
75
|
-
//////////////////////////////////////////////////////////////*/
|
|
76
|
-
|
|
77
|
-
function getBaseTokens() public view override returns (address[] memory res) {
|
|
78
|
-
res = new address[](3);
|
|
79
|
-
res[0] = token0;
|
|
80
|
-
res[1] = token1;
|
|
81
|
-
res[2] = joePair;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function isValidBaseToken(address token) public view override returns (bool res) {
|
|
85
|
-
res = (token == token0 || token == token1 || token == joePair);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function assetInfo()
|
|
89
|
-
external
|
|
90
|
-
view
|
|
91
|
-
returns (
|
|
92
|
-
AssetType assetType,
|
|
93
|
-
address assetAddress,
|
|
94
|
-
uint8 assetDecimals
|
|
95
|
-
)
|
|
96
|
-
{
|
|
97
|
-
return (AssetType.LIQUIDITY, joePair, IERC20Metadata(joePair).decimals());
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/*///////////////////////////////////////////////////////////////
|
|
101
|
-
ZAPPING IN/OUT USING ZAPPER'S ALGORITHMS
|
|
102
|
-
//////////////////////////////////////////////////////////////*/
|
|
103
|
-
|
|
104
|
-
function _performZapIn(address fromToken, uint256 amount) internal returns (uint256) {
|
|
105
|
-
require(fromToken == token0 || fromToken == token1, "Invalid fromToken");
|
|
106
|
-
// divide intermediate into appropriate amount to add liquidity
|
|
107
|
-
(uint256 token0Bought, uint256 token1Bought) = _swapIntermediate(fromToken, amount);
|
|
108
|
-
|
|
109
|
-
return _joeAddLiquidity(token0Bought, token1Bought, true);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function _performZapOut(address toToken, uint256 lpToRemove) internal returns (uint256) {
|
|
113
|
-
(uint256 token0Received, uint256 token1Received) = _joeRemoveLiquidity(lpToRemove);
|
|
114
|
-
|
|
115
|
-
if (toToken == token0) {
|
|
116
|
-
uint256 token0FromSwap = _token2Token(token1, token0, token1Received);
|
|
117
|
-
return token0Received + token0FromSwap;
|
|
118
|
-
} else {
|
|
119
|
-
uint256 token1FromSwap = _token2Token(token0, token1, token0Received);
|
|
120
|
-
return token1Received + token1FromSwap;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function _swapIntermediate(address fromToken, uint256 amount)
|
|
125
|
-
internal
|
|
126
|
-
returns (uint256 token0Bought, uint256 token1Bought)
|
|
127
|
-
{
|
|
128
|
-
(uint256 res0, uint256 res1, ) = IJoePair(joePair).getReserves();
|
|
129
|
-
if (fromToken == token0) {
|
|
130
|
-
uint256 amountToSwap = calculateSwapInAmount(res0, amount);
|
|
131
|
-
//if no reserve or a new pair is created
|
|
132
|
-
if (amountToSwap <= 0) amountToSwap = amount / 2;
|
|
133
|
-
token1Bought = _token2Token(fromToken, token1, amountToSwap);
|
|
134
|
-
token0Bought = amount - amountToSwap;
|
|
135
|
-
} else {
|
|
136
|
-
uint256 amountToSwap = calculateSwapInAmount(res1, amount);
|
|
137
|
-
//if no reserve or a new pair is created
|
|
138
|
-
if (amountToSwap <= 0) amountToSwap = amount / 2;
|
|
139
|
-
token0Bought = _token2Token(fromToken, token0, amountToSwap);
|
|
140
|
-
token1Bought = amount - amountToSwap;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function _joeAddLiquidity(
|
|
145
|
-
uint256 token0Bought,
|
|
146
|
-
uint256 token1Bought,
|
|
147
|
-
bool transferResidual
|
|
148
|
-
) internal returns (uint256) {
|
|
149
|
-
(uint256 amountA, uint256 amountB, uint256 LP) = IJoeRouter02(joeRouter).addLiquidity(
|
|
150
|
-
token0,
|
|
151
|
-
token1,
|
|
152
|
-
token0Bought,
|
|
153
|
-
token1Bought,
|
|
154
|
-
1,
|
|
155
|
-
1,
|
|
156
|
-
address(this),
|
|
157
|
-
type(uint256).max
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
if (transferResidual) {
|
|
161
|
-
//Returning Residue in token0, if any.
|
|
162
|
-
if (token0Bought - amountA > 0) {
|
|
163
|
-
_transferOut(token0, msg.sender, token0Bought - amountA);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
//Returning Residue in token1, if any
|
|
167
|
-
if (token1Bought - amountB > 0) {
|
|
168
|
-
_transferOut(token1, msg.sender, token1Bought - amountB);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return LP;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function _joeRemoveLiquidity(uint256 lpToRemove)
|
|
176
|
-
internal
|
|
177
|
-
returns (uint256 token0Received, uint256 token1Received)
|
|
178
|
-
{
|
|
179
|
-
(token0Received, token1Received) = IJoeRouter02(joeRouter).removeLiquidity(
|
|
180
|
-
token0,
|
|
181
|
-
token1,
|
|
182
|
-
lpToRemove,
|
|
183
|
-
1,
|
|
184
|
-
1,
|
|
185
|
-
address(this),
|
|
186
|
-
type(uint256).max
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function calculateSwapInAmount(uint256 reserveIn, uint256 userIn)
|
|
191
|
-
internal
|
|
192
|
-
pure
|
|
193
|
-
returns (uint256)
|
|
194
|
-
{
|
|
195
|
-
return
|
|
196
|
-
(_babylonianSqrt(reserveIn * ((userIn * 3988000) + (reserveIn * 3988009))) -
|
|
197
|
-
(reserveIn * 1997)) / 1994;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function _babylonianSqrt(uint256 y) internal pure returns (uint256 z) {
|
|
201
|
-
if (y > 3) {
|
|
202
|
-
z = y;
|
|
203
|
-
uint256 x = y / 2 + 1;
|
|
204
|
-
while (x < z) {
|
|
205
|
-
z = x;
|
|
206
|
-
x = (y / x + x) / 2;
|
|
207
|
-
}
|
|
208
|
-
} else if (y != 0) {
|
|
209
|
-
z = 1;
|
|
210
|
-
}
|
|
211
|
-
// else z = 0
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
@notice This function is used to swap ERC20 <> ERC20
|
|
216
|
-
@param fromToken The token address to swap from.
|
|
217
|
-
@param toToken The token address to swap to.
|
|
218
|
-
@param tokens2Trade The amount of tokens to swap
|
|
219
|
-
@return tokenBought The quantity of tokens bought
|
|
220
|
-
*/
|
|
221
|
-
function _token2Token(
|
|
222
|
-
address fromToken,
|
|
223
|
-
address toToken,
|
|
224
|
-
uint256 tokens2Trade
|
|
225
|
-
) internal returns (uint256 tokenBought) {
|
|
226
|
-
if (fromToken == toToken) {
|
|
227
|
-
return tokens2Trade;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
require(joePair != address(0), "No Swap Available");
|
|
231
|
-
address[] memory path = new address[](2);
|
|
232
|
-
path[0] = fromToken;
|
|
233
|
-
path[1] = toToken;
|
|
234
|
-
|
|
235
|
-
tokenBought = IJoeRouter02(joeRouter).swapExactTokensForTokens(
|
|
236
|
-
tokens2Trade,
|
|
237
|
-
1,
|
|
238
|
-
path,
|
|
239
|
-
address(this),
|
|
240
|
-
type(uint256).max
|
|
241
|
-
)[path.length - 1];
|
|
242
|
-
|
|
243
|
-
require(tokenBought > 0, "Error Swapping Tokens 2");
|
|
244
|
-
}
|
|
245
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
-
pragma solidity 0.8.15;
|
|
3
|
-
|
|
4
|
-
interface IPMarketAddRemoveCallback {
|
|
5
|
-
function addLiquidityCallback(
|
|
6
|
-
uint256 lpToAccount,
|
|
7
|
-
uint256 scyUsed,
|
|
8
|
-
uint256 ptUsed,
|
|
9
|
-
bytes calldata data
|
|
10
|
-
) external;
|
|
11
|
-
|
|
12
|
-
function removeLiquidityCallback(
|
|
13
|
-
uint256 lpOwed,
|
|
14
|
-
uint256 scyToAccount,
|
|
15
|
-
uint256 ptToAccount,
|
|
16
|
-
bytes calldata data
|
|
17
|
-
) external;
|
|
18
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
-
pragma solidity >=0.8.0;
|
|
3
|
-
|
|
4
|
-
/// @notice Library for converting between addresses and bytes32 values.
|
|
5
|
-
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/Bytes32AddressLib.sol)
|
|
6
|
-
library Bytes32AddressLib {
|
|
7
|
-
function fromLast20Bytes(bytes32 bytesValue) internal pure returns (address) {
|
|
8
|
-
return address(uint160(uint256(bytesValue)));
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function fillLast12Bytes(address addressValue) internal pure returns (bytes32) {
|
|
12
|
-
return bytes32(bytes20(addressValue));
|
|
13
|
-
}
|
|
14
|
-
}
|