Feature Tip: Add private address tag to any address under My Name Tag !
More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 25 from a total of 109 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Approve | 21213828 | 9 hrs ago | IN | 0 ETH | 0.00051131 | ||||
Transfer | 21205619 | 36 hrs ago | IN | 0 ETH | 0.00070674 | ||||
Transfer | 21205615 | 36 hrs ago | IN | 0 ETH | 0.00084564 | ||||
Transfer | 21205613 | 36 hrs ago | IN | 0 ETH | 0.00081057 | ||||
Transfer | 21205612 | 36 hrs ago | IN | 0 ETH | 0.00080146 | ||||
Transfer | 21205611 | 36 hrs ago | IN | 0 ETH | 0.00080897 | ||||
Transfer | 21205609 | 36 hrs ago | IN | 0 ETH | 0.00078344 | ||||
Transfer | 21205608 | 36 hrs ago | IN | 0 ETH | 0.00076543 | ||||
Transfer | 21205606 | 36 hrs ago | IN | 0 ETH | 0.00076553 | ||||
Transfer | 21205604 | 36 hrs ago | IN | 0 ETH | 0.00081951 | ||||
Transfer | 21205603 | 36 hrs ago | IN | 0 ETH | 0.00082353 | ||||
Transfer | 21203478 | 44 hrs ago | IN | 0 ETH | 0.00091159 | ||||
Transfer | 21203470 | 44 hrs ago | IN | 0 ETH | 0.00092734 | ||||
Transfer | 21203439 | 44 hrs ago | IN | 0 ETH | 0.00093522 | ||||
Transfer | 21203431 | 44 hrs ago | IN | 0 ETH | 0.00093793 | ||||
Transfer | 21203426 | 44 hrs ago | IN | 0 ETH | 0.00093357 | ||||
Transfer | 21203376 | 44 hrs ago | IN | 0 ETH | 0.00053863 | ||||
Transfer | 21203363 | 44 hrs ago | IN | 0 ETH | 0.00095497 | ||||
Transfer | 21203306 | 44 hrs ago | IN | 0 ETH | 0.00083771 | ||||
Transfer | 21203290 | 44 hrs ago | IN | 0 ETH | 0.00092584 | ||||
Transfer | 21203270 | 44 hrs ago | IN | 0 ETH | 0.00102358 | ||||
Transfer | 21190743 | 3 days ago | IN | 0 ETH | 0.00137833 | ||||
Approve | 21186929 | 4 days ago | IN | 0 ETH | 0.00070005 | ||||
Approve | 21125891 | 12 days ago | IN | 0 ETH | 0.00295127 | ||||
Approve | 21120061 | 13 days ago | IN | 0 ETH | 0.00026442 |
Latest 1 internal transaction
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
20824952 | 54 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x719B51Dd...BF58f1D7A The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
PendleYieldToken
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 1000000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "../../interfaces/IStandardizedYield.sol"; import "../../interfaces/IPYieldToken.sol"; import "../../interfaces/IPPrincipalToken.sol"; import "../libraries/math/PMath.sol"; import "../libraries/ArrayLib.sol"; import "../../interfaces/IPYieldContractFactory.sol"; import "../StandardizedYield/SYUtils.sol"; import "../libraries/Errors.sol"; import "../libraries/MiniHelpers.sol"; import "../RewardManager/RewardManagerAbstract.sol"; import "../erc20/PendleERC20.sol"; import "./InterestManagerYT.sol"; /** Invariance to maintain: - address(0) & address(this) should never have any rewards & activeBalance accounting done. This is guaranteed by address(0) & address(this) check in each updateForTwo function */ contract PendleYieldToken is IPYieldToken, PendleERC20, RewardManagerAbstract, InterestManagerYT { using PMath for uint256; using SafeERC20 for IERC20; using ArrayLib for uint256[]; struct PostExpiryData { uint128 firstPYIndex; uint128 totalSyInterestForTreasury; mapping(address => uint256) firstRewardIndex; mapping(address => uint256) userRewardOwed; } address public immutable SY; address public immutable PT; address public immutable factory; uint256 public immutable expiry; bool public immutable doCacheIndexSameBlock; uint256 public syReserve; uint128 public pyIndexLastUpdatedBlock; uint128 internal _pyIndexStored; PostExpiryData public postExpiry; modifier updateData() { if (isExpired()) _setPostExpiryData(); _; _updateSyReserve(); } modifier notExpired() { if (isExpired()) revert Errors.YCExpired(); _; } /** * @param _doCacheIndexSameBlock if true, the PY index is cached for each block, and thus is * constant for all txs within the same block. Otherwise, the PY index is recalculated for * every tx. */ constructor( address _SY, address _PT, string memory _name, string memory _symbol, uint8 __decimals, uint256 _expiry, bool _doCacheIndexSameBlock ) PendleERC20(_name, _symbol, __decimals) { SY = _SY; PT = _PT; expiry = _expiry; factory = msg.sender; doCacheIndexSameBlock = _doCacheIndexSameBlock; } /** * @notice Tokenize SY into PT + YT of equal qty. Every unit of asset of SY will create 1 PT + 1 YT * @dev SY must be transferred to this contract prior to calling */ function mintPY( address receiverPT, address receiverYT ) external nonReentrant notExpired updateData returns (uint256 amountPYOut) { address[] memory receiverPTs = new address[](1); address[] memory receiverYTs = new address[](1); uint256[] memory amountSyToMints = new uint256[](1); (receiverPTs[0], receiverYTs[0], amountSyToMints[0]) = (receiverPT, receiverYT, _getFloatingSyAmount()); uint256[] memory amountPYOuts = _mintPY(receiverPTs, receiverYTs, amountSyToMints); amountPYOut = amountPYOuts[0]; } /// @notice Tokenize SY into PT + YT for multiple receivers. See `mintPY()` for more details function mintPYMulti( address[] calldata receiverPTs, address[] calldata receiverYTs, uint256[] calldata amountSyToMints ) external nonReentrant notExpired updateData returns (uint256[] memory amountPYOuts) { uint256 length = receiverPTs.length; if (length == 0) revert Errors.ArrayEmpty(); if (receiverYTs.length != length || amountSyToMints.length != length) revert Errors.ArrayLengthMismatch(); uint256 totalSyToMint = amountSyToMints.sum(); if (totalSyToMint > _getFloatingSyAmount()) revert Errors.YieldContractInsufficientSy(totalSyToMint, _getFloatingSyAmount()); amountPYOuts = _mintPY(receiverPTs, receiverYTs, amountSyToMints); } /** * @notice converts PT(+YT) tokens into SY, but interests & rewards are not redeemed at the * same time * @dev PT/YT must be transferred to this contract prior to calling */ function redeemPY(address receiver) external nonReentrant updateData returns (uint256 amountSyOut) { address[] memory receivers = new address[](1); uint256[] memory amounts = new uint256[](1); (receivers[0], amounts[0]) = (receiver, _getAmountPYToRedeem()); uint256[] memory amountSyOuts; amountSyOuts = _redeemPY(receivers, amounts); amountSyOut = amountSyOuts[0]; } /** * @notice redeems PT(+YT) for multiple users. See `redeemPY()` * @dev PT/YT must be transferred to this contract prior to calling * @dev fails if unable to redeem the total PY amount in `amountPYToRedeems` */ function redeemPYMulti( address[] calldata receivers, uint256[] calldata amountPYToRedeems ) external nonReentrant updateData returns (uint256[] memory amountSyOuts) { if (receivers.length != amountPYToRedeems.length) revert Errors.ArrayLengthMismatch(); if (receivers.length == 0) revert Errors.ArrayEmpty(); amountSyOuts = _redeemPY(receivers, amountPYToRedeems); } /** * @notice Redeems interests and rewards for `user` * @param redeemInterest will only transfer out interest for user if true * @param redeemRewards will only transfer out rewards for user if true * @dev With YT yielding interest in the form of SY, which is redeemable by users, the reward * distribution should be based on the amount of SYs that their YT currently represent, plus * their dueInterest. It has been proven and tested that _rewardSharesUser will not change over * time, unless users redeem their dueInterest or redeemPY. Due to this, it is required to * update users' accruedReward STRICTLY BEFORE transferring out their interest. */ function redeemDueInterestAndRewards( address user, bool redeemInterest, bool redeemRewards ) external nonReentrant updateData returns (uint256 interestOut, uint256[] memory rewardsOut) { if (!redeemInterest && !redeemRewards) revert Errors.YCNothingToRedeem(); // if redeemRewards == true, this line must be here for obvious reason // if redeemInterest == true, this line must be here because of the reason above _updateAndDistributeRewards(user); if (redeemRewards) { rewardsOut = _doTransferOutRewards(user, user); emit RedeemRewards(user, rewardsOut); } else { address[] memory tokens = getRewardTokens(); rewardsOut = new uint256[](tokens.length); } if (redeemInterest) { _distributeInterest(user); interestOut = _doTransferOutInterest(user, SY, factory); emit RedeemInterest(user, interestOut); } else { interestOut = 0; } } /** * @dev All rewards and interests accrued post-expiry goes to the treasury. * Reverts if called pre-expiry. */ function redeemInterestAndRewardsPostExpiryForTreasury() external nonReentrant updateData returns (uint256 interestOut, uint256[] memory rewardsOut) { if (!isExpired()) revert Errors.YCNotExpired(); address treasury = IPYieldContractFactory(factory).treasury(); address[] memory tokens = getRewardTokens(); rewardsOut = new uint256[](tokens.length); _redeemExternalReward(); for (uint256 i = 0; i < tokens.length; i++) { rewardsOut[i] = _selfBalance(tokens[i]) - postExpiry.userRewardOwed[tokens[i]]; emit CollectRewardFee(tokens[i], rewardsOut[i]); } _transferOut(tokens, treasury, rewardsOut); interestOut = postExpiry.totalSyInterestForTreasury; postExpiry.totalSyInterestForTreasury = 0; _transferOut(SY, treasury, interestOut); emit CollectInterestFee(interestOut); } /// @notice updates and returns the reward indexes function rewardIndexesCurrent() external override nonReentrant returns (uint256[] memory) { return IStandardizedYield(SY).rewardIndexesCurrent(); } /** * @notice updates and returns the current PY index * @dev this function maximizes the current PY index with the previous index, guaranteeing * non-decreasing PY index * @dev if `doCacheIndexSameBlock` is true, PY index only updates at most once per block, * and has no state changes on the second call onwards (within the same block). * @dev see `pyIndexStored()` for view function for cached value. */ function pyIndexCurrent() public nonReentrant returns (uint256 currentIndex) { currentIndex = _pyIndexCurrent(); } /// @notice returns the last-updated PY index function pyIndexStored() public view returns (uint256) { return _pyIndexStored; } /** * @notice do a final rewards redeeming, and sets post-expiry data * @dev has no effect if called pre-expiry */ function setPostExpiryData() external nonReentrant { if (isExpired()) { _setPostExpiryData(); } } /** * @notice returns the current data post-expiry, if exists * @dev reverts if post-expiry data not set (see `setPostExpiryData()`) * @return firstPYIndex the earliest PY index post-expiry * @return totalSyInterestForTreasury current amount of SY interests post-expiry for treasury * @return firstRewardIndexes the earliest reward indices post-expiry, for each reward token * @return userRewardOwed amount of unclaimed user rewards, for each reward token */ function getPostExpiryData() external view returns ( uint256 firstPYIndex, uint256 totalSyInterestForTreasury, uint256[] memory firstRewardIndexes, uint256[] memory userRewardOwed ) { if (postExpiry.firstPYIndex == 0) revert Errors.YCPostExpiryDataNotSet(); firstPYIndex = postExpiry.firstPYIndex; totalSyInterestForTreasury = postExpiry.totalSyInterestForTreasury; address[] memory tokens = getRewardTokens(); firstRewardIndexes = new uint256[](tokens.length); userRewardOwed = new uint256[](tokens.length); for (uint256 i = 0; i < tokens.length; ++i) { firstRewardIndexes[i] = postExpiry.firstRewardIndex[tokens[i]]; userRewardOwed[i] = postExpiry.userRewardOwed[tokens[i]]; } } function _mintPY( address[] memory receiverPTs, address[] memory receiverYTs, uint256[] memory amountSyToMints ) internal returns (uint256[] memory amountPYOuts) { amountPYOuts = new uint256[](amountSyToMints.length); uint256 index = _pyIndexCurrent(); for (uint256 i = 0; i < amountSyToMints.length; i++) { amountPYOuts[i] = _calcPYToMint(amountSyToMints[i], index); _mint(receiverYTs[i], amountPYOuts[i]); IPPrincipalToken(PT).mintByYT(receiverPTs[i], amountPYOuts[i]); emit Mint(msg.sender, receiverPTs[i], receiverYTs[i], amountSyToMints[i], amountPYOuts[i]); } } function isExpired() public view returns (bool) { return MiniHelpers.isCurrentlyExpired(expiry); } function _redeemPY( address[] memory receivers, uint256[] memory amountPYToRedeems ) internal returns (uint256[] memory amountSyOuts) { uint256 totalAmountPYToRedeem = amountPYToRedeems.sum(); IPPrincipalToken(PT).burnByYT(address(this), totalAmountPYToRedeem); if (!isExpired()) _burn(address(this), totalAmountPYToRedeem); uint256 index = _pyIndexCurrent(); uint256 totalSyInterestPostExpiry; amountSyOuts = new uint256[](receivers.length); for (uint256 i = 0; i < receivers.length; i++) { uint256 syInterestPostExpiry; (amountSyOuts[i], syInterestPostExpiry) = _calcSyRedeemableFromPY(amountPYToRedeems[i], index); _transferOut(SY, receivers[i], amountSyOuts[i]); totalSyInterestPostExpiry += syInterestPostExpiry; emit Burn(msg.sender, receivers[i], amountPYToRedeems[i], amountSyOuts[i]); } if (totalSyInterestPostExpiry != 0) { postExpiry.totalSyInterestForTreasury += totalSyInterestPostExpiry.Uint128(); } } function _calcPYToMint(uint256 amountSy, uint256 indexCurrent) internal pure returns (uint256 amountPY) { // doesn't matter before or after expiry, since mintPY is only allowed before expiry return SYUtils.syToAsset(indexCurrent, amountSy); } function _calcSyRedeemableFromPY( uint256 amountPY, uint256 indexCurrent ) internal view returns (uint256 syToUser, uint256 syInterestPostExpiry) { syToUser = SYUtils.assetToSy(indexCurrent, amountPY); if (isExpired()) { uint256 totalSyRedeemable = SYUtils.assetToSy(postExpiry.firstPYIndex, amountPY); syInterestPostExpiry = totalSyRedeemable - syToUser; } } function _getAmountPYToRedeem() internal view returns (uint256) { if (!isExpired()) return PMath.min(_selfBalance(PT), balanceOf(address(this))); else return _selfBalance(PT); } function _updateSyReserve() internal virtual { syReserve = _selfBalance(SY); } function _getFloatingSyAmount() internal view returns (uint256 amount) { amount = _selfBalance(SY) - syReserve; if (amount == 0) revert Errors.YCNoFloatingSy(); } function _setPostExpiryData() internal { PostExpiryData storage local = postExpiry; if (local.firstPYIndex != 0) return; // already set _redeemExternalReward(); // do a final redeem. All the future reward income will belong to the treasury local.firstPYIndex = _pyIndexCurrent().Uint128(); address[] memory rewardTokens = IStandardizedYield(SY).getRewardTokens(); uint256[] memory rewardIndexes = IStandardizedYield(SY).rewardIndexesCurrent(); for (uint256 i = 0; i < rewardTokens.length; i++) { local.firstRewardIndex[rewardTokens[i]] = rewardIndexes[i]; local.userRewardOwed[rewardTokens[i]] = _selfBalance(rewardTokens[i]); } } /*/////////////////////////////////////////////////////////////// INTEREST-RELATED //////////////////////////////////////////////////////////////*/ function _getInterestIndex() internal virtual override returns (uint256 index) { if (isExpired()) index = postExpiry.firstPYIndex; else index = _pyIndexCurrent(); } function _pyIndexCurrent() internal returns (uint256 currentIndex) { if (doCacheIndexSameBlock && pyIndexLastUpdatedBlock == block.number) return _pyIndexStored; uint128 index128 = PMath.max(IStandardizedYield(SY).exchangeRate(), _pyIndexStored).Uint128(); currentIndex = index128; _pyIndexStored = index128; pyIndexLastUpdatedBlock = uint128(block.number); emit NewInterestIndex(currentIndex); } function _YTbalance(address user) internal view override returns (uint256) { return balanceOf(user); } /*/////////////////////////////////////////////////////////////// REWARDS-RELATED //////////////////////////////////////////////////////////////*/ function getRewardTokens() public view returns (address[] memory) { return IStandardizedYield(SY).getRewardTokens(); } function _doTransferOutRewards( address user, address receiver ) internal virtual override returns (uint256[] memory rewardAmounts) { address[] memory tokens = getRewardTokens(); if (isExpired()) { // post-expiry, all incoming rewards will go to the treasury // hence, we can save users one _redeemExternal here for (uint256 i = 0; i < tokens.length; i++) { uint256 owed = postExpiry.userRewardOwed[tokens[i]]; uint256 accrued = userReward[tokens[i]][user].accrued; postExpiry.userRewardOwed[tokens[i]] = (owed < accrued) ? 0 : owed - accrued; } rewardAmounts = __doTransferOutRewardsLocal(tokens, user, receiver, false); } else { rewardAmounts = __doTransferOutRewardsLocal(tokens, user, receiver, true); } } function __doTransferOutRewardsLocal( address[] memory tokens, address user, address receiver, bool allowedToRedeemExternalReward ) internal returns (uint256[] memory rewardAmounts) { address treasury = IPYieldContractFactory(factory).treasury(); uint256 feeRate = IPYieldContractFactory(factory).rewardFeeRate(); bool redeemExternalThisRound; rewardAmounts = new uint256[](tokens.length); for (uint256 i = 0; i < tokens.length; i++) { uint256 rewardPreFee = userReward[tokens[i]][user].accrued; userReward[tokens[i]][user].accrued = 0; uint256 feeAmount = rewardPreFee.mulDown(feeRate); rewardAmounts[i] = rewardPreFee - feeAmount; if (!redeemExternalThisRound && allowedToRedeemExternalReward) { if (_selfBalance(tokens[i]) < rewardPreFee) { _redeemExternalReward(); redeemExternalThisRound = true; } } _transferOut(tokens[i], treasury, feeAmount); _transferOut(tokens[i], receiver, rewardAmounts[i]); emit CollectRewardFee(tokens[i], feeAmount); } } function _redeemExternalReward() internal virtual override { IStandardizedYield(SY).claimRewards(address(this)); } /// @dev effectively returning the amount of SY generating rewards for this user function _rewardSharesUser(address user) internal view virtual override returns (uint256) { uint256 index = userInterest[user].index; if (index == 0) return 0; return SYUtils.assetToSy(index, balanceOf(user)) + userInterest[user].accrued; } function _updateRewardIndex() internal override returns (address[] memory tokens, uint256[] memory indexes) { tokens = getRewardTokens(); if (isExpired()) { indexes = new uint256[](tokens.length); for (uint256 i = 0; i < tokens.length; i++) indexes[i] = postExpiry.firstRewardIndex[tokens[i]]; } else { indexes = IStandardizedYield(SY).rewardIndexesCurrent(); } } //solhint-disable-next-line ordering function _beforeTokenTransfer(address from, address to, uint256) internal override { if (isExpired()) _setPostExpiryData(); _updateAndDistributeRewardsForTwo(from, to); _distributeInterestForTwo(from, to); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: GPL-3.0-or-later // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import "@openzeppelin/contracts/utils/Context.sol"; /** * @dev Pendle's ERC20 implementation, modified from @openzeppelin implementation * Changes are: * - comes with built-in reentrancy protection, storage-packed with totalSupply variable * - delete increaseAllowance / decreaseAllowance * - add nonReentrancy protection to transfer / transferFrom functions * - allow decimals to be passed in * - block self-transfer by default */ // solhint-disable contract PendleERC20 is Context, IERC20, IERC20Metadata { uint8 private constant _NOT_ENTERED = 1; uint8 private constant _ENTERED = 2; mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint248 private _totalSupply; uint8 private _status; string private _name; string private _symbol; uint8 public immutable decimals; /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev Sets the values for {name}, {symbol} and {decimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_, uint8 decimals_) { _name = name_; _symbol = symbol_; decimals = decimals_; _status = _NOT_ENTERED; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) external virtual override nonReentrant returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) external virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) external virtual override nonReentrant returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer(address from, address to, uint256 amount) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(from != to, "ERC20: transfer to self"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += toUint248(amount); _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= toUint248(amount); emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {} function toUint248(uint256 x) internal virtual returns (uint248) { require(x <= type(uint248).max); // signed, lim = bit-1 return uint248(x); } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; library ArrayLib { function sum(uint256[] memory input) internal pure returns (uint256) { uint256 value = 0; for (uint256 i = 0; i < input.length; ) { value += input[i]; unchecked { i++; } } return value; } /// @notice return index of the element if found, else return uint256.max function find(address[] memory array, address element) internal pure returns (uint256 index) { uint256 length = array.length; for (uint256 i = 0; i < length; ) { if (array[i] == element) return i; unchecked { i++; } } return type(uint256).max; } function append(address[] memory inp, address element) internal pure returns (address[] memory out) { uint256 length = inp.length; out = new address[](length + 1); for (uint256 i = 0; i < length; ) { out[i] = inp[i]; unchecked { i++; } } out[length] = element; } function appendHead(address[] memory inp, address element) internal pure returns (address[] memory out) { uint256 length = inp.length; out = new address[](length + 1); out[0] = element; for (uint256 i = 1; i <= length; ) { out[i] = inp[i - 1]; unchecked { i++; } } } /** * @dev This function assumes a and b each contains unidentical elements * @param a array of addresses a * @param b array of addresses b * @return out Concatenation of a and b containing unidentical elements */ function merge(address[] memory a, address[] memory b) internal pure returns (address[] memory out) { unchecked { uint256 countUnidenticalB = 0; bool[] memory isUnidentical = new bool[](b.length); for (uint256 i = 0; i < b.length; ++i) { if (!contains(a, b[i])) { countUnidenticalB++; isUnidentical[i] = true; } } out = new address[](a.length + countUnidenticalB); for (uint256 i = 0; i < a.length; ++i) { out[i] = a[i]; } uint256 id = a.length; for (uint256 i = 0; i < b.length; ++i) { if (isUnidentical[i]) { out[id++] = b[i]; } } } } // various version of contains function contains(address[] memory array, address element) internal pure returns (bool) { uint256 length = array.length; for (uint256 i = 0; i < length; ) { if (array[i] == element) return true; unchecked { i++; } } return false; } function contains(bytes4[] memory array, bytes4 element) internal pure returns (bool) { uint256 length = array.length; for (uint256 i = 0; i < length; ) { if (array[i] == element) return true; unchecked { i++; } } return false; } function create(address a) internal pure returns (address[] memory res) { res = new address[](1); res[0] = a; } function create(address a, address b) internal pure returns (address[] memory res) { res = new address[](2); res[0] = a; res[1] = b; } function create(address a, address b, address c) internal pure returns (address[] memory res) { res = new address[](3); res[0] = a; res[1] = b; res[2] = c; } function create(address a, address b, address c, address d) internal pure returns (address[] memory res) { res = new address[](4); res[0] = a; res[1] = b; res[2] = c; res[3] = d; } function create( address a, address b, address c, address d, address e ) internal pure returns (address[] memory res) { res = new address[](5); res[0] = a; res[1] = b; res[2] = c; res[3] = d; res[4] = e; } function create(uint256 a) internal pure returns (uint256[] memory res) { res = new uint256[](1); res[0] = a; } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; library Errors { // BulkSeller error BulkInsufficientSyForTrade(uint256 currentAmount, uint256 requiredAmount); error BulkInsufficientTokenForTrade(uint256 currentAmount, uint256 requiredAmount); error BulkInSufficientSyOut(uint256 actualSyOut, uint256 requiredSyOut); error BulkInSufficientTokenOut(uint256 actualTokenOut, uint256 requiredTokenOut); error BulkInsufficientSyReceived(uint256 actualBalance, uint256 requiredBalance); error BulkNotMaintainer(); error BulkNotAdmin(); error BulkSellerAlreadyExisted(address token, address SY, address bulk); error BulkSellerInvalidToken(address token, address SY); error BulkBadRateTokenToSy(uint256 actualRate, uint256 currentRate, uint256 eps); error BulkBadRateSyToToken(uint256 actualRate, uint256 currentRate, uint256 eps); // APPROX error ApproxFail(); error ApproxParamsInvalid(uint256 guessMin, uint256 guessMax, uint256 eps); error ApproxBinarySearchInputInvalid( uint256 approxGuessMin, uint256 approxGuessMax, uint256 minGuessMin, uint256 maxGuessMax ); // MARKET + MARKET MATH CORE error MarketExpired(); error MarketZeroAmountsInput(); error MarketZeroAmountsOutput(); error MarketZeroLnImpliedRate(); error MarketInsufficientPtForTrade(int256 currentAmount, int256 requiredAmount); error MarketInsufficientPtReceived(uint256 actualBalance, uint256 requiredBalance); error MarketInsufficientSyReceived(uint256 actualBalance, uint256 requiredBalance); error MarketZeroTotalPtOrTotalAsset(int256 totalPt, int256 totalAsset); error MarketExchangeRateBelowOne(int256 exchangeRate); error MarketProportionMustNotEqualOne(); error MarketRateScalarBelowZero(int256 rateScalar); error MarketScalarRootBelowZero(int256 scalarRoot); error MarketProportionTooHigh(int256 proportion, int256 maxProportion); error OracleUninitialized(); error OracleTargetTooOld(uint32 target, uint32 oldest); error OracleZeroCardinality(); error MarketFactoryExpiredPt(); error MarketFactoryInvalidPt(); error MarketFactoryMarketExists(); error MarketFactoryLnFeeRateRootTooHigh(uint80 lnFeeRateRoot, uint256 maxLnFeeRateRoot); error MarketFactoryOverriddenFeeTooHigh(uint80 overriddenFee, uint256 marketLnFeeRateRoot); error MarketFactoryReserveFeePercentTooHigh(uint8 reserveFeePercent, uint8 maxReserveFeePercent); error MarketFactoryZeroTreasury(); error MarketFactoryInitialAnchorTooLow(int256 initialAnchor, int256 minInitialAnchor); error MFNotPendleMarket(address addr); // ROUTER error RouterInsufficientLpOut(uint256 actualLpOut, uint256 requiredLpOut); error RouterInsufficientSyOut(uint256 actualSyOut, uint256 requiredSyOut); error RouterInsufficientPtOut(uint256 actualPtOut, uint256 requiredPtOut); error RouterInsufficientYtOut(uint256 actualYtOut, uint256 requiredYtOut); error RouterInsufficientPYOut(uint256 actualPYOut, uint256 requiredPYOut); error RouterInsufficientTokenOut(uint256 actualTokenOut, uint256 requiredTokenOut); error RouterInsufficientSyRepay(uint256 actualSyRepay, uint256 requiredSyRepay); error RouterInsufficientPtRepay(uint256 actualPtRepay, uint256 requiredPtRepay); error RouterNotAllSyUsed(uint256 netSyDesired, uint256 netSyUsed); error RouterTimeRangeZero(); error RouterCallbackNotPendleMarket(address caller); error RouterInvalidAction(bytes4 selector); error RouterInvalidFacet(address facet); error RouterKyberSwapDataZero(); error SimulationResults(bool success, bytes res); // YIELD CONTRACT error YCExpired(); error YCNotExpired(); error YieldContractInsufficientSy(uint256 actualSy, uint256 requiredSy); error YCNothingToRedeem(); error YCPostExpiryDataNotSet(); error YCNoFloatingSy(); // YieldFactory error YCFactoryInvalidExpiry(); error YCFactoryYieldContractExisted(); error YCFactoryZeroExpiryDivisor(); error YCFactoryZeroTreasury(); error YCFactoryInterestFeeRateTooHigh(uint256 interestFeeRate, uint256 maxInterestFeeRate); error YCFactoryRewardFeeRateTooHigh(uint256 newRewardFeeRate, uint256 maxRewardFeeRate); // SY error SYInvalidTokenIn(address token); error SYInvalidTokenOut(address token); error SYZeroDeposit(); error SYZeroRedeem(); error SYInsufficientSharesOut(uint256 actualSharesOut, uint256 requiredSharesOut); error SYInsufficientTokenOut(uint256 actualTokenOut, uint256 requiredTokenOut); // SY-specific error SYQiTokenMintFailed(uint256 errCode); error SYQiTokenRedeemFailed(uint256 errCode); error SYQiTokenRedeemRewardsFailed(uint256 rewardAccruedType0, uint256 rewardAccruedType1); error SYQiTokenBorrowRateTooHigh(uint256 borrowRate, uint256 borrowRateMax); error SYCurveInvalidPid(); error SYCurve3crvPoolNotFound(); error SYApeDepositAmountTooSmall(uint256 amountDeposited); error SYBalancerInvalidPid(); error SYInvalidRewardToken(address token); error SYStargateRedeemCapExceeded(uint256 amountLpDesired, uint256 amountLpRedeemable); error SYBalancerReentrancy(); error NotFromTrustedRemote(uint16 srcChainId, bytes path); error ApxETHNotEnoughBuffer(); // Liquidity Mining error VCInactivePool(address pool); error VCPoolAlreadyActive(address pool); error VCZeroVePendle(address user); error VCExceededMaxWeight(uint256 totalWeight, uint256 maxWeight); error VCEpochNotFinalized(uint256 wTime); error VCPoolAlreadyAddAndRemoved(address pool); error VEInvalidNewExpiry(uint256 newExpiry); error VEExceededMaxLockTime(); error VEInsufficientLockTime(); error VENotAllowedReduceExpiry(); error VEZeroAmountLocked(); error VEPositionNotExpired(); error VEZeroPosition(); error VEZeroSlope(uint128 bias, uint128 slope); error VEReceiveOldSupply(uint256 msgTime); error GCNotPendleMarket(address caller); error GCNotVotingController(address caller); error InvalidWTime(uint256 wTime); error ExpiryInThePast(uint256 expiry); error ChainNotSupported(uint256 chainId); error FDTotalAmountFundedNotMatch(uint256 actualTotalAmount, uint256 expectedTotalAmount); error FDEpochLengthMismatch(); error FDInvalidPool(address pool); error FDPoolAlreadyExists(address pool); error FDInvalidNewFinishedEpoch(uint256 oldFinishedEpoch, uint256 newFinishedEpoch); error FDInvalidStartEpoch(uint256 startEpoch); error FDInvalidWTimeFund(uint256 lastFunded, uint256 wTime); error FDFutureFunding(uint256 lastFunded, uint256 currentWTime); error BDInvalidEpoch(uint256 epoch, uint256 startTime); // Cross-Chain error MsgNotFromSendEndpoint(uint16 srcChainId, bytes path); error MsgNotFromReceiveEndpoint(address sender); error InsufficientFeeToSendMsg(uint256 currentFee, uint256 requiredFee); error ApproxDstExecutionGasNotSet(); error InvalidRetryData(); // GENERIC MSG error ArrayLengthMismatch(); error ArrayEmpty(); error ArrayOutOfBounds(); error ZeroAddress(); error FailedToSendEther(); error InvalidMerkleProof(); error OnlyLayerZeroEndpoint(); error OnlyYT(); error OnlyYCFactory(); error OnlyWhitelisted(); // Swap Aggregator error SAInsufficientTokenIn(address tokenIn, uint256 amountExpected, uint256 amountActual); error UnsupportedSelector(uint256 aggregatorType, bytes4 selector); }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.0; /* solhint-disable private-vars-leading-underscore, reason-string */ library PMath { uint256 internal constant ONE = 1e18; // 18 decimal places int256 internal constant IONE = 1e18; // 18 decimal places function subMax0(uint256 a, uint256 b) internal pure returns (uint256) { unchecked { return (a >= b ? a - b : 0); } } function subNoNeg(int256 a, int256 b) internal pure returns (int256) { require(a >= b, "negative"); return a - b; // no unchecked since if b is very negative, a - b might overflow } function mulDown(uint256 a, uint256 b) internal pure returns (uint256) { uint256 product = a * b; unchecked { return product / ONE; } } function mulDown(int256 a, int256 b) internal pure returns (int256) { int256 product = a * b; unchecked { return product / IONE; } } function divDown(uint256 a, uint256 b) internal pure returns (uint256) { uint256 aInflated = a * ONE; unchecked { return aInflated / b; } } function divDown(int256 a, int256 b) internal pure returns (int256) { int256 aInflated = a * IONE; unchecked { return aInflated / b; } } function rawDivUp(uint256 a, uint256 b) internal pure returns (uint256) { return (a + b - 1) / b; } function rawDivUp(int256 a, int256 b) internal pure returns (int256) { return (a + b - 1) / b; } function slipUp(uint256 a, uint256 factor) internal pure returns (uint256) { return mulDown(a, ONE + factor); } function slipDown(uint256 a, uint256 factor) internal pure returns (uint256) { return mulDown(a, ONE - factor); } // @author Uniswap function sqrt(uint256 y) internal pure returns (uint256 z) { if (y > 3) { z = y; uint256 x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } } function square(uint256 x) internal pure returns (uint256) { return x * x; } function squareDown(uint256 x) internal pure returns (uint256) { return mulDown(x, x); } function abs(int256 x) internal pure returns (uint256) { return uint256(x > 0 ? x : -x); } function neg(int256 x) internal pure returns (int256) { return x * (-1); } function neg(uint256 x) internal pure returns (int256) { return Int(x) * (-1); } function max(uint256 x, uint256 y) internal pure returns (uint256) { return (x > y ? x : y); } function max(int256 x, int256 y) internal pure returns (int256) { return (x > y ? x : y); } function min(uint256 x, uint256 y) internal pure returns (uint256) { return (x < y ? x : y); } function min(int256 x, int256 y) internal pure returns (int256) { return (x < y ? x : y); } /*/////////////////////////////////////////////////////////////// SIGNED CASTS //////////////////////////////////////////////////////////////*/ function Int(uint256 x) internal pure returns (int256) { require(x <= uint256(type(int256).max)); return int256(x); } function Int128(int256 x) internal pure returns (int128) { require(type(int128).min <= x && x <= type(int128).max); return int128(x); } function Int128(uint256 x) internal pure returns (int128) { return Int128(Int(x)); } /*/////////////////////////////////////////////////////////////// UNSIGNED CASTS //////////////////////////////////////////////////////////////*/ function Uint(int256 x) internal pure returns (uint256) { require(x >= 0); return uint256(x); } function Uint32(uint256 x) internal pure returns (uint32) { require(x <= type(uint32).max); return uint32(x); } function Uint64(uint256 x) internal pure returns (uint64) { require(x <= type(uint64).max); return uint64(x); } function Uint112(uint256 x) internal pure returns (uint112) { require(x <= type(uint112).max); return uint112(x); } function Uint96(uint256 x) internal pure returns (uint96) { require(x <= type(uint96).max); return uint96(x); } function Uint128(uint256 x) internal pure returns (uint128) { require(x <= type(uint128).max); return uint128(x); } function Uint192(uint256 x) internal pure returns (uint192) { require(x <= type(uint192).max); return uint192(x); } function isAApproxB(uint256 a, uint256 b, uint256 eps) internal pure returns (bool) { return mulDown(b, ONE - eps) <= a && a <= mulDown(b, ONE + eps); } function isAGreaterApproxB(uint256 a, uint256 b, uint256 eps) internal pure returns (bool) { return a >= b && a <= mulDown(b, ONE + eps); } function isASmallerApproxB(uint256 a, uint256 b, uint256 eps) internal pure returns (bool) { return a <= b && a >= mulDown(b, ONE - eps); } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; library MiniHelpers { function isCurrentlyExpired(uint256 expiry) internal view returns (bool) { return (expiry <= block.timestamp); } function isExpired(uint256 expiry, uint256 blockTime) internal pure returns (bool) { return (expiry <= blockTime); } function isTimeInThePast(uint256 timestamp) internal view returns (bool) { return (timestamp <= block.timestamp); // same definition as isCurrentlyExpired } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "../../interfaces/IWETH.sol"; abstract contract TokenHelper { using SafeERC20 for IERC20; address internal constant NATIVE = address(0); uint256 internal constant LOWER_BOUND_APPROVAL = type(uint96).max / 2; // some tokens use 96 bits for approval function _transferIn(address token, address from, uint256 amount) internal { if (token == NATIVE) require(msg.value == amount, "eth mismatch"); else if (amount != 0) IERC20(token).safeTransferFrom(from, address(this), amount); } function _transferFrom(IERC20 token, address from, address to, uint256 amount) internal { if (amount != 0) token.safeTransferFrom(from, to, amount); } function _transferOut(address token, address to, uint256 amount) internal { if (amount == 0) return; if (token == NATIVE) { (bool success, ) = to.call{value: amount}(""); require(success, "eth send failed"); } else { IERC20(token).safeTransfer(to, amount); } } function _transferOut(address[] memory tokens, address to, uint256[] memory amounts) internal { uint256 numTokens = tokens.length; require(numTokens == amounts.length, "length mismatch"); for (uint256 i = 0; i < numTokens; ) { _transferOut(tokens[i], to, amounts[i]); unchecked { i++; } } } function _selfBalance(address token) internal view returns (uint256) { return (token == NATIVE) ? address(this).balance : IERC20(token).balanceOf(address(this)); } function _selfBalance(IERC20 token) internal view returns (uint256) { return token.balanceOf(address(this)); } /// @notice Approves the stipulated contract to spend the given allowance in the given token /// @dev PLS PAY ATTENTION to tokens that requires the approval to be set to 0 before changing it function _safeApprove(address token, address to, uint256 value) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), "Safe Approve"); } function _safeApproveInf(address token, address to) internal { if (token == NATIVE) return; if (IERC20(token).allowance(address(this), to) < LOWER_BOUND_APPROVAL) { _safeApprove(token, to, 0); _safeApprove(token, to, type(uint256).max); } } function _wrap_unwrap_ETH(address tokenIn, address tokenOut, uint256 netTokenIn) internal { if (tokenIn == NATIVE) IWETH(tokenOut).deposit{value: netTokenIn}(); else IWETH(tokenIn).withdraw(netTokenIn); } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; import "../../interfaces/IRewardManager.sol"; import "../libraries/ArrayLib.sol"; import "../libraries/TokenHelper.sol"; import "../libraries/math/PMath.sol"; import "./RewardManagerAbstract.sol"; /// NOTE: RewardManager must not have duplicated rewardTokens abstract contract RewardManagerAbstract is IRewardManager, TokenHelper { using PMath for uint256; uint256 internal constant INITIAL_REWARD_INDEX = 1; struct RewardState { uint128 index; uint128 lastBalance; } struct UserReward { uint128 index; uint128 accrued; } // [token] => [user] => (index,accrued) mapping(address => mapping(address => UserReward)) public userReward; function _updateAndDistributeRewards(address user) internal virtual { _updateAndDistributeRewardsForTwo(user, address(0)); } function _updateAndDistributeRewardsForTwo(address user1, address user2) internal virtual { (address[] memory tokens, uint256[] memory indexes) = _updateRewardIndex(); if (tokens.length == 0) return; if (user1 != address(0) && user1 != address(this)) _distributeRewardsPrivate(user1, tokens, indexes); if (user2 != address(0) && user2 != address(this)) _distributeRewardsPrivate(user2, tokens, indexes); } // should only be callable from `_updateAndDistributeRewardsForTwo` to guarantee user != address(0) && user != address(this) function _distributeRewardsPrivate(address user, address[] memory tokens, uint256[] memory indexes) private { assert(user != address(0) && user != address(this)); uint256 userShares = _rewardSharesUser(user); for (uint256 i = 0; i < tokens.length; ++i) { address token = tokens[i]; uint256 index = indexes[i]; uint256 userIndex = userReward[token][user].index; if (userIndex == 0) { userIndex = INITIAL_REWARD_INDEX.Uint128(); } if (userIndex == index || index == 0) continue; uint256 deltaIndex = index - userIndex; uint256 rewardDelta = userShares.mulDown(deltaIndex); uint256 rewardAccrued = userReward[token][user].accrued + rewardDelta; userReward[token][user] = UserReward({index: index.Uint128(), accrued: rewardAccrued.Uint128()}); } } function _updateRewardIndex() internal virtual returns (address[] memory tokens, uint256[] memory indexes); function _redeemExternalReward() internal virtual; function _doTransferOutRewards( address user, address receiver ) internal virtual returns (uint256[] memory rewardAmounts); function _rewardSharesUser(address user) internal view virtual returns (uint256); }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; library SYUtils { uint256 internal constant ONE = 1e18; function syToAsset(uint256 exchangeRate, uint256 syAmount) internal pure returns (uint256) { return (syAmount * exchangeRate) / ONE; } function syToAssetUp(uint256 exchangeRate, uint256 syAmount) internal pure returns (uint256) { return (syAmount * exchangeRate + ONE - 1) / ONE; } function assetToSy(uint256 exchangeRate, uint256 assetAmount) internal pure returns (uint256) { return (assetAmount * ONE) / exchangeRate; } function assetToSyUp(uint256 exchangeRate, uint256 assetAmount) internal pure returns (uint256) { return (assetAmount * ONE + exchangeRate - 1) / exchangeRate; } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import "../../interfaces/IPYieldToken.sol"; import "../../interfaces/IPPrincipalToken.sol"; import "../../interfaces/IPInterestManagerYT.sol"; import "../../interfaces/IPYieldContractFactory.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "../libraries/math/PMath.sol"; import "../libraries/TokenHelper.sol"; import "../StandardizedYield/SYUtils.sol"; /* With YT yielding more SYs overtime, which is allowed to be redeemed by users, the reward distribution should be based on the amount of SYs that their YT currently represent, plus with their dueInterest. It has been proven and tested that totalSyRedeemable will not change over time, unless users redeem their interest or redeemPY. Due to this, it is required to update users' accruedReward STRICTLY BEFORE redeeming their interest. */ abstract contract InterestManagerYT is TokenHelper, IPInterestManagerYT { using PMath for uint256; struct UserInterest { uint128 index; uint128 accrued; } mapping(address => UserInterest) public userInterest; function _distributeInterest(address user) internal { _distributeInterestForTwo(user, address(0)); } function _distributeInterestForTwo(address user1, address user2) internal { uint256 index = _getInterestIndex(); if (user1 != address(0) && user1 != address(this)) _distributeInterestPrivate(user1, index); if (user2 != address(0) && user2 != address(this)) _distributeInterestPrivate(user2, index); } function _doTransferOutInterest( address user, address SY, address factory ) internal returns (uint256 interestAmount) { address treasury = IPYieldContractFactory(factory).treasury(); uint256 feeRate = IPYieldContractFactory(factory).interestFeeRate(); uint256 interestPreFee = userInterest[user].accrued; userInterest[user].accrued = 0; uint256 feeAmount = interestPreFee.mulDown(feeRate); interestAmount = interestPreFee - feeAmount; _transferOut(SY, treasury, feeAmount); _transferOut(SY, user, interestAmount); emit CollectInterestFee(feeAmount); } // should only be callable from `_distributeInterestForTwo` & make sure user != address(0) && user != address(this) function _distributeInterestPrivate(address user, uint256 currentIndex) private { assert(user != address(0) && user != address(this)); uint256 prevIndex = userInterest[user].index; if (prevIndex == currentIndex) return; if (prevIndex == 0) { userInterest[user].index = currentIndex.Uint128(); return; } uint256 principal = _YTbalance(user); uint256 interestFromYT = (principal * (currentIndex - prevIndex)).divDown(prevIndex * currentIndex); userInterest[user].accrued += interestFromYT.Uint128(); userInterest[user].index = currentIndex.Uint128(); } function _getInterestIndex() internal virtual returns (uint256 index); function _YTbalance(address user) internal view virtual returns (uint256); }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; interface IPInterestManagerYT { event CollectInterestFee(uint256 amountInterestFee); function userInterest(address user) external view returns (uint128 lastPYIndex, uint128 accruedInterest); }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; interface IPPrincipalToken is IERC20Metadata { function burnByYT(address user, uint256 amount) external; function mintByYT(address user, uint256 amount) external; function initialize(address _YT) external; function SY() external view returns (address); function YT() external view returns (address); function factory() external view returns (address); function expiry() external view returns (uint256); function isExpired() external view returns (bool); }
// SPDX-License-Identifier: GPL-3.0-or-later /* * MIT License * =========== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ pragma solidity ^0.8.0; interface IPYieldContractFactory { event CreateYieldContract(address indexed SY, uint256 indexed expiry, address PT, address YT); event SetExpiryDivisor(uint256 newExpiryDivisor); event SetInterestFeeRate(uint256 newInterestFeeRate); event SetRewardFeeRate(uint256 newRewardFeeRate); event SetTreasury(address indexed treasury); function getPT(address SY, uint256 expiry) external view returns (address); function getYT(address SY, uint256 expiry) external view returns (address); function expiryDivisor() external view returns (uint96); function interestFeeRate() external view returns (uint128); function rewardFeeRate() external view returns (uint128); function treasury() external view returns (address); function isPT(address) external view returns (bool); function isYT(address) external view returns (bool); function createYieldContract( address SY, uint32 expiry, bool doCacheIndexSameBlock ) external returns (address PT, address YT); }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import "./IRewardManager.sol"; import "./IPInterestManagerYT.sol"; interface IPYieldToken is IERC20Metadata, IRewardManager, IPInterestManagerYT { event NewInterestIndex(uint256 indexed newIndex); event Mint( address indexed caller, address indexed receiverPT, address indexed receiverYT, uint256 amountSyToMint, uint256 amountPYOut ); event Burn(address indexed caller, address indexed receiver, uint256 amountPYToRedeem, uint256 amountSyOut); event RedeemRewards(address indexed user, uint256[] amountRewardsOut); event RedeemInterest(address indexed user, uint256 interestOut); event CollectRewardFee(address indexed rewardToken, uint256 amountRewardFee); function mintPY(address receiverPT, address receiverYT) external returns (uint256 amountPYOut); function redeemPY(address receiver) external returns (uint256 amountSyOut); function redeemPYMulti( address[] calldata receivers, uint256[] calldata amountPYToRedeems ) external returns (uint256[] memory amountSyOuts); function redeemDueInterestAndRewards( address user, bool redeemInterest, bool redeemRewards ) external returns (uint256 interestOut, uint256[] memory rewardsOut); function rewardIndexesCurrent() external returns (uint256[] memory); function pyIndexCurrent() external returns (uint256); function pyIndexStored() external view returns (uint256); function getRewardTokens() external view returns (address[] memory); function SY() external view returns (address); function PT() external view returns (address); function factory() external view returns (address); function expiry() external view returns (uint256); function isExpired() external view returns (bool); function doCacheIndexSameBlock() external view returns (bool); function pyIndexLastUpdatedBlock() external view returns (uint128); }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; interface IRewardManager { function userReward(address token, address user) external view returns (uint128 index, uint128 accrued); }
// SPDX-License-Identifier: GPL-3.0-or-later /* * MIT License * =========== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; interface IStandardizedYield is IERC20Metadata { /// @dev Emitted when any base tokens is deposited to mint shares event Deposit( address indexed caller, address indexed receiver, address indexed tokenIn, uint256 amountDeposited, uint256 amountSyOut ); /// @dev Emitted when any shares are redeemed for base tokens event Redeem( address indexed caller, address indexed receiver, address indexed tokenOut, uint256 amountSyToRedeem, uint256 amountTokenOut ); /// @dev check `assetInfo()` for more information enum AssetType { TOKEN, LIQUIDITY } /// @dev Emitted when (`user`) claims their rewards event ClaimRewards(address indexed user, address[] rewardTokens, uint256[] rewardAmounts); /** * @notice mints an amount of shares by depositing a base token. * @param receiver shares recipient address * @param tokenIn address of the base tokens to mint shares * @param amountTokenToDeposit amount of base tokens to be transferred from (`msg.sender`) * @param minSharesOut reverts if amount of shares minted is lower than this * @return amountSharesOut amount of shares minted * @dev Emits a {Deposit} event * * Requirements: * - (`tokenIn`) must be a valid base token. */ function deposit( address receiver, address tokenIn, uint256 amountTokenToDeposit, uint256 minSharesOut ) external payable returns (uint256 amountSharesOut); /** * @notice redeems an amount of base tokens by burning some shares * @param receiver recipient address * @param amountSharesToRedeem amount of shares to be burned * @param tokenOut address of the base token to be redeemed * @param minTokenOut reverts if amount of base token redeemed is lower than this * @param burnFromInternalBalance if true, burns from balance of `address(this)`, otherwise burns from `msg.sender` * @return amountTokenOut amount of base tokens redeemed * @dev Emits a {Redeem} event * * Requirements: * - (`tokenOut`) must be a valid base token. */ function redeem( address receiver, uint256 amountSharesToRedeem, address tokenOut, uint256 minTokenOut, bool burnFromInternalBalance ) external returns (uint256 amountTokenOut); /** * @notice exchangeRate * syBalance / 1e18 must return the asset balance of the account * @notice vice-versa, if a user uses some amount of tokens equivalent to X asset, the amount of sy he can mint must be X * exchangeRate / 1e18 * @dev SYUtils's assetToSy & syToAsset should be used instead of raw multiplication & division */ function exchangeRate() external view returns (uint256 res); /** * @notice claims reward for (`user`) * @param user the user receiving their rewards * @return rewardAmounts an array of reward amounts in the same order as `getRewardTokens` * @dev * Emits a `ClaimRewards` event * See {getRewardTokens} for list of reward tokens */ function claimRewards(address user) external returns (uint256[] memory rewardAmounts); /** * @notice get the amount of unclaimed rewards for (`user`) * @param user the user to check for * @return rewardAmounts an array of reward amounts in the same order as `getRewardTokens` */ function accruedRewards(address user) external view returns (uint256[] memory rewardAmounts); function rewardIndexesCurrent() external returns (uint256[] memory indexes); function rewardIndexesStored() external view returns (uint256[] memory indexes); /** * @notice returns the list of reward token addresses */ function getRewardTokens() external view returns (address[] memory); /** * @notice returns the address of the underlying yield token */ function yieldToken() external view returns (address); /** * @notice returns all tokens that can mint this SY */ function getTokensIn() external view returns (address[] memory res); /** * @notice returns all tokens that can be redeemed by this SY */ function getTokensOut() external view returns (address[] memory res); function isValidTokenIn(address token) external view returns (bool); function isValidTokenOut(address token) external view returns (bool); function previewDeposit( address tokenIn, uint256 amountTokenToDeposit ) external view returns (uint256 amountSharesOut); function previewRedeem( address tokenOut, uint256 amountSharesToRedeem ) external view returns (uint256 amountTokenOut); /** * @notice This function contains information to interpret what the asset is * @return assetType the type of the asset (0 for ERC20 tokens, 1 for AMM liquidity tokens, 2 for bridged yield bearing tokens like wstETH, rETH on Arbi whose the underlying asset doesn't exist on the chain) * @return assetAddress the address of the asset * @return assetDecimals the decimals of the asset */ function assetInfo() external view returns (AssetType assetType, address assetAddress, uint8 assetDecimals); }
// SPDX-License-Identifier: GPL-3.0-or-later /* * MIT License * =========== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IWETH is IERC20 { event Deposit(address indexed dst, uint256 wad); event Withdrawal(address indexed src, uint256 wad); function deposit() external payable; function withdraw(uint256 wad) external; }
{ "optimizer": { "enabled": true, "runs": 1000000 }, "viaIR": true, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_SY","type":"address"},{"internalType":"address","name":"_PT","type":"address"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"__decimals","type":"uint8"},{"internalType":"uint256","name":"_expiry","type":"uint256"},{"internalType":"bool","name":"_doCacheIndexSameBlock","type":"bool"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ArrayEmpty","type":"error"},{"inputs":[],"name":"ArrayLengthMismatch","type":"error"},{"inputs":[],"name":"YCExpired","type":"error"},{"inputs":[],"name":"YCNoFloatingSy","type":"error"},{"inputs":[],"name":"YCNotExpired","type":"error"},{"inputs":[],"name":"YCNothingToRedeem","type":"error"},{"inputs":[],"name":"YCPostExpiryDataNotSet","type":"error"},{"inputs":[{"internalType":"uint256","name":"actualSy","type":"uint256"},{"internalType":"uint256","name":"requiredSy","type":"uint256"}],"name":"YieldContractInsufficientSy","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountPYToRedeem","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountSyOut","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amountInterestFee","type":"uint256"}],"name":"CollectInterestFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rewardToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountRewardFee","type":"uint256"}],"name":"CollectRewardFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"receiverPT","type":"address"},{"indexed":true,"internalType":"address","name":"receiverYT","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountSyToMint","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountPYOut","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"newIndex","type":"uint256"}],"name":"NewInterestIndex","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"interestOut","type":"uint256"}],"name":"RedeemInterest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"amountRewardsOut","type":"uint256[]"}],"name":"RedeemRewards","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"PT","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SY","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"doCacheIndexSameBlock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"expiry","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPostExpiryData","outputs":[{"internalType":"uint256","name":"firstPYIndex","type":"uint256"},{"internalType":"uint256","name":"totalSyInterestForTreasury","type":"uint256"},{"internalType":"uint256[]","name":"firstRewardIndexes","type":"uint256[]"},{"internalType":"uint256[]","name":"userRewardOwed","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRewardTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isExpired","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiverPT","type":"address"},{"internalType":"address","name":"receiverYT","type":"address"}],"name":"mintPY","outputs":[{"internalType":"uint256","name":"amountPYOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"receiverPTs","type":"address[]"},{"internalType":"address[]","name":"receiverYTs","type":"address[]"},{"internalType":"uint256[]","name":"amountSyToMints","type":"uint256[]"}],"name":"mintPYMulti","outputs":[{"internalType":"uint256[]","name":"amountPYOuts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"postExpiry","outputs":[{"internalType":"uint128","name":"firstPYIndex","type":"uint128"},{"internalType":"uint128","name":"totalSyInterestForTreasury","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pyIndexCurrent","outputs":[{"internalType":"uint256","name":"currentIndex","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pyIndexLastUpdatedBlock","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pyIndexStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"bool","name":"redeemInterest","type":"bool"},{"internalType":"bool","name":"redeemRewards","type":"bool"}],"name":"redeemDueInterestAndRewards","outputs":[{"internalType":"uint256","name":"interestOut","type":"uint256"},{"internalType":"uint256[]","name":"rewardsOut","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"redeemInterestAndRewardsPostExpiryForTreasury","outputs":[{"internalType":"uint256","name":"interestOut","type":"uint256"},{"internalType":"uint256[]","name":"rewardsOut","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"redeemPY","outputs":[{"internalType":"uint256","name":"amountSyOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"receivers","type":"address[]"},{"internalType":"uint256[]","name":"amountPYToRedeems","type":"uint256[]"}],"name":"redeemPYMulti","outputs":[{"internalType":"uint256[]","name":"amountSyOuts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardIndexesCurrent","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setPostExpiryData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"syReserve","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userInterest","outputs":[{"internalType":"uint128","name":"index","type":"uint128"},{"internalType":"uint128","name":"accrued","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"userReward","outputs":[{"internalType":"uint128","name":"index","type":"uint128"},{"internalType":"uint128","name":"accrued","type":"uint128"}],"stateMutability":"view","type":"function"}]
Deployed Bytecode
0x608080604052600436101561001357600080fd5b60003560e01c90816306fdde03146126f957508063095ea7b3146126aa5780630a2b83a7146126515780630b49fcef1461251057806318160ddd146124b35780631d52edc4146123ed57806323b872dd146122275780632f13b60c146121cb578063313ce5671461216f5780634ba6dcd714612133578063516399df146120d85780635333581914611f025780635cbadbe414611e6757806360e0a9e114611e1957806370a0823114611dae5780637d24da4d1461129357806395d89b411461113b578063a9059cbb14611067578063acc5da4c14610cb0578063afd27bf514610c41578063b0d8898114610a55578063bcb7ea5d146108fe578063c45a01551461088f578063c4f59f9b146107fd578063cdbb03611461070f578063d2a3584e146106d0578063d68076c31461064a578063d94073d4146105db578063db74aa15146103f4578063dd62ed3e14610377578063e184c9be1461031e5763f8b2f9911461017f57600080fd5b346103195760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610319576002546101c160028260f81c1415612a3c565b7f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80921617600255604051907ff8b2f9910000000000000000000000000000000000000000000000000000000082526000826004818373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000056bb34a12b70046b0a03ee63392c09cdddaaa430165af190811561030d576102c2926000926102c6575b507f0100000000000000000000000000000000000000000000000000000000000000906002541617600255604051918291602083526020830190612880565b0390f35b7f0100000000000000000000000000000000000000000000000000000000000000919250610306903d806000833e6102fe8183612944565b810190612cd0565b9190610283565b6040513d6000823e3d90fd5b600080fd5b346103195760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103195760206040517f00000000000000000000000000000000000000000000000000000000676c9c808152f35b346103195760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610319576103ae61283a565b6103b661285d565b9073ffffffffffffffffffffffffffffffffffffffff8091166000526001602052604060002091166000526020526020604060002054604051908152f35b346103195760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103195761042b61283a565b61043361285d565b6002549061044760028360f81c1415612a3c565b7f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80931617600255427f00000000000000000000000000000000000000000000000000000000676c9c8011156105b15761057361056e7f010000000000000000000000000000000000000000000000000000000000000092604051956104ec87612928565b600187526020968736818301376040519161050683612928565b600183528836818501376040519361051d85612928565b6001855289368187013761052f613569565b610538866129ec565b52610542846129ec565b73ffffffffffffffffffffffffffffffffffffffff8092169052610565836129ec565b911690526135d1565b6129ec565b519161059e7f00000000000000000000000056bb34a12b70046b0a03ee63392c09cdddaaa430613995565b6007556002541617600255604051908152f35b60046040517f5b15a6da000000000000000000000000000000000000000000000000000000008152fd5b346103195760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031957602060405173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000a76f0c6e5f286bff151b891d2a0245077f1ad74c168152f35b346103195760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103195773ffffffffffffffffffffffffffffffffffffffff61069661283a565b166000908152600660209081526040918290205482516fffffffffffffffffffffffffffffffff8216815260809190911c91810191909152f35b346103195760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031957602060085460801c604051908152f35b346103195760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610319577f010000000000000000000000000000000000000000000000000000000000000060025461077260028260f81c1415612a3c565b7f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80921617600255427f00000000000000000000000000000000000000000000000000000000676c9c8011156107f0575b6002541617600255600080f35b6107f8613373565b6107e3565b346103195760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031957610834612c39565b6040518091602080830160208452825180915260206040850193019160005b82811061086257505050500390f35b835173ffffffffffffffffffffffffffffffffffffffff1685528695509381019392810192600101610853565b346103195760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031957602060405173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000035a338522a435d46f77be32c70e215b813d0e3ac168152f35b34610319576020807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103195761093661283a565b7f010000000000000000000000000000000000000000000000000000000000000061057361056e6002549361097160028660f81c1415612a3c565b7f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80961617600255427f00000000000000000000000000000000000000000000000000000000676c9c801115610a48575b6040516109ee81612928565b6001815286368183013760405191610a0583612928565b60018352873681850137610a1761420d565b610a20846129ec565b5273ffffffffffffffffffffffffffffffffffffffff610a3f836129ec565b91169052613d0a565b610a50613373565b6109e2565b346103195760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103195767ffffffffffffffff60043581811161031957610aa59036906004016128b4565b909160243590811161031957610abf9036906004016128b4565b9160025492610ad460028560f81c1415612a3c565b7f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80951617600255427f00000000000000000000000000000000000000000000000000000000676c9c801115610c34575b808203610c0a578115610be057610b917f010000000000000000000000000000000000000000000000000000000000000093610b896102c297610b97953691612aef565b923691612aa1565b90613d0a565b91610bc17f00000000000000000000000056bb34a12b70046b0a03ee63392c09cdddaaa430613995565b6007556002541617600255604051918291602083526020830190612880565b60046040517ff1364a74000000000000000000000000000000000000000000000000000000008152fd5b60046040517fa24a13a6000000000000000000000000000000000000000000000000000000008152fd5b610c3c613373565b610b45565b346103195760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031957602060405173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000056bb34a12b70046b0a03ee63392c09cdddaaa430168152f35b346103195760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031957600254610cf260028260f81c1415612a3c565b7f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80921617600255427f00000000000000000000000000000000000000000000000000000000676c9c8011801561105a575b6110305773ffffffffffffffffffffffffffffffffffffffff906040517f61d027b30000000000000000000000000000000000000000000000000000000081526020928382600481847f00000000000000000000000035a338522a435d46f77be32c70e215b813d0e3ac165afa91821561030d57600092610ff9575b50610de9612c39565b610df3815161299d565b92610dfc613908565b60005b8251811015610e955780610e43610e2386610e1c60019588612a28565b5116613995565b86610e2e8488612a28565b5116600052600b8a5260406000205490612b7b565b610e4d8288612a28565b5284610e598286612a28565b51167f880a48d40a6133941abdcfabd5c5f9a791b1e6c8afd23138c5a36e3d9503922289610e87848a612a28565b51604051908152a201610dff565b50939181519184518303610f9b5760005b838110610f705787876102c2887f010000000000000000000000000000000000000000000000000000000000000089610f4f600954956fffffffffffffffffffffffffffffffff8760801c9716600955610f22877f00000000000000000000000056bb34a12b70046b0a03ee63392c09cdddaaa4309283613aa1565b7e4e8d79e4b41c5fad7561dc7c07786ee4e52292da7a3f5dc7ab90e32cc3042388604051898152a1613995565b60075560025416176002556040805194859485528401526040830190612880565b80610f9584610f8160019486612a28565b511689610f8e848b612a28565b5191613aa1565b01610ea6565b606487604051907f08c379a00000000000000000000000000000000000000000000000000000000082526004820152600f60248201527f6c656e677468206d69736d6174636800000000000000000000000000000000006044820152fd5b9091508381813d8311611029575b6110118183612944565b810103126103195761102290612b5a565b9084610de0565b503d611007565b60046040517fcd81a636000000000000000000000000000000000000000000000000000000008152fd5b611062613373565b610d64565b346103195760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610319577f01000000000000000000000000000000000000000000000000000000000000006110bf61283a565b611128600254916110d660028460f81c1415612a3c565b7f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80941617600255602435903361304e565b6002541617600255602060405160018152f35b346103195760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103195760405160009060045460018160011c9060018316928315611289575b602093848410811461125a5783865290811561121c57506001146111c1575b6102c2846111b581880382612944565b604051918291826127d4565b600460009081529294507f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b5b82841061120957505050816102c2936111b592820101936111a5565b80548585018701529285019281016111ed565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016858501525050151560051b82010191506111b5816102c26111a5565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b91607f1691611186565b346103195760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610319576112ca61283a565b60243515908115602435036103195760443580159283158203610319577f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60025461133b60028260f81c1415612a3c565b1617600255427f00000000000000000000000000000000000000000000000000000000676c9c8011159384611da1575b81611d99575b50611d6f5761137f826142a9565b15611d565761138c612c39565b9115611aaf5760005b8251811015611475578073ffffffffffffffffffffffffffffffffffffffff6113c060019386612a28565b5116600052600b60209080825260406000205473ffffffffffffffffffffffffffffffffffffffff6113f28589612a28565b511660005260058352604060002073ffffffffffffffffffffffffffffffffffffffff8716600052835260406000205460801c8082106000146114665750506000915b73ffffffffffffffffffffffffffffffffffffffff6114548589612a28565b51166000525260406000205501611395565b61146f91612b7b565b91611435565b5073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000035a338522a435d46f77be32c70e215b813d0e3ac1691604051917f61d027b3000000000000000000000000000000000000000000000000000000008352602083600481875afa92831561030d57600093611a70575b50602060049394604051948580927ff5de2d1f0000000000000000000000000000000000000000000000000000000082525afa92831561030d57600093611a4f575b50600061153c835161299d565b9460005b84518110156117475773ffffffffffffffffffffffffffffffffffffffff6115688287612a28565b5116600052600580602052604060002073ffffffffffffffffffffffffffffffffffffffff861660005260205260406000205460801c9073ffffffffffffffffffffffffffffffffffffffff6115be8489612a28565b5116600052602052604060002073ffffffffffffffffffffffffffffffffffffffff861660005260205260406000206fffffffffffffffffffffffffffffffff8154169055670de0b6b3a76400006116286fffffffffffffffffffffffffffffffff891683614639565b04906116348282612b7b565b61163e848b612a28565b5284158061173f575b6116fd575b50908161167c6001938573ffffffffffffffffffffffffffffffffffffffff611675868c612a28565b5116613aa1565b6116ab73ffffffffffffffffffffffffffffffffffffffff61169e848a612a28565b511687610f8e858d612a28565b7f880a48d40a6133941abdcfabd5c5f9a791b1e6c8afd23138c5a36e3d95039222602073ffffffffffffffffffffffffffffffffffffffff6116ed858b612a28565b511692604051908152a201611540565b61171f73ffffffffffffffffffffffffffffffffffffffff610e1c858a612a28565b1061172b575b8861164c565b9250600190611738613908565b9092611725565b506000611647565b509193505050505b817f78d61a0c27b13f43911095f9f356f14daa3cd8b125eea1aa22421245e90e813d604051602081528061179e73ffffffffffffffffffffffffffffffffffffffff8616946020830190612880565b0390a25b60243515611a47576117b3816145b1565b7f00000000000000000000000056bb34a12b70046b0a03ee63392c09cdddaaa4309073ffffffffffffffffffffffffffffffffffffffff90817f00000000000000000000000035a338522a435d46f77be32c70e215b813d0e3ac16604051917f61d027b30000000000000000000000000000000000000000000000000000000083526020918284600481845afa93841561030d57600094611a0c575b5082600491604051928380927fdd86fea10000000000000000000000000000000000000000000000000000000082525afa95861561030d5761192d967f83a945bd12c713615b59a6e48a3467c05d1a7442350600d6f7fce6af9f7190e9957e4e8d79e4b41c5fad7561dc7c07786ee4e52292da7a3f5dc7ab90e32cc304239486946000936119db575b5061193b9293611936670de0b6b3a76400006119236fffffffffffffffffffffffffffffffff9c85169c8d60005260068a52604060002098895499828b60801c9b1690551688614639565b049b8c8097612b7b565b9b8c9483613aa1565b613aa1565b604051908152a1604051848152a25b6119737f00000000000000000000000056bb34a12b70046b0a03ee63392c09cdddaaa430613995565b6007557f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60025416176002556102c26040519283928352604060208401526040830190612880565b61193b93506119ff90863d8811611a05575b6119f78183612944565b8101906138e0565b926118d8565b503d6119ed565b9093508281813d8311611a40575b611a248183612944565b810103126103195782611a38600492612b5a565b94915061184f565b503d611a1a565b50600061194a565b611a6991935060203d602011611a05576119f78183612944565b918461152f565b92506020833d602011611aa7575b81611a8b60209383612944565b81010312610319576020611aa0600494612b5a565b93506114ed565b3d9150611a7e565b9073ffffffffffffffffffffffffffffffffffffffff807f00000000000000000000000035a338522a435d46f77be32c70e215b813d0e3ac1691604051917f61d027b30000000000000000000000000000000000000000000000000000000083526020908184600481885afa93841561030d57600094611d1d575b508160049495604051958680927ff5de2d1f0000000000000000000000000000000000000000000000000000000082525afa93841561030d57600094611cfe575b506fffffffffffffffffffffffffffffffff94939480951693600093611b91815161299d565b958884169060005b8a8451821015611ced578989918789888f8d9083611bb78a85612a28565b511660005260059182815260406000208c600052815260406000205460801c9285611be28c87612a28565b511660005281526040600020908c600052526040600020908154169055670de0b6b3a7640000611c128a83614639565b0496611c1e8883612b7b565b611c288a89612a28565b521580611ce5575b611ca3575b508587969593611c66959361167560019a611c4f95612a28565b610f8e858c611c5e828d612a28565b511693612a28565b7f880a48d40a6133941abdcfabd5c5f9a791b1e6c8afd23138c5a36e3d950392228989611c93858a612a28565b511692604051908152a201611b99565b925090610e1c87611cb393612a28565b10611cc2575b87898838611c35565b869a506001939291611c6691611cd6613908565b949b5092939192919050611cb9565b506001611c30565b50505050505050505090509061174f565b611d16919450823d8411611a05576119f78183612944565b9286611b6b565b93508184813d8311611d4f575b611d348183612944565b810103126103195781611d48600495612b5a565b9450611b2a565b503d611d2a565b9050611d69611d63612c39565b5161299d565b906117a2565b60046040517f68146f1d000000000000000000000000000000000000000000000000000000008152fd5b905084611371565b611da9613373565b61136b565b346103195760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610319576020611e11611dea61283a565b73ffffffffffffffffffffffffffffffffffffffff16600052600060205260406000205490565b604051908152f35b346103195760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103195760206fffffffffffffffffffffffffffffffff60085416604051908152f35b346103195760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031957611e9e61283a565b611ea661285d565b73ffffffffffffffffffffffffffffffffffffffff91821660009081526005602090815260408083209390941682529182528290205482516fffffffffffffffffffffffffffffffff8216815260809190911c91810191909152f35b346103195760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103195767ffffffffffffffff60043581811161031957611f529036906004016128b4565b909160243581811161031957611f6c9036906004016128b4565b93909160443590811161031957611f879036906004016128b4565b92909160025494611f9e60028760f81c1415612a3c565b7f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80971617600255427f00000000000000000000000000000000000000000000000000000000676c9c8011156105b1578015610be0578087148015906120ce575b610c0a57612036612031368787612aa1565b613536565b61203e613569565b81116120905750610b9793610b896102c298946120827f0100000000000000000000000000000000000000000000000000000000000000989561208a953691612aef565b953691612aef565b916135d1565b60449061209b613569565b604051917fa2cb081900000000000000000000000000000000000000000000000000000000835260048301526024820152fd5b508085141561201f565b346103195760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103195760206040517f000000000000000000000000000000000000000000000000000000000000000115158152f35b346103195760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610319576020600754604051908152f35b346103195760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031957602060405160ff7f0000000000000000000000000000000000000000000000000000000000000008168152f35b346103195760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610319576020604051427f00000000000000000000000000000000000000000000000000000000676c9c8011158152f35b346103195760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103195761225e61283a565b61226661285d565b6044356002549161227d60028460f81c1415612a3c565b7f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8094161760025573ffffffffffffffffffffffffffffffffffffffff841660005260016020526040600020336000526020526040600020547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff810361234b575b5090611128917f01000000000000000000000000000000000000000000000000000000000000009461304e565b919081831061238f577f0100000000000000000000000000000000000000000000000000000000000000946123868361112895033383612d4a565b9450909161231e565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152fd5b346103195760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031957602060025461243160028260f81c1415612a3c565b7f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff809216176002557f01000000000000000000000000000000000000000000000000000000000000006124a2612ebf565b916002541617600255604051908152f35b346103195760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103195760207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60025416604051908152f35b346103195760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610319576009546fffffffffffffffffffffffffffffffff8116801561262757612563612c39565b9161256e835161299d565b612578845161299d565b9160005b85518110156125ee57600190600b73ffffffffffffffffffffffffffffffffffffffff806125aa848b612a28565b5116600052602090600a82526040600020546125c68589612a28565b526125d1848b612a28565b5116600052526040600020546125e78287612a28565b520161257c565b5092916126196102c292604051958695865260801c6020860152608060408601526080850190612880565b908382036060850152612880565b60046040517fd2509633000000000000000000000000000000000000000000000000000000008152fd5b346103195760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031957600954604080516fffffffffffffffffffffffffffffffff8316815260809290921c602083015290f35b346103195760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610319576126ee6126e461283a565b6024359033612d4a565b602060405160018152f35b346103195760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103195760009060035460018160011c90600183169283156127ca575b602093848410811461125a5783865290811561121c575060011461276f576102c2846111b581880382612944565b600360009081529294507fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b5b8284106127b757505050816102c2936111b592820101936111a5565b805485850187015292850192810161279b565b91607f1691612741565b60208082528251818301819052939260005b858110612826575050507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8460006040809697860101520116010190565b8181018301518482016040015282016127e6565b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361031957565b6024359073ffffffffffffffffffffffffffffffffffffffff8216820361031957565b90815180825260208080930193019160005b8281106128a0575050505090565b835185529381019392810192600101612892565b9181601f840112156103195782359167ffffffffffffffff8311610319576020808501948460051b01011161031957565b67ffffffffffffffff81116128f957604052565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040810190811067ffffffffffffffff8211176128f957604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176128f957604052565b67ffffffffffffffff81116128f95760051b60200190565b906129a782612985565b6129b46040519182612944565b8281527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe06129e28294612985565b0190602036910137565b8051156129f95760200190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b80518210156129f95760209160051b010190565b15612a4357565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b9291612aac82612985565b91612aba6040519384612944565b829481845260208094019160051b810192831161031957905b828210612ae05750505050565b81358152908301908301612ad3565b9291612afa82612985565b91612b086040519384612944565b829481845260208094019160051b810192831161031957905b828210612b2e5750505050565b813573ffffffffffffffffffffffffffffffffffffffff81168103610319578152908301908301612b21565b519073ffffffffffffffffffffffffffffffffffffffff8216820361031957565b91908203918211612b8857565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60209081818403126103195780519067ffffffffffffffff821161031957019180601f84011215610319578251612bed81612985565b93612bfb6040519586612944565b818552838086019260051b820101928311610319578301905b828210612c22575050505090565b838091612c2e84612b5a565b815201910190612c14565b6040517fc4f59f9b00000000000000000000000000000000000000000000000000000000815260008160048173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000056bb34a12b70046b0a03ee63392c09cdddaaa430165afa90811561030d57600091612cb0575090565b612ccd91503d806000833e612cc58183612944565b810190612bb7565b90565b60209081818403126103195780519067ffffffffffffffff821161031957019180601f84011215610319578251612d0681612985565b93612d146040519586612944565b818552838086019260051b820101928311610319578301905b828210612d3b575050505090565b81518152908301908301612d2d565b73ffffffffffffffffffffffffffffffffffffffff809116918215612e3c5716918215612db85760207f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925918360005260018252604060002085600052825280604060002055604051908152a3565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152fd5b60846040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152fd5b7f000000000000000000000000000000000000000000000000000000000000000180613024575b61301b576040517f3ba0b9a900000000000000000000000000000000000000000000000000000000815260208160048173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000056bb34a12b70046b0a03ee63392c09cdddaaa430165afa90811561030d57600091612fe9575b5060085460801c80821115612fe15750905b6fffffffffffffffffffffffffffffffff91828111610319577fffffffffffffffffffffffffffffffff000000000000000000000000000000008382169343169160801b1617600855817f71475f2f645813fdbebf53a58968008bff11ee21a58f01c5a9cc263d0bc4703d600080a2565b905090612f70565b90506020813d602011613013575b8161300460209383612944565b81010312610319575138612f5e565b3d9150612ff7565b60085460801c90565b506fffffffffffffffffffffffffffffffff600854164314612ee6565b91908201809211612b8857565b9173ffffffffffffffffffffffffffffffffffffffff918284169283156132ef57811693841561326b5784841461320d57427f00000000000000000000000000000000000000000000000000000000676c9c80111580613200575b6130b3838361441b565b156131f2576fffffffffffffffffffffffffffffffff60095416905b813086036131e2575b50503085036131d2575b505081600052600060205260406000205481811061314e57817fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92602092856000526000845203604060002055846000526040600020613143828254613041565b9055604051908152a3565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152fd5b6131db9161488a565b38806130e2565b6131eb9161488a565b38816130d8565b6131fa612ebf565b906130cf565b613208613373565b6130a9565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f45524332303a207472616e7366657220746f2073656c660000000000000000006044820152fd5b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152fd5b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152fd5b6fffffffffffffffffffffffffffffffff806009541661353357613395613908565b61339d612ebf565b81811161031957167fffffffffffffffffffffffffffffffff00000000000000000000000000000000600954161760095573ffffffffffffffffffffffffffffffffffffffff90817f00000000000000000000000056bb34a12b70046b0a03ee63392c09cdddaaa4301660408051917fc4f59f9b0000000000000000000000000000000000000000000000000000000083526000908184600481845afa938415613509578294613513575b5081809160048551809481937ff8b2f9910000000000000000000000000000000000000000000000000000000083525af19081156135095782916134ef575b50815b84518110156134e657806134a060019284612a28565b51886134ac8389612a28565b51168552602090600a825286862055600b6134cb8a610e1c858b612a28565b918a6134d7858b612a28565b5116875252858520550161348a565b50505050509050565b61350391503d8084833e6102fe8183612944565b38613487565b83513d84823e3d90fd5b8291945061352b82913d8084833e612cc58183612944565b949150613448565b50565b600090815b81518310156135635761355b6001916135548585612a28565b5190613041565b92019161353b565b91505090565b61359e6135957f00000000000000000000000056bb34a12b70046b0a03ee63392c09cdddaaa430613995565b60075490612b7b565b9081156135a757565b60046040517f22826619000000000000000000000000000000000000000000000000000000008152fd5b9291906135de825161299d565b6135e6612ebf565b60009573ffffffffffffffffffffffffffffffffffffffff90817f000000000000000000000000a76f0c6e5f286bff151b891d2a0245077f1ad74c1692427f00000000000000000000000000000000000000000000000000000000676c9c801115985b87518110156138d557670de0b6b3a764000061366f83613669848c612a28565b51614639565b0461367a8288612a28565b52836136868289612a28565b51166136928288612a28565b51908015613877578b61386a575b6136a9816142a9565b6136b2816145b1565b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808311610319576002908154908085168183160190808211612b88577fff0000000000000000000000000000000000000000000000000000000000000091169116179055806000526020906000825260007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604095868420613756828254613041565b90558651908152a3856137698487612a28565b5116613775848a612a28565b5190883b156103195783517f12a31dcc00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9190911660048201526024810191909152600081604481838c5af1801561385f577fc0025304673122449dd60b9b0093874b0e2fd6fe57af1c7c2fbfee0ccf5ead5885948d9461383d878f968f969a8e61382e8f8260019f8580936138369861382693613850575b50612a28565b51169b612a28565b511699612a28565b5195612a28565b519082519485528401523392a401613649565b613859906128e5565b38613820565b83513d6000823e3d90fd5b613872613373565b6136a0565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152fd5b505050505093505050565b9081602091031261031957516fffffffffffffffffffffffffffffffff811681036103195790565b6040517fef5cfb8c0000000000000000000000000000000000000000000000000000000081523060048201526000816024818373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000056bb34a12b70046b0a03ee63392c09cdddaaa430165af1801561030d576139815750565b613533903d806000833e6102fe8183612944565b60009073ffffffffffffffffffffffffffffffffffffffff16806139b95750504790565b6020602491604051928380927f70a082310000000000000000000000000000000000000000000000000000000082523060048301525afa918215613a37578092613a03575b505090565b9091506020823d602011613a2f575b81613a1f60209383612944565b81010312613a2c57505190565b80fd5b3d9150613a12565b604051903d90823e3d90fd5b3d15613a9c573d9067ffffffffffffffff82116128f95760405191613a9060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8401160184612944565b82523d6000602084013e565b606090565b8215613ce15773ffffffffffffffffffffffffffffffffffffffff1680613b3a5750600080809381935af1613ad4613a43565b5015613adc57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f6574682073656e64206661696c656400000000000000000000000000000000006044820152fd5b613c1a9060405190613bcb82613b9f602097888301977fa9059cbb000000000000000000000000000000000000000000000000000000008952602484016020909392919373ffffffffffffffffffffffffffffffffffffffff60408201951681520152565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101845283612944565b60405191613bd883612928565b8583527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656486840152600080958192519082855af1613c14613a43565b91614b0a565b805191821591848315613cb9575b505050905015613c355750565b608490604051907f08c379a00000000000000000000000000000000000000000000000000000000082526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b919381809450010312613cdd57820151908115158203613a2c575080388084613c28565b5080fd5b505050565b9190916fffffffffffffffffffffffffffffffff80809416911601918211612b8857565b9190613d1581613536565b9273ffffffffffffffffffffffffffffffffffffffff807f000000000000000000000000a76f0c6e5f286bff151b891d2a0245077f1ad74c1691823b15610319576040958651937fb64761f90000000000000000000000000000000000000000000000000000000085526000948581600493818381613dbb8930600484016020909392919373ffffffffffffffffffffffffffffffffffffffff60408201951681520152565b03925af18015614203576141f0575b50427f00000000000000000000000000000000000000000000000000000000676c9c801191821592613fdb575b50613e00612ebf565b85613e0b855161299d565b9680927f00000000000000000000000056bb34a12b70046b0a03ee63392c09cdddaaa430925b8751851015613f7057613e44858c612a28565b518390670de0b6b3a7640000808202908282041482151715613f42578f918e8d8f928b978f91978f8a99613e798d8c9a61464c565b91613f11575b50613e8a8888612a28565b528c84613e978986612a28565b5116613ea38989612a28565b5190613eae92613aa1565b613eb791613041565b9b613ec191612a28565b511694613ecd91612a28565b5191613ed891612a28565b518251918252602082015233917f5d624aa9c148153ab3446c1b154f660ee7701e549fe9b62dab7171b1c80e6fa291a360010193613e31565b81925090613f36613f3b926fffffffffffffffffffffffffffffffff60095416614a7e565b612b7b565b9038613e7f565b6011897f4e487b71000000000000000000000000000000000000000000000000000000006000525260246000fd5b99505050505050505050925080613f845750565b6fffffffffffffffffffffffffffffffff808211610319577fffffffffffffffffffffffffffffffff00000000000000000000000000000000613fcf8260095494168460801c613ce6565b60801b16911617600955565b301561416d5782614160575b613ff0306142a9565b613ff9306145b1565b30865285602052888620548181106140dd5781903088528760205203898720557effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8082116103195760025490808316818316038181116140b057889392917fff00000000000000000000000000000000000000000000000000000000000000911691161760025589519081527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60203092a338613df7565b6024897f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b60848a517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152fd5b614168613373565b613fe7565b608489517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152fd5b6141fc909591956128e5565b9338613dca565b89513d88823e3d90fd5b427f00000000000000000000000000000000000000000000000000000000676c9c8011156142805761425e7f000000000000000000000000a76f0c6e5f286bff151b891d2a0245077f1ad74c613995565b30600052600060205260406000205480821060001461427b575090565b905090565b612ccd7f000000000000000000000000a76f0c6e5f286bff151b891d2a0245077f1ad74c613995565b6000916142b4612c39565b92427f00000000000000000000000000000000000000000000000000000000676c9c801161438257506142e7835161299d565b9060005b8451811015614337578073ffffffffffffffffffffffffffffffffffffffff61431660019388612a28565b5116600052600a6020526040600020546143308286612a28565b52016142eb565b50925b805115613ce15773ffffffffffffffffffffffffffffffffffffffff83168015159081614377575b5061436c57505050565b614375926146bb565b565b905030141538614362565b6040939193517ff8b2f99100000000000000000000000000000000000000000000000000000000815281816004818373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000056bb34a12b70046b0a03ee63392c09cdddaaa430165af1918215613a37578092614400575b50509061433a565b61441492503d8091833e6102fe8183612944565b38806143f8565b906000614426612c39565b90427f00000000000000000000000000000000000000000000000000000000676c9c80116145185750614459815161299d565b9160005b82518110156144a9578073ffffffffffffffffffffffffffffffffffffffff61448860019386612a28565b5116600052600a6020526040600020546144a28287612a28565b520161445d565b50925b8151156145125773ffffffffffffffffffffffffffffffffffffffff9083838383168015159081614507575b506144f6575b50505083168015159081614377575061436c57505050565b6144ff926146bb565b3883836144de565b9050301415386144d8565b50505050565b6040939293517ff8b2f99100000000000000000000000000000000000000000000000000000000815281816004818373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000056bb34a12b70046b0a03ee63392c09cdddaaa430165af1918215613a37578092614596575b5050916144ac565b6145aa92503d8091833e6102fe8183612944565b388061458e565b427f00000000000000000000000000000000000000000000000000000000676c9c801161462c576fffffffffffffffffffffffffffffffff600954165b73ffffffffffffffffffffffffffffffffffffffff82168015159081614621575b50614618575050565b6143759161488a565b90503014153861460f565b614634612ebf565b6145ee565b81810292918115918404141715612b8857565b8115614656570490565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b1561468c57565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b9092919273ffffffffffffffffffffffffffffffffffffffff6146f28184169384151580614880575b6146ed90614685565b614aa1565b9160005b81518110156134e6578261470a8284612a28565b5116906147178189612a28565b51826000526005906020908282526040806000208a60005283526fffffffffffffffffffffffffffffffff91828260002054168015614878575b8181148015614870575b61486157670de0b6b3a764000061477e61477861479d9385612b7b565b8d614639565b0488600052868652836000208d6000528652836000205460801c613041565b9183821161031957838311610319578051948186019686881067ffffffffffffffff8911176128f95760019986809561485b9a86521688528483890196168652600052815281600020908d600052526000209351167fffffffffffffffffffffffffffffffff0000000000000000000000000000000084541617835551166fffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffff0000000000000000000000000000000083549260801b169116179055565b016146f6565b5050505050506001915061485b565b50811561475b565b506001614751565b50308514156146e4565b73ffffffffffffffffffffffffffffffffffffffff811680151580614a74575b6148b390614685565b600090808252600660205260408220928354906fffffffffffffffffffffffffffffffff9485831692878414614a6a578315614a2e5750508561492d61491d6149339373ffffffffffffffffffffffffffffffffffffffff16600052600060205260406000205490565b6149278584612b7b565b90614639565b92614639565b90670de0b6b3a764000090818102918183041490151715614a0157906149589161464c565b8381116149fd576149bf90828452600660205261497f85604086209216825460801c613ce6565b6fffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffff0000000000000000000000000000000083549260801b169116179055565b828411613cdd5790604091815260066020522091167fffffffffffffffffffffffffffffffff00000000000000000000000000000000825416179055565b8280fd5b6024847f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b959492509580935084915011613a2c5750907fffffffffffffffffffffffffffffffff0000000000000000000000000000000091169116179055565b5050505050505050565b50308114156148aa565b670de0b6b3a764000091828102928184041490151715612b8857612ccd9161464c565b73ffffffffffffffffffffffffffffffffffffffff1660009080825260066020526fffffffffffffffffffffffffffffffff60408320541680156139fe5782614af7604092612ccd956020528383205490614a7e565b9281526006602052205460801c90613041565b91929015614b855750815115614b1e575090565b3b15614b275790565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b825190915015614b985750805190602001fd5b614bce906040519182917f08c379a0000000000000000000000000000000000000000000000000000000008352600483016127d4565b0390fdfea2646970667358221220430d9d58981384c975b27e0372f23f6fca8d41e0f2261c3c3a43a0f94b8c5a0f64736f6c63430008180033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.