Address Contract Partially Verified
Address
0x0353a9591acff4957ce938df458BF2c107C3d5B8
Balance
0 ETH
Nonce
1
Code Size
2437 bytes
Creator
0x2f2d07d6...76EF at tx 0xa92c065a...af5662
Indexed Transactions
0
Contract Bytecode
2437 bytes
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c8063b4d1d79511610071578063b4d1d7951461030f578063bca67b9314610336578063bd11c4c01461035d578063c2f8666614610384578063edbc9768146103ab578063fe70f69d146103cb57600080fd5b806316fa4fe7146100b9578063468b8ffa146100f35780635cdb8be8146102665780638fa6a29514610291578063b0594468146102b8578063b343a0df146102f6575b600080fd5b6100e07f00000000000000000000000000000000000000000000000000000000000000e681565b6040519081526020015b60405180910390f35b60408051610140810182527f000000000000000000000000000000000000000000000000000000000000000a81527f000000000000000000000000000000000000000000000000000000000000001e602082015265ffffffffffff7f000000000000000000000000000000000000000000000000000000000000000c8116828401527f0000000000000000000000000000000000000000000000000000000000001c20811660608301527f0000000000000000000000000000000000000000000000000000000000005460811660808301527f00000000000000000000000000000000000000000000000000000000000000e660c08301527f0000000000000000000000000000000000000000000000000000000000000258811660a08301527f000000000000000000000000000000000000000000000000000000000001518060e08301526000546001600160801b038116610100840152600160801b90041661012082015290516100ea919061076d565b600054610279906001600160801b031681565b6040516001600160801b0390911681526020016100ea565b6100e07f000000000000000000000000000000000000000000000000000000000000001e81565b6102df7f000000000000000000000000000000000000000000000000000000000000025881565b60405165ffffffffffff90911681526020016100ea565b6000546102df90600160801b900465ffffffffffff1681565b6100e07f000000000000000000000000000000000000000000000000000000000001518081565b6102df7f000000000000000000000000000000000000000000000000000000000000000c81565b6100e07f000000000000000000000000000000000000000000000000000000000000000a81565b6102df7f000000000000000000000000000000000000000000000000000000000000546081565b6103be6103b9366004610834565b6103f2565b6040516100ea919061084c565b6102df7f0000000000000000000000000000000000000000000000000000000000001c2081565b6040805180820190915260008082526020820152604080518082019091526002815261323360f01b6020820152336001600160a01b037f0000000000000000000000006d596fdfd3381ebb5ecd526ebcaec8cc2ba019ff16146104715760405162461bcd60e51b8152600401610468919061088d565b60405180910390fd5b504261048d604080518082019091526000808252602082015290565b6104a38261049e86604001356105d8565b610645565b6104ad90836108f1565b815182906104bc9083906108f1565b65ffffffffffff169052507f000000000000000000000000000000000000000000000000000000000000000a60408501351015610535577f000000000000000000000000000000000000000000000000000000000000000c8160000181815161052591906108f1565b65ffffffffffff169052506105d1565b7f000000000000000000000000000000000000000000000000000000000000001e84604001351015610593577f0000000000000000000000000000000000000000000000000000000000001c208160000181815161052591906108f1565b7f0000000000000000000000000000000000000000000000000000000000005460816000018181516105c591906108f1565b65ffffffffffff169052505b9392505050565b60006001600160801b038211156106415760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663238206269747360c81b6064820152608401610468565b5090565b600080547f00000000000000000000000000000000000000000000000000000000000151809061068490600160801b900465ffffffffffff1685610910565b65ffffffffffff16106106d957600080546001600160b01b031916600160801b65ffffffffffff8616021781556040517f9d26d68d3551d8e6920af85ae14553e5e89fd48bab1201c39604396f1a688dcb9190a15b600080546106f19084906001600160801b031661092f565b600080546fffffffffffffffffffffffffffffffff19166001600160801b0383169081179091559091507f00000000000000000000000000000000000000000000000000000000000000e61015610766577f000000000000000000000000000000000000000000000000000000000000025891505b5092915050565b6000610140820190508251825260208301516020830152604083015161079d604084018265ffffffffffff169052565b5060608301516107b7606084018265ffffffffffff169052565b5060808301516107d1608084018265ffffffffffff169052565b5060a08301516107eb60a084018265ffffffffffff169052565b5060c083015160c083015260e083015160e08301526101008084015161081b828501826001600160801b03169052565b50506101209283015165ffffffffffff16919092015290565b60006060828403121561084657600080fd5b50919050565b815165ffffffffffff168152602082015160408201906002811061088057634e487b7160e01b600052602160045260246000fd5b8060208401525092915050565b600060208083528351808285015260005b818110156108ba5785810183015185820160400152820161089e565b506000604082860101526040601f19601f8301168501019250505092915050565b634e487b7160e01b600052601160045260246000fd5b65ffffffffffff818116838216019080821115610766576107666108db565b65ffffffffffff828116828216039080821115610766576107666108db565b6001600160801b03818116838216019080821115610766576107666108db56fea2646970667358221220a1a2857c77b6059f3df949b2a542be2e38bcb0f75f8a355a6776677800c64a9e64736f6c63430008110033
Verified Source Code Partial Match
Compiler: v0.8.17+commit.8df45f5f
EVM: london
Optimization: Yes (200 runs)
ITimeLockStrategy.sol 35 lines
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import {DataTypes} from "../protocol/libraries/types/DataTypes.sol";
// ITimeLockStrategy defines an interface for implementing custom time lock strategies.
interface ITimeLockStrategy {
struct TimeLockStrategyData {
uint256 minThreshold;
uint256 midThreshold;
uint48 minWaitTime;
uint48 midWaitTime;
uint48 maxWaitTime;
uint48 poolPeriodWaitTime;
uint256 poolPeriodLimit;
uint256 period;
uint128 totalAmountInCurrentPeriod;
uint48 lastResetTimestamp;
}
/**
* @dev Calculates the time lock parameters based on the provided factor params.
*
* @param params The TimeLockFactorParams struct containing relevant information to calculate time lock params.
* @return A TimeLockParams struct containing the calculated time lock parameters.
*/
function calculateTimeLockParams(
DataTypes.TimeLockFactorParams calldata params
) external returns (DataTypes.TimeLockParams memory);
function getTimeLockStrategyData()
external
view
returns (TimeLockStrategyData memory);
}
DefaultTimeLockStrategy.sol 121 lines
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import "../interfaces/ITimeLockStrategy.sol";
import "../protocol/libraries/helpers/Errors.sol";
import "../dependencies/openzeppelin/contracts/SafeCast.sol";
contract DefaultTimeLockStrategy is ITimeLockStrategy {
using SafeCast for uint256;
address private immutable POOL;
uint256 public immutable MIN_THRESHOLD;
uint256 public immutable MID_THRESHOLD;
uint48 public immutable MIN_WAIT_TIME;
uint48 public immutable MID_WAIT_TIME;
uint48 public immutable MAX_WAIT_TIME;
uint48 public immutable POOL_PERIOD_WAIT_TIME;
uint256 public immutable POOL_PERIOD_LIMIT;
uint256 public immutable PERIOD;
uint128 public totalAmountInCurrentPeriod;
uint48 public lastResetTimestamp;
event PeriodReset();
modifier onlyPool() {
require(msg.sender == POOL, Errors.CALLER_MUST_BE_POOL);
_;
}
constructor(
address pool,
uint256 minThreshold,
uint256 midThreshold,
uint48 minWaitTime,
uint48 midWaitTime,
uint48 maxWaitTime,
uint256 poolPeriodLimit,
uint48 poolPeriodWaitTime,
uint256 period
) {
POOL = pool;
require(minThreshold < midThreshold, "minThreshold > midThreshold");
require(minWaitTime < midWaitTime, "minWaitTime > midWaitTime");
require(midWaitTime < maxWaitTime, "midWaitTime > maxWaitTime");
require(poolPeriodLimit > 0, "poolPeriodLimit can't be 0");
MIN_THRESHOLD = minThreshold;
MID_THRESHOLD = midThreshold;
MIN_WAIT_TIME = minWaitTime;
MID_WAIT_TIME = midWaitTime;
MAX_WAIT_TIME = maxWaitTime;
POOL_PERIOD_LIMIT = poolPeriodLimit;
POOL_PERIOD_WAIT_TIME = poolPeriodWaitTime;
PERIOD = period;
}
function _updatePeriodLimit(
uint48 currentTimestamp,
uint128 amount
) internal returns (uint48 extraDelay) {
if (currentTimestamp - lastResetTimestamp >= PERIOD) {
totalAmountInCurrentPeriod = 0;
lastResetTimestamp = currentTimestamp;
emit PeriodReset();
}
uint128 newTotalAmountInCurrentPeriod = totalAmountInCurrentPeriod +
amount;
totalAmountInCurrentPeriod = newTotalAmountInCurrentPeriod;
if (newTotalAmountInCurrentPeriod > POOL_PERIOD_LIMIT) {
extraDelay = POOL_PERIOD_WAIT_TIME;
}
}
function calculateTimeLockParams(
DataTypes.TimeLockFactorParams calldata params
) external onlyPool returns (DataTypes.TimeLockParams memory) {
uint48 currentTimestamp = uint48(block.timestamp);
DataTypes.TimeLockParams memory timeLockParams;
timeLockParams.releaseTime +=
currentTimestamp +
_updatePeriodLimit(currentTimestamp, params.amount.toUint128());
if (params.amount < MIN_THRESHOLD) {
timeLockParams.releaseTime += MIN_WAIT_TIME;
} else if (params.amount < MID_THRESHOLD) {
timeLockParams.releaseTime += MID_WAIT_TIME;
} else {
timeLockParams.releaseTime += MAX_WAIT_TIME;
}
return timeLockParams;
}
function getTimeLockStrategyData()
external
view
returns (TimeLockStrategyData memory timeLockStrategyData)
{
timeLockStrategyData.minThreshold = MIN_THRESHOLD;
timeLockStrategyData.midThreshold = MID_THRESHOLD;
timeLockStrategyData.minWaitTime = MIN_WAIT_TIME;
timeLockStrategyData.midWaitTime = MID_WAIT_TIME;
timeLockStrategyData.maxWaitTime = MAX_WAIT_TIME;
timeLockStrategyData.poolPeriodLimit = POOL_PERIOD_LIMIT;
timeLockStrategyData.poolPeriodWaitTime = POOL_PERIOD_WAIT_TIME;
timeLockStrategyData.period = PERIOD;
timeLockStrategyData
.totalAmountInCurrentPeriod = totalAmountInCurrentPeriod;
timeLockStrategyData.lastResetTimestamp = lastResetTimestamp;
}
}
IStakefishValidator.sol 62 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title The interface for StakefishValidator
/// @notice Defines implementation of the wallet (deposit, withdraw, collect fees)
interface IStakefishValidator {
enum State {
PreDeposit,
PostDeposit,
Active,
ExitRequested,
Exited,
Withdrawn,
Burnable
}
/// @dev aligns into 32 byte
struct StateChange {
State state; // 1 byte
bytes15 userData; // 15 byte (future use)
uint128 changedAt; // 16 byte
}
function validatorIndex() external view returns (uint256);
function pubkey() external view returns (bytes memory);
function withdrawnBalance() external view returns (uint256);
function feePoolAddress() external view returns (address);
function stateHistory(
uint256 index
) external view returns (StateChange memory);
/// @notice Inspect state of the change
function lastStateChange() external view returns (StateChange memory);
/// @notice NFT Owner requests a validator exit
/// State.Running -> State.ExitRequested
/// emit ValidatorExitRequest(pubkey)
function requestExit() external;
/// @notice user withdraw balance and charge a fee
function withdraw() external;
/// @notice get pending fee pool rewards
function pendingFeePoolReward() external view returns (uint256, uint256);
/// @notice claim fee pool and forward to nft owner
function claimFeePool(uint256 amountRequested) external;
function getProtocolFee() external view returns (uint256);
function getNFTArtUrl() external view returns (string memory);
/// @notice computes commission, useful for showing on UI
function computeCommission(uint256 amount) external view returns (uint256);
function render() external view returns (string memory);
}
Errors.sol 139 lines
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
/**
* @title Errors library
*
* @notice Defines the error messages emitted by the different contracts of the ParaSpace protocol
*/
library Errors {
string public constant CALLER_NOT_POOL_ADMIN = "1"; // 'The caller of the function is not a pool admin'
string public constant CALLER_NOT_EMERGENCY_ADMIN = "2"; // 'The caller of the function is not an emergency admin'
string public constant CALLER_NOT_POOL_OR_EMERGENCY_ADMIN = "3"; // 'The caller of the function is not a pool or emergency admin'
string public constant CALLER_NOT_RISK_OR_POOL_ADMIN = "4"; // 'The caller of the function is not a risk or pool admin'
string public constant CALLER_NOT_ASSET_LISTING_OR_POOL_ADMIN = "5"; // 'The caller of the function is not an asset listing or pool admin'
string public constant CALLER_NOT_BRIDGE = "6"; // 'The caller of the function is not a bridge'
string public constant ADDRESSES_PROVIDER_NOT_REGISTERED = "7"; // 'Pool addresses provider is not registered'
string public constant INVALID_ADDRESSES_PROVIDER_ID = "8"; // 'Invalid id for the pool addresses provider'
string public constant NOT_CONTRACT = "9"; // 'Address is not a contract'
string public constant CALLER_NOT_POOL_CONFIGURATOR = "10"; // 'The caller of the function is not the pool configurator'
string public constant CALLER_NOT_XTOKEN = "11"; // 'The caller of the function is not an PToken or NToken'
string public constant INVALID_ADDRESSES_PROVIDER = "12"; // 'The address of the pool addresses provider is invalid'
string public constant RESERVE_ALREADY_ADDED = "14"; // 'Reserve has already been added to reserve list'
string public constant NO_MORE_RESERVES_ALLOWED = "15"; // 'Maximum amount of reserves in the pool reached'
string public constant RESERVE_LIQUIDITY_NOT_ZERO = "18"; // 'The liquidity of the reserve needs to be 0'
string public constant INVALID_RESERVE_PARAMS = "20"; // 'Invalid risk parameters for the reserve'
string public constant CALLER_MUST_BE_POOL = "23"; // 'The caller of this function must be a pool'
string public constant INVALID_MINT_AMOUNT = "24"; // 'Invalid amount to mint'
string public constant INVALID_BURN_AMOUNT = "25"; // 'Invalid amount to burn'
string public constant INVALID_AMOUNT = "26"; // 'Amount must be greater than 0'
string public constant RESERVE_INACTIVE = "27"; // 'Action requires an active reserve'
string public constant RESERVE_FROZEN = "28"; // 'Action cannot be performed because the reserve is frozen'
string public constant RESERVE_PAUSED = "29"; // 'Action cannot be performed because the reserve is paused'
string public constant BORROWING_NOT_ENABLED = "30"; // 'Borrowing is not enabled'
string public constant STABLE_BORROWING_NOT_ENABLED = "31"; // 'Stable borrowing is not enabled'
string public constant NOT_ENOUGH_AVAILABLE_USER_BALANCE = "32"; // 'User cannot withdraw more than the available balance'
string public constant INVALID_INTEREST_RATE_MODE_SELECTED = "33"; // 'Invalid interest rate mode selected'
string public constant COLLATERAL_BALANCE_IS_ZERO = "34"; // 'The collateral balance is 0'
string public constant HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD =
"35"; // 'Health factor is lesser than the liquidation threshold'
string public constant COLLATERAL_CANNOT_COVER_NEW_BORROW = "36"; // 'There is not enough collateral to cover a new borrow'
string public constant COLLATERAL_SAME_AS_BORROWING_CURRENCY = "37"; // 'Collateral is (mostly) the same currency that is being borrowed'
string public constant AMOUNT_BIGGER_THAN_MAX_LOAN_SIZE_STABLE = "38"; // 'The requested amount is greater than the max loan size in stable rate mode'
string public constant NO_DEBT_OF_SELECTED_TYPE = "39"; // 'For repayment of a specific type of debt, the user needs to have debt that type'
string public constant NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF = "40"; // 'To repay on behalf of a user an explicit amount to repay is needed'
string public constant NO_OUTSTANDING_STABLE_DEBT = "41"; // 'User does not have outstanding stable rate debt on this reserve'
string public constant NO_OUTSTANDING_VARIABLE_DEBT = "42"; // 'User does not have outstanding variable rate debt on this reserve'
string public constant UNDERLYING_BALANCE_ZERO = "43"; // 'The underlying balance needs to be greater than 0'
string public constant INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET = "44"; // 'Interest rate rebalance conditions were not met'
string public constant HEALTH_FACTOR_NOT_BELOW_THRESHOLD = "45"; // 'Health factor is not below the threshold'
string public constant COLLATERAL_CANNOT_BE_AUCTIONED_OR_LIQUIDATED = "46"; // 'The collateral chosen cannot be auctioned OR liquidated'
string public constant SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER = "47"; // 'User did not borrow the specified currency'
string public constant SAME_BLOCK_BORROW_REPAY = "48"; // 'Borrow and repay in same block is not allowed'
string public constant BORROW_CAP_EXCEEDED = "50"; // 'Borrow cap is exceeded'
string public constant SUPPLY_CAP_EXCEEDED = "51"; // 'Supply cap is exceeded'
string public constant XTOKEN_SUPPLY_NOT_ZERO = "54"; // 'PToken supply is not zero'
string public constant STABLE_DEBT_NOT_ZERO = "55"; // 'Stable debt supply is not zero'
string public constant VARIABLE_DEBT_SUPPLY_NOT_ZERO = "56"; // 'Variable debt supply is not zero'
string public constant LTV_VALIDATION_FAILED = "57"; // 'Ltv validation failed'
string public constant PRICE_ORACLE_SENTINEL_CHECK_FAILED = "59"; // 'Price oracle sentinel validation failed'
string public constant RESERVE_ALREADY_INITIALIZED = "61"; // 'Reserve has already been initialized'
string public constant INVALID_LTV = "63"; // 'Invalid ltv parameter for the reserve'
string public constant INVALID_LIQ_THRESHOLD = "64"; // 'Invalid liquidity threshold parameter for the reserve'
string public constant INVALID_LIQ_BONUS = "65"; // 'Invalid liquidity bonus parameter for the reserve'
string public constant INVALID_DECIMALS = "66"; // 'Invalid decimals parameter of the underlying asset of the reserve'
string public constant INVALID_RESERVE_FACTOR = "67"; // 'Invalid reserve factor parameter for the reserve'
string public constant INVALID_BORROW_CAP = "68"; // 'Invalid borrow cap for the reserve'
string public constant INVALID_SUPPLY_CAP = "69"; // 'Invalid supply cap for the reserve'
string public constant INVALID_LIQUIDATION_PROTOCOL_FEE = "70"; // 'Invalid liquidation protocol fee for the reserve'
string public constant INVALID_DEBT_CEILING = "73"; // 'Invalid debt ceiling for the reserve
string public constant INVALID_RESERVE_INDEX = "74"; // 'Invalid reserve index'
string public constant ACL_ADMIN_CANNOT_BE_ZERO = "75"; // 'ACL admin cannot be set to the zero address'
string public constant INCONSISTENT_PARAMS_LENGTH = "76"; // 'Array parameters that should be equal length are not'
string public constant ZERO_ADDRESS_NOT_VALID = "77"; // 'Zero address not valid'
string public constant INVALID_EXPIRATION = "78"; // 'Invalid expiration'
string public constant INVALID_SIGNATURE = "79"; // 'Invalid signature'
string public constant OPERATION_NOT_SUPPORTED = "80"; // 'Operation not supported'
string public constant ASSET_NOT_LISTED = "82"; // 'Asset is not listed'
string public constant INVALID_OPTIMAL_USAGE_RATIO = "83"; // 'Invalid optimal usage ratio'
string public constant INVALID_OPTIMAL_STABLE_TO_TOTAL_DEBT_RATIO = "84"; // 'Invalid optimal stable to total debt ratio'
string public constant UNDERLYING_CANNOT_BE_RESCUED = "85"; // 'The underlying asset cannot be rescued'
string public constant ADDRESSES_PROVIDER_ALREADY_ADDED = "86"; // 'Reserve has already been added to reserve list'
string public constant POOL_ADDRESSES_DO_NOT_MATCH = "87"; // 'The token implementation pool address and the pool address provided by the initializing pool do not match'
string public constant STABLE_BORROWING_ENABLED = "88"; // 'Stable borrowing is enabled'
string public constant SILOED_BORROWING_VIOLATION = "89"; // 'User is trying to borrow multiple assets including a siloed one'
string public constant RESERVE_DEBT_NOT_ZERO = "90"; // the total debt of the reserve needs to be 0
string public constant NOT_THE_OWNER = "91"; // user is not the owner of a given asset
string public constant LIQUIDATION_AMOUNT_NOT_ENOUGH = "92";
string public constant INVALID_ASSET_TYPE = "93"; // invalid asset type for action.
string public constant INVALID_FLASH_CLAIM_RECEIVER = "94"; // invalid flash claim receiver.
string public constant ERC721_HEALTH_FACTOR_NOT_BELOW_THRESHOLD = "95"; // ERC721 Health factor is not below the threshold. Can only liquidate ERC20.
string public constant UNDERLYING_ASSET_CAN_NOT_BE_TRANSFERRED = "96"; //underlying asset can not be transferred.
string public constant TOKEN_TRANSFERRED_CAN_NOT_BE_SELF_ADDRESS = "97"; //token transferred can not be self address.
string public constant INVALID_AIRDROP_CONTRACT_ADDRESS = "98"; //invalid airdrop contract address.
string public constant INVALID_AIRDROP_PARAMETERS = "99"; //invalid airdrop parameters.
string public constant CALL_AIRDROP_METHOD_FAILED = "100"; //call airdrop method failed.
string public constant SUPPLIER_NOT_NTOKEN = "101"; //supplier is not the NToken contract
string public constant CALL_MARKETPLACE_FAILED = "102"; //call marketplace failed.
string public constant INVALID_MARKETPLACE_ID = "103"; //invalid marketplace id.
string public constant INVALID_MARKETPLACE_ORDER = "104"; //invalid marketplace id.
string public constant CREDIT_DOES_NOT_MATCH_ORDER = "105"; //credit doesn't match order.
string public constant PAYNOW_NOT_ENOUGH = "106"; //paynow not enough.
string public constant INVALID_CREDIT_SIGNATURE = "107"; //invalid credit signature.
string public constant INVALID_ORDER_TAKER = "108"; //invalid order taker.
string public constant MARKETPLACE_PAUSED = "109"; //marketplace paused.
string public constant INVALID_AUCTION_RECOVERY_HEALTH_FACTOR = "110"; //invalid auction recovery health factor.
string public constant AUCTION_ALREADY_STARTED = "111"; //auction already started.
string public constant AUCTION_NOT_STARTED = "112"; //auction not started yet.
string public constant AUCTION_NOT_ENABLED = "113"; //auction not enabled on the reserve.
string public constant ERC721_HEALTH_FACTOR_NOT_ABOVE_THRESHOLD = "114"; //ERC721 Health factor is not above the threshold.
string public constant TOKEN_IN_AUCTION = "115"; //tokenId is in auction.
string public constant AUCTIONED_BALANCE_NOT_ZERO = "116"; //auctioned balance not zero.
string public constant LIQUIDATOR_CAN_NOT_BE_SELF = "117"; //user can not liquidate himself.
string public constant INVALID_RECIPIENT = "118"; //invalid recipient specified in order.
string public constant FLASHCLAIM_NOT_ALLOWED = "119"; //flash claim is not allowed for UniswapV3 & Stakefish
string public constant NTOKEN_BALANCE_EXCEEDED = "120"; //ntoken balance exceed limit.
string public constant ORACLE_PRICE_NOT_READY = "121"; //oracle price not ready.
string public constant SET_ORACLE_SOURCE_NOT_ALLOWED = "122"; //source of oracle not allowed to set.
string public constant INVALID_LIQUIDATION_ASSET = "123"; //invalid liquidation asset.
string public constant XTOKEN_TYPE_NOT_ALLOWED = "124"; //the corresponding xTokenType not allowed in this action
string public constant GLOBAL_DEBT_IS_ZERO = "125"; //liquidation is not allowed when global debt is zero.
string public constant ORACLE_PRICE_EXPIRED = "126"; //oracle price expired.
string public constant APE_STAKING_POSITION_EXISTED = "127"; //ape staking position is existed.
string public constant SAPE_NOT_ALLOWED = "128"; //operation is not allow for sApe.
string public constant TOTAL_STAKING_AMOUNT_WRONG = "129"; //cash plus borrow amount not equal to total staking amount.
string public constant NOT_THE_BAKC_OWNER = "130"; //user is not the bakc owner.
string public constant CALLER_NOT_EOA = "131"; //The caller of the function is not an EOA account
string public constant MAKER_SAME_AS_TAKER = "132"; //maker and taker shouldn't be the same address
string public constant TOKEN_ALREADY_DELEGATED = "133"; //token is already delegted
string public constant INVALID_STATE = "134"; //invalid token status
string public constant INVALID_TOKEN_ID = "135"; //invalid token id
string public constant SENDER_SAME_AS_RECEIVER = "136"; //sender and receiver shouldn't be the same address
string public constant INVALID_YIELD_UNDERLYING_TOKEN = "137"; //invalid yield underlying token
string public constant CALLER_NOT_OPERATOR = "138"; // The caller of the function is not operator
string public constant INVALID_FEE_VALUE = "139"; // invalid fee rate value
string public constant TOKEN_NOT_ALLOW_RESCUE = "140"; // token is not allow rescue
string public constant INVALID_PARAMETER = "170"; //invalid parameter
string public constant INVALID_CALLER = "171"; //invalid callser
}
DataTypes.sol 461 lines
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import {OfferItem, ConsiderationItem} from "../../../dependencies/seaport/contracts/lib/ConsiderationStructs.sol";
import {IStakefishValidator} from "../../../interfaces/IStakefishValidator.sol";
library DataTypes {
enum AssetType {
ERC20,
ERC721
}
address public constant SApeAddress = address(0x1);
uint256 public constant HEALTH_FACTOR_LIQUIDATION_THRESHOLD = 1e18;
struct ReserveData {
//stores the reserve configuration
ReserveConfigurationMap configuration;
//the liquidity index. Expressed in ray
uint128 liquidityIndex;
//the current supply rate. Expressed in ray
uint128 currentLiquidityRate;
//variable borrow index. Expressed in ray
uint128 variableBorrowIndex;
//the current variable borrow rate. Expressed in ray
uint128 currentVariableBorrowRate;
//timestamp of last update
uint40 lastUpdateTimestamp;
//the id of the reserve. Represents the position in the list of the active reserves
uint16 id;
//xToken address
address xTokenAddress;
//variableDebtToken address
address variableDebtTokenAddress;
//address of the interest rate strategy
address interestRateStrategyAddress;
//address of the auction strategy
address auctionStrategyAddress;
//the current treasury balance, scaled
uint128 accruedToTreasury;
// timelock strategy
address timeLockStrategyAddress;
// use uint128 to be used for crosschain in the future
// after position move
uint128 unbacked;
}
struct ReserveConfigurationMap {
//bit 0-15: LTV
//bit 16-31: Liq. threshold
//bit 32-47: Liq. bonus
//bit 48-55: Decimals
//bit 56: reserve is active
//bit 57: reserve is frozen
//bit 58: borrowing is enabled
//bit 59: stable rate borrowing enabled
//bit 60: asset is paused
//bit 61: borrowing in isolation mode is enabled
//bit 62-63: reserved
//bit 64-79: reserve factor
//bit 80-115 borrow cap in whole tokens, borrowCap == 0 => no cap
//bit 116-151 supply cap in whole tokens, supplyCap == 0 => no cap
//bit 152-167 liquidation protocol fee
//bit 168-175 eMode category
//bit 176-211 unbacked mint cap in whole tokens, unbackedMintCap == 0 => minting disabled
//bit 212-251 debt ceiling for isolation mode with (ReserveConfiguration::DEBT_CEILING_DECIMALS) decimals
//bit 252-255 unused
uint256 data;
}
struct UserConfigurationMap {
/**
* @dev Bitmap of the users collaterals and borrows. It is divided in pairs of bits, one pair per asset.
* The first bit indicates if an asset is used as collateral by the user, the second whether an
* asset is borrowed by the user.
*/
uint256 data;
// auction validity time for closing invalid auctions in one tx.
uint256 auctionValidityTime;
}
struct ERC721SupplyParams {
uint256 tokenId;
bool useAsCollateral;
}
struct StakefishNTokenData {
uint256 validatorIndex;
bytes pubkey;
uint256 withdrawnBalance;
address feePoolAddress;
string nftArtUrl;
uint256 protocolFee;
IStakefishValidator.StateChange[] stateHistory;
uint256[2] pendingFeePoolReward;
}
struct NTokenData {
uint256 tokenId;
uint256 multiplier;
bool useAsCollateral;
bool isAuctioned;
StakefishNTokenData stakefishNTokenData;
}
struct ReserveCache {
uint256 currScaledVariableDebt;
uint256 nextScaledVariableDebt;
uint256 currLiquidityIndex;
uint256 nextLiquidityIndex;
uint256 currVariableBorrowIndex;
uint256 nextVariableBorrowIndex;
uint256 currLiquidityRate;
uint256 currVariableBorrowRate;
uint256 reserveFactor;
ReserveConfigurationMap reserveConfiguration;
address xTokenAddress;
address variableDebtTokenAddress;
uint40 reserveLastUpdateTimestamp;
}
struct ExecuteLiquidateParams {
uint256 reservesCount;
uint256 liquidationAmount;
uint256 collateralTokenId;
uint256 auctionRecoveryHealthFactor;
address weth;
address collateralAsset;
address liquidationAsset;
address borrower;
address liquidator;
bool receiveXToken;
address priceOracle;
address priceOracleSentinel;
}
struct ExecuteAuctionParams {
uint256 reservesCount;
uint256 auctionRecoveryHealthFactor;
uint256 collateralTokenId;
address collateralAsset;
address user;
address priceOracle;
}
struct ExecuteSupplyParams {
address asset;
uint256 amount;
address onBehalfOf;
address payer;
uint16 referralCode;
}
struct ExecuteSupplyERC721Params {
address asset;
DataTypes.ERC721SupplyParams[] tokenData;
address onBehalfOf;
address payer;
uint16 referralCode;
}
struct ExecuteBorrowParams {
address asset;
address user;
address onBehalfOf;
uint256 amount;
uint16 referralCode;
bool releaseUnderlying;
uint256 reservesCount;
address oracle;
address priceOracleSentinel;
}
struct ExecuteRepayParams {
address asset;
uint256 amount;
address onBehalfOf;
address payer;
bool usePTokens;
}
struct ExecuteWithdrawParams {
address asset;
uint256 amount;
address to;
uint256 reservesCount;
address oracle;
}
struct ExecuteWithdrawERC721Params {
address asset;
uint256[] tokenIds;
address to;
uint256 reservesCount;
address oracle;
}
struct ExecuteDecreaseUniswapV3LiquidityParams {
address user;
address asset;
uint256 tokenId;
uint256 reservesCount;
uint128 liquidityDecrease;
uint256 amount0Min;
uint256 amount1Min;
bool receiveEthAsWeth;
address oracle;
}
struct FinalizeTransferParams {
address asset;
address from;
address to;
bool usedAsCollateral;
uint256 amount;
uint256 balanceFromBefore;
uint256 balanceToBefore;
uint256 reservesCount;
address oracle;
}
struct FinalizeTransferERC721Params {
address asset;
address from;
address to;
bool usedAsCollateral;
uint256 tokenId;
uint256 balanceFromBefore;
uint256 reservesCount;
address oracle;
}
struct CalculateUserAccountDataParams {
UserConfigurationMap userConfig;
uint256 reservesCount;
address user;
address oracle;
}
struct ValidateBorrowParams {
ReserveCache reserveCache;
UserConfigurationMap userConfig;
address asset;
address userAddress;
uint256 amount;
uint256 reservesCount;
address oracle;
address priceOracleSentinel;
}
struct ValidateLiquidateERC20Params {
ReserveCache liquidationAssetReserveCache;
address liquidationAsset;
address weth;
uint256 totalDebt;
uint256 healthFactor;
uint256 liquidationAmount;
uint256 actualLiquidationAmount;
address priceOracleSentinel;
}
struct ValidateLiquidateERC721Params {
ReserveCache liquidationAssetReserveCache;
address liquidationAsset;
address liquidator;
address borrower;
uint256 globalDebt;
uint256 healthFactor;
address collateralAsset;
uint256 tokenId;
address weth;
uint256 actualLiquidationAmount;
uint256 maxLiquidationAmount;
uint256 auctionRecoveryHealthFactor;
address priceOracleSentinel;
address xTokenAddress;
bool auctionEnabled;
}
struct ValidateAuctionParams {
address user;
uint256 auctionRecoveryHealthFactor;
uint256 erc721HealthFactor;
address collateralAsset;
uint256 tokenId;
address xTokenAddress;
}
struct CalculateInterestRatesParams {
uint256 liquidityAdded;
uint256 liquidityTaken;
uint256 totalVariableDebt;
uint256 reserveFactor;
address reserve;
address xToken;
}
struct InitReserveParams {
address asset;
address xTokenAddress;
address variableDebtAddress;
address interestRateStrategyAddress;
address auctionStrategyAddress;
address timeLockStrategyAddress;
uint16 reservesCount;
uint16 maxNumberReserves;
}
struct ExecuteFlashClaimParams {
address receiverAddress;
address[] nftAssets;
uint256[][] nftTokenIds;
bytes params;
address oracle;
}
struct Credit {
address token;
uint256 amount;
bytes orderId;
uint8 v;
bytes32 r;
bytes32 s;
}
struct ExecuteMarketplaceParams {
bytes32 marketplaceId;
bytes payload;
Credit credit;
uint256 ethLeft;
DataTypes.Marketplace marketplace;
OrderInfo orderInfo;
address weth;
uint16 referralCode;
uint256 reservesCount;
address oracle;
address priceOracleSentinel;
}
struct OrderInfo {
address maker;
address taker;
bytes id;
OfferItem[] offer;
ConsiderationItem[] consideration;
}
struct Marketplace {
address marketplace;
address adapter;
address operator;
bool paused;
}
struct Auction {
uint256 startTime;
}
struct AuctionData {
address asset;
uint256 tokenId;
uint256 startTime;
uint256 currentPriceMultiplier;
uint256 maxPriceMultiplier;
uint256 minExpPriceMultiplier;
uint256 minPriceMultiplier;
uint256 stepLinear;
uint256 stepExp;
uint256 tickLength;
}
struct TokenData {
string symbol;
address tokenAddress;
}
enum ApeCompoundType {
SwapAndSupply
}
enum ApeCompoundTokenOut {
USDC,
WETH
}
struct ApeCompoundStrategy {
ApeCompoundType ty;
ApeCompoundTokenOut swapTokenOut;
uint256 swapPercent;
}
struct PoolStorage {
// Map of reserves and their data (underlyingAssetOfReserve => reserveData)
mapping(address => ReserveData) _reserves;
// Map of users address and their configuration data (userAddress => userConfiguration)
mapping(address => UserConfigurationMap) _usersConfig;
// List of reserves as a map (reserveId => reserve).
// It is structured as a mapping for gas savings reasons, using the reserve id as index
mapping(uint256 => address) _reservesList;
// Maximum number of active reserves there have been in the protocol. It is the upper bound of the reserves list
uint16 _reservesCount;
// Auction recovery health factor
uint64 _auctionRecoveryHealthFactor;
// Incentive fee for claim ape reward to compound
uint16 _apeCompoundFee;
// Map of user's ape compound strategies
mapping(address => ApeCompoundStrategy) _apeCompoundStrategies;
}
struct ReserveConfigData {
uint256 decimals;
uint256 ltv;
uint256 liquidationThreshold;
uint256 liquidationBonus;
uint256 reserveFactor;
bool usageAsCollateralEnabled;
bool borrowingEnabled;
bool isActive;
bool isFrozen;
bool isPaused;
}
struct TimeLockParams {
uint48 releaseTime;
TimeLockActionType actionType;
}
struct TimeLockFactorParams {
AssetType assetType;
address asset;
uint256 amount;
}
enum TimeLockActionType {
BORROW,
WITHDRAW
}
struct ParaSpacePositionMoveInfo {
address[] cTokens;
DataTypes.AssetType[] cTypes;
uint256[][] cAmountsOrTokenIds;
address[] dTokens;
uint256[] dAmounts;
address to;
}
struct ParaSpacePositionMoveParams {
address user;
address[] cTokens;
DataTypes.AssetType[] cTypes;
uint256[][] cAmountsOrTokenIds;
address[] dTokens;
uint256[] dAmounts;
address to;
address priceOracle;
address priceOracleSentinel;
uint256 reservesCount;
}
}
SafeCast.sol 313 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)
pragma solidity ^0.8.0;
/**
* @dev Wrappers over Solidity's uintXX/intXX 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.
*
* Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
* all math on `uint256` and `int256` and then downcasting.
*/
library SafeCast {
/**
* @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) {
require(
value <= type(uint224).max,
"SafeCast: value doesn't fit in 224 bits"
);
return uint224(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
*
* _Available since v4.7._
*/
function toUint184(uint256 value) internal pure returns (uint184) {
require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits");
return uint184(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) {
require(
value <= type(uint128).max,
"SafeCast: value doesn't fit in 128 bits"
);
return uint128(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) {
require(
value <= type(uint96).max,
"SafeCast: value doesn't fit in 96 bits"
);
return uint96(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) {
require(
value <= type(uint64).max,
"SafeCast: value doesn't fit in 64 bits"
);
return uint64(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
*
* _Available since v4.7._
*/
function toUint48(uint256 value) internal pure returns (uint48) {
require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits");
return uint48(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) {
require(
value <= type(uint32).max,
"SafeCast: value doesn't fit in 32 bits"
);
return uint32(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) {
require(
value <= type(uint16).max,
"SafeCast: value doesn't fit in 16 bits"
);
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) {
require(
value <= type(uint8).max,
"SafeCast: value doesn't fit in 8 bits"
);
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) {
require(value >= 0, "SafeCast: value must be positive");
return uint256(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
*
* _Available since v3.1._
*/
function toInt128(int256 value) internal pure returns (int128) {
require(
value >= type(int128).min && value <= type(int128).max,
"SafeCast: value doesn't fit in 128 bits"
);
return int128(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
*
* _Available since v3.1._
*/
function toInt64(int256 value) internal pure returns (int64) {
require(
value >= type(int64).min && value <= type(int64).max,
"SafeCast: value doesn't fit in 64 bits"
);
return int64(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
*
* _Available since v3.1._
*/
function toInt32(int256 value) internal pure returns (int32) {
require(
value >= type(int32).min && value <= type(int32).max,
"SafeCast: value doesn't fit in 32 bits"
);
return int32(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
*
* _Available since v3.1._
*/
function toInt16(int256 value) internal pure returns (int16) {
require(
value >= type(int16).min && value <= type(int16).max,
"SafeCast: value doesn't fit in 16 bits"
);
return int16(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.
*
* _Available since v3.1._
*/
function toInt8(int256 value) internal pure returns (int8) {
require(
value >= type(int8).min && value <= type(int8).max,
"SafeCast: value doesn't fit in 8 bits"
);
return int8(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
require(
value <= uint256(type(int256).max),
"SafeCast: value doesn't fit in an int256"
);
return int256(value);
}
}
ConsiderationEnums.sol 143 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// prettier-ignore
enum OrderType {
// 0: no partial fills, anyone can execute
FULL_OPEN,
// 1: partial fills supported, anyone can execute
PARTIAL_OPEN,
// 2: no partial fills, only offerer or zone can execute
FULL_RESTRICTED,
// 3: partial fills supported, only offerer or zone can execute
PARTIAL_RESTRICTED
}
// prettier-ignore
enum BasicOrderType {
// 0: no partial fills, anyone can execute
ETH_TO_ERC721_FULL_OPEN,
// 1: partial fills supported, anyone can execute
ETH_TO_ERC721_PARTIAL_OPEN,
// 2: no partial fills, only offerer or zone can execute
ETH_TO_ERC721_FULL_RESTRICTED,
// 3: partial fills supported, only offerer or zone can execute
ETH_TO_ERC721_PARTIAL_RESTRICTED,
// 4: no partial fills, anyone can execute
ETH_TO_ERC1155_FULL_OPEN,
// 5: partial fills supported, anyone can execute
ETH_TO_ERC1155_PARTIAL_OPEN,
// 6: no partial fills, only offerer or zone can execute
ETH_TO_ERC1155_FULL_RESTRICTED,
// 7: partial fills supported, only offerer or zone can execute
ETH_TO_ERC1155_PARTIAL_RESTRICTED,
// 8: no partial fills, anyone can execute
ERC20_TO_ERC721_FULL_OPEN,
// 9: partial fills supported, anyone can execute
ERC20_TO_ERC721_PARTIAL_OPEN,
// 10: no partial fills, only offerer or zone can execute
ERC20_TO_ERC721_FULL_RESTRICTED,
// 11: partial fills supported, only offerer or zone can execute
ERC20_TO_ERC721_PARTIAL_RESTRICTED,
// 12: no partial fills, anyone can execute
ERC20_TO_ERC1155_FULL_OPEN,
// 13: partial fills supported, anyone can execute
ERC20_TO_ERC1155_PARTIAL_OPEN,
// 14: no partial fills, only offerer or zone can execute
ERC20_TO_ERC1155_FULL_RESTRICTED,
// 15: partial fills supported, only offerer or zone can execute
ERC20_TO_ERC1155_PARTIAL_RESTRICTED,
// 16: no partial fills, anyone can execute
ERC721_TO_ERC20_FULL_OPEN,
// 17: partial fills supported, anyone can execute
ERC721_TO_ERC20_PARTIAL_OPEN,
// 18: no partial fills, only offerer or zone can execute
ERC721_TO_ERC20_FULL_RESTRICTED,
// 19: partial fills supported, only offerer or zone can execute
ERC721_TO_ERC20_PARTIAL_RESTRICTED,
// 20: no partial fills, anyone can execute
ERC1155_TO_ERC20_FULL_OPEN,
// 21: partial fills supported, anyone can execute
ERC1155_TO_ERC20_PARTIAL_OPEN,
// 22: no partial fills, only offerer or zone can execute
ERC1155_TO_ERC20_FULL_RESTRICTED,
// 23: partial fills supported, only offerer or zone can execute
ERC1155_TO_ERC20_PARTIAL_RESTRICTED
}
// prettier-ignore
enum BasicOrderRouteType {
// 0: provide Ether (or other native token) to receive offered ERC721 item.
ETH_TO_ERC721,
// 1: provide Ether (or other native token) to receive offered ERC1155 item.
ETH_TO_ERC1155,
// 2: provide ERC20 item to receive offered ERC721 item.
ERC20_TO_ERC721,
// 3: provide ERC20 item to receive offered ERC1155 item.
ERC20_TO_ERC1155,
// 4: provide ERC721 item to receive offered ERC20 item.
ERC721_TO_ERC20,
// 5: provide ERC1155 item to receive offered ERC20 item.
ERC1155_TO_ERC20
}
// prettier-ignore
enum ItemType {
// 0: ETH on mainnet, MATIC on polygon, etc.
NATIVE,
// 1: ERC20 items (ERC777 and ERC20 analogues could also technically work)
ERC20,
// 2: ERC721 items
ERC721,
// 3: ERC1155 items
ERC1155,
// 4: ERC721 items where a number of tokenIds are supported
ERC721_WITH_CRITERIA,
// 5: ERC1155 items where a number of ids are supported
ERC1155_WITH_CRITERIA
}
// prettier-ignore
enum Side {
// 0: Items that can be spent
OFFER,
// 1: Items that must be received
CONSIDERATION
}
ConsiderationStructs.sol 243 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {
OrderType,
BasicOrderType,
ItemType,
Side
} from "./ConsiderationEnums.sol";
/**
* @dev An order contains eleven components: an offerer, a zone (or account that
* can cancel the order or restrict who can fulfill the order depending on
* the type), the order type (specifying partial fill support as well as
* restricted order status), the start and end time, a hash that will be
* provided to the zone when validating restricted orders, a salt, a key
* corresponding to a given conduit, a counter, and an arbitrary number of
* offer items that can be spent along with consideration items that must
* be received by their respective recipient.
*/
struct OrderComponents {
address offerer;
address zone;
OfferItem[] offer;
ConsiderationItem[] consideration;
OrderType orderType;
uint256 startTime;
uint256 endTime;
bytes32 zoneHash;
uint256 salt;
bytes32 conduitKey;
uint256 counter;
}
/**
* @dev An offer item has five components: an item type (ETH or other native
* tokens, ERC20, ERC721, and ERC1155, as well as criteria-based ERC721 and
* ERC1155), a token address, a dual-purpose "identifierOrCriteria"
* component that will either represent a tokenId or a merkle root
* depending on the item type, and a start and end amount that support
* increasing or decreasing amounts over the duration of the respective
* order.
*/
struct OfferItem {
ItemType itemType;
address token;
uint256 identifierOrCriteria;
uint256 startAmount;
uint256 endAmount;
}
/**
* @dev A consideration item has the same five components as an offer item and
* an additional sixth component designating the required recipient of the
* item.
*/
struct ConsiderationItem {
ItemType itemType;
address token;
uint256 identifierOrCriteria;
uint256 startAmount;
uint256 endAmount;
address payable recipient;
}
/**
* @dev A spent item is translated from a utilized offer item and has four
* components: an item type (ETH or other native tokens, ERC20, ERC721, and
* ERC1155), a token address, a tokenId, and an amount.
*/
struct SpentItem {
ItemType itemType;
address token;
uint256 identifier;
uint256 amount;
}
/**
* @dev A received item is translated from a utilized consideration item and has
* the same four components as a spent item, as well as an additional fifth
* component designating the required recipient of the item.
*/
struct ReceivedItem {
ItemType itemType;
address token;
uint256 identifier;
uint256 amount;
address payable recipient;
}
/**
* @dev For basic orders involving ETH / native / ERC20 <=> ERC721 / ERC1155
* matching, a group of six functions may be called that only requires a
* subset of the usual order arguments. Note the use of a "basicOrderType"
* enum; this represents both the usual order type as well as the "route"
* of the basic order (a simple derivation function for the basic order
* type is `basicOrderType = orderType + (4 * basicOrderRoute)`.)
*/
struct BasicOrderParameters {
// calldata offset
address considerationToken; // 0x24
uint256 considerationIdentifier; // 0x44
uint256 considerationAmount; // 0x64
address payable offerer; // 0x84
address zone; // 0xa4
address offerToken; // 0xc4
uint256 offerIdentifier; // 0xe4
uint256 offerAmount; // 0x104
BasicOrderType basicOrderType; // 0x124
uint256 startTime; // 0x144
uint256 endTime; // 0x164
bytes32 zoneHash; // 0x184
uint256 salt; // 0x1a4
bytes32 offererConduitKey; // 0x1c4
bytes32 fulfillerConduitKey; // 0x1e4
uint256 totalOriginalAdditionalRecipients; // 0x204
AdditionalRecipient[] additionalRecipients; // 0x224
bytes signature; // 0x244
// Total length, excluding dynamic array data: 0x264 (580)
}
/**
* @dev Basic orders can supply any number of additional recipients, with the
* implied assumption that they are supplied from the offered ETH (or other
* native token) or ERC20 token for the order.
*/
struct AdditionalRecipient {
uint256 amount;
address payable recipient;
}
/**
* @dev The full set of order components, with the exception of the counter,
* must be supplied when fulfilling more sophisticated orders or groups of
* orders. The total number of original consideration items must also be
* supplied, as the caller may specify additional consideration items.
*/
struct OrderParameters {
address offerer; // 0x00
address zone; // 0x20
OfferItem[] offer; // 0x40
ConsiderationItem[] consideration; // 0x60
OrderType orderType; // 0x80
uint256 startTime; // 0xa0
uint256 endTime; // 0xc0
bytes32 zoneHash; // 0xe0
uint256 salt; // 0x100
bytes32 conduitKey; // 0x120
uint256 totalOriginalConsiderationItems; // 0x140
// offer.length // 0x160
}
/**
* @dev Orders require a signature in addition to the other order parameters.
*/
struct Order {
OrderParameters parameters;
bytes signature;
}
/**
* @dev Advanced orders include a numerator (i.e. a fraction to attempt to fill)
* and a denominator (the total size of the order) in addition to the
* signature and other order parameters. It also supports an optional field
* for supplying extra data; this data will be included in a staticcall to
* `isValidOrderIncludingExtraData` on the zone for the order if the order
* type is restricted and the offerer or zone are not the caller.
*/
struct AdvancedOrder {
OrderParameters parameters;
uint120 numerator;
uint120 denominator;
bytes signature;
bytes extraData;
}
/**
* @dev Orders can be validated (either explicitly via `validate`, or as a
* consequence of a full or partial fill), specifically cancelled (they can
* also be cancelled in bulk via incrementing a per-zone counter), and
* partially or fully filled (with the fraction filled represented by a
* numerator and denominator).
*/
struct OrderStatus {
bool isValidated;
bool isCancelled;
uint120 numerator;
uint120 denominator;
}
/**
* @dev A criteria resolver specifies an order, side (offer vs. consideration),
* and item index. It then provides a chosen identifier (i.e. tokenId)
* alongside a merkle proof demonstrating the identifier meets the required
* criteria.
*/
struct CriteriaResolver {
uint256 orderIndex;
Side side;
uint256 index;
uint256 identifier;
bytes32[] criteriaProof;
}
/**
* @dev A fulfillment is applied to a group of orders. It decrements a series of
* offer and consideration items, then generates a single execution
* element. A given fulfillment can be applied to as many offer and
* consideration items as desired, but must contain at least one offer and
* at least one consideration that match. The fulfillment must also remain
* consistent on all key parameters across all offer items (same offerer,
* token, type, tokenId, and conduit preference) as well as across all
* consideration items (token, type, tokenId, and recipient).
*/
struct Fulfillment {
FulfillmentComponent[] offerComponents;
FulfillmentComponent[] considerationComponents;
}
/**
* @dev Each fulfillment component contains one index referencing a specific
* order and another referencing a specific offer or consideration item.
*/
struct FulfillmentComponent {
uint256 orderIndex;
uint256 itemIndex;
}
/**
* @dev An execution is triggered once all consideration items have been zeroed
* out. It sends the item in question from the offerer to the item's
* recipient, optionally sourcing approvals from either this contract
* directly or from the offerer's chosen conduit if one is specified. An
* execution is not provided as an argument, but rather is derived via
* orders, criteria resolvers, and fulfillments (where the total number of
* executions will be less than or equal to the total number of indicated
* fulfillments) and returned as part of `matchOrders`.
*/
struct Execution {
ReceivedItem item;
address offerer;
bytes32 conduitKey;
}
Read Contract
MAX_WAIT_TIME 0xc2f86666 → uint48
MID_THRESHOLD 0x8fa6a295 → uint256
MID_WAIT_TIME 0xfe70f69d → uint48
MIN_THRESHOLD 0xbd11c4c0 → uint256
MIN_WAIT_TIME 0xbca67b93 → uint48
PERIOD 0xb4d1d795 → uint256
POOL_PERIOD_LIMIT 0x16fa4fe7 → uint256
POOL_PERIOD_WAIT_TIME 0xb0594468 → uint48
getTimeLockStrategyData 0x468b8ffa → tuple
lastResetTimestamp 0xb343a0df → uint48
totalAmountInCurrentPeriod 0x5cdb8be8 → uint128
Write Contract 1 functions
These functions modify contract state and require a wallet transaction to execute.
calculateTimeLockParams 0x16421f55
tuple params
returns: tuple
Recent Transactions
No transactions found for this address