Overview
ETH Balance
ETH Value
$0.00Latest 25 from a total of 222 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Settle Single | 430615033 | 7 days ago | IN | 0 ETH | 0.00000321 | ||||
| Settle Single | 430608074 | 7 days ago | IN | 0 ETH | 0.00000319 | ||||
| Settle Single | 430575295 | 7 days ago | IN | 0 ETH | 0.0000032 | ||||
| Settle Single | 430319830 | 8 days ago | IN | 0 ETH | 0.00000323 | ||||
| Settle Single | 430319491 | 8 days ago | IN | 0 ETH | 0.00000209 | ||||
| Settle Single | 430317178 | 8 days ago | IN | 0 ETH | 0.00000325 | ||||
| Settle | 430316879 | 8 days ago | IN | 0 ETH | 0.00000989 | ||||
| Settle Single | 430243123 | 8 days ago | IN | 0 ETH | 0.0000032 | ||||
| Settle Single | 430243059 | 8 days ago | IN | 0 ETH | 0.0000032 | ||||
| Settle Single | 430242862 | 8 days ago | IN | 0 ETH | 0.00000323 | ||||
| Settle Single | 430242623 | 8 days ago | IN | 0 ETH | 0.00000319 | ||||
| Settle Single | 430241925 | 8 days ago | IN | 0 ETH | 0.0000032 | ||||
| Settle Single | 430241759 | 8 days ago | IN | 0 ETH | 0.00000323 | ||||
| Settle Single | 430241681 | 8 days ago | IN | 0 ETH | 0.00000319 | ||||
| Settle Single | 430241617 | 8 days ago | IN | 0 ETH | 0.00000203 | ||||
| Settle Single | 430241404 | 8 days ago | IN | 0 ETH | 0.00000322 | ||||
| Settle Single | 430240718 | 8 days ago | IN | 0 ETH | 0.0000032 | ||||
| Settle Single | 430240646 | 8 days ago | IN | 0 ETH | 0.00000204 | ||||
| Settle Single | 430236295 | 8 days ago | IN | 0 ETH | 0.0000032 | ||||
| Settle Single | 430236120 | 8 days ago | IN | 0 ETH | 0.00000326 | ||||
| Settle Single | 430235521 | 8 days ago | IN | 0 ETH | 0.0000032 | ||||
| Settle Single | 430235033 | 8 days ago | IN | 0 ETH | 0.0000032 | ||||
| Settle Single | 430234641 | 8 days ago | IN | 0 ETH | 0.0000032 | ||||
| Settle Single | 430234385 | 8 days ago | IN | 0 ETH | 0.0000032 | ||||
| Settle Single | 430233958 | 8 days ago | IN | 0 ETH | 0.0000032 |
Latest 2 internal transactions
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 377359003 | 161 days ago | Contract Creation | 0 ETH | |||
| 377359003 | 161 days ago | Contract Creation | 0 ETH |
Cross-Chain Transactions
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.23;
import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import {ReentrancyGuard} from '@openzeppelin/contracts/utils/ReentrancyGuard.sol';
import {Math} from '@openzeppelin/contracts/utils/math/Math.sol';
import {IAllowListAuthentication} from '../../interfaces/IAllowListAuthentication.sol';
import {IBalanceManager} from '../../interfaces/IBalanceManager.sol';
import {ILiquoriceSettlement} from '../../interfaces/ILiquoriceSettlement.sol';
import {IRepository} from '../../interfaces/IRepository.sol';
import {GPv2Interaction} from '../lib/GPv2Interaction.sol';
import {Signature} from '../lib/Signature.sol';
import {BalanceManager} from './BalanceManager.sol';
import {Signing} from './Signing.sol';
/**
* @title Liquorice Settlement Contract
* @notice Handles settlement of orders and interactions
*/
contract LiquoriceSettlement is Signing, ReentrancyGuard, ILiquoriceSettlement {
using SafeERC20 for IERC20;
/* ============ Immutables ============ */
/// @notice Authenticator for verifying solvers and makers
IAllowListAuthentication public immutable override AUTHENTICATOR;
/// @notice Manager for handling balance transfers
IBalanceManager public immutable override BALANCE_MANAGER;
/// @notice Repository that stores data for Lending Pools
IRepository public immutable override REPOSITORY;
/* ============ Events ============ */
/**
* @notice Emitted when an interaction is executed
* @param target Address of the interaction target
* @param value Value associated with the interaction
* @param selector Selector of the interaction function
*/
event Interaction(address indexed target, uint256 value, bytes4 selector);
event TradeOrder(
string indexed rfqId,
address trader,
address effectiveTrader,
address baseToken,
address quoteToken,
uint256 baseTokenAmount,
uint256 quoteTokenAmount,
address recipient
);
/* ============ Errors ============ */
error NotMaker();
error NotSolver();
error ReceiverNotManager();
/* ============ Modifiers ============ */
modifier onlySolver() {
if (!AUTHENTICATOR.isSolver(msg.sender)) revert NotSolver();
_;
}
modifier onlyMaker() {
if (!AUTHENTICATOR.isMaker(msg.sender)) revert NotMaker();
_;
}
/* ============ Constructor ============ */
constructor(IAllowListAuthentication authenticator_, IRepository repository_, address permit2_) {
AUTHENTICATOR = authenticator_;
BALANCE_MANAGER = new BalanceManager(address(this), permit2_);
REPOSITORY = repository_;
}
/* ============ External Functions ============ */
// solhint-disable-next-line no-empty-blocks
receive() external payable {}
/// @inheritdoc ILiquoriceSettlement
function settle(
address _signer,
uint256 _filledTakerAmount,
Order calldata _order,
GPv2Interaction.Data[] calldata _interactions,
GPv2Interaction.Hooks calldata _hooks,
Signature.TypedSignature calldata _makerSignature,
Signature.TypedSignature calldata _takerSignature
) external override nonReentrant onlySolver {
if (!AUTHENTICATOR.isMaker(_signer)) revert NotMaker();
uint256 makerFilledAmount = _order.quoteTokenData.toTrader;
if (_filledTakerAmount > 0 && _filledTakerAmount <= _order.baseTokenData.toRecipient) {
makerFilledAmount = Math.mulDiv(
_filledTakerAmount, _order.quoteTokenData.toTrader, _order.baseTokenData.toRecipient, Math.Rounding.Ceil
);
}
validateOrder(
REPOSITORY, _signer, makerFilledAmount, _order, _interactions, _hooks, _makerSignature, _takerSignature
);
_executeOrder(
_order,
_signer,
makerFilledAmount,
_filledTakerAmount == 0 || _filledTakerAmount > _order.baseTokenData.toRecipient
? _order.baseTokenData.toRecipient
: _filledTakerAmount,
_hooks,
_interactions,
Signature.TransferCommand.SIMPLE_TRANSFER,
_makerSignature.transferCommand
);
emit TradeOrder(
_order.rfqId,
_order.trader,
_order.effectiveTrader,
_order.baseTokenData.addr,
_order.quoteTokenData.addr,
_filledTakerAmount == 0 || _filledTakerAmount > _order.baseTokenData.toRecipient
? _order.baseTokenData.amount
: _filledTakerAmount,
makerFilledAmount == _order.quoteTokenData.toTrader ? _order.quoteTokenData.amount : makerFilledAmount,
_order.recipient
);
}
/// @inheritdoc ILiquoriceSettlement
function settleSingle(
address _signer,
Single calldata _order,
Signature.TypedSignature calldata _makerSignature,
uint256 _filledTakerAmount,
Signature.TypedSignature calldata _takerSignature
) external payable override {
_validateTakerSignatureForSingleOrder(_order, _takerSignature);
_executeSingleOrder(
_signer,
_order,
_makerSignature,
_filledTakerAmount,
Signature.TransferCommand.SIMPLE_TRANSFER,
Signature.TransferCommand.SIMPLE_TRANSFER
);
}
function settleSingleWithPermitsSignatures(
address _signer,
Single calldata _order,
Signature.TypedSignature calldata _makerSignature,
uint256 _filledTakerAmount,
Signature.TypedSignature calldata _takerSignature,
Signature.TakerPermitInfo calldata _takerPermitInfo
) external payable {
_validateTakerSignatureForSingleOrder(_order, _takerSignature);
BALANCE_MANAGER.tokenPermits(_order.effectiveTrader, _order.baseToken, _order.baseTokenAmount, _takerPermitInfo);
_executeSingleOrder(
_signer,
_order,
_makerSignature,
_filledTakerAmount,
Signature.TransferCommand.PERMIT2_TRANSFER,
_makerSignature.transferCommand
);
}
function settleWithPermitsSignatures(
address _signer,
uint256 _filledTakerAmount,
Order calldata _order,
GPv2Interaction.Data[] calldata _interactions,
GPv2Interaction.Hooks calldata _hooks,
Signature.TypedSignature calldata _makerSignature,
Signature.TypedSignature calldata _takerSignature,
Signature.TakerPermitInfo calldata _takerPermitInfo
) external payable nonReentrant {
if (!AUTHENTICATOR.isMaker(_signer)) revert NotMaker();
uint256 makerFilledAmount = _order.quoteTokenData.toTrader;
if (_filledTakerAmount > 0 && _filledTakerAmount <= _order.baseTokenData.toRecipient) {
makerFilledAmount = Math.mulDiv(
_filledTakerAmount, _order.quoteTokenData.toTrader, _order.baseTokenData.toRecipient, Math.Rounding.Ceil
);
}
validateOrder(
REPOSITORY, _signer, makerFilledAmount, _order, _interactions, _hooks, _makerSignature, _takerSignature
);
BALANCE_MANAGER.tokenPermits(
_order.effectiveTrader, _order.baseTokenData.addr, _order.baseTokenData.toRecipient, _takerPermitInfo
);
_executeOrder(
_order,
_signer,
makerFilledAmount,
_filledTakerAmount == 0 || _filledTakerAmount > _order.baseTokenData.toRecipient
? _order.baseTokenData.toRecipient
: _filledTakerAmount,
_hooks,
_interactions,
Signature.TransferCommand.PERMIT2_TRANSFER,
_makerSignature.transferCommand
);
emit TradeOrder(
_order.rfqId,
_order.trader,
_order.effectiveTrader,
_order.baseTokenData.addr,
_order.quoteTokenData.addr,
_filledTakerAmount == 0 || _filledTakerAmount > _order.baseTokenData.toRecipient
? _order.baseTokenData.amount
: _filledTakerAmount,
makerFilledAmount == _order.quoteTokenData.toTrader ? _order.quoteTokenData.amount : makerFilledAmount,
_order.recipient
);
}
/// @inheritdoc ILiquoriceSettlement
function isValidSignature(bytes32 _hash, bytes calldata _signature) external view override returns (bytes4) {
address recoveredSigner = recoverSignature(_hash, _signature);
if (AUTHENTICATOR.isMaker(recoveredSigner)) {
return _EIP1271_MAGICVALUE;
} else {
return 0xffffffff;
}
}
/* ============ Private Functions ============ */
/**
* @notice Executes a series of interactions
* @param _interactions Array of interaction data
*/
// solhint-disable-next-line private-vars-leading-underscore
function executeInteractions(
GPv2Interaction.Data[] calldata _interactions
) internal {
for (uint256 i; i < _interactions.length; ++i) {
GPv2Interaction.Data calldata interaction = _interactions[i];
if (interaction.target == address(BALANCE_MANAGER)) revert ReceiverNotManager();
GPv2Interaction.execute(interaction);
emit Interaction(interaction.target, interaction.value, GPv2Interaction.selector(interaction));
}
}
function _executeOrder(
Order calldata _order,
address _signer,
uint256 makerFilledAmount,
uint256 takerFilledAmount,
GPv2Interaction.Hooks calldata _hooks,
GPv2Interaction.Data[] calldata _interactions,
Signature.TransferCommand _takerTransferCommand,
Signature.TransferCommand _makerTransferCommand
) internal {
executeInteractions(_hooks.beforeSettle);
uint256 lendingTransfer = _order.baseTokenData.toSupply + _order.baseTokenData.toRepay;
BALANCE_MANAGER.transferTokens(
IBalanceManager.TransferData(
_order.effectiveTrader, address(this), _order.baseTokenData.addr, lendingTransfer, _takerTransferCommand
)
);
BALANCE_MANAGER.transferTokens(
IBalanceManager.TransferData(
_order.effectiveTrader, _order.recipient, _order.baseTokenData.addr, takerFilledAmount, _takerTransferCommand
)
);
executeInteractions(_interactions);
BALANCE_MANAGER.transferTokens(
IBalanceManager.TransferData(
_signer, _order.trader, _order.quoteTokenData.addr, makerFilledAmount, _makerTransferCommand
)
);
executeInteractions(_hooks.afterSettle);
uint256 balance = IERC20(_order.baseTokenData.addr).balanceOf(address(this));
if (balance != 0) {
IERC20(_order.baseTokenData.addr).safeTransfer(_order.recipient, balance);
}
}
/**
* @notice Executes a single order
* @param _order Single order data
* @param _makerSignature Signature of the maker
* @param _filledTakerAmount Amount filled by the taker
*/
function _executeSingleOrder(
address _signer,
Single calldata _order,
Signature.TypedSignature calldata _makerSignature,
uint256 _filledTakerAmount,
Signature.TransferCommand _takerTransferCommand,
Signature.TransferCommand _makerTransferCommand
) internal {
uint256 newQuoteAmount = _order.quoteTokenAmount;
if (_filledTakerAmount != 0 && _filledTakerAmount < _order.baseTokenAmount) {
newQuoteAmount =
Math.mulDiv(_filledTakerAmount, _order.quoteTokenAmount, _order.baseTokenAmount, Math.Rounding.Ceil);
}
_validateSingleOrder(_signer, newQuoteAmount, _order, _makerSignature);
BALANCE_MANAGER.transferTokens(
IBalanceManager.TransferData(
_order.effectiveTrader,
_order.recipient,
_order.baseToken,
_filledTakerAmount == 0 || _filledTakerAmount > _order.baseTokenAmount
? _order.baseTokenAmount
: _filledTakerAmount,
_takerTransferCommand
)
);
BALANCE_MANAGER.transferTokens(
IBalanceManager.TransferData(_signer, _order.trader, _order.quoteToken, newQuoteAmount, _makerTransferCommand)
);
emit TradeOrder(
_order.rfqId,
_order.trader,
_order.effectiveTrader,
_order.baseToken,
_order.quoteToken,
_filledTakerAmount == 0 || _filledTakerAmount > _order.baseTokenAmount
? _order.baseTokenAmount
: _filledTakerAmount,
newQuoteAmount,
_order.recipient
);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
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 value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` 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 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 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 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @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.encodeCall(token.transfer, (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.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, 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.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @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.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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 {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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 silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @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() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * SafeCast.toUint(condition));
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a < b, a, b);
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
Panic.panic(Panic.DIVISION_BY_ZERO);
}
// The following calculation ensures accurate ceiling division without overflow.
// Since a is non-zero, (a - 1) / b will not overflow.
// The largest possible result occurs when (a - 1) / b is type(uint256).max,
// but the largest value we can obtain is type(uint256).max - 1, which happens
// when a = type(uint256).max and b = 1.
unchecked {
return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
}
}
/**
* @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
*
* Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use
// the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2²⁵⁶ + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
if (denominator <= prod1) {
Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
// that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv ≡ 1 mod 2⁴.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2⁸
inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
inverse *= 2 - denominator * inverse; // inverse mod 2³²
inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is
// less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @dev Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
}
/**
* @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
*
* If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
* If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
*
* If the input value is not inversible, 0 is returned.
*
* NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
* inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
*/
function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
unchecked {
if (n == 0) return 0;
// The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
// Used to compute integers x and y such that: ax + ny = gcd(a, n).
// When the gcd is 1, then the inverse of a modulo n exists and it's x.
// ax + ny = 1
// ax = 1 + (-y)n
// ax ≡ 1 (mod n) # x is the inverse of a modulo n
// If the remainder is 0 the gcd is n right away.
uint256 remainder = a % n;
uint256 gcd = n;
// Therefore the initial coefficients are:
// ax + ny = gcd(a, n) = n
// 0a + 1n = n
int256 x = 0;
int256 y = 1;
while (remainder != 0) {
uint256 quotient = gcd / remainder;
(gcd, remainder) = (
// The old remainder is the next gcd to try.
remainder,
// Compute the next remainder.
// Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
// where gcd is at most n (capped to type(uint256).max)
gcd - remainder * quotient
);
(x, y) = (
// Increment the coefficient of a.
y,
// Decrement the coefficient of n.
// Can overflow, but the result is casted to uint256 so that the
// next value of y is "wrapped around" to a value between 0 and n - 1.
x - y * int256(quotient)
);
}
if (gcd != 1) return 0; // No inverse exists.
return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
}
}
/**
* @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
*
* From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
* prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
* `a**(p-2)` is the modular multiplicative inverse of a in Fp.
*
* NOTE: this function does NOT check that `p` is a prime greater than `2`.
*/
function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
unchecked {
return Math.modExp(a, p - 2, p);
}
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
*
* Requirements:
* - modulus can't be zero
* - underlying staticcall to precompile must succeed
*
* IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
* sure the chain you're using it on supports the precompiled contract for modular exponentiation
* at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
* the underlying function will succeed given the lack of a revert, but the result may be incorrectly
* interpreted as 0.
*/
function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
(bool success, uint256 result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
* It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
* to operate modulo 0 or if the underlying precompile reverted.
*
* IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
* you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
* https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
* of a revert, but the result may be incorrectly interpreted as 0.
*/
function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
if (m == 0) return (false, 0);
assembly ("memory-safe") {
let ptr := mload(0x40)
// | Offset | Content | Content (Hex) |
// |-----------|------------|--------------------------------------------------------------------|
// | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x60:0x7f | value of b | 0x<.............................................................b> |
// | 0x80:0x9f | value of e | 0x<.............................................................e> |
// | 0xa0:0xbf | value of m | 0x<.............................................................m> |
mstore(ptr, 0x20)
mstore(add(ptr, 0x20), 0x20)
mstore(add(ptr, 0x40), 0x20)
mstore(add(ptr, 0x60), b)
mstore(add(ptr, 0x80), e)
mstore(add(ptr, 0xa0), m)
// Given the result < m, it's guaranteed to fit in 32 bytes,
// so we can use the memory scratch space located at offset 0.
success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
result := mload(0x00)
}
}
/**
* @dev Variant of {modExp} that supports inputs of arbitrary length.
*/
function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
(bool success, bytes memory result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Variant of {tryModExp} that supports inputs of arbitrary length.
*/
function tryModExp(
bytes memory b,
bytes memory e,
bytes memory m
) internal view returns (bool success, bytes memory result) {
if (_zeroBytes(m)) return (false, new bytes(0));
uint256 mLen = m.length;
// Encode call args in result and move the free memory pointer
result = abi.encodePacked(b.length, e.length, mLen, b, e, m);
assembly ("memory-safe") {
let dataPtr := add(result, 0x20)
// Write result on top of args to avoid allocating extra memory.
success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
// Overwrite the length.
// result.length > returndatasize() is guaranteed because returndatasize() == m.length
mstore(result, mLen)
// Set the memory pointer after the returned data.
mstore(0x40, add(dataPtr, mLen))
}
}
/**
* @dev Returns whether the provided byte array is zero.
*/
function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
for (uint256 i = 0; i < byteArray.length; ++i) {
if (byteArray[i] != 0) {
return false;
}
}
return true;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* This method is based on Newton's method for computing square roots; the algorithm is restricted to only
* using integer operations.
*/
function sqrt(uint256 a) internal pure returns (uint256) {
unchecked {
// Take care of easy edge cases when a == 0 or a == 1
if (a <= 1) {
return a;
}
// In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
// sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
// the current value as `ε_n = | x_n - sqrt(a) |`.
//
// For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
// of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
// bigger than any uint256.
//
// By noticing that
// `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
// we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
// to the msb function.
uint256 aa = a;
uint256 xn = 1;
if (aa >= (1 << 128)) {
aa >>= 128;
xn <<= 64;
}
if (aa >= (1 << 64)) {
aa >>= 64;
xn <<= 32;
}
if (aa >= (1 << 32)) {
aa >>= 32;
xn <<= 16;
}
if (aa >= (1 << 16)) {
aa >>= 16;
xn <<= 8;
}
if (aa >= (1 << 8)) {
aa >>= 8;
xn <<= 4;
}
if (aa >= (1 << 4)) {
aa >>= 4;
xn <<= 2;
}
if (aa >= (1 << 2)) {
xn <<= 1;
}
// We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
//
// We can refine our estimation by noticing that the middle of that interval minimizes the error.
// If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
// This is going to be our x_0 (and ε_0)
xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)
// From here, Newton's method give us:
// x_{n+1} = (x_n + a / x_n) / 2
//
// One should note that:
// x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
// = ((x_n² + a) / (2 * x_n))² - a
// = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
// = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
// = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
// = (x_n² - a)² / (2 * x_n)²
// = ((x_n² - a) / (2 * x_n))²
// ≥ 0
// Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
//
// This gives us the proof of quadratic convergence of the sequence:
// ε_{n+1} = | x_{n+1} - sqrt(a) |
// = | (x_n + a / x_n) / 2 - sqrt(a) |
// = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
// = | (x_n - sqrt(a))² / (2 * x_n) |
// = | ε_n² / (2 * x_n) |
// = ε_n² / | (2 * x_n) |
//
// For the first iteration, we have a special case where x_0 is known:
// ε_1 = ε_0² / | (2 * x_0) |
// ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
// ≤ 2**(2*e-4) / (3 * 2**(e-1))
// ≤ 2**(e-3) / 3
// ≤ 2**(e-3-log2(3))
// ≤ 2**(e-4.5)
//
// For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
// ε_{n+1} = ε_n² / | (2 * x_n) |
// ≤ (2**(e-k))² / (2 * 2**(e-1))
// ≤ 2**(2*e-2*k) / 2**e
// ≤ 2**(e-2*k)
xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above
xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5
xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9
xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18
xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36
xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72
// Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
// ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
// sqrt(a) or sqrt(a) + 1.
return xn - SafeCast.toUint(xn > a / xn);
}
}
/**
* @dev Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// If upper 8 bits of 16-bit half set, add 8 to result
r |= SafeCast.toUint((x >> r) > 0xff) << 3;
// If upper 4 bits of 8-bit half set, add 4 to result
r |= SafeCast.toUint((x >> r) > 0xf) << 2;
// Shifts value right by the current result and use it as an index into this lookup table:
//
// | x (4 bits) | index | table[index] = MSB position |
// |------------|---------|-----------------------------|
// | 0000 | 0 | table[0] = 0 |
// | 0001 | 1 | table[1] = 0 |
// | 0010 | 2 | table[2] = 1 |
// | 0011 | 3 | table[3] = 1 |
// | 0100 | 4 | table[4] = 2 |
// | 0101 | 5 | table[5] = 2 |
// | 0110 | 6 | table[6] = 2 |
// | 0111 | 7 | table[7] = 2 |
// | 1000 | 8 | table[8] = 3 |
// | 1001 | 9 | table[9] = 3 |
// | 1010 | 10 | table[10] = 3 |
// | 1011 | 11 | table[11] = 3 |
// | 1100 | 12 | table[12] = 3 |
// | 1101 | 13 | table[13] = 3 |
// | 1110 | 14 | table[14] = 3 |
// | 1111 | 15 | table[15] = 3 |
//
// The lookup table is represented as a 32-byte value with the MSB positions for 0-15 in the last 16 bytes.
assembly ("memory-safe") {
r := or(r, byte(shr(r, x), 0x0000010102020202030303030303030300000000000000000000000000000000))
}
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// Add 1 if upper 8 bits of 16-bit half set, and divide accumulated result by 8
return (r >> 3) | SafeCast.toUint((x >> r) > 0xff);
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
interface IAllowListAuthentication {
function setManager(
address manager_
) external;
function addSolver(
address _solver
) external;
function removeSolver(
address _solver
) external;
function addMaker(
address _maker
) external;
function removeMaker(
address _maker
) external;
function isSolver(
address _addr
) external view returns (bool);
function isMaker(
address _addr
) external view returns (bool);
function manager() external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
import {Signature} from '../contracts/lib/Signature.sol';
/**
* @title IBalanceManager
* @notice Interface for managing token balances and transfers between addresses
*/
interface IBalanceManager {
struct TransferData {
address from;
address receiver;
address token;
uint256 amount;
Signature.TransferCommand tokenTransferTypes;
}
/**
* @notice Transfers tokens from one address to another
* @dev Only callable by the operator
* @param data Struct containing token, from, receiver, and amount information
*/
function transferTokens(
TransferData calldata data
) external;
/**
* @notice Allows a token transfer with a permit
* @dev Only callable by the operator
* @param _from Address of the owner
* @param _token Address of the token
* @param _amount Amount of the token to transfer
* @param takerPermitInfo Struct containing the permit information
*/
function tokenPermits(
address _from,
address _token,
uint256 _amount,
Signature.TakerPermitInfo calldata takerPermitInfo
) external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
import {GPv2Interaction} from '../contracts/lib/GPv2Interaction.sol';
import {Signature} from '../contracts/lib/Signature.sol';
import {IAllowListAuthentication} from './IAllowListAuthentication.sol';
import {IBalanceManager} from './IBalanceManager.sol';
import {IRepository} from './IRepository.sol';
interface ILiquoriceSettlement {
struct BaseTokenData {
address addr;
uint256 amount;
uint256 toRecipient;
uint256 toRepay;
uint256 toSupply;
}
struct QuoteTokenData {
address addr;
uint256 amount;
uint256 toTrader;
uint256 toWithdraw;
uint256 toBorrow;
}
struct Order {
address market;
uint256 chainId;
string rfqId;
uint256 nonce;
address trader;
address effectiveTrader;
uint256 quoteExpiry;
address recipient;
uint256 minFillAmount;
BaseTokenData baseTokenData;
QuoteTokenData quoteTokenData;
}
struct Single {
string rfqId;
uint256 nonce;
address trader;
address effectiveTrader;
address baseToken;
address quoteToken;
uint256 baseTokenAmount;
uint256 quoteTokenAmount;
uint256 minFillAmount;
uint256 quoteExpiry;
address recipient;
}
/**
* @notice Settles a signed order with the given interactions and hooks
* @param _signer Address that signed the order
* @param _filledTakerAmount Amount filled by the taker
* @param _order Order data
* @param _interactions Array of interaction data to be executed during settlement
* @param _hooks Hooks to be called before and after settlement
* @param _makerSignature Typed signature of the maker
* @param _takerSignature Typed signature of the taker
*/
function settle(
address _signer,
uint256 _filledTakerAmount,
Order calldata _order,
GPv2Interaction.Data[] calldata _interactions,
GPv2Interaction.Hooks calldata _hooks,
Signature.TypedSignature calldata _makerSignature,
Signature.TypedSignature calldata _takerSignature
) external;
/**
* @notice Settles a single order
* @param _signer Address that signed the order
* @param _order Single order data
* @param _makerSignature Signature of the maker
* @param _filledTakerAmount Amount filled by the taker
* @param _takerSignature Signature of the taker
*/
function settleSingle(
address _signer,
Single calldata _order,
Signature.TypedSignature calldata _makerSignature,
uint256 _filledTakerAmount,
Signature.TypedSignature calldata _takerSignature
) external payable;
/**
* @notice Returns the address of the authenticator contract
* @return IAllowListAuthentication Authenticator interface
*/
function AUTHENTICATOR() external view returns (IAllowListAuthentication);
/**
* @notice Returns the address of the balance manager contract
* @return IBalanceManager The balance manager interface
*/
function BALANCE_MANAGER() external view returns (IBalanceManager);
/**
* @notice Returns the address of the repository contract
* @return IRepository Repository interface
*/
function REPOSITORY() external view returns (IRepository);
/**
* @notice Validates a signature
* @param _hash Hash of the data
* @param _signature Signature to validate
* @return Magic value if signature is valid, otherwise 0xffffffff
*/
function isValidSignature(bytes32 _hash, bytes calldata _signature) external view returns (bytes4);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
import {IACLManager} from './IACLManager.sol';
import {IPriceProvider} from './IPriceProvider.sol';
import {IInterestRateModel} from 'interfaces/IInterestRateModel.sol';
interface IRepository is IACLManager {
enum PauseType {
/// @dev not paused status
NOT_PAUSED,
/// @dev all actions are paused
PAUSED,
/// @dev only action with supply of an asset are paused
SUPPLY_PAUSED,
/// @dev only action with withdrawal of an asset are paused
WITHDRAW_PAUSED
}
struct Fees {
uint64 entryFee;
uint64 protocolShareFee;
uint64 protocolLiquidationFee;
}
struct AssetConfig {
IInterestRateModel interestRateModel;
uint256 maxSupplyLimit;
uint64 maxLoanToValue;
uint64 liquidationThreshold;
}
/**
* @notice Deploys new lending pool and adds assets to it
* @param assets array of assets to add
* @param configs array of configs for assets
* @return createdPool deployed lending pool address
*/
function newLendingPool(
address[] calldata assets,
IInterestRateModel.Config[] calldata configs
) external returns (address createdPool);
/**
* @notice Adds new assets to a lending pool
* @param _lendingPool address of a lending pool
* @param _assets array of assets to add
* @param _configs array of configs for assets
*/
function newAssets(
address _lendingPool,
address[] calldata _assets,
IInterestRateModel.Config[] calldata _configs
) external;
/**
* @notice Set factory contract for deploying new lending pools
* @param _newLendingPoolsFactory address of a new lending pools factory
*/
function setLendingPoolsFactory(
address _newLendingPoolsFactory
) external;
/**
* @notice Set factory contract for deploying new collateral, locked collateral and debt tokens
* @param _newTokensFactory address of a new tokens factory
*/
function setTokensFactory(
address _newTokensFactory
) external;
/**
* @notice Set default interest rate model
* @param _defaultInterestRateModel address of a new default interest rate model
*/
function setDefaultInterestRateModel(
IInterestRateModel _defaultInterestRateModel
) external;
/**
* @notice Set default maximum loan-to-value
* @param _defaultMaxLoanToValue new default loan-to-value
*/
function setDefaultMaxLoanToValue(
uint64 _defaultMaxLoanToValue
) external;
/**
* @notice Set default liquidation threshold
* @param _defaultLiquidationThreshold new default liquidation threshold
*/
function setDefaultLiquidationThreshold(
uint64 _defaultLiquidationThreshold
) external;
/**
* @notice Set default maximum supply limit in quote token
* @param _defaulMaxSupplyLimit new default maximum supply limit
*/
function setDefaultMaxSupplyLimit(
uint256 _defaulMaxSupplyLimit
) external;
/**
* @notice Set default interest rate model for an asset in a lending pool
* @param _lendingPool address of a lending pool
* @param _asset address of an asset
* @param _interestRateModel address of a new interest rate model
*/
function setInterestRateModel(address _lendingPool, address _asset, IInterestRateModel _interestRateModel) external;
/**
* @notice Set maximum loan-to-value for an asset in a lending pool
* @param _lendingPool address of a lending pool
* @param _asset address of an asset
* @param _maxLoanToValue new loan-to-value
*/
function setMaxLoanToValue(address _lendingPool, address _asset, uint64 _maxLoanToValue) external;
/**
* @notice Set liquidation threshold for an asset in a lending pool
* @param _lendingPool address of a lending pool
* @param _asset address of an asset
* @param _liquidationThreshold new liquidation threshold
*/
function setLiquidationThreshold(address _lendingPool, address _asset, uint64 _liquidationThreshold) external;
/**
* @notice Set maximum supply limit in quote token for an asset in a lending pool
* @param _lendingPool address of a lending pool
* @param _asset address of an asset
* @param _maxSupplyLimit new maximum supply limit in quote token
*/
function setMaxSupplyLimit(address _lendingPool, address _asset, uint256 _maxSupplyLimit) external;
/**
* @notice Set protocol fees
* @param _fees new protocol fees
*/
function setFees(
Fees calldata _fees
) external;
/**
* @notice Set swap connector
* @param _newSwapConnector new swap connector
*/
function setSwapConnector(
address _newSwapConnector
) external;
/**
* @notice Set liquorice settlement contract
* @param _settlement new liquorice settlement contract
*/
function setSettlement(
address _settlement
) external;
/**
* @notice Set price provider
* @param _priceProvider new price provider
*/
function setPriceProvider(
IPriceProvider _priceProvider
) external;
/**
* @notice Set global limit of maximum supplied assets in quote token
* @param _globalLimit new global limit value
*/
function setGlobalSupplyLimit(
bool _globalLimit
) external;
/**
* @notice Set global pause for lending pools interactions
* @param _globalPause new global pause value
*/
function setGlobalPause(
bool _globalPause
) external;
/**
* @notice Set pause for specific lending pool's asset interactions
* @param _lendingPool address of a lending pool
* @param _asset address of an asset
* @param _pauseType type of pause
*/
function setPause(address _lendingPool, address _asset, PauseType _pauseType) external;
/**
* @notice Get address of the Liquorice Settlement contract
* @return address of LiquoriceSettlement contract
*/
function settlement() external view returns (address);
/**
* @notice Get address of default role admin
* @return address of default role admin
*/
function aclAdmin() external view returns (address);
/**
* @notice Get global supply limit flag value
* @return bool global supply limit flag value
*/
function globalSupplyLimit() external view returns (bool);
/**
* @notice Get global pause flag value
* @return bool global pause flag value
*/
function globalPause() external view returns (bool);
/**
* @notice Get interest rate model for specific lending pool and asset
* @param _lendingPool address of a lending pool
* @param _asset address of an asset
* @return model address of interest rate model
*/
function getInterestRateModel(address _lendingPool, address _asset) external view returns (IInterestRateModel model);
/**
* @notice Get maximum loan-to-value for specific lending pool and asset
* @param _lendingPool address of a lending pool
* @param _asset address of an asset
* @return uint256 maximum loan-to-value
*/
function getMaximumLTV(address _lendingPool, address _asset) external view returns (uint256);
/**
* @notice Get liquidation threshold for specific lending pool and asset
* @param _lendingPool address of a lending pool
* @param _asset address of an asset
* @return uint256 liquidation threshold
*/
function getLiquidationThreshold(address _lendingPool, address _asset) external view returns (uint256);
/**
* @notice Get maximum supply limit in quote token for specific lending pool and asset
* @param _lendingPool address of a lending pool
* @param _asset address of an asset
* @return uint256 maximum supply limit in quote token
*/
function getMaxSupplyLimit(address _lendingPool, address _asset) external view returns (uint256);
/**
* @notice Get pause status for specific lending pool and asset
* @param _lendingPool address of a lending pool
* @param _asset address of an asset
* @return PauseType type of pause set
*/
function getPauseStatus(address _lendingPool, address _asset) external view returns (PauseType);
/**
* @notice Get fee for entering the lending pool
* @return uint256 entry fee
*/
function entryFee() external view returns (uint256);
/**
* @notice Check if contract address is existing lending pool
* @return true if address is lending pool, otherwise faulse
*/
function isLendingPool(
address _lendingPool
) external view returns (bool);
/**
* @notice Get PriceProvider contract
* @return IPriceProvider address
*/
function priceProvider() external view returns (IPriceProvider);
/**
* @notice Get protocol share fee value
* @return uint256 protocol share fee
*/
function protocolShareFee() external view returns (uint256);
/**
* @notice Get protocol liquidation fee value
* @return uint256 protocol liquidation fee
*/
function protocolLiquidationFee() external view returns (uint256);
/**
* @notice Get swap connector contract address
* @return address of swap connector contract
*/
function swapConnector() external view returns (address);
}// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity >=0.7.6 <0.9.0;
/// @title Gnosis Protocol v2 Interaction Library
/// @author Gnosis Developers
library GPv2Interaction {
/// @dev Interaction data for performing arbitrary contract interactions.
/// Submitted to [`GPv2Settlement.settle`] for code execution.
struct Data {
address target;
uint256 value;
bytes callData;
}
struct Hooks {
Data[] beforeSettle;
Data[] afterSettle;
}
/// @dev Execute an arbitrary contract interaction.
///
/// @param interaction Interaction data.
function execute(
Data calldata interaction
) internal {
address target = interaction.target;
uint256 value = interaction.value;
bytes calldata callData = interaction.callData;
// NOTE: Use assembly to call the interaction instead of a low level
// call for two reasons:
// - We don't want to copy the return data, since we discard it for
// interactions.
// - Solidity will under certain conditions generate code to copy input
// calldata twice to memory (the second being a "memcopy loop").
// <https://github.com/gnosis/gp-v2-contracts/pull/417#issuecomment-775091258>
// solhint-disable-next-line no-inline-assembly
assembly {
let freeMemoryPointer := mload(0x40)
calldatacopy(freeMemoryPointer, callData.offset, callData.length)
if iszero(call(gas(), target, value, freeMemoryPointer, callData.length, 0, 0)) {
returndatacopy(0, 0, returndatasize())
revert(0, returndatasize())
}
}
}
/// @dev Extracts the Solidity ABI selector for the specified interaction.
///
/// @param interaction Interaction data.
/// @return result The 4 byte function selector of the call encoded in
/// this interaction.
function selector(
Data calldata interaction
) internal pure returns (bytes4 result) {
bytes calldata callData = interaction.callData;
if (callData.length >= 4) {
// NOTE: Read the first word of the interaction's calldata. The
// value does not need to be shifted since `bytesN` values are left
// aligned, and the value does not need to be masked since masking
// occurs when the value is accessed and not stored:
// <https://docs.soliditylang.org/en/v0.7.6/abi-spec.html#encoding-of-indexed-event-parameters>
// <https://docs.soliditylang.org/en/v0.7.6/assembly.html#access-to-external-variables-functions-and-libraries>
// solhint-disable-next-line no-inline-assembly
assembly {
result := calldataload(callData.offset)
}
}
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.23;
/**
* @title Signature Library
* @dev Library for handling and validating Ethereum signatures
*/
library Signature {
enum Type {
NONE, // 0
ETHSIGN, //1
EIP1271, // 2
EIP712 // 3
}
enum TransferCommand {
NONE,
SIMPLE_TRANSFER,
PERMIT2_TRANSFER
}
struct TakerPermitInfo {
bytes signature;
uint48 nonce;
uint48 deadline;
}
/**
* @dev Struct representing a typed signature
* @param signatureType Type of the signature
* @param signatureBytes Bytes of the signature
*/
struct TypedSignature {
Type signatureType;
TransferCommand transferCommand;
bytes signatureBytes;
}
error InvalidSignatureValueV();
error InvalidSignatureValueS();
error InvalidSignatureLength();
/**
* @dev Extracts r, s, and v values from a signature
* @param sig Signature bytes
* @return r r value of the signature
* @return s s value of the signature
* @return v v value of the signature
*/
function getRsv(
bytes memory sig
) internal pure returns (bytes32 r, bytes32 s, uint8 v) {
if (sig.length != 65) revert InvalidSignatureLength();
assembly {
r := mload(add(sig, 32))
s := mload(add(sig, 64))
v := and(mload(add(sig, 65)), 255)
}
if (v < 27) v += 27;
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
revert InvalidSignatureValueS();
}
if (v != 27 && v != 28) revert InvalidSignatureValueV();
return (r, s, v);
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.23;
import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import {Signature} from '../lib/Signature.sol';
import {IBalanceManager} from '../../interfaces/IBalanceManager.sol';
import {IAllowanceTransfer} from '../../interfaces/external/permit/IAllowanceTransfer.sol';
/**
* @title BalanceManager
* @notice Manages token balances and allows transfers by an authorized operator
*/
contract BalanceManager is IBalanceManager {
using SafeERC20 for IERC20;
address private immutable _OPERATOR;
IAllowanceTransfer public immutable PERMIT2;
error NotOperator();
error InvalidTransferType();
modifier onlyOperator(
address account
) {
if (account != _OPERATOR) revert NotOperator();
_;
}
constructor(address operator_, address permit2_) {
// Operator can be defined at creation time with `msg.sender`
// Pass in the settlement - and that can be the only caller.
_OPERATOR = operator_;
PERMIT2 = IAllowanceTransfer(permit2_);
}
/// @inheritdoc IBalanceManager
function transferTokens(
TransferData calldata data
) external onlyOperator(msg.sender) {
if (data.amount == 0) return;
if (data.tokenTransferTypes == Signature.TransferCommand.SIMPLE_TRANSFER) {
IERC20(data.token).safeTransferFrom(data.from, data.receiver, data.amount);
} else if (data.tokenTransferTypes == Signature.TransferCommand.PERMIT2_TRANSFER) {
PERMIT2.transferFrom(data.from, data.receiver, uint160(data.amount), data.token);
} else {
revert InvalidTransferType();
}
}
function tokenPermits(
address _from,
address _token,
uint256 _amount,
Signature.TakerPermitInfo calldata takerPermitInfo
) external onlyOperator(msg.sender) {
PERMIT2.permit({
owner: _from,
permitSingle: IAllowanceTransfer.PermitSingle({
details: IAllowanceTransfer.PermitDetails({
token: _token,
amount: uint160(_amount),
expiration: takerPermitInfo.deadline,
nonce: takerPermitInfo.nonce
}),
spender: address(this),
sigDeadline: takerPermitInfo.deadline
}),
signature: takerPermitInfo.signature
});
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.23;
import {IERC1271} from '@openzeppelin/contracts/interfaces/IERC1271.sol';
import {ECDSA} from '@openzeppelin/contracts/utils/cryptography/ECDSA.sol';
import {GPv2Interaction} from '../lib/GPv2Interaction.sol';
import {Signature} from '../lib/Signature.sol';
import {ILiquoriceSettlement} from '../../interfaces/ILiquoriceSettlement.sol';
import {IRepository} from '../../interfaces/IRepository.sol';
/**
* @title Signing
* @notice Handles signature validation and order verification for Liquorice settlement
*/
abstract contract Signing {
struct ExtractedVariables {
uint256 toRepay;
uint256 toSupply;
uint256 toWithdraw;
uint256 toBorrow;
uint256 toBorrowFromTrade;
uint256 toSupplyFromTrade;
}
/* ============ Constants ============ */
bytes32 private constant DOMAIN_NAME = keccak256('LiquoriceSettlement');
bytes32 private constant DOMAIN_VERSION = keccak256('1');
bytes32 private constant EIP712_DOMAIN_TYPEHASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;
uint256 private constant ETH_SIGN_HASH_PREFIX = 0x19457468657265756d205369676e6564204d6573736167653a0a333200000000;
bytes4 private constant _SUPPLY_SIGNATURE_SELECTOR = bytes4(keccak256('supplyFor(address,address,uint256,bool)'));
bytes4 private constant _BORROW_SIGNATURE_SELECTOR = bytes4(keccak256('borrowFor(address,address,address,uint256)'));
bytes4 private constant _BORROW_TRADE_SIGNATURE_SELECTOR =
bytes4(keccak256('borrowFor(address,address,address,address,uint256,address,uint256)'));
bytes4 private constant _REPAY_SIGNATURE_SELECTOR = bytes4(keccak256('repayFor(address,address,uint256)'));
bytes4 private constant _WITHDRAW_SIGNATURE_SELECTOR =
bytes4(keccak256('withdrawFor(address,address,address,uint256,bool)'));
bytes4 internal constant _EIP1271_MAGICVALUE = bytes4(keccak256('isValidSignature(bytes32,bytes)'));
bytes32 private constant _SINGLE_ORDER_TYPED_HASH =
keccak256('Single(string,uint256,address,address,address,address,uint256,uint256,uint256,uint256,address)');
bytes32 private constant _BASE_TOKEN_DATA_TYPED_HASH =
keccak256('BaseTokenData(address,uint256,uint256,uint256,uint256)');
bytes32 private constant _QUOTE_TOKEN_DATA_TYPED_HASH =
keccak256('QuoteTokenData(address,uint256,uint256,uint256,uint256)');
bytes32 private constant _SETTLE_ORDER_TYPED_HASH = keccak256(
'Order(string,uint256,address,address,uint256,address,uint256,BaseTokenData,QuoteTokenData)BaseTokenData(address,uint256,uint256,uint256,uint256)QuoteTokenData(address,uint256,uint256,uint256,uint256)'
);
bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
uint256 private immutable _CACHED_CHAIN_ID;
/* ============ State Variables ============ */
mapping(address => mapping(uint256 => bool)) private _nonces;
/* ============ Errors ============ */
error InvalidAmount();
error InvalidAsset();
error InvalidBaseTokenAmounts();
error InvalidDestination();
error InvalidHooksTarget();
error InvalidInteractionsBaseTokenAmounts();
error InvalidInteractionsQuoteTokenAmounts();
error InvalidLendingPoolInteraction();
error InvalidQuoteTokenAmounts();
error InvalidSigner();
error InvalidSource();
error InvalidSignatureType();
error InvalidEIP1271Signature();
error InvalidETHSignSignature();
error InvalidEIP712Signature();
error NonceInvalid();
error SignatureIsExpired();
error UpdatedMakerAmountsTooLow();
error ZeroMakerAmount();
error OrderExpired();
error InvalidFillAmount();
error PartialFillNotSupported();
error SignatureIsNotEmpty();
/* ============ Constructor ============ */
constructor() {
_CACHED_CHAIN_ID = block.chainid;
_CACHED_DOMAIN_SEPARATOR =
keccak256(abi.encode(EIP712_DOMAIN_TYPEHASH, DOMAIN_NAME, DOMAIN_VERSION, block.chainid, address(this)));
}
/* ============ Public Functions ============ */
/**
* @notice Cancels a limit order by invalidating its nonce
* @param nonce Nonce of the order to be canceled
*/
function cancelLimitOrder(
uint256 nonce
) external {
_invalidateOrderNonce(msg.sender, nonce);
}
/**
* @notice Computes the hash of an order
* @param _order Order data to hash
* @return bytes32 Hash of the order
*/
function hashOrder(
ILiquoriceSettlement.Order calldata _order
) public view returns (bytes32) {
return keccak256(
abi.encodePacked(
'\x19\x01',
DOMAIN_SEPARATOR(),
keccak256(
bytes.concat(
// avoiding stack too deep
abi.encode(
_SETTLE_ORDER_TYPED_HASH,
keccak256(abi.encode(_order.rfqId)),
_order.nonce,
_order.trader,
_order.effectiveTrader,
_order.quoteExpiry,
_order.recipient,
_order.minFillAmount
),
hashBaseTokenData(_order.baseTokenData),
hashQuoteTokenData(_order.quoteTokenData)
)
)
)
);
}
function hashBaseTokenData(
ILiquoriceSettlement.BaseTokenData calldata _baseTokenData
) public pure returns (bytes32) {
return keccak256(
abi.encode(
_BASE_TOKEN_DATA_TYPED_HASH,
_baseTokenData.addr,
_baseTokenData.amount,
_baseTokenData.toRecipient,
_baseTokenData.toRepay,
_baseTokenData.toSupply
)
);
}
function hashQuoteTokenData(
ILiquoriceSettlement.QuoteTokenData calldata _quoteTokenData
) public pure returns (bytes32) {
return keccak256(
abi.encode(
_QUOTE_TOKEN_DATA_TYPED_HASH,
_quoteTokenData.addr,
_quoteTokenData.amount,
_quoteTokenData.toTrader,
_quoteTokenData.toWithdraw,
_quoteTokenData.toBorrow
)
);
}
/**
* @notice Computes the hash of a single order
* @param _order Single order data to hash
* @return bytes32 Hash of the single order
*/
function hashSingleOrder(
ILiquoriceSettlement.Single calldata _order
) public view returns (bytes32) {
return keccak256(
abi.encodePacked(
'\x19\x01',
DOMAIN_SEPARATOR(),
keccak256(
bytes.concat(
// avoiding stack too deep
abi.encode(_SINGLE_ORDER_TYPED_HASH, keccak256(abi.encode(_order.rfqId)), _order.nonce, _order.trader),
abi.encode(
_order.effectiveTrader,
_order.baseToken,
_order.quoteToken,
_order.baseTokenAmount,
_order.quoteTokenAmount,
_order.minFillAmount,
_order.quoteExpiry,
_order.recipient
)
)
)
)
);
}
function DOMAIN_SEPARATOR() public view returns (bytes32) {
return block.chainid == _CACHED_CHAIN_ID
? _CACHED_DOMAIN_SEPARATOR
: keccak256(abi.encode(EIP712_DOMAIN_TYPEHASH, DOMAIN_NAME, DOMAIN_VERSION, block.chainid, address(this)));
}
/**
* @notice Validates interactions for an order
* @param _repository Repository interface
* @param _signer Signer address
* @param _order Order data
* @param _interactions Array of interaction data
*/
function validateInteractions(
IRepository _repository,
address _signer,
bool _isPartialFill,
ILiquoriceSettlement.Order calldata _order,
GPv2Interaction.Data[] calldata _interactions
) public view {
ExtractedVariables memory v;
for (uint256 i; i < _interactions.length; ++i) {
GPv2Interaction.Data calldata interaction = _interactions[i];
bytes calldata callData = interaction.callData;
if (_repository.isLendingPool(interaction.target)) {
bytes4 sig;
if (_isPartialFill) revert PartialFillNotSupported();
if (callData.length >= 4) {
assembly {
sig := calldataload(callData.offset)
}
}
if (sig == _SUPPLY_SIGNATURE_SELECTOR) {
v.toSupply += _validateSupplyFor(callData, _signer, _order);
} else if (sig == _BORROW_SIGNATURE_SELECTOR) {
v.toBorrow += _validateBorrowFor(callData, _signer, _order);
} else if (sig == _BORROW_TRADE_SIGNATURE_SELECTOR) {
(v.toBorrowFromTrade, v.toSupplyFromTrade) = _validateBorrowForTrade(callData, _signer, _order);
v.toBorrow += v.toBorrowFromTrade;
v.toSupply += v.toSupplyFromTrade;
} else if (sig == _REPAY_SIGNATURE_SELECTOR) {
v.toRepay += _validateRepayFor(callData, _signer, _order);
} else if (sig == _WITHDRAW_SIGNATURE_SELECTOR) {
v.toWithdraw += _validateWithdrawFor(callData, _signer, _order);
} else {
revert InvalidLendingPoolInteraction();
}
}
}
_validateInteractionsAmount(_order, v);
}
/**
* @notice Validates supply interaction
* @param callData Call data for the interaction
* @param _signer Signer address
* @param _order Order data
* @return uint256 Amount to supply
*/
function _validateSupplyFor(
bytes calldata callData,
address _signer,
ILiquoriceSettlement.Order calldata _order
) private view returns (uint256) {
(address asset, address receiver, uint256 amount,) = abi.decode(callData[4:], (address, address, uint256, bool));
if (asset != _order.baseTokenData.addr) revert InvalidAsset();
if (_signer != receiver) revert InvalidSigner();
if (amount != _order.baseTokenData.toSupply) revert InvalidAmount();
return amount;
}
/**
* @notice Validates borrow interaction
* @param callData Call data for the interaction
* @param _signer Signer address
* @param _order Order data
* @return uint256 Amount to borrow
*/
function _validateBorrowFor(
bytes calldata callData,
address _signer,
ILiquoriceSettlement.Order calldata _order
) private pure returns (uint256) {
(address asset, address borrower, address receiver, uint256 amount) =
abi.decode(callData[4:], (address, address, address, uint256));
if (asset != _order.quoteTokenData.addr) revert InvalidAsset();
if (_signer != borrower) revert InvalidSigner();
if (receiver != _order.trader) revert InvalidDestination();
if (amount != _order.quoteTokenData.toBorrow) revert InvalidAmount();
return amount;
}
/**
* @notice Validates borrow for trade interaction
* @param callData Call data for the interaction
* @param _signer Signer address
* @param _order Order data
* @return (uint256, uint256) Amounts to borrow and supply
*/
function _validateBorrowForTrade(
bytes calldata callData,
address _signer,
ILiquoriceSettlement.Order calldata _order
) private view returns (uint256, uint256) {
(
address asset,
address borrower,
address source,
address recipient,
uint256 amount,
address tradeAsset,
uint256 tradeAmount
) = abi.decode(callData[4:], (address, address, address, address, uint256, address, uint256));
if (asset != _order.quoteTokenData.addr) revert InvalidAsset();
if (_signer != borrower) revert InvalidSigner();
if (source != address(this)) revert InvalidSource();
if (recipient != _order.trader) revert InvalidDestination();
if (amount != _order.quoteTokenData.toBorrow) revert InvalidAmount();
if (tradeAsset != _order.baseTokenData.addr) revert InvalidAsset();
if (tradeAmount != _order.baseTokenData.toSupply) revert InvalidAmount();
return (amount, tradeAmount);
}
/**
* @notice Validates repay interaction
* @param callData Call data for the interaction
* @param _signer Signer address
* @param _order Order data
* @return uint256 Amount to repay
*/
function _validateRepayFor(
bytes calldata callData,
address _signer,
ILiquoriceSettlement.Order calldata _order
) private view returns (uint256) {
(address asset, address borrower, uint256 amount) = abi.decode(callData[4:], (address, address, uint256));
if (asset != _order.baseTokenData.addr) revert InvalidAsset();
if (_signer != borrower) revert InvalidSigner();
if (amount != _order.baseTokenData.toRepay) revert InvalidAmount();
return amount;
}
/**
* @notice Validates withdraw interaction
* @param callData Call data for the interaction
* @param _signer Signer address
* @param _order Order data
* @return uint256 Amount to withdraw
*/
function _validateWithdrawFor(
bytes calldata callData,
address _signer,
ILiquoriceSettlement.Order calldata _order
) private pure returns (uint256) {
(address asset, address depositor, address receiver, uint256 amount,) =
abi.decode(callData[4:], (address, address, address, uint256, bool));
if (asset != _order.quoteTokenData.addr) revert InvalidAsset();
if (_signer != depositor) revert InvalidSigner();
if (receiver != _order.trader) revert InvalidDestination();
if (amount != _order.quoteTokenData.toWithdraw) revert InvalidAmount();
return amount;
}
/**
* @notice Validates the total amounts for interactions
* @param _order Order data
* @param v Extracted variables containing amounts
*/
function _validateInteractionsAmount(
ILiquoriceSettlement.Order calldata _order,
ExtractedVariables memory v
) private pure {
if (v.toRepay != _order.baseTokenData.toRepay || v.toSupply != _order.baseTokenData.toSupply) {
revert InvalidInteractionsBaseTokenAmounts();
}
if (v.toWithdraw != _order.quoteTokenData.toWithdraw || v.toBorrow != _order.quoteTokenData.toBorrow) {
revert InvalidInteractionsQuoteTokenAmounts();
}
}
/**
* @notice Validates the amounts in an order
* @param _order Order data
*/
function validateOrderAmounts(
ILiquoriceSettlement.Order calldata _order
) public pure {
if (
_order.baseTokenData.amount
!= _order.baseTokenData.toRecipient + _order.baseTokenData.toRepay + _order.baseTokenData.toSupply
) revert InvalidBaseTokenAmounts();
if (
_order.quoteTokenData.amount
!= _order.quoteTokenData.toTrader + _order.quoteTokenData.toWithdraw + _order.quoteTokenData.toBorrow
) revert InvalidQuoteTokenAmounts();
}
/**
* @notice Validates hooks for an order
* @param _repository Repository interface
* @param _hooks Hooks data
*/
function validateHooks(IRepository _repository, GPv2Interaction.Hooks calldata _hooks) public view {
for (uint256 i; i < _hooks.beforeSettle.length; ++i) {
GPv2Interaction.Data calldata hook = _hooks.beforeSettle[i];
if (_repository.isLendingPool(hook.target)) {
revert InvalidHooksTarget();
}
}
for (uint256 i; i < _hooks.afterSettle.length; ++i) {
GPv2Interaction.Data calldata hook = _hooks.afterSettle[i];
if (_repository.isLendingPool(hook.target)) {
revert InvalidHooksTarget();
}
}
}
/**
* @notice Validates a signature
* @param _validationAddress Address to validate against
* @param _hash Hash of the data
* @param _signature Signature data
*/
function validateSignature(
address _validationAddress,
bytes32 _hash,
Signature.TypedSignature calldata _signature
) public view {
if (_signature.signatureType == Signature.Type.EIP712) {
if (recoverSignature(_hash, _signature.signatureBytes) != _validationAddress) {
revert InvalidEIP712Signature();
}
} else if (_signature.signatureType == Signature.Type.ETHSIGN) {
bytes32 ethSignHash;
assembly {
mstore(0, ETH_SIGN_HASH_PREFIX)
mstore(28, _hash)
ethSignHash := keccak256(0, 60)
}
if (recoverSignature(ethSignHash, _signature.signatureBytes) != _validationAddress) {
revert InvalidETHSignSignature();
}
} else if (_signature.signatureType == Signature.Type.EIP1271) {
if (IERC1271(_validationAddress).isValidSignature(_hash, _signature.signatureBytes) != _EIP1271_MAGICVALUE) {
revert InvalidEIP1271Signature();
}
} else {
revert InvalidSignatureType();
}
}
/* ============ Private Functions ============ */
/**
* @notice Recovers the signer address from a signature
* @param _hash Hash of the data
* @param _signature Signature data
* @return address Signer address
*/
function recoverSignature(bytes32 _hash, bytes calldata _signature) internal pure returns (address) {
address signer = ECDSA.recover(_hash, _signature);
if (signer == address(0)) revert InvalidSigner();
return signer;
}
/**
* @notice Validates an order
* @param _repository Repository interface
* @param _signer Signer address
* @param _order Order data
* @param _interactions Array of interaction data
* @param _hooks Hooks data
* @param _makerSignature Typed signature of the maker
* @param _takerSignature Typed signature of the taker
*/
// solhint-disable-next-line private-vars-leading-underscore
function validateOrder(
IRepository _repository,
address _signer,
uint256 _curFillAmount,
ILiquoriceSettlement.Order calldata _order,
GPv2Interaction.Data[] calldata _interactions,
GPv2Interaction.Hooks calldata _hooks,
Signature.TypedSignature calldata _makerSignature,
Signature.TypedSignature calldata _takerSignature
) internal {
bytes32 orderHash = hashOrder(_order);
validateSignature(_signer, orderHash, _makerSignature);
if (msg.sender != _order.effectiveTrader) {
validateSignature(_order.effectiveTrader, orderHash, _takerSignature);
} else {
if (_takerSignature.signatureBytes.length == 0) revert SignatureIsNotEmpty();
}
_invalidateOrderNonce(_order.effectiveTrader, _order.nonce);
if (block.timestamp > _order.quoteExpiry) revert SignatureIsExpired();
if (_curFillAmount > 0 && (_curFillAmount < _order.minFillAmount)) revert InvalidFillAmount();
validateOrderAmounts(_order);
validateHooks(_repository, _hooks);
validateInteractions(
_repository,
_signer,
_curFillAmount > 0 && _curFillAmount != _order.quoteTokenData.toTrader,
_order,
_interactions
);
_invalidateOrderNonce(_signer, _order.nonce);
}
/**
* @notice Validates taker signature for a single order
* @param _order Single order data
* @param _takerSignature Taker's signature data
*/
function _validateTakerSignatureForSingleOrder(
ILiquoriceSettlement.Single calldata _order,
Signature.TypedSignature calldata _takerSignature
) internal {
if (msg.sender != _order.effectiveTrader) {
validateSignature(_order.effectiveTrader, hashSingleOrder(_order), _takerSignature);
} else {
if (_takerSignature.signatureBytes.length == 0) revert SignatureIsNotEmpty();
}
_invalidateSingleOrderNonce(_order.effectiveTrader, _order.nonce);
}
/**
* @notice Validates a single order
* @param _order Single order data
* @param _makerSignature Maker's signature data
*/
function _validateSingleOrder(
address _signer,
uint256 _curFillAmount,
ILiquoriceSettlement.Single calldata _order,
Signature.TypedSignature calldata _makerSignature
) internal {
if (_curFillAmount > 0 && (_curFillAmount < _order.minFillAmount)) revert InvalidFillAmount();
validateSignature(_signer, hashSingleOrder(_order), _makerSignature);
_invalidateSingleOrderNonce(_signer, _order.nonce);
if (_order.quoteExpiry <= block.timestamp) revert OrderExpired();
}
/**
* @notice Invalidates a single order nonce
* @param _signer Signer address
* @param _nonce Nonce to invalidate
*/
function _invalidateSingleOrderNonce(address _signer, uint256 _nonce) internal {
if (_nonces[_signer][_nonce]) revert NonceInvalid();
_nonces[_signer][_nonce] = true;
}
/**
* @notice Invalidates an order nonce
* @param _signer Signer address
* @param _nonce Nonce to invalidate
*/
function _invalidateOrderNonce(address _signer, uint256 _nonce) internal {
if (_nonces[_signer][_nonce]) revert NonceInvalid();
_nonces[_signer][_nonce] = true;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)
pragma solidity ^0.8.20;
/**
* @dev Helper library for emitting standardized panic codes.
*
* ```solidity
* contract Example {
* using Panic for uint256;
*
* // Use any of the declared internal constants
* function foo() { Panic.GENERIC.panic(); }
*
* // Alternatively
* function foo() { Panic.panic(Panic.GENERIC); }
* }
* ```
*
* Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
*
* _Available since v5.1._
*/
// slither-disable-next-line unused-state
library Panic {
/// @dev generic / unspecified error
uint256 internal constant GENERIC = 0x00;
/// @dev used by the assert() builtin
uint256 internal constant ASSERT = 0x01;
/// @dev arithmetic underflow or overflow
uint256 internal constant UNDER_OVERFLOW = 0x11;
/// @dev division or modulo by zero
uint256 internal constant DIVISION_BY_ZERO = 0x12;
/// @dev enum conversion error
uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
/// @dev invalid encoding in storage
uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
/// @dev empty array pop
uint256 internal constant EMPTY_ARRAY_POP = 0x31;
/// @dev array out of bounds access
uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
/// @dev resource error (too large allocation or too large array)
uint256 internal constant RESOURCE_ERROR = 0x41;
/// @dev calling invalid internal function
uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;
/// @dev Reverts with a panic code. Recommended to use with
/// the internal constants with predefined codes.
function panic(uint256 code) internal pure {
assembly ("memory-safe") {
mstore(0x00, 0x4e487b71)
mstore(0x20, code)
revert(0x1c, 0x24)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
assembly ("memory-safe") {
u := iszero(iszero(b))
}
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
interface IACLManager {
function setRoleAdmin(bytes32 _role, bytes32 _adminRole) external;
function addEmergency(
address admin
) external;
function addManager(
address admin
) external;
function addConsumer(
address admin
) external;
function removeConsumer(
address admin
) external;
function removeManager(
address admin
) external;
function removeEmergency(
address admin
) external;
function isEmergencyRole(
address admin
) external view returns (bool);
function isManagerRole(
address admin
) external view returns (bool);
function isConsumerRole(
address admin
) external view returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
interface IPriceProvider {
function getPrice(
address _asset
) external view returns (uint256 price);
function assetSupported(
address _asset
) external view returns (bool);
function QUOTE_TOKEN() external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
/**
* @title IInterestRateModel
* @notice Interface for interest rate calculation and configuration
*/
interface IInterestRateModel {
struct Config {
int256 r0;
int256 r1;
int256 r2;
uint256 ri;
int256 uopt;
uint256 rMax;
uint256 rMin;
}
/**
* @dev Set the current asset config.
* @param _pool Address of the pool for which the config is set
* @param _asset Address of the asset for which the config is set
* @param _config Current config for this token
*/
function setConfig(address _pool, address _asset, Config calldata _config) external;
/**
* @notice Gets and updates the current interest rate for an asset
* @param _asset Address of the asset
* @return rcur Current interest rate
*/
function getInterestRateAndUpdate(
address _asset
) external returns (uint256 rcur);
/**
* @notice Returns the current asset config. If no config is found, returns the default one.
* @param _pool Address of the pool where the config is searched for
* @param _asset Address of the asset
* @return Current configuration parameters
*/
function getConfig(address _pool, address _asset) external returns (Config memory);
/**
* @notice Gets the current interest rate for a pool's asset without updating state
* @param _pool Address of the lending pool
* @param _asset Address of the asset
* @return rcur Current interest rate
*/
function getCurrentInterestRate(address _pool, address _asset) external view returns (uint256 rcur);
/**
* @notice Returns the current APR for pool and asset
* @param _pool Address of the lending pool
* @param _asset Address of the asset
* @return apr Current APR
*/
function getCurrentAPR(address _pool, address _asset) external view returns (uint256 apr);
/**
* @dev Returns the current rate.
* @param _c Current config for this token
* @param _totalDeposits Total amount deposited for this asset
* @param _totalBorrowAmount Total amount borrowed for this asset
* @return Current interest rate
*/
function calculateCurrentInterestRate(
Config memory _c,
uint256 _totalDeposits,
uint256 _totalBorrowAmount
) external pure returns (uint256);
/// @dev DP is 18 decimal points used for integer calculations
// solhint-disable-next-line func-name-mixedcase
function DP() external pure returns (uint256);
/// @dev Number of seconds in a year
// solhint-disable-next-line func-name-mixedcase
function SECONDS_PER_YEAR() external pure returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
import {IEIP712} from './IEIP712.sol';
/// @title AllowanceTransfer
/// @notice Handles ERC20 token permissions through signature based allowance setting and ERC20 token transfers by checking allowed amounts
/// @dev Requires user's token approval on the Permit2 contract
interface IAllowanceTransfer is IEIP712 {
/// @notice Thrown when an allowance on a token has expired.
/// @param deadline The timestamp at which the allowed amount is no longer valid
error AllowanceExpired(uint256 deadline);
/// @notice Thrown when an allowance on a token has been depleted.
/// @param amount The maximum amount allowed
error InsufficientAllowance(uint256 amount);
/// @notice Thrown when too many nonces are invalidated.
error ExcessiveInvalidation();
/// @notice Emits an event when the owner successfully invalidates an ordered nonce.
event NonceInvalidation(
address indexed owner, address indexed token, address indexed spender, uint48 newNonce, uint48 oldNonce
);
/// @notice Emits an event when the owner successfully sets permissions on a token for the spender.
event Approval(
address indexed owner, address indexed token, address indexed spender, uint160 amount, uint48 expiration
);
/// @notice Emits an event when the owner successfully sets permissions using a permit signature on a token for the spender.
event Permit(
address indexed owner,
address indexed token,
address indexed spender,
uint160 amount,
uint48 expiration,
uint48 nonce
);
/// @notice Emits an event when the owner sets the allowance back to 0 with the lockdown function.
event Lockdown(address indexed owner, address token, address spender);
/// @notice The permit data for a token
struct PermitDetails {
// ERC20 token address
address token;
// the maximum amount allowed to spend
uint160 amount;
// timestamp at which a spender's token allowances become invalid
uint48 expiration;
// an incrementing value indexed per owner,token,and spender for each signature
uint48 nonce;
}
/// @notice The permit message signed for a single token allowance
struct PermitSingle {
// the permit data for a single token alownce
PermitDetails details;
// address permissioned on the allowed tokens
address spender;
// deadline on the permit signature
uint256 sigDeadline;
}
/// @notice The permit message signed for multiple token allowances
struct PermitBatch {
// the permit data for multiple token allowances
PermitDetails[] details;
// address permissioned on the allowed tokens
address spender;
// deadline on the permit signature
uint256 sigDeadline;
}
/// @notice The saved permissions
/// @dev This info is saved per owner, per token, per spender and all signed over in the permit message
/// @dev Setting amount to type(uint160).max sets an unlimited approval
struct PackedAllowance {
// amount allowed
uint160 amount;
// permission expiry
uint48 expiration;
// an incrementing value indexed per owner,token,and spender for each signature
uint48 nonce;
}
/// @notice A token spender pair.
struct TokenSpenderPair {
// the token the spender is approved
address token;
// the spender address
address spender;
}
/// @notice Details for a token transfer.
struct AllowanceTransferDetails {
// the owner of the token
address from;
// the recipient of the token
address to;
// the amount of the token
uint160 amount;
// the token to be transferred
address token;
}
/// @notice A mapping from owner address to token address to spender address to PackedAllowance struct, which contains details and conditions of the approval.
/// @notice The mapping is indexed in the above order see: allowance[ownerAddress][tokenAddress][spenderAddress]
/// @dev The packed slot holds the allowed amount, expiration at which the allowed amount is no longer valid, and current nonce thats updated on any signature based approvals.
function allowance(
address user,
address token,
address spender
) external view returns (uint160 amount, uint48 expiration, uint48 nonce);
/// @notice Approves the spender to use up to amount of the specified token up until the expiration
/// @param token The token to approve
/// @param spender The spender address to approve
/// @param amount The approved amount of the token
/// @param expiration The timestamp at which the approval is no longer valid
/// @dev The packed allowance also holds a nonce, which will stay unchanged in approve
/// @dev Setting amount to type(uint160).max sets an unlimited approval
function approve(address token, address spender, uint160 amount, uint48 expiration) external;
/// @notice Permit a spender to a given amount of the owners token via the owner's EIP-712 signature
/// @dev May fail if the owner's nonce was invalidated in-flight by invalidateNonce
/// @param owner The owner of the tokens being approved
/// @param permitSingle Data signed over by the owner specifying the terms of approval
/// @param signature The owner's signature over the permit data
function permit(address owner, PermitSingle memory permitSingle, bytes calldata signature) external;
/// @notice Transfer approved tokens from one address to another
/// @param from The address to transfer from
/// @param to The address of the recipient
/// @param amount The amount of the token to transfer
/// @param token The token address to transfer
/// @dev Requires the from address to have approved at least the desired amount
/// of tokens to msg.sender.
function transferFrom(address from, address to, uint160 amount, address token) external;
/// @notice Transfer approved tokens in a batch
/// @param transferDetails Array of owners, recipients, amounts, and tokens for the transfers
/// @dev Requires the from addresses to have approved at least the desired amount
/// of tokens to msg.sender.
function transferFrom(
AllowanceTransferDetails[] calldata transferDetails
) external;
/// @notice Enables performing a "lockdown" of the sender's Permit2 identity
/// by batch revoking approvals
/// @param approvals Array of approvals to revoke.
function lockdown(
TokenSpenderPair[] calldata approvals
) external;
/// @notice Invalidate nonces for a given (token, spender) pair
/// @param token The token to invalidate nonces for
/// @param spender The spender to invalidate nonces for
/// @param newNonce The new nonce to set. Invalidates all nonces less than it.
/// @dev Can't invalidate more than 2**16 nonces per transaction.
function invalidateNonces(address token, address spender, uint48 newNonce) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1271.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-1271 standard signature validation method for
* contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].
*/
interface IERC1271 {
/**
* @dev Should return whether the signature provided is valid for the provided data
* @param hash Hash of the data to be signed
* @param signature Signature byte array associated with `hash`
*/
function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.20;
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS
}
/**
* @dev The signature derives the `address(0)`.
*/
error ECDSAInvalidSignature();
/**
* @dev The signature has an invalid length.
*/
error ECDSAInvalidSignatureLength(uint256 length);
/**
* @dev The signature has an S value that is in the upper half order.
*/
error ECDSAInvalidSignatureS(bytes32 s);
/**
* @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not
* return address(0) without also returning an error description. Errors are documented using an enum (error type)
* and a bytes32 providing additional information about the error.
*
* If no error is returned, then the address can be used for verification purposes.
*
* The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*/
function tryRecover(
bytes32 hash,
bytes memory signature
) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly ("memory-safe") {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[ERC-2098 short signatures]
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
unchecked {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
// We do not check for an overflow here since the shift operation results in 0 or 1.
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*/
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS, s);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature, bytes32(0));
}
return (signer, RecoverError.NoError, bytes32(0));
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.
*/
function _throwError(RecoverError error, bytes32 errorArg) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert ECDSAInvalidSignature();
} else if (error == RecoverError.InvalidSignatureLength) {
revert ECDSAInvalidSignatureLength(uint256(errorArg));
} else if (error == RecoverError.InvalidSignatureS) {
revert ECDSAInvalidSignatureS(errorArg);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
interface IEIP712 {
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}{
"remappings": [
"ds-test/=node_modules/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"@chainlink/=lib/chainlink/contracts/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"contracts/=src/contracts/",
"interfaces/=src/interfaces/",
"chainlink/=lib/chainlink/",
"erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"openzeppelin-upgrades/=lib/openzeppelin-upgrades/"
],
"optimizer": {
"enabled": true,
"runs": 10000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "shanghai",
"viaIR": false
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"contract IAllowListAuthentication","name":"authenticator_","type":"address"},{"internalType":"contract IRepository","name":"repository_","type":"address"},{"internalType":"address","name":"permit2_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"InvalidAsset","type":"error"},{"inputs":[],"name":"InvalidBaseTokenAmounts","type":"error"},{"inputs":[],"name":"InvalidDestination","type":"error"},{"inputs":[],"name":"InvalidEIP1271Signature","type":"error"},{"inputs":[],"name":"InvalidEIP712Signature","type":"error"},{"inputs":[],"name":"InvalidETHSignSignature","type":"error"},{"inputs":[],"name":"InvalidFillAmount","type":"error"},{"inputs":[],"name":"InvalidHooksTarget","type":"error"},{"inputs":[],"name":"InvalidInteractionsBaseTokenAmounts","type":"error"},{"inputs":[],"name":"InvalidInteractionsQuoteTokenAmounts","type":"error"},{"inputs":[],"name":"InvalidLendingPoolInteraction","type":"error"},{"inputs":[],"name":"InvalidQuoteTokenAmounts","type":"error"},{"inputs":[],"name":"InvalidSignatureType","type":"error"},{"inputs":[],"name":"InvalidSigner","type":"error"},{"inputs":[],"name":"InvalidSource","type":"error"},{"inputs":[],"name":"NonceInvalid","type":"error"},{"inputs":[],"name":"NotMaker","type":"error"},{"inputs":[],"name":"NotSolver","type":"error"},{"inputs":[],"name":"OrderExpired","type":"error"},{"inputs":[],"name":"PartialFillNotSupported","type":"error"},{"inputs":[],"name":"ReceiverNotManager","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"SignatureIsExpired","type":"error"},{"inputs":[],"name":"SignatureIsNotEmpty","type":"error"},{"inputs":[],"name":"UpdatedMakerAmountsTooLow","type":"error"},{"inputs":[],"name":"ZeroMakerAmount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"bytes4","name":"selector","type":"bytes4"}],"name":"Interaction","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"rfqId","type":"string"},{"indexed":false,"internalType":"address","name":"trader","type":"address"},{"indexed":false,"internalType":"address","name":"effectiveTrader","type":"address"},{"indexed":false,"internalType":"address","name":"baseToken","type":"address"},{"indexed":false,"internalType":"address","name":"quoteToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"baseTokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"quoteTokenAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"TradeOrder","type":"event"},{"inputs":[],"name":"AUTHENTICATOR","outputs":[{"internalType":"contract IAllowListAuthentication","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"BALANCE_MANAGER","outputs":[{"internalType":"contract IBalanceManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REPOSITORY","outputs":[{"internalType":"contract IRepository","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"cancelLimitOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"toRecipient","type":"uint256"},{"internalType":"uint256","name":"toRepay","type":"uint256"},{"internalType":"uint256","name":"toSupply","type":"uint256"}],"internalType":"struct ILiquoriceSettlement.BaseTokenData","name":"_baseTokenData","type":"tuple"}],"name":"hashBaseTokenData","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"market","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"string","name":"rfqId","type":"string"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"address","name":"trader","type":"address"},{"internalType":"address","name":"effectiveTrader","type":"address"},{"internalType":"uint256","name":"quoteExpiry","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"minFillAmount","type":"uint256"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"toRecipient","type":"uint256"},{"internalType":"uint256","name":"toRepay","type":"uint256"},{"internalType":"uint256","name":"toSupply","type":"uint256"}],"internalType":"struct ILiquoriceSettlement.BaseTokenData","name":"baseTokenData","type":"tuple"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"toTrader","type":"uint256"},{"internalType":"uint256","name":"toWithdraw","type":"uint256"},{"internalType":"uint256","name":"toBorrow","type":"uint256"}],"internalType":"struct ILiquoriceSettlement.QuoteTokenData","name":"quoteTokenData","type":"tuple"}],"internalType":"struct ILiquoriceSettlement.Order","name":"_order","type":"tuple"}],"name":"hashOrder","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"toTrader","type":"uint256"},{"internalType":"uint256","name":"toWithdraw","type":"uint256"},{"internalType":"uint256","name":"toBorrow","type":"uint256"}],"internalType":"struct ILiquoriceSettlement.QuoteTokenData","name":"_quoteTokenData","type":"tuple"}],"name":"hashQuoteTokenData","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"rfqId","type":"string"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"address","name":"trader","type":"address"},{"internalType":"address","name":"effectiveTrader","type":"address"},{"internalType":"address","name":"baseToken","type":"address"},{"internalType":"address","name":"quoteToken","type":"address"},{"internalType":"uint256","name":"baseTokenAmount","type":"uint256"},{"internalType":"uint256","name":"quoteTokenAmount","type":"uint256"},{"internalType":"uint256","name":"minFillAmount","type":"uint256"},{"internalType":"uint256","name":"quoteExpiry","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"internalType":"struct ILiquoriceSettlement.Single","name":"_order","type":"tuple"}],"name":"hashSingleOrder","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_hash","type":"bytes32"},{"internalType":"bytes","name":"_signature","type":"bytes"}],"name":"isValidSignature","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_signer","type":"address"},{"internalType":"uint256","name":"_filledTakerAmount","type":"uint256"},{"components":[{"internalType":"address","name":"market","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"string","name":"rfqId","type":"string"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"address","name":"trader","type":"address"},{"internalType":"address","name":"effectiveTrader","type":"address"},{"internalType":"uint256","name":"quoteExpiry","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"minFillAmount","type":"uint256"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"toRecipient","type":"uint256"},{"internalType":"uint256","name":"toRepay","type":"uint256"},{"internalType":"uint256","name":"toSupply","type":"uint256"}],"internalType":"struct ILiquoriceSettlement.BaseTokenData","name":"baseTokenData","type":"tuple"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"toTrader","type":"uint256"},{"internalType":"uint256","name":"toWithdraw","type":"uint256"},{"internalType":"uint256","name":"toBorrow","type":"uint256"}],"internalType":"struct ILiquoriceSettlement.QuoteTokenData","name":"quoteTokenData","type":"tuple"}],"internalType":"struct ILiquoriceSettlement.Order","name":"_order","type":"tuple"},{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct GPv2Interaction.Data[]","name":"_interactions","type":"tuple[]"},{"components":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct GPv2Interaction.Data[]","name":"beforeSettle","type":"tuple[]"},{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct GPv2Interaction.Data[]","name":"afterSettle","type":"tuple[]"}],"internalType":"struct GPv2Interaction.Hooks","name":"_hooks","type":"tuple"},{"components":[{"internalType":"enum Signature.Type","name":"signatureType","type":"uint8"},{"internalType":"enum Signature.TransferCommand","name":"transferCommand","type":"uint8"},{"internalType":"bytes","name":"signatureBytes","type":"bytes"}],"internalType":"struct Signature.TypedSignature","name":"_makerSignature","type":"tuple"},{"components":[{"internalType":"enum Signature.Type","name":"signatureType","type":"uint8"},{"internalType":"enum Signature.TransferCommand","name":"transferCommand","type":"uint8"},{"internalType":"bytes","name":"signatureBytes","type":"bytes"}],"internalType":"struct Signature.TypedSignature","name":"_takerSignature","type":"tuple"}],"name":"settle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_signer","type":"address"},{"components":[{"internalType":"string","name":"rfqId","type":"string"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"address","name":"trader","type":"address"},{"internalType":"address","name":"effectiveTrader","type":"address"},{"internalType":"address","name":"baseToken","type":"address"},{"internalType":"address","name":"quoteToken","type":"address"},{"internalType":"uint256","name":"baseTokenAmount","type":"uint256"},{"internalType":"uint256","name":"quoteTokenAmount","type":"uint256"},{"internalType":"uint256","name":"minFillAmount","type":"uint256"},{"internalType":"uint256","name":"quoteExpiry","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"internalType":"struct ILiquoriceSettlement.Single","name":"_order","type":"tuple"},{"components":[{"internalType":"enum Signature.Type","name":"signatureType","type":"uint8"},{"internalType":"enum Signature.TransferCommand","name":"transferCommand","type":"uint8"},{"internalType":"bytes","name":"signatureBytes","type":"bytes"}],"internalType":"struct Signature.TypedSignature","name":"_makerSignature","type":"tuple"},{"internalType":"uint256","name":"_filledTakerAmount","type":"uint256"},{"components":[{"internalType":"enum Signature.Type","name":"signatureType","type":"uint8"},{"internalType":"enum Signature.TransferCommand","name":"transferCommand","type":"uint8"},{"internalType":"bytes","name":"signatureBytes","type":"bytes"}],"internalType":"struct Signature.TypedSignature","name":"_takerSignature","type":"tuple"}],"name":"settleSingle","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_signer","type":"address"},{"components":[{"internalType":"string","name":"rfqId","type":"string"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"address","name":"trader","type":"address"},{"internalType":"address","name":"effectiveTrader","type":"address"},{"internalType":"address","name":"baseToken","type":"address"},{"internalType":"address","name":"quoteToken","type":"address"},{"internalType":"uint256","name":"baseTokenAmount","type":"uint256"},{"internalType":"uint256","name":"quoteTokenAmount","type":"uint256"},{"internalType":"uint256","name":"minFillAmount","type":"uint256"},{"internalType":"uint256","name":"quoteExpiry","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"internalType":"struct ILiquoriceSettlement.Single","name":"_order","type":"tuple"},{"components":[{"internalType":"enum Signature.Type","name":"signatureType","type":"uint8"},{"internalType":"enum Signature.TransferCommand","name":"transferCommand","type":"uint8"},{"internalType":"bytes","name":"signatureBytes","type":"bytes"}],"internalType":"struct Signature.TypedSignature","name":"_makerSignature","type":"tuple"},{"internalType":"uint256","name":"_filledTakerAmount","type":"uint256"},{"components":[{"internalType":"enum Signature.Type","name":"signatureType","type":"uint8"},{"internalType":"enum Signature.TransferCommand","name":"transferCommand","type":"uint8"},{"internalType":"bytes","name":"signatureBytes","type":"bytes"}],"internalType":"struct Signature.TypedSignature","name":"_takerSignature","type":"tuple"},{"components":[{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"uint48","name":"nonce","type":"uint48"},{"internalType":"uint48","name":"deadline","type":"uint48"}],"internalType":"struct Signature.TakerPermitInfo","name":"_takerPermitInfo","type":"tuple"}],"name":"settleSingleWithPermitsSignatures","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_signer","type":"address"},{"internalType":"uint256","name":"_filledTakerAmount","type":"uint256"},{"components":[{"internalType":"address","name":"market","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"string","name":"rfqId","type":"string"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"address","name":"trader","type":"address"},{"internalType":"address","name":"effectiveTrader","type":"address"},{"internalType":"uint256","name":"quoteExpiry","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"minFillAmount","type":"uint256"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"toRecipient","type":"uint256"},{"internalType":"uint256","name":"toRepay","type":"uint256"},{"internalType":"uint256","name":"toSupply","type":"uint256"}],"internalType":"struct ILiquoriceSettlement.BaseTokenData","name":"baseTokenData","type":"tuple"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"toTrader","type":"uint256"},{"internalType":"uint256","name":"toWithdraw","type":"uint256"},{"internalType":"uint256","name":"toBorrow","type":"uint256"}],"internalType":"struct ILiquoriceSettlement.QuoteTokenData","name":"quoteTokenData","type":"tuple"}],"internalType":"struct ILiquoriceSettlement.Order","name":"_order","type":"tuple"},{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct GPv2Interaction.Data[]","name":"_interactions","type":"tuple[]"},{"components":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct GPv2Interaction.Data[]","name":"beforeSettle","type":"tuple[]"},{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct GPv2Interaction.Data[]","name":"afterSettle","type":"tuple[]"}],"internalType":"struct GPv2Interaction.Hooks","name":"_hooks","type":"tuple"},{"components":[{"internalType":"enum Signature.Type","name":"signatureType","type":"uint8"},{"internalType":"enum Signature.TransferCommand","name":"transferCommand","type":"uint8"},{"internalType":"bytes","name":"signatureBytes","type":"bytes"}],"internalType":"struct Signature.TypedSignature","name":"_makerSignature","type":"tuple"},{"components":[{"internalType":"enum Signature.Type","name":"signatureType","type":"uint8"},{"internalType":"enum Signature.TransferCommand","name":"transferCommand","type":"uint8"},{"internalType":"bytes","name":"signatureBytes","type":"bytes"}],"internalType":"struct Signature.TypedSignature","name":"_takerSignature","type":"tuple"},{"components":[{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"uint48","name":"nonce","type":"uint48"},{"internalType":"uint48","name":"deadline","type":"uint48"}],"internalType":"struct Signature.TakerPermitInfo","name":"_takerPermitInfo","type":"tuple"}],"name":"settleWithPermitsSignatures","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IRepository","name":"_repository","type":"address"},{"components":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct GPv2Interaction.Data[]","name":"beforeSettle","type":"tuple[]"},{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct GPv2Interaction.Data[]","name":"afterSettle","type":"tuple[]"}],"internalType":"struct GPv2Interaction.Hooks","name":"_hooks","type":"tuple"}],"name":"validateHooks","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IRepository","name":"_repository","type":"address"},{"internalType":"address","name":"_signer","type":"address"},{"internalType":"bool","name":"_isPartialFill","type":"bool"},{"components":[{"internalType":"address","name":"market","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"string","name":"rfqId","type":"string"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"address","name":"trader","type":"address"},{"internalType":"address","name":"effectiveTrader","type":"address"},{"internalType":"uint256","name":"quoteExpiry","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"minFillAmount","type":"uint256"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"toRecipient","type":"uint256"},{"internalType":"uint256","name":"toRepay","type":"uint256"},{"internalType":"uint256","name":"toSupply","type":"uint256"}],"internalType":"struct ILiquoriceSettlement.BaseTokenData","name":"baseTokenData","type":"tuple"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"toTrader","type":"uint256"},{"internalType":"uint256","name":"toWithdraw","type":"uint256"},{"internalType":"uint256","name":"toBorrow","type":"uint256"}],"internalType":"struct ILiquoriceSettlement.QuoteTokenData","name":"quoteTokenData","type":"tuple"}],"internalType":"struct ILiquoriceSettlement.Order","name":"_order","type":"tuple"},{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct GPv2Interaction.Data[]","name":"_interactions","type":"tuple[]"}],"name":"validateInteractions","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"market","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"string","name":"rfqId","type":"string"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"address","name":"trader","type":"address"},{"internalType":"address","name":"effectiveTrader","type":"address"},{"internalType":"uint256","name":"quoteExpiry","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"minFillAmount","type":"uint256"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"toRecipient","type":"uint256"},{"internalType":"uint256","name":"toRepay","type":"uint256"},{"internalType":"uint256","name":"toSupply","type":"uint256"}],"internalType":"struct ILiquoriceSettlement.BaseTokenData","name":"baseTokenData","type":"tuple"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"toTrader","type":"uint256"},{"internalType":"uint256","name":"toWithdraw","type":"uint256"},{"internalType":"uint256","name":"toBorrow","type":"uint256"}],"internalType":"struct ILiquoriceSettlement.QuoteTokenData","name":"quoteTokenData","type":"tuple"}],"internalType":"struct ILiquoriceSettlement.Order","name":"_order","type":"tuple"}],"name":"validateOrderAmounts","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_validationAddress","type":"address"},{"internalType":"bytes32","name":"_hash","type":"bytes32"},{"components":[{"internalType":"enum Signature.Type","name":"signatureType","type":"uint8"},{"internalType":"enum Signature.TransferCommand","name":"transferCommand","type":"uint8"},{"internalType":"bytes","name":"signatureBytes","type":"bytes"}],"internalType":"struct Signature.TypedSignature","name":"_signature","type":"tuple"}],"name":"validateSignature","outputs":[],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
61012060405234801562000011575f80fd5b5060405162004ef638038062004ef6833981016040819052620000349162000175565b4660a0818152604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f64afec7be651c92f86754beb2bd5eeaf2fa95e83faf4aee989877dde08e4498c918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201526080810192909252309082015260c00160408051601f19818403018152908290528051602090910120608052600180556001600160a01b03841660c05230908290620000fe906200014f565b6001600160a01b03928316815291166020820152604001604051809103905ff0801580156200012f573d5f803e3d5ffd5b506001600160a01b0390811660e052919091166101005250620001c69050565b610963806200459383390190565b6001600160a01b038116811462000172575f80fd5b50565b5f805f6060848603121562000188575f80fd5b835162000195816200015d565b6020850151909350620001a8816200015d565b6040850151909250620001bb816200015d565b809150509250925092565b60805160a05160c05160e0516101005161432d620002665f395f81816102570152818161078401526116dc01525f8181610197015281816107ba0152818161188c01528181611e2c01528181611f1e0152818161202c0152818161230b01528181612427015261303c01525f818161033801528181610412015281816106a70152818161152001526115ff01525f6104da01525f6105a4015261432d5ff3fe608060405260043610610126575f3560e01c8063a5cdc8fc116100a1578063c618618111610071578063db58772811610057578063db58772814610379578063e242924e1461038c578063fa5cd56c146103ab575f80fd5b8063c618618114610327578063cba673a71461035a575f80fd5b8063a5cdc8fc146102ab578063a7ab49bc146102ca578063ae80c584146102e9578063b11f126214610308575f80fd5b806351d46815116100f65780636f35d2d2116100dc5780636f35d2d214610246578063875530ff146102795780639935c86814610298575f80fd5b806351d46815146102125780635aa0e95d14610227575f80fd5b80631626ba7e1461013157806329bcdc95146101865780633644e515146101d15780634c9e03d3146101f3575f80fd5b3661012d57005b5f80fd5b34801561013c575f80fd5b5061015061014b366004613595565b6103ca565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020015b60405180910390f35b348015610191575f80fd5b506101b97f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161017d565b3480156101dc575f80fd5b506101e56104d7565b60405190815260200161017d565b3480156101fe575f80fd5b506101e561020d366004613620565b6105c6565b6102256102203660046136d7565b610667565b005b348015610232575f80fd5b506102256102413660046137e1565b6109e8565b348015610251575f80fd5b506101b97f000000000000000000000000000000000000000000000000000000000000000081565b348015610284575f80fd5b506101e5610293366004613620565b610c30565b6102256102a636600461383f565b610c5f565b3480156102b6575f80fd5b506102256102c53660046138dd565b610c7f565b3480156102d5575f80fd5b506102256102e4366004613901565b610c8c565b3480156102f4575f80fd5b5061022561030336600461399d565b611067565b348015610313575f80fd5b506101e56103223660046139f2565b6112eb565b348015610332575f80fd5b506101b97f000000000000000000000000000000000000000000000000000000000000000081565b348015610365575f80fd5b50610225610374366004613a24565b6114ea565b610225610387366004613b0b565b611878565b348015610397575f80fd5b506101e56103a6366004613bc9565b61194c565b3480156103b6575f80fd5b506102256103c5366004613bc9565b611a8e565b5f806103d7858585611b50565b6040517fe75600c30000000000000000000000000000000000000000000000000000000081526001600160a01b0380831660048301529192507f00000000000000000000000000000000000000000000000000000000000000009091169063e75600c390602401602060405180830381865afa158015610459573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061047d9190613bfb565b156104ab577f1626ba7e356f5979dd355a3d2bfb43e80420a480c3b854edce286a82d74968699150506104d0565b507fffffffff0000000000000000000000000000000000000000000000000000000090505b9392505050565b5f7f000000000000000000000000000000000000000000000000000000000000000046146105a157604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f64afec7be651c92f86754beb2bd5eeaf2fa95e83faf4aee989877dde08e4498c918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b5f7f68b8e94dc077458241d6c8d89f0a7665c7cda2cfe70c9eb4437efee1663c66fe6105f56020840184613c16565b836020013584604001358560600135866080013560405160200161064a969594939291909586526001600160a01b0394909416602086015260408501929092526060840152608083015260a082015260c00190565b604051602081830303815290604052805190602001209050919050565b61066f611bdb565b6040517fe75600c30000000000000000000000000000000000000000000000000000000081526001600160a01b038a811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063e75600c390602401602060405180830381865afa1580156106ec573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107109190613bfb565b610746576040517fb331e42100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610200870135881580159061076057506101608801358911155b1561077f5761077c896102008a01356101608b01356001611c1e565b90505b6107b07f00000000000000000000000000000000000000000000000000000000000000008b838b8b8b8b8b8b611c69565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663bc1178e66107ef60c08b0160a08c01613c16565b6108016101408c016101208d01613c16565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526108449291906101608e0135908890600401613c8d565b5f604051808303815f87803b15801561085b575f80fd5b505af115801561086d573d5f803e3d5ffd5b505050506108b4888b838c5f148061088957506101608c01358d115b610893578c61089a565b6101608c01355b898c8c60026108af60408e0160208f01613d61565b611e01565b6108c16040890189613d7f565b6040516108cf929190613de0565b6040519081900390207f0fce007c38c6c8ed9e545b3a148095762738618f8c21b673222613e4d45734b661090960a08b0160808c01613c16565b61091960c08c0160a08d01613c16565b61092b6101408d016101208e01613c16565b61093d6101e08e016101c08f01613c16565b8e158061094e57506101608e01358f115b610958578e61095f565b6101408e01355b6102008f013588146109715787610978565b6101e08f01355b8f60e001602081019061098b9190613c16565b604080516001600160a01b0398891681529688166020880152948716948601949094529185166060850152608084015260a083015290911660c082015260e00160405180910390a2506109dd60018055565b505050505050505050565b5f5b6109f48280613def565b9050811015610b065736610a088380613def565b83818110610a1857610a18613e53565b9050602002810190610a2a9190613e80565b90506001600160a01b03841663a8c4bc95610a486020840184613c16565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015610aa2573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ac69190613bfb565b15610afd576040517fc99e887200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b506001016109ea565b505f5b610b166020830183613def565b9050811015610c2b5736610b2d6020840184613def565b83818110610b3d57610b3d613e53565b9050602002810190610b4f9190613e80565b90506001600160a01b03841663a8c4bc95610b6d6020840184613c16565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015610bc7573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610beb9190613bfb565b15610c22576040517fc99e887200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50600101610b09565b505050565b5f7fae676bf6913ac2689b7331293c989fe7723124faf8b5d275f06fbcebc77950096105f56020840184613c16565b610c698482612212565b610c78858585856001806122c9565b5050505050565b610c89338261261e565b50565b610cbf6040518060c001604052805f81526020015f81526020015f81526020015f81526020015f81526020015f81525090565b5f5b828110156110535736848483818110610cdc57610cdc613e53565b9050602002810190610cee9190613e80565b9050365f610cff6040840184613d7f565b90925090506001600160a01b038b1663a8c4bc95610d206020860186613c16565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015610d7a573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d9e9190613bfb565b15611045575f8915610ddc576040517f7d617bb300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60048210610de8575081355b7fc03a9de9000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000821601610e5657610e3d83838d8c6126c4565b86602001818151610e4e9190613ebc565b905250611043565b7f243a4b7f000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000821601610ebc57610eab83838d8c6127da565b86606001818151610e4e9190613ebc565b7f7dc4f458000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000821601610f4757610f1183838d8c61294e565b60a088015260808701819052606087018051610f2e908390613ebc565b90525060a0860151602087018051610e4e908390613ebc565b7f68931b6b000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000821601610fab57610f9c83838d8c612bb6565b86518790610e4e908390613ebc565b7f0c9be7e4000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008216016110115761100083838d8c612cc0565b86604001818151610e4e9190613ebc565b6040517f0561d8b300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b505050806001019050610cc1565b5061105e8482612e29565b50505050505050565b60036110766020830183613f21565b600381111561108757611087613ef4565b036110ec576001600160a01b0383166110ac836110a76040850185613d7f565b611b50565b6001600160a01b031614610c2b576040517fb81d58e700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60016110fb6020830183613f21565b600381111561110c5761110c613ef4565b036111a0577f19457468657265756d205369676e6564204d6573736167653a0a3332000000005f908152601c839052603c90206001600160a01b03841661115a826110a76040860186613d7f565b6001600160a01b03161461119a576040517f644ae6c300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050565b60026111af6020830183613f21565b60038111156111c0576111c0613ef4565b036112b9577f1626ba7e000000000000000000000000000000000000000000000000000000006001600160a01b038416631626ba7e846112036040860186613d7f565b6040518463ffffffff1660e01b815260040161122193929190613f3f565b602060405180830381865afa15801561123c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112609190613f58565b7fffffffff000000000000000000000000000000000000000000000000000000001614610c2b576040517f5d52cbe300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f60cd402d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6112f46104d7565b7fd28e809b708f5ee38be8347d6d869d8232493c094ab2dde98369e4102369a99d61131f8480613d7f565b604051602001611330929190613f97565b60405160208183030381529060405280519060200120846020013585604001602081019061135e9190613c16565b60408051602081019590955284019290925260608301526001600160a01b0316608082015260a001604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526113c46080850160608601613c16565b6113d460a0860160808701613c16565b6113e460c0870160a08801613c16565b60c087013560e08801356101008901356101208a013561140c6101608c016101408d01613c16565b604080516001600160a01b03998a166020820152978916908801529487166060870152608086019390935260a085019190915260c084015260e083015290911661010082015261012001604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290526114929291602001613fd7565b6040516020818303038152906040528051906020012060405160200161064a9291907f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b6114f2611bdb565b6040517f02cc250d0000000000000000000000000000000000000000000000000000000081523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906302cc250d90602401602060405180830381865afa15801561156d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115919190613bfb565b6115c7576040517fc139eabd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fe75600c30000000000000000000000000000000000000000000000000000000081526001600160a01b0389811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063e75600c390602401602060405180830381865afa158015611644573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116689190613bfb565b61169e576040517fb331e42100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61020086013587158015906116b857506101608701358811155b156116d7576116d4886102008901356101608a01356001611c1e565b90505b6117087f00000000000000000000000000000000000000000000000000000000000000008a838a8a8a8a8a8a611c69565b611745878a838b158061171f57506101608b01358c115b611729578b611730565b6101608b01355b888b8b60016108af60408d0160208e01613d61565b6117526040880188613d7f565b604051611760929190613de0565b6040519081900390207f0fce007c38c6c8ed9e545b3a148095762738618f8c21b673222613e4d45734b661179a60a08a0160808b01613c16565b6117aa60c08b0160a08c01613c16565b6117bc6101408c016101208d01613c16565b6117ce6101e08d016101c08e01613c16565b8d15806117df57506101608d01358e115b6117e9578d6117f0565b6101408d01355b6102008e013588146118025787611809565b6101e08e01355b8e60e001602081019061181c9190613c16565b604080516001600160a01b0398891681529688166020880152948716948601949094529185166060850152608084015260a083015290911660c082015260e00160405180910390a25061186e60018055565b5050505050505050565b6118828583612212565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663bc1178e66118c16080880160608901613c16565b6118d160a0890160808a01613c16565b8860c00135856040518563ffffffff1660e01b81526004016118f69493929190613c8d565b5f604051808303815f87803b15801561190d575f80fd5b505af115801561191f573d5f803e3d5ffd5b5050505061194486868686600289602001602081019061193f9190613d61565b6122c9565b505050505050565b5f6119556104d7565b7fc994d2ca0375d6d473785e0ce0b1d203f069121bac1314f72c5c0fe601eb39106119836040850185613d7f565b604051602001611994929190613f97565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152919052805160209091012060608501356119df60a0870160808801613c16565b6119ef60c0880160a08901613c16565b60c0880135611a056101008a0160e08b01613c16565b60408051602081019890985287019590955260608601939093526001600160a01b039182166080860152811660a085015260c08401919091521660e0820152610100808501359082015261012001604051602081830303815290604052611a6f8461012001610c30565b611a7c856101c0016105c6565b60405160200161149293929190613feb565b6101a0810135611aa8610180830135610160840135613ebc565b611ab29190613ebc565b61014082013514611aef576040517fc04377d300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610240810135611b09610220830135610200840135613ebc565b611b139190613ebc565b6101e082013514610c89576040517f877630be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f80611b918585858080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250612ed692505050565b90506001600160a01b038116611bd3576040517f815e1d6400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b949350505050565b600260015403611c17576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600155565b5f611c4b611c2b83612f00565b8015611c4657505f8480611c4157611c41614008565b868809115b151590565b611c56868686612f2c565b611c609190613ebc565b95945050505050565b5f611c738761194c565b9050611c80898285611067565b611c9060c0880160a08901613c16565b6001600160a01b0316336001600160a01b031614611cc757611cc2611cbb60c0890160a08a01613c16565b8284611067565b611d0e565b611cd46040830183613d7f565b90505f03611d0e576040517f0e364efc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611d2b611d2160c0890160a08a01613c16565b886060013561261e565b8660c00135421115611d69576040517f133df02900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f88118015611d7c575086610100013588105b15611db3576040517f9469744400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611dbc87611a8e565b611dc68a856109e8565b611de78a8a5f8b118015611ddf57506102008a01358b14155b8a8a8a610c8c565b611df589886060013561261e565b50505050505050505050565b611e13611e0e8680613def565b613001565b5f611e286101808b01356101a08c0135613ebc565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b519d3696040518060a001604052808d60a0016020810190611e779190613c16565b6001600160a01b03168152602001306001600160a01b031681526020018d610120015f016020810190611eaa9190613c16565b6001600160a01b03168152602001848152602001866002811115611ed057611ed0613ef4565b8152506040518263ffffffff1660e01b8152600401611eef9190614035565b5f604051808303815f87803b158015611f06575f80fd5b505af1158015611f18573d5f803e3d5ffd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b519d3696040518060a001604052808d60a0016020810190611f699190613c16565b6001600160a01b031681526020018d60e0016020810190611f8a9190613c16565b6001600160a01b031681526020018d610120015f016020810190611fae9190613c16565b6001600160a01b031681526020018a8152602001866002811115611fd457611fd4613ef4565b8152506040518263ffffffff1660e01b8152600401611ff39190614035565b5f604051808303815f87803b15801561200a575f80fd5b505af115801561201c573d5f803e3d5ffd5b5050505061202a8585613001565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b519d3696040518060a001604052808c6001600160a01b031681526020018d60800160208101906120869190613c16565b6001600160a01b031681526020018d6101c0015f0160208101906120aa9190613c16565b6001600160a01b031681526020018b81526020018560028111156120d0576120d0613ef4565b8152506040518263ffffffff1660e01b81526004016120ef9190614035565b5f604051808303815f87803b158015612106575f80fd5b505af1158015612118573d5f803e3d5ffd5b5061212e9250611e0e9150506020880188613def565b5f6121416101408c016101208d01613c16565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa15801561219e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121c291906140b4565b90508015612205576122056121de6101008d0160e08e01613c16565b828d610120015f0160208101906121f59190613c16565b6001600160a01b03169190613139565b5050505050505050505050565b6122226080830160608401613c16565b6001600160a01b0316336001600160a01b0316146122615761225c61224d6080840160608501613c16565b612256846112eb565b83611067565b6122a8565b61226e6040820182613d7f565b90505f036122a8576040517f0e364efc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6122c56122bb6080840160608501613c16565b836020013561261e565b5050565b60e085013583158015906122e057508560c0013584105b156122fd576122fa848760e001358860c001356001611c1e565b90505b612309878288886131b9565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b519d3696040518060a001604052808960600160208101906123569190613c16565b6001600160a01b031681526020016123766101608b016101408c01613c16565b6001600160a01b0316815260200161239460a08b0160808c01613c16565b6001600160a01b031681526020018715806123b257508960c0013588115b6123bc57876123c2565b8960c001355b81526020018660028111156123d9576123d9613ef4565b8152506040518263ffffffff1660e01b81526004016123f89190614035565b5f604051808303815f87803b15801561240f575f80fd5b505af1158015612421573d5f803e3d5ffd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b519d3696040518060a001604052808a6001600160a01b031681526020018960400160208101906124819190613c16565b6001600160a01b0316815260200161249f60c08b0160a08c01613c16565b6001600160a01b031681526020018481526020018560028111156124c5576124c5613ef4565b8152506040518263ffffffff1660e01b81526004016124e49190614035565b5f604051808303815f87803b1580156124fb575f80fd5b505af115801561250d573d5f803e3d5ffd5b5061251e9250889150819050613d7f565b60405161252c929190613de0565b60405180910390207f0fce007c38c6c8ed9e545b3a148095762738618f8c21b673222613e4d45734b68760400160208101906125689190613c16565b61257860808a0160608b01613c16565b61258860a08b0160808c01613c16565b61259860c08c0160a08d01613c16565b8915806125a857508b60c001358a115b6125b257896125b8565b8b60c001355b878d6101400160208101906125cd9190613c16565b604080516001600160a01b0398891681529688166020880152948716948601949094529185166060850152608084015260a083015290911660c082015260e00160405180910390a250505050505050565b6001600160a01b0382165f9081526020818152604080832084845290915290205460ff1615612679576040517fbc0da7d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b039091165f908152602081815260408083209383529290522080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b5f8080806126d5876004818b6140cb565b8101906126e291906140f2565b50919450925090506126fc61014086016101208701613c16565b6001600160a01b0316836001600160a01b031614612746576040517fc891add200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b816001600160a01b0316866001600160a01b031614612791576040517f815e1d6400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6101a085013581146127cf576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b979650505050505050565b5f808080806127ec886004818c6140cb565b8101906127f99190614142565b929650909450925090506128156101e087016101c08801613c16565b6001600160a01b0316846001600160a01b03161461285f576040517fc891add200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b826001600160a01b0316876001600160a01b0316146128aa576040517f815e1d6400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6128ba60a0870160808801613c16565b6001600160a01b0316826001600160a01b031614612904576040517fac6b05f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6102408601358114612942576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b98975050505050505050565b5f805f805f805f805f8c8c600490809261296a939291906140cb565b8101906129779190614190565b959c50939a50919850965094509250905061299a6101e08b016101c08c01613c16565b6001600160a01b0316876001600160a01b0316146129e4576040517fc891add200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b856001600160a01b03168b6001600160a01b031614612a2f576040517f815e1d6400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0385163014612a71576040517f8154374b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612a8160a08b0160808c01613c16565b6001600160a01b0316846001600160a01b031614612acb576040517fac6b05f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6102408a01358314612b09576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612b1b6101408b016101208c01613c16565b6001600160a01b0316826001600160a01b031614612b65576040517fc891add200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6101a08a01358114612ba3576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919c919b50909950505050505050505050565b5f808080612bc7876004818b6140cb565b810190612bd4919061420f565b91945092509050612bed61014086016101208701613c16565b6001600160a01b0316836001600160a01b031614612c37576040517fc891add200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b816001600160a01b0316866001600160a01b031614612c82576040517f815e1d6400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61018085013581146127cf576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f80808080612cd2886004818c6140cb565b810190612cdf919061424d565b5092965090945092509050612cfc6101e087016101c08801613c16565b6001600160a01b0316846001600160a01b031614612d46576040517fc891add200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b826001600160a01b0316876001600160a01b031614612d91576040517f815e1d6400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612da160a0870160808801613c16565b6001600160a01b0316826001600160a01b031614612deb576040517fac6b05f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6102208601358114612942576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8051610180830135141580612e47575060208101516101a083013514155b15612e7e576040517f4a55da2000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040810151610220830135141580612e9f5750606081015161024083013514155b156122c5576040517f77a5920300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f805f80612ee4868661325c565b925092509250612ef482826132a5565b50909150505b92915050565b5f6002826003811115612f1557612f15613ef4565b612f1f91906142b1565b60ff166001149050919050565b5f838302817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85870982811083820303915050805f03612f7f57838281612f7557612f75614008565b04925050506104d0565b808411612f9657612f9660038515026011186133ad565b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b5f5b81811015610c2b573683838381811061301e5761301e613e53565b90506020028101906130309190613e80565b90506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166130696020830183613c16565b6001600160a01b0316036130a9576040517f79a1bff000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6130b2816133be565b6130bf6020820182613c16565b6001600160a01b03167fed99827efb37016f2275f98c4bcf71c7551c75d59e9b450f79fa32e60be672c282602001356130f784613401565b604080519283527fffffffff0000000000000000000000000000000000000000000000000000000090911660208301520160405180910390a250600101613003565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052610c2b90849061342a565b5f831180156131cc575081610100013583105b15613203576040517f9469744400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61321084612256846112eb565b61321e84836020013561261e565b428261012001351161119a576040517fc56873ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f805f8351604103613293576020840151604085015160608601515f1a613285888285856134af565b95509550955050505061329e565b505081515f91506002905b9250925092565b5f8260038111156132b8576132b8613ef4565b036132c1575050565b60018260038111156132d5576132d5613ef4565b0361330c576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600282600381111561332057613320613ef4565b0361335f576040517ffce698f7000000000000000000000000000000000000000000000000000000008152600481018290526024015b60405180910390fd5b600382600381111561337357613373613ef4565b036122c5576040517fd78bce0c00000000000000000000000000000000000000000000000000000000815260048101829052602401613356565b634e487b715f52806020526024601cfd5b5f6133cc6020830183613c16565b90506020820135365f6133e26040860186613d7f565b91509150604051818382375f80838387895af1611944573d5f803e3d5ffd5b5f36816134116040850185613d7f565b90925090506004811061342357813592505b5050919050565b5f8060205f8451602086015f885af180613449576040513d5f823e3d81fd5b50505f513d9150811561346057806001141561346d565b6001600160a01b0384163b155b1561119a576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401613356565b5f80807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411156134e857505f9150600390508261358b565b604080515f808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015613539573d5f803e3d5ffd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001519150506001600160a01b03811661358257505f92506001915082905061358b565b92505f91508190505b9450945094915050565b5f805f604084860312156135a7575f80fd5b83359250602084013567ffffffffffffffff808211156135c5575f80fd5b818601915086601f8301126135d8575f80fd5b8135818111156135e6575f80fd5b8760208285010111156135f7575f80fd5b6020830194508093505050509250925092565b5f60a0828403121561361a575f80fd5b50919050565b5f60a08284031215613630575f80fd5b6104d0838361360a565b6001600160a01b0381168114610c89575f80fd5b80356136598161363a565b919050565b5f610260828403121561361a575f80fd5b5f8083601f84011261367f575f80fd5b50813567ffffffffffffffff811115613696575f80fd5b6020830191508360208260051b85010111156136b0575f80fd5b9250929050565b5f6040828403121561361a575f80fd5b5f6060828403121561361a575f80fd5b5f805f805f805f805f6101008a8c0312156136f0575f80fd5b6136f98a61364e565b985060208a0135975060408a013567ffffffffffffffff8082111561371c575f80fd5b6137288d838e0161365e565b985060608c013591508082111561373d575f80fd5b6137498d838e0161366f565b909850965060808c0135915080821115613761575f80fd5b61376d8d838e016136b7565b955060a08c0135915080821115613782575f80fd5b61378e8d838e016136c7565b945060c08c01359150808211156137a3575f80fd5b6137af8d838e016136c7565b935060e08c01359150808211156137c4575f80fd5b506137d18c828d016136c7565b9150509295985092959850929598565b5f80604083850312156137f2575f80fd5b82356137fd8161363a565b9150602083013567ffffffffffffffff811115613818575f80fd5b613824858286016136b7565b9150509250929050565b5f610160828403121561361a575f80fd5b5f805f805f60a08688031215613853575f80fd5b853561385e8161363a565b9450602086013567ffffffffffffffff8082111561387a575f80fd5b61388689838a0161382e565b9550604088013591508082111561389b575f80fd5b6138a789838a016136c7565b94506060880135935060808801359150808211156138c3575f80fd5b506138d0888289016136c7565b9150509295509295909350565b5f602082840312156138ed575f80fd5b5035919050565b8015158114610c89575f80fd5b5f805f805f8060a08789031215613916575f80fd5b86356139218161363a565b955060208701356139318161363a565b94506040870135613941816138f4565b9350606087013567ffffffffffffffff8082111561395d575f80fd5b6139698a838b0161365e565b9450608089013591508082111561397e575f80fd5b5061398b89828a0161366f565b979a9699509497509295939492505050565b5f805f606084860312156139af575f80fd5b83356139ba8161363a565b925060208401359150604084013567ffffffffffffffff8111156139dc575f80fd5b6139e8868287016136c7565b9150509250925092565b5f60208284031215613a02575f80fd5b813567ffffffffffffffff811115613a18575f80fd5b611bd38482850161382e565b5f805f805f805f8060e0898b031215613a3b575f80fd5b613a448961364e565b975060208901359650604089013567ffffffffffffffff80821115613a67575f80fd5b613a738c838d0161365e565b975060608b0135915080821115613a88575f80fd5b613a948c838d0161366f565b909750955060808b0135915080821115613aac575f80fd5b613ab88c838d016136b7565b945060a08b0135915080821115613acd575f80fd5b613ad98c838d016136c7565b935060c08b0135915080821115613aee575f80fd5b50613afb8b828c016136c7565b9150509295985092959890939650565b5f805f805f8060c08789031215613b20575f80fd5b613b298761364e565b9550602087013567ffffffffffffffff80821115613b45575f80fd5b613b518a838b0161382e565b96506040890135915080821115613b66575f80fd5b613b728a838b016136c7565b9550606089013594506080890135915080821115613b8e575f80fd5b613b9a8a838b016136c7565b935060a0890135915080821115613baf575f80fd5b50613bbc89828a016136c7565b9150509295509295509295565b5f60208284031215613bd9575f80fd5b813567ffffffffffffffff811115613bef575f80fd5b611bd38482850161365e565b5f60208284031215613c0b575f80fd5b81516104d0816138f4565b5f60208284031215613c26575f80fd5b81356104d08161363a565b81835281816020850137505f602082840101525f60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b803565ffffffffffff81168114613659575f80fd5b5f6001600160a01b0380871683528086166020840152508360408301526080606083015282357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112613ce2575f80fd5b830160208101903567ffffffffffffffff811115613cfe575f80fd5b803603821315613d0c575f80fd5b60606080850152613d2160e085018284613c31565b915050613d3060208501613c78565b65ffffffffffff80821660a086015280613d4c60408801613c78565b1660c086015250508091505095945050505050565b5f60208284031215613d71575f80fd5b8135600381106104d0575f80fd5b5f8083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112613db2575f80fd5b83018035915067ffffffffffffffff821115613dcc575f80fd5b6020019150368190038213156136b0575f80fd5b818382375f9101908152919050565b5f8083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112613e22575f80fd5b83018035915067ffffffffffffffff821115613e3c575f80fd5b6020019150600581901b36038213156136b0575f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f82357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1833603018112613eb2575f80fd5b9190910192915050565b80820180821115612efa577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b5f60208284031215613f31575f80fd5b8135600481106104d0575f80fd5b838152604060208201525f611c60604083018486613c31565b5f60208284031215613f68575f80fd5b81517fffffffff00000000000000000000000000000000000000000000000000000000811681146104d0575f80fd5b602081525f611bd3602083018486613c31565b5f81515f5b81811015613fc95760208185018101518683015201613faf565b505f93019283525090919050565b5f611bd3613fe58386613faa565b84613faa565b5f613ff68286613faa565b93845250506020820152604001919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f60a0820190506001600160a01b0380845116835280602085015116602084015280604085015116604084015250606083015160608301526080830151600381106140a7577f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b8060808401525092915050565b5f602082840312156140c4575f80fd5b5051919050565b5f80858511156140d9575f80fd5b838611156140e5575f80fd5b5050820193919092039150565b5f805f8060808587031215614105575f80fd5b84356141108161363a565b935060208501356141208161363a565b9250604085013591506060850135614137816138f4565b939692955090935050565b5f805f8060808587031215614155575f80fd5b84356141608161363a565b935060208501356141708161363a565b925060408501356141808161363a565b9396929550929360600135925050565b5f805f805f805f60e0888a0312156141a6575f80fd5b87356141b18161363a565b965060208801356141c18161363a565b955060408801356141d18161363a565b945060608801356141e18161363a565b93506080880135925060a08801356141f88161363a565b8092505060c0880135905092959891949750929550565b5f805f60608486031215614221575f80fd5b833561422c8161363a565b9250602084013561423c8161363a565b929592945050506040919091013590565b5f805f805f60a08688031215614261575f80fd5b853561426c8161363a565b9450602086013561427c8161363a565b9350604086013561428c8161363a565b92506060860135915060808601356142a3816138f4565b809150509295509295909350565b5f60ff8316806142e8577f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b8060ff8416069150509291505056fea26469706673582212208555c743fc35cce326f37ad4f36f36ad0b8db84eb8b41019a66544e10171cd0364736f6c6343000817003360c060405234801561000f575f80fd5b5060405161096338038061096383398101604081905261002e91610060565b6001600160a01b039182166080521660a052610091565b80516001600160a01b038116811461005b575f80fd5b919050565b5f8060408385031215610071575f80fd5b61007a83610045565b915061008860208401610045565b90509250929050565b60805160a05161089e6100c55f395f81816048015281816101f2015261038101525f818160d30152610327015261089e5ff3fe608060405234801561000f575f80fd5b506004361061003f575f3560e01c80636afdd85014610043578063b519d36914610093578063bc1178e6146100a8575b5f80fd5b61006a7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6100a66100a136600461060a565b6100bb565b005b6100a66100b6366004610648565b61030f565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016811461012b576040517f7c214f0400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6060820135156101af57600161014760a08401608085016106dd565b6002811115610158576101586106b0565b036101b3576101af61016d6020840184610702565b61017d6040850160208601610702565b606085018035906101919060408801610702565b73ffffffffffffffffffffffffffffffffffffffff169291906104cc565b5050565b60026101c560a08401608085016106dd565b60028111156101d6576101d66106b0565b036102dd5773ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000166336c785166102246020850185610702565b6102346040860160208701610702565b606086018035906102489060408901610702565b60405160e086901b7fffffffff0000000000000000000000000000000000000000000000000000000016815273ffffffffffffffffffffffffffffffffffffffff94851660048201529284166024840152908316604483015290911660648201526084015f604051808303815f87803b1580156102c3575f80fd5b505af11580156102d5573d5f803e3d5ffd5b505050505050565b6040517fc79aaa4400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016811461037f576040517f7c214f0400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632b67b57086604051806060016040528060405180608001604052808a73ffffffffffffffffffffffffffffffffffffffff1681526020018973ffffffffffffffffffffffffffffffffffffffff16815260200188604001602081019061041d919061071b565b65ffffffffffff16815260200188602001602081019061043d919061071b565b65ffffffffffff1690528152306020820152604090810190610465906060890190890161071b565b65ffffffffffff1690526104798680610740565b6040518563ffffffff1660e01b815260040161049894939291906107a8565b5f604051808303815f87803b1580156104af575f80fd5b505af11580156104c1573d5f803e3d5ffd5b505050505050505050565b6040805173ffffffffffffffffffffffffffffffffffffffff85811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052610561908590610567565b50505050565b5f8060205f8451602086015f885af180610586576040513d5f823e3d81fd5b50505f513d9150811561059d5780600114156105b7565b73ffffffffffffffffffffffffffffffffffffffff84163b155b15610561576040517f5274afe700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8516600482015260240160405180910390fd5b5f60a0828403121561061a575f80fd5b50919050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610643575f80fd5b919050565b5f805f806080858703121561065b575f80fd5b61066485610620565b935061067260208601610620565b925060408501359150606085013567ffffffffffffffff811115610694575f80fd5b8501606081880312156106a5575f80fd5b939692955090935050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b5f602082840312156106ed575f80fd5b8135600381106106fb575f80fd5b9392505050565b5f60208284031215610712575f80fd5b6106fb82610620565b5f6020828403121561072b575f80fd5b813565ffffffffffff811681146106fb575f80fd5b5f8083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112610773575f80fd5b83018035915067ffffffffffffffff82111561078d575f80fd5b6020019150368190038213156107a1575f80fd5b9250929050565b5f61010073ffffffffffffffffffffffffffffffffffffffff80881684528651818151166020860152816020820151166040860152604081015165ffffffffffff80821660608801528060608401511660808801525050508060208801511660a085015250604086015160c08401528060e08401528381840152506101208385828501375f838501820152601f9093017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910190910194935050505056fea2646970667358221220d912c30bbd02d5a1aad333499e57806a83add16d5a92993a737b709e836a693064736f6c634300081700330000000000000000000000007cd723cdd11773aa80b21748a0c6f411e93aebee0000000000000000000000008c9dc23cbd4fdee6688c5fb6ddfa543f7a5b75f8000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3
Deployed Bytecode
0x608060405260043610610126575f3560e01c8063a5cdc8fc116100a1578063c618618111610071578063db58772811610057578063db58772814610379578063e242924e1461038c578063fa5cd56c146103ab575f80fd5b8063c618618114610327578063cba673a71461035a575f80fd5b8063a5cdc8fc146102ab578063a7ab49bc146102ca578063ae80c584146102e9578063b11f126214610308575f80fd5b806351d46815116100f65780636f35d2d2116100dc5780636f35d2d214610246578063875530ff146102795780639935c86814610298575f80fd5b806351d46815146102125780635aa0e95d14610227575f80fd5b80631626ba7e1461013157806329bcdc95146101865780633644e515146101d15780634c9e03d3146101f3575f80fd5b3661012d57005b5f80fd5b34801561013c575f80fd5b5061015061014b366004613595565b6103ca565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020015b60405180910390f35b348015610191575f80fd5b506101b97f000000000000000000000000b87bae43a665eb5943a5642f81b26666bc9e5c9581565b6040516001600160a01b03909116815260200161017d565b3480156101dc575f80fd5b506101e56104d7565b60405190815260200161017d565b3480156101fe575f80fd5b506101e561020d366004613620565b6105c6565b6102256102203660046136d7565b610667565b005b348015610232575f80fd5b506102256102413660046137e1565b6109e8565b348015610251575f80fd5b506101b97f0000000000000000000000008c9dc23cbd4fdee6688c5fb6ddfa543f7a5b75f881565b348015610284575f80fd5b506101e5610293366004613620565b610c30565b6102256102a636600461383f565b610c5f565b3480156102b6575f80fd5b506102256102c53660046138dd565b610c7f565b3480156102d5575f80fd5b506102256102e4366004613901565b610c8c565b3480156102f4575f80fd5b5061022561030336600461399d565b611067565b348015610313575f80fd5b506101e56103223660046139f2565b6112eb565b348015610332575f80fd5b506101b97f0000000000000000000000007cd723cdd11773aa80b21748a0c6f411e93aebee81565b348015610365575f80fd5b50610225610374366004613a24565b6114ea565b610225610387366004613b0b565b611878565b348015610397575f80fd5b506101e56103a6366004613bc9565b61194c565b3480156103b6575f80fd5b506102256103c5366004613bc9565b611a8e565b5f806103d7858585611b50565b6040517fe75600c30000000000000000000000000000000000000000000000000000000081526001600160a01b0380831660048301529192507f0000000000000000000000007cd723cdd11773aa80b21748a0c6f411e93aebee9091169063e75600c390602401602060405180830381865afa158015610459573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061047d9190613bfb565b156104ab577f1626ba7e356f5979dd355a3d2bfb43e80420a480c3b854edce286a82d74968699150506104d0565b507fffffffff0000000000000000000000000000000000000000000000000000000090505b9392505050565b5f7f000000000000000000000000000000000000000000000000000000000000a4b146146105a157604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f64afec7be651c92f86754beb2bd5eeaf2fa95e83faf4aee989877dde08e4498c918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b507f914e2a67bbd172b212d1198f87e37197f5b03090258abc9bac10a04fba7c9c2a90565b5f7f68b8e94dc077458241d6c8d89f0a7665c7cda2cfe70c9eb4437efee1663c66fe6105f56020840184613c16565b836020013584604001358560600135866080013560405160200161064a969594939291909586526001600160a01b0394909416602086015260408501929092526060840152608083015260a082015260c00190565b604051602081830303815290604052805190602001209050919050565b61066f611bdb565b6040517fe75600c30000000000000000000000000000000000000000000000000000000081526001600160a01b038a811660048301527f0000000000000000000000007cd723cdd11773aa80b21748a0c6f411e93aebee169063e75600c390602401602060405180830381865afa1580156106ec573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107109190613bfb565b610746576040517fb331e42100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610200870135881580159061076057506101608801358911155b1561077f5761077c896102008a01356101608b01356001611c1e565b90505b6107b07f0000000000000000000000008c9dc23cbd4fdee6688c5fb6ddfa543f7a5b75f88b838b8b8b8b8b8b611c69565b6001600160a01b037f000000000000000000000000b87bae43a665eb5943a5642f81b26666bc9e5c951663bc1178e66107ef60c08b0160a08c01613c16565b6108016101408c016101208d01613c16565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526108449291906101608e0135908890600401613c8d565b5f604051808303815f87803b15801561085b575f80fd5b505af115801561086d573d5f803e3d5ffd5b505050506108b4888b838c5f148061088957506101608c01358d115b610893578c61089a565b6101608c01355b898c8c60026108af60408e0160208f01613d61565b611e01565b6108c16040890189613d7f565b6040516108cf929190613de0565b6040519081900390207f0fce007c38c6c8ed9e545b3a148095762738618f8c21b673222613e4d45734b661090960a08b0160808c01613c16565b61091960c08c0160a08d01613c16565b61092b6101408d016101208e01613c16565b61093d6101e08e016101c08f01613c16565b8e158061094e57506101608e01358f115b610958578e61095f565b6101408e01355b6102008f013588146109715787610978565b6101e08f01355b8f60e001602081019061098b9190613c16565b604080516001600160a01b0398891681529688166020880152948716948601949094529185166060850152608084015260a083015290911660c082015260e00160405180910390a2506109dd60018055565b505050505050505050565b5f5b6109f48280613def565b9050811015610b065736610a088380613def565b83818110610a1857610a18613e53565b9050602002810190610a2a9190613e80565b90506001600160a01b03841663a8c4bc95610a486020840184613c16565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015610aa2573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ac69190613bfb565b15610afd576040517fc99e887200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b506001016109ea565b505f5b610b166020830183613def565b9050811015610c2b5736610b2d6020840184613def565b83818110610b3d57610b3d613e53565b9050602002810190610b4f9190613e80565b90506001600160a01b03841663a8c4bc95610b6d6020840184613c16565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015610bc7573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610beb9190613bfb565b15610c22576040517fc99e887200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50600101610b09565b505050565b5f7fae676bf6913ac2689b7331293c989fe7723124faf8b5d275f06fbcebc77950096105f56020840184613c16565b610c698482612212565b610c78858585856001806122c9565b5050505050565b610c89338261261e565b50565b610cbf6040518060c001604052805f81526020015f81526020015f81526020015f81526020015f81526020015f81525090565b5f5b828110156110535736848483818110610cdc57610cdc613e53565b9050602002810190610cee9190613e80565b9050365f610cff6040840184613d7f565b90925090506001600160a01b038b1663a8c4bc95610d206020860186613c16565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015610d7a573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d9e9190613bfb565b15611045575f8915610ddc576040517f7d617bb300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60048210610de8575081355b7fc03a9de9000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000821601610e5657610e3d83838d8c6126c4565b86602001818151610e4e9190613ebc565b905250611043565b7f243a4b7f000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000821601610ebc57610eab83838d8c6127da565b86606001818151610e4e9190613ebc565b7f7dc4f458000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000821601610f4757610f1183838d8c61294e565b60a088015260808701819052606087018051610f2e908390613ebc565b90525060a0860151602087018051610e4e908390613ebc565b7f68931b6b000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000821601610fab57610f9c83838d8c612bb6565b86518790610e4e908390613ebc565b7f0c9be7e4000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008216016110115761100083838d8c612cc0565b86604001818151610e4e9190613ebc565b6040517f0561d8b300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b505050806001019050610cc1565b5061105e8482612e29565b50505050505050565b60036110766020830183613f21565b600381111561108757611087613ef4565b036110ec576001600160a01b0383166110ac836110a76040850185613d7f565b611b50565b6001600160a01b031614610c2b576040517fb81d58e700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60016110fb6020830183613f21565b600381111561110c5761110c613ef4565b036111a0577f19457468657265756d205369676e6564204d6573736167653a0a3332000000005f908152601c839052603c90206001600160a01b03841661115a826110a76040860186613d7f565b6001600160a01b03161461119a576040517f644ae6c300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050565b60026111af6020830183613f21565b60038111156111c0576111c0613ef4565b036112b9577f1626ba7e000000000000000000000000000000000000000000000000000000006001600160a01b038416631626ba7e846112036040860186613d7f565b6040518463ffffffff1660e01b815260040161122193929190613f3f565b602060405180830381865afa15801561123c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112609190613f58565b7fffffffff000000000000000000000000000000000000000000000000000000001614610c2b576040517f5d52cbe300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f60cd402d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6112f46104d7565b7fd28e809b708f5ee38be8347d6d869d8232493c094ab2dde98369e4102369a99d61131f8480613d7f565b604051602001611330929190613f97565b60405160208183030381529060405280519060200120846020013585604001602081019061135e9190613c16565b60408051602081019590955284019290925260608301526001600160a01b0316608082015260a001604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526113c46080850160608601613c16565b6113d460a0860160808701613c16565b6113e460c0870160a08801613c16565b60c087013560e08801356101008901356101208a013561140c6101608c016101408d01613c16565b604080516001600160a01b03998a166020820152978916908801529487166060870152608086019390935260a085019190915260c084015260e083015290911661010082015261012001604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290526114929291602001613fd7565b6040516020818303038152906040528051906020012060405160200161064a9291907f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b6114f2611bdb565b6040517f02cc250d0000000000000000000000000000000000000000000000000000000081523360048201527f0000000000000000000000007cd723cdd11773aa80b21748a0c6f411e93aebee6001600160a01b0316906302cc250d90602401602060405180830381865afa15801561156d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115919190613bfb565b6115c7576040517fc139eabd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fe75600c30000000000000000000000000000000000000000000000000000000081526001600160a01b0389811660048301527f0000000000000000000000007cd723cdd11773aa80b21748a0c6f411e93aebee169063e75600c390602401602060405180830381865afa158015611644573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116689190613bfb565b61169e576040517fb331e42100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61020086013587158015906116b857506101608701358811155b156116d7576116d4886102008901356101608a01356001611c1e565b90505b6117087f0000000000000000000000008c9dc23cbd4fdee6688c5fb6ddfa543f7a5b75f88a838a8a8a8a8a8a611c69565b611745878a838b158061171f57506101608b01358c115b611729578b611730565b6101608b01355b888b8b60016108af60408d0160208e01613d61565b6117526040880188613d7f565b604051611760929190613de0565b6040519081900390207f0fce007c38c6c8ed9e545b3a148095762738618f8c21b673222613e4d45734b661179a60a08a0160808b01613c16565b6117aa60c08b0160a08c01613c16565b6117bc6101408c016101208d01613c16565b6117ce6101e08d016101c08e01613c16565b8d15806117df57506101608d01358e115b6117e9578d6117f0565b6101408d01355b6102008e013588146118025787611809565b6101e08e01355b8e60e001602081019061181c9190613c16565b604080516001600160a01b0398891681529688166020880152948716948601949094529185166060850152608084015260a083015290911660c082015260e00160405180910390a25061186e60018055565b5050505050505050565b6118828583612212565b6001600160a01b037f000000000000000000000000b87bae43a665eb5943a5642f81b26666bc9e5c951663bc1178e66118c16080880160608901613c16565b6118d160a0890160808a01613c16565b8860c00135856040518563ffffffff1660e01b81526004016118f69493929190613c8d565b5f604051808303815f87803b15801561190d575f80fd5b505af115801561191f573d5f803e3d5ffd5b5050505061194486868686600289602001602081019061193f9190613d61565b6122c9565b505050505050565b5f6119556104d7565b7fc994d2ca0375d6d473785e0ce0b1d203f069121bac1314f72c5c0fe601eb39106119836040850185613d7f565b604051602001611994929190613f97565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152919052805160209091012060608501356119df60a0870160808801613c16565b6119ef60c0880160a08901613c16565b60c0880135611a056101008a0160e08b01613c16565b60408051602081019890985287019590955260608601939093526001600160a01b039182166080860152811660a085015260c08401919091521660e0820152610100808501359082015261012001604051602081830303815290604052611a6f8461012001610c30565b611a7c856101c0016105c6565b60405160200161149293929190613feb565b6101a0810135611aa8610180830135610160840135613ebc565b611ab29190613ebc565b61014082013514611aef576040517fc04377d300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610240810135611b09610220830135610200840135613ebc565b611b139190613ebc565b6101e082013514610c89576040517f877630be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f80611b918585858080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250612ed692505050565b90506001600160a01b038116611bd3576040517f815e1d6400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b949350505050565b600260015403611c17576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600155565b5f611c4b611c2b83612f00565b8015611c4657505f8480611c4157611c41614008565b868809115b151590565b611c56868686612f2c565b611c609190613ebc565b95945050505050565b5f611c738761194c565b9050611c80898285611067565b611c9060c0880160a08901613c16565b6001600160a01b0316336001600160a01b031614611cc757611cc2611cbb60c0890160a08a01613c16565b8284611067565b611d0e565b611cd46040830183613d7f565b90505f03611d0e576040517f0e364efc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611d2b611d2160c0890160a08a01613c16565b886060013561261e565b8660c00135421115611d69576040517f133df02900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f88118015611d7c575086610100013588105b15611db3576040517f9469744400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611dbc87611a8e565b611dc68a856109e8565b611de78a8a5f8b118015611ddf57506102008a01358b14155b8a8a8a610c8c565b611df589886060013561261e565b50505050505050505050565b611e13611e0e8680613def565b613001565b5f611e286101808b01356101a08c0135613ebc565b90507f000000000000000000000000b87bae43a665eb5943a5642f81b26666bc9e5c956001600160a01b031663b519d3696040518060a001604052808d60a0016020810190611e779190613c16565b6001600160a01b03168152602001306001600160a01b031681526020018d610120015f016020810190611eaa9190613c16565b6001600160a01b03168152602001848152602001866002811115611ed057611ed0613ef4565b8152506040518263ffffffff1660e01b8152600401611eef9190614035565b5f604051808303815f87803b158015611f06575f80fd5b505af1158015611f18573d5f803e3d5ffd5b505050507f000000000000000000000000b87bae43a665eb5943a5642f81b26666bc9e5c956001600160a01b031663b519d3696040518060a001604052808d60a0016020810190611f699190613c16565b6001600160a01b031681526020018d60e0016020810190611f8a9190613c16565b6001600160a01b031681526020018d610120015f016020810190611fae9190613c16565b6001600160a01b031681526020018a8152602001866002811115611fd457611fd4613ef4565b8152506040518263ffffffff1660e01b8152600401611ff39190614035565b5f604051808303815f87803b15801561200a575f80fd5b505af115801561201c573d5f803e3d5ffd5b5050505061202a8585613001565b7f000000000000000000000000b87bae43a665eb5943a5642f81b26666bc9e5c956001600160a01b031663b519d3696040518060a001604052808c6001600160a01b031681526020018d60800160208101906120869190613c16565b6001600160a01b031681526020018d6101c0015f0160208101906120aa9190613c16565b6001600160a01b031681526020018b81526020018560028111156120d0576120d0613ef4565b8152506040518263ffffffff1660e01b81526004016120ef9190614035565b5f604051808303815f87803b158015612106575f80fd5b505af1158015612118573d5f803e3d5ffd5b5061212e9250611e0e9150506020880188613def565b5f6121416101408c016101208d01613c16565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa15801561219e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121c291906140b4565b90508015612205576122056121de6101008d0160e08e01613c16565b828d610120015f0160208101906121f59190613c16565b6001600160a01b03169190613139565b5050505050505050505050565b6122226080830160608401613c16565b6001600160a01b0316336001600160a01b0316146122615761225c61224d6080840160608501613c16565b612256846112eb565b83611067565b6122a8565b61226e6040820182613d7f565b90505f036122a8576040517f0e364efc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6122c56122bb6080840160608501613c16565b836020013561261e565b5050565b60e085013583158015906122e057508560c0013584105b156122fd576122fa848760e001358860c001356001611c1e565b90505b612309878288886131b9565b7f000000000000000000000000b87bae43a665eb5943a5642f81b26666bc9e5c956001600160a01b031663b519d3696040518060a001604052808960600160208101906123569190613c16565b6001600160a01b031681526020016123766101608b016101408c01613c16565b6001600160a01b0316815260200161239460a08b0160808c01613c16565b6001600160a01b031681526020018715806123b257508960c0013588115b6123bc57876123c2565b8960c001355b81526020018660028111156123d9576123d9613ef4565b8152506040518263ffffffff1660e01b81526004016123f89190614035565b5f604051808303815f87803b15801561240f575f80fd5b505af1158015612421573d5f803e3d5ffd5b505050507f000000000000000000000000b87bae43a665eb5943a5642f81b26666bc9e5c956001600160a01b031663b519d3696040518060a001604052808a6001600160a01b031681526020018960400160208101906124819190613c16565b6001600160a01b0316815260200161249f60c08b0160a08c01613c16565b6001600160a01b031681526020018481526020018560028111156124c5576124c5613ef4565b8152506040518263ffffffff1660e01b81526004016124e49190614035565b5f604051808303815f87803b1580156124fb575f80fd5b505af115801561250d573d5f803e3d5ffd5b5061251e9250889150819050613d7f565b60405161252c929190613de0565b60405180910390207f0fce007c38c6c8ed9e545b3a148095762738618f8c21b673222613e4d45734b68760400160208101906125689190613c16565b61257860808a0160608b01613c16565b61258860a08b0160808c01613c16565b61259860c08c0160a08d01613c16565b8915806125a857508b60c001358a115b6125b257896125b8565b8b60c001355b878d6101400160208101906125cd9190613c16565b604080516001600160a01b0398891681529688166020880152948716948601949094529185166060850152608084015260a083015290911660c082015260e00160405180910390a250505050505050565b6001600160a01b0382165f9081526020818152604080832084845290915290205460ff1615612679576040517fbc0da7d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b039091165f908152602081815260408083209383529290522080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b5f8080806126d5876004818b6140cb565b8101906126e291906140f2565b50919450925090506126fc61014086016101208701613c16565b6001600160a01b0316836001600160a01b031614612746576040517fc891add200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b816001600160a01b0316866001600160a01b031614612791576040517f815e1d6400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6101a085013581146127cf576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b979650505050505050565b5f808080806127ec886004818c6140cb565b8101906127f99190614142565b929650909450925090506128156101e087016101c08801613c16565b6001600160a01b0316846001600160a01b03161461285f576040517fc891add200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b826001600160a01b0316876001600160a01b0316146128aa576040517f815e1d6400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6128ba60a0870160808801613c16565b6001600160a01b0316826001600160a01b031614612904576040517fac6b05f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6102408601358114612942576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b98975050505050505050565b5f805f805f805f805f8c8c600490809261296a939291906140cb565b8101906129779190614190565b959c50939a50919850965094509250905061299a6101e08b016101c08c01613c16565b6001600160a01b0316876001600160a01b0316146129e4576040517fc891add200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b856001600160a01b03168b6001600160a01b031614612a2f576040517f815e1d6400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0385163014612a71576040517f8154374b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612a8160a08b0160808c01613c16565b6001600160a01b0316846001600160a01b031614612acb576040517fac6b05f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6102408a01358314612b09576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612b1b6101408b016101208c01613c16565b6001600160a01b0316826001600160a01b031614612b65576040517fc891add200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6101a08a01358114612ba3576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919c919b50909950505050505050505050565b5f808080612bc7876004818b6140cb565b810190612bd4919061420f565b91945092509050612bed61014086016101208701613c16565b6001600160a01b0316836001600160a01b031614612c37576040517fc891add200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b816001600160a01b0316866001600160a01b031614612c82576040517f815e1d6400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61018085013581146127cf576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f80808080612cd2886004818c6140cb565b810190612cdf919061424d565b5092965090945092509050612cfc6101e087016101c08801613c16565b6001600160a01b0316846001600160a01b031614612d46576040517fc891add200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b826001600160a01b0316876001600160a01b031614612d91576040517f815e1d6400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612da160a0870160808801613c16565b6001600160a01b0316826001600160a01b031614612deb576040517fac6b05f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6102208601358114612942576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8051610180830135141580612e47575060208101516101a083013514155b15612e7e576040517f4a55da2000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040810151610220830135141580612e9f5750606081015161024083013514155b156122c5576040517f77a5920300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f805f80612ee4868661325c565b925092509250612ef482826132a5565b50909150505b92915050565b5f6002826003811115612f1557612f15613ef4565b612f1f91906142b1565b60ff166001149050919050565b5f838302817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85870982811083820303915050805f03612f7f57838281612f7557612f75614008565b04925050506104d0565b808411612f9657612f9660038515026011186133ad565b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b5f5b81811015610c2b573683838381811061301e5761301e613e53565b90506020028101906130309190613e80565b90506001600160a01b037f000000000000000000000000b87bae43a665eb5943a5642f81b26666bc9e5c95166130696020830183613c16565b6001600160a01b0316036130a9576040517f79a1bff000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6130b2816133be565b6130bf6020820182613c16565b6001600160a01b03167fed99827efb37016f2275f98c4bcf71c7551c75d59e9b450f79fa32e60be672c282602001356130f784613401565b604080519283527fffffffff0000000000000000000000000000000000000000000000000000000090911660208301520160405180910390a250600101613003565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052610c2b90849061342a565b5f831180156131cc575081610100013583105b15613203576040517f9469744400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61321084612256846112eb565b61321e84836020013561261e565b428261012001351161119a576040517fc56873ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f805f8351604103613293576020840151604085015160608601515f1a613285888285856134af565b95509550955050505061329e565b505081515f91506002905b9250925092565b5f8260038111156132b8576132b8613ef4565b036132c1575050565b60018260038111156132d5576132d5613ef4565b0361330c576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600282600381111561332057613320613ef4565b0361335f576040517ffce698f7000000000000000000000000000000000000000000000000000000008152600481018290526024015b60405180910390fd5b600382600381111561337357613373613ef4565b036122c5576040517fd78bce0c00000000000000000000000000000000000000000000000000000000815260048101829052602401613356565b634e487b715f52806020526024601cfd5b5f6133cc6020830183613c16565b90506020820135365f6133e26040860186613d7f565b91509150604051818382375f80838387895af1611944573d5f803e3d5ffd5b5f36816134116040850185613d7f565b90925090506004811061342357813592505b5050919050565b5f8060205f8451602086015f885af180613449576040513d5f823e3d81fd5b50505f513d9150811561346057806001141561346d565b6001600160a01b0384163b155b1561119a576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401613356565b5f80807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411156134e857505f9150600390508261358b565b604080515f808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015613539573d5f803e3d5ffd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001519150506001600160a01b03811661358257505f92506001915082905061358b565b92505f91508190505b9450945094915050565b5f805f604084860312156135a7575f80fd5b83359250602084013567ffffffffffffffff808211156135c5575f80fd5b818601915086601f8301126135d8575f80fd5b8135818111156135e6575f80fd5b8760208285010111156135f7575f80fd5b6020830194508093505050509250925092565b5f60a0828403121561361a575f80fd5b50919050565b5f60a08284031215613630575f80fd5b6104d0838361360a565b6001600160a01b0381168114610c89575f80fd5b80356136598161363a565b919050565b5f610260828403121561361a575f80fd5b5f8083601f84011261367f575f80fd5b50813567ffffffffffffffff811115613696575f80fd5b6020830191508360208260051b85010111156136b0575f80fd5b9250929050565b5f6040828403121561361a575f80fd5b5f6060828403121561361a575f80fd5b5f805f805f805f805f6101008a8c0312156136f0575f80fd5b6136f98a61364e565b985060208a0135975060408a013567ffffffffffffffff8082111561371c575f80fd5b6137288d838e0161365e565b985060608c013591508082111561373d575f80fd5b6137498d838e0161366f565b909850965060808c0135915080821115613761575f80fd5b61376d8d838e016136b7565b955060a08c0135915080821115613782575f80fd5b61378e8d838e016136c7565b945060c08c01359150808211156137a3575f80fd5b6137af8d838e016136c7565b935060e08c01359150808211156137c4575f80fd5b506137d18c828d016136c7565b9150509295985092959850929598565b5f80604083850312156137f2575f80fd5b82356137fd8161363a565b9150602083013567ffffffffffffffff811115613818575f80fd5b613824858286016136b7565b9150509250929050565b5f610160828403121561361a575f80fd5b5f805f805f60a08688031215613853575f80fd5b853561385e8161363a565b9450602086013567ffffffffffffffff8082111561387a575f80fd5b61388689838a0161382e565b9550604088013591508082111561389b575f80fd5b6138a789838a016136c7565b94506060880135935060808801359150808211156138c3575f80fd5b506138d0888289016136c7565b9150509295509295909350565b5f602082840312156138ed575f80fd5b5035919050565b8015158114610c89575f80fd5b5f805f805f8060a08789031215613916575f80fd5b86356139218161363a565b955060208701356139318161363a565b94506040870135613941816138f4565b9350606087013567ffffffffffffffff8082111561395d575f80fd5b6139698a838b0161365e565b9450608089013591508082111561397e575f80fd5b5061398b89828a0161366f565b979a9699509497509295939492505050565b5f805f606084860312156139af575f80fd5b83356139ba8161363a565b925060208401359150604084013567ffffffffffffffff8111156139dc575f80fd5b6139e8868287016136c7565b9150509250925092565b5f60208284031215613a02575f80fd5b813567ffffffffffffffff811115613a18575f80fd5b611bd38482850161382e565b5f805f805f805f8060e0898b031215613a3b575f80fd5b613a448961364e565b975060208901359650604089013567ffffffffffffffff80821115613a67575f80fd5b613a738c838d0161365e565b975060608b0135915080821115613a88575f80fd5b613a948c838d0161366f565b909750955060808b0135915080821115613aac575f80fd5b613ab88c838d016136b7565b945060a08b0135915080821115613acd575f80fd5b613ad98c838d016136c7565b935060c08b0135915080821115613aee575f80fd5b50613afb8b828c016136c7565b9150509295985092959890939650565b5f805f805f8060c08789031215613b20575f80fd5b613b298761364e565b9550602087013567ffffffffffffffff80821115613b45575f80fd5b613b518a838b0161382e565b96506040890135915080821115613b66575f80fd5b613b728a838b016136c7565b9550606089013594506080890135915080821115613b8e575f80fd5b613b9a8a838b016136c7565b935060a0890135915080821115613baf575f80fd5b50613bbc89828a016136c7565b9150509295509295509295565b5f60208284031215613bd9575f80fd5b813567ffffffffffffffff811115613bef575f80fd5b611bd38482850161365e565b5f60208284031215613c0b575f80fd5b81516104d0816138f4565b5f60208284031215613c26575f80fd5b81356104d08161363a565b81835281816020850137505f602082840101525f60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b803565ffffffffffff81168114613659575f80fd5b5f6001600160a01b0380871683528086166020840152508360408301526080606083015282357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112613ce2575f80fd5b830160208101903567ffffffffffffffff811115613cfe575f80fd5b803603821315613d0c575f80fd5b60606080850152613d2160e085018284613c31565b915050613d3060208501613c78565b65ffffffffffff80821660a086015280613d4c60408801613c78565b1660c086015250508091505095945050505050565b5f60208284031215613d71575f80fd5b8135600381106104d0575f80fd5b5f8083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112613db2575f80fd5b83018035915067ffffffffffffffff821115613dcc575f80fd5b6020019150368190038213156136b0575f80fd5b818382375f9101908152919050565b5f8083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112613e22575f80fd5b83018035915067ffffffffffffffff821115613e3c575f80fd5b6020019150600581901b36038213156136b0575f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f82357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1833603018112613eb2575f80fd5b9190910192915050565b80820180821115612efa577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b5f60208284031215613f31575f80fd5b8135600481106104d0575f80fd5b838152604060208201525f611c60604083018486613c31565b5f60208284031215613f68575f80fd5b81517fffffffff00000000000000000000000000000000000000000000000000000000811681146104d0575f80fd5b602081525f611bd3602083018486613c31565b5f81515f5b81811015613fc95760208185018101518683015201613faf565b505f93019283525090919050565b5f611bd3613fe58386613faa565b84613faa565b5f613ff68286613faa565b93845250506020820152604001919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f60a0820190506001600160a01b0380845116835280602085015116602084015280604085015116604084015250606083015160608301526080830151600381106140a7577f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b8060808401525092915050565b5f602082840312156140c4575f80fd5b5051919050565b5f80858511156140d9575f80fd5b838611156140e5575f80fd5b5050820193919092039150565b5f805f8060808587031215614105575f80fd5b84356141108161363a565b935060208501356141208161363a565b9250604085013591506060850135614137816138f4565b939692955090935050565b5f805f8060808587031215614155575f80fd5b84356141608161363a565b935060208501356141708161363a565b925060408501356141808161363a565b9396929550929360600135925050565b5f805f805f805f60e0888a0312156141a6575f80fd5b87356141b18161363a565b965060208801356141c18161363a565b955060408801356141d18161363a565b945060608801356141e18161363a565b93506080880135925060a08801356141f88161363a565b8092505060c0880135905092959891949750929550565b5f805f60608486031215614221575f80fd5b833561422c8161363a565b9250602084013561423c8161363a565b929592945050506040919091013590565b5f805f805f60a08688031215614261575f80fd5b853561426c8161363a565b9450602086013561427c8161363a565b9350604086013561428c8161363a565b92506060860135915060808601356142a3816138f4565b809150509295509295909350565b5f60ff8316806142e8577f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b8060ff8416069150509291505056fea26469706673582212208555c743fc35cce326f37ad4f36f36ad0b8db84eb8b41019a66544e10171cd0364736f6c63430008170033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000007cd723cdd11773aa80b21748a0c6f411e93aebee0000000000000000000000008c9dc23cbd4fdee6688c5fb6ddfa543f7a5b75f8000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3
-----Decoded View---------------
Arg [0] : authenticator_ (address): 0x7CD723CDD11773aA80B21748A0C6f411e93AeBee
Arg [1] : repository_ (address): 0x8c9dC23cbD4fDEE6688c5fb6ddfA543F7A5b75f8
Arg [2] : permit2_ (address): 0x000000000022D473030F116dDEE9F6B43aC78BA3
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000007cd723cdd11773aa80b21748a0c6f411e93aebee
Arg [1] : 0000000000000000000000008c9dc23cbd4fdee6688c5fb6ddfa543f7a5b75f8
Arg [2] : 000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3
Net Worth in USD
Net Worth in ETH
Token Allocations
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|---|---|---|---|---|
| ETH | 100.00% | $76,149 | 0.00000566 | $0.431 |
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.