Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multi Chain
Multichain Addresses
N/ALatest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
Value | ||||
---|---|---|---|---|---|---|---|---|---|
0x60806040 | 7791637 | 416 days 3 hrs ago | IN | Create: StagingBox | 0 ETH | 0.12574201 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Txn Hash | Block | From | To | Value | ||
---|---|---|---|---|---|---|
8176564 | 351 days 23 hrs ago | 0 ETH | ||||
8176561 | 351 days 23 hrs ago | 0 ETH | ||||
8176558 | 351 days 23 hrs ago | 0 ETH | ||||
8176552 | 351 days 23 hrs ago | 0 ETH | ||||
8176550 | 351 days 23 hrs ago | 0 ETH | ||||
8176550 | 351 days 23 hrs ago | 0 ETH | ||||
8176550 | 351 days 23 hrs ago | 0 ETH | ||||
8176550 | 351 days 23 hrs ago | 0 ETH | ||||
8176550 | 351 days 23 hrs ago | 0 ETH | ||||
8176550 | 351 days 23 hrs ago | 0 ETH | ||||
8176550 | 351 days 23 hrs ago | 0 ETH | ||||
8176550 | 351 days 23 hrs ago | 0 ETH | ||||
8176550 | 351 days 23 hrs ago | 0 ETH | ||||
8176550 | 351 days 23 hrs ago | 0 ETH | ||||
8176550 | 351 days 23 hrs ago | 0 ETH | ||||
8176550 | 351 days 23 hrs ago | 0 ETH | ||||
8176547 | 351 days 23 hrs ago | 0 ETH | ||||
8176540 | 351 days 23 hrs ago | 0 ETH | ||||
8170084 | 353 days 2 hrs ago | 0 ETH | ||||
8170084 | 353 days 2 hrs ago | 0 ETH | ||||
8165185 | 353 days 22 hrs ago | 0 ETH | ||||
8165184 | 353 days 22 hrs ago | 0 ETH | ||||
8165184 | 353 days 22 hrs ago | 0 ETH | ||||
8165184 | 353 days 22 hrs ago | 0 ETH | ||||
8165184 | 353 days 22 hrs ago | 0 ETH |
Loading...
Loading
Contract Name:
StagingBox
Compiler Version
v0.8.13+commit.abaa5c0e
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
//SPDX-License-Identifier: Unlicense pragma solidity 0.8.13; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@uniswap/lib/contracts/libraries/TransferHelper.sol"; import "../../utils/SBImmutableArgs.sol"; import "../interfaces/IStagingBox.sol"; /** * @dev Staging Box for reinitializing a ConvertibleBondBox * * Invariants: * - initialPrice should meet conditions needed to reinitialize CBB * - I.e. initialPrice <= priceGranularity, and initialPrice != 0 */ contract StagingBox is OwnableUpgradeable, SBImmutableArgs, IStagingBox { uint256 public s_reinitLendAmount; modifier beforeReinitialize() { if (convertibleBondBox().s_startDate() != 0) { revert CBBReinitialized({state: true, requiredState: false}); } _; } function initialize(address _owner) external initializer { require(_owner != address(0), "StagingBox: invalid owner address"); //check if valid initialPrice immutable arg if (initialPrice() > priceGranularity()) revert InitialPriceTooHigh({ given: initialPrice(), maxPrice: priceGranularity() }); if (initialPrice() == 0) revert InitialPriceIsZero({given: 0, maxPrice: priceGranularity()}); //Setup ownership __Ownable_init(); transferOwnership(_owner); //Add event stuff emit Initialized(_owner); } function depositBorrow(address _borrower, uint256 _borrowAmount) external override beforeReinitialize { //- transfers `_safeTrancheAmount` of SafeTranche Tokens from msg.sender to SB uint256 safeTrancheAmount = (_borrowAmount * priceGranularity() * trancheDecimals()) / initialPrice() / stableDecimals(); safeTranche().transferFrom( _msgSender(), address(this), safeTrancheAmount ); //- transfers `_safeTrancheAmount * riskRatio() / safeRatio()` of RiskTranches from msg.sender to SB riskTranche().transferFrom( _msgSender(), address(this), (safeTrancheAmount * riskRatio()) / safeRatio() ); //- mints `_safeTrancheAmount` of BorrowerSlips to `_borrower` borrowSlip().mint(_borrower, _borrowAmount); //add event stuff emit BorrowDeposit(_borrower, _borrowAmount); } function depositLend(address _lender, uint256 _lendAmount) external override beforeReinitialize { //- transfers `_lendAmount`of Stable Tokens from msg.sender to SB TransferHelper.safeTransferFrom( address(stableToken()), _msgSender(), address(this), _lendAmount ); //- mints `_lendAmount`of LenderSlips to `_lender` lendSlip().mint(_lender, _lendAmount); //add event stuff emit LendDeposit(_lender, _lendAmount); } function withdrawBorrow(uint256 _borrowSlipAmount) external override { //- Reverse of depositBorrow() function //- transfers `_borrowSlipAmount` of SafeTranche Tokens from SB to msg.sender uint256 safeTrancheAmount = (_borrowSlipAmount * priceGranularity() * trancheDecimals()) / initialPrice() / stableDecimals(); safeTranche().transfer(_msgSender(), (safeTrancheAmount)); //- transfers `_borrowSlipAmount*riskRatio()/safeRatio()` of RiskTranche Tokens from SB to msg.sender riskTranche().transfer( _msgSender(), (safeTrancheAmount * riskRatio()) / safeRatio() ); //- burns `_borrowSlipAmount` of msg.sender’s BorrowSlips borrowSlip().burn(_msgSender(), _borrowSlipAmount); //event stuff emit BorrowWithdrawal(_msgSender(), _borrowSlipAmount); } function withdrawLend(uint256 _lendSlipAmount) external override { //- Reverse of depositBorrow() function //revert check for _lendSlipAmount after CBB reinitialized if (convertibleBondBox().s_startDate() != 0) { uint256 maxWithdrawAmount = stableToken().balanceOf(address(this)) - s_reinitLendAmount; if (_lendSlipAmount > maxWithdrawAmount) { revert WithdrawAmountTooHigh({ requestAmount: _lendSlipAmount, maxAmount: maxWithdrawAmount }); } } //- transfers `_lendSlipAmount` of Stable Tokens from SB to msg.sender TransferHelper.safeTransfer( address(stableToken()), _msgSender(), _lendSlipAmount ); //- burns `_lendSlipAmount` of msg.sender’s LenderSlips lendSlip().burn(_msgSender(), _lendSlipAmount); //event stuff emit LendWithdrawal(_msgSender(), _lendSlipAmount); } function redeemBorrowSlip(uint256 _borrowSlipAmount) external override { //decrement s_reinitLendAmount s_reinitLendAmount -= _borrowSlipAmount; // Transfer `_borrowSlipAmount*riskRatio()/safeRatio()` of RiskSlips to msg.sender ISlip(riskSlipAddress()).transfer( _msgSender(), ((_borrowSlipAmount * priceGranularity() * riskRatio() * trancheDecimals()) / initialPrice() / safeRatio() / stableDecimals()) ); // Transfer `_borrowSlipAmount*initialPrice()/priceGranularity()` of StableToken to msg.sender TransferHelper.safeTransfer( address(stableToken()), _msgSender(), _borrowSlipAmount ); // burns `_borrowSlipAmount` of msg.sender’s BorrowSlips borrowSlip().burn(_msgSender(), _borrowSlipAmount); //event stuff emit RedeemBorrowSlip(_msgSender(), _borrowSlipAmount); } function redeemLendSlip(uint256 _lendSlipAmount) external override { //- Transfer `_lendSlipAmount*priceGranularity()/initialPrice()` of SafeSlips to msg.sender ISlip(safeSlipAddress()).transfer( _msgSender(), (_lendSlipAmount * priceGranularity() * trancheDecimals()) / initialPrice() / stableDecimals() ); //- burns `_lendSlipAmount` of msg.sender’s LendSlips lendSlip().burn(_msgSender(), _lendSlipAmount); emit RedeemLendSlip(_msgSender(), _lendSlipAmount); } function transmitReInit(bool _isLend) external override onlyOwner { /* - calls `CBB.reinitialize(…)` - `Address(this)` as borrower + lender - if `_isLend` is true: calls CBB with balance of StableAmount - if `_isLend` is false: calls CBB with balance of SafeTrancheAmount */ safeTranche().approve(address(convertibleBondBox()), type(uint256).max); riskTranche().approve(address(convertibleBondBox()), type(uint256).max); if (_isLend) { uint256 stableAmount = stableToken().balanceOf(address(this)); s_reinitLendAmount = stableAmount; convertibleBondBox().reinitialize(initialPrice()); convertibleBondBox().lend( address(this), address(this), stableAmount ); } else { uint256 safeTrancheBalance = safeTranche().balanceOf(address(this)); s_reinitLendAmount = (safeTrancheBalance * initialPrice() * stableDecimals()) / priceGranularity() / trancheDecimals(); convertibleBondBox().reinitialize(initialPrice()); convertibleBondBox().borrow( address(this), address(this), safeTrancheBalance ); } //- calls `CBB.transferOwner(owner())` to transfer ownership of CBB back to Owner() convertibleBondBox().transferOwnership(owner()); } function transferOwnership(address newOwner) public override(IStagingBox, OwnableUpgradeable) onlyOwner { _transferOwnership(newOwner); } function transferCBBOwnership(address newOwner) public override onlyOwner { convertibleBondBox().transferOwnership(newOwner); } }
// SPDX-License-Identifier: BSD pragma solidity ^0.8.4; /// @title Clone /// @author zefram.eth /// @notice Provides helper functions for reading immutable args from calldata contract Clone { /// @notice Reads an immutable arg with type address /// @param argOffset The offset of the arg in the packed data /// @return arg The arg value function _getArgAddress(uint256 argOffset) internal pure returns (address arg) { uint256 offset = _getImmutableArgsOffset(); // solhint-disable-next-line no-inline-assembly assembly { arg := shr(0x60, calldataload(add(offset, argOffset))) } } /// @notice Reads an immutable arg with type uint256 /// @param argOffset The offset of the arg in the packed data /// @return arg The arg value function _getArgUint256(uint256 argOffset) internal pure returns (uint256 arg) { uint256 offset = _getImmutableArgsOffset(); // solhint-disable-next-line no-inline-assembly assembly { arg := calldataload(add(offset, argOffset)) } } /// @notice Reads a uint256 array stored in the immutable args. /// @param argOffset The offset of the arg in the packed data /// @param arrLen Number of elements in the array /// @return arr The array function _getArgUint256Array(uint256 argOffset, uint64 arrLen) internal pure returns (uint256[] memory arr) { uint256 offset = _getImmutableArgsOffset(); uint256 el; arr = new uint256[](arrLen); for (uint64 i = 0; i < arrLen; i++) { assembly { // solhint-disable-next-line no-inline-assembly el := calldataload(add(add(offset, argOffset), mul(i, 32))) } arr[i] = el; } return arr; } /// @notice Reads an immutable arg with type uint64 /// @param argOffset The offset of the arg in the packed data /// @return arg The arg value function _getArgUint64(uint256 argOffset) internal pure returns (uint64 arg) { uint256 offset = _getImmutableArgsOffset(); // solhint-disable-next-line no-inline-assembly assembly { arg := shr(0xc0, calldataload(add(offset, argOffset))) } } /// @notice Reads an immutable arg with type uint8 /// @param argOffset The offset of the arg in the packed data /// @return arg The arg value function _getArgUint8(uint256 argOffset) internal pure returns (uint8 arg) { uint256 offset = _getImmutableArgsOffset(); // solhint-disable-next-line no-inline-assembly assembly { arg := shr(0xf8, calldataload(add(offset, argOffset))) } } /// @return offset The offset of the packed immutable args in calldata function _getImmutableArgsOffset() internal pure returns (uint256 offset) { // solhint-disable-next-line no-inline-assembly assembly { offset := sub( calldatasize(), add(shr(240, calldataload(sub(calldatasize(), 2))), 2) ) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original * initialization step. This is essential to configure modules that are added through upgrades and that require * initialization. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.6.0; // helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false library TransferHelper { function safeApprove( address token, address to, uint256 value ) internal { // bytes4(keccak256(bytes('approve(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require( success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper::safeApprove: approve failed' ); } function safeTransfer( address token, address to, uint256 value ) internal { // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require( success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper::safeTransfer: transfer failed' ); } function safeTransferFrom( address token, address from, address to, uint256 value ) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require( success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper::transferFrom: transferFrom failed' ); } function safeTransferETH(address to, uint256 value) internal { (bool success, ) = to.call{value: value}(new bytes(0)); require(success, 'TransferHelper::safeTransferETH: ETH transfer failed'); } }
pragma solidity ^0.8.3; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@uniswap/lib/contracts/libraries/TransferHelper.sol"; import "./ITranche.sol"; struct TrancheData { ITranche token; uint256 ratio; } /** * @dev Controller for a ButtonTranche bond system */ interface IBondController { event Deposit(address from, uint256 amount, uint256 feeBps); event Mature(address caller); event RedeemMature(address user, address tranche, uint256 amount); event Redeem(address user, uint256[] amounts); event FeeUpdate(uint256 newFee); function collateralToken() external view returns (address); function tranches(uint256 i) external view returns (ITranche token, uint256 ratio); function trancheCount() external view returns (uint256 count); function feeBps() external view returns (uint256 fee); function maturityDate() external view returns (uint256 maturityDate); function isMature() external view returns (bool isMature); function creationDate() external view returns (uint256 creationDate); function totalDebt() external view returns (uint256 totalDebt); /** * @dev Deposit `amount` tokens from `msg.sender`, get tranche tokens in return * Requirements: * - `msg.sender` must have `approved` `amount` collateral tokens to this contract */ function deposit(uint256 amount) external; /** * @dev Matures the bond. Disables deposits, * fixes the redemption ratio, and distributes collateral to redemption pools * Redeems any fees collected from deposits, sending redeemed funds to the contract owner * Requirements: * - The bond is not already mature * - One of: * - `msg.sender` is owner * - `maturityDate` has passed */ function mature() external; /** * @dev Redeems some tranche tokens * Requirements: * - The bond is mature * - `msg.sender` owns at least `amount` tranche tokens from address `tranche` * - `tranche` must be a valid tranche token on this bond */ function redeemMature(address tranche, uint256 amount) external; /** * @dev Redeems a slice of tranche tokens from all tranches. * Returns collateral to the user proportionally to the amount of debt they are removing * Requirements * - The bond is not mature * - The number of `amounts` is the same as the number of tranches * - The `amounts` are in equivalent ratio to the tranche order */ function redeem(uint256[] memory amounts) external; /** * @dev Updates the fee taken on deposit to the given new fee * * Requirements * - `msg.sender` has admin role * - `newFeeBps` is in range [0, 50] */ function setFee(uint256 newFeeBps) external; }
pragma solidity ^0.8.3; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@uniswap/lib/contracts/libraries/TransferHelper.sol"; /** * @dev ERC20 token to represent a single tranche for a ButtonTranche bond * */ interface ITranche is IERC20 { /** * @dev returns the BondController address which owns this Tranche contract * It should have admin permissions to call mint, burn, and redeem functions */ function bond() external view returns (address); /** * @dev Mint `amount` tokens to `to` * Only callable by the owner (bond controller). Used to * manage bonds, specifically creating tokens upon deposit * @param to the address to mint tokens to * @param amount The amount of tokens to mint */ function mint(address to, uint256 amount) external; /** * @dev Burn `amount` tokens from `from`'s balance * Only callable by the owner (bond controller). Used to * manage bonds, specifically burning tokens upon redemption * @param from The address to burn tokens from * @param amount The amount of tokens to burn */ function burn(address from, uint256 amount) external; /** * @dev Burn `amount` tokens from `from` and return the proportional * value of the collateral token to `to` * @param from The address to burn tokens from * @param to The address to send collateral back to * @param amount The amount of tokens to burn */ function redeem( address from, address to, uint256 amount ) external; }
//SPDX-License-Identifier: Unlicense pragma solidity 0.8.13; import "../../utils/ICBBImmutableArgs.sol"; /** * @dev Convertible Bond Box for a ButtonTranche bond */ interface IConvertibleBondBox is ICBBImmutableArgs { event Lend( address caller, address borrower, address lender, uint256 stableAmount, uint256 price ); event Borrow( address caller, address borrower, address lender, uint256 stableAmount, uint256 price ); event RedeemStable(address caller, uint256 safeSlipAmount, uint256 price); event RedeemSafeTranche(address caller, uint256 safeSlipAmount); event RedeemRiskTranche(address caller, uint256 riskSlipAmount); event Repay( address caller, uint256 stablesPaid, uint256 riskTranchePayout, uint256 price ); event Initialized(address owner); event ReInitialized(uint256 initialPrice, uint256 timestamp); event FeeUpdate(uint256 newFee); error PenaltyTooHigh(uint256 given, uint256 maxPenalty); error BondIsMature(uint256 currentTime, uint256 maturity); error InitialPriceTooHigh(uint256 given, uint256 maxPrice); error InitialPriceIsZero(uint256 given, uint256 maxPrice); error ConvertibleBondBoxNotStarted(uint256 given, uint256 minStartDate); error BondNotMatureYet(uint256 maturityDate, uint256 currentTime); error MinimumInput(uint256 input, uint256 reqInput); error FeeTooLarge(uint256 input, uint256 maximum); //Need to add getters for state variables /** * @dev Sets startdate to be block.timestamp, sets initialPrice, and takes initial atomic deposit * @param _initialPrice the initialPrice for the CBB * Requirements: * - `msg.sender` is owner */ function reinitialize(uint256 _initialPrice) external; /** * @dev Lends StableTokens for SafeSlips when provided with matching borrow collateral * @param _borrower The address to send the RiskSlip and StableTokens to * @param _lender The address to send the SafeSlips to * @param _stableAmount The amount of StableTokens to lend * Requirements: * - `msg.sender` must have `approved` `_stableAmount` stable tokens to this contract - CBB must be reinitialized */ function lend( address _borrower, address _lender, uint256 _stableAmount ) external; /** * @dev Borrows with tranches of CollateralTokens when provided with a matching amount of StableTokens * Collateral tokens get tranched and any non-convertible bond box tranches get sent back to borrower * @param _borrower The address to send the RiskSlip and StableTokens to * @param _lender The address to send the SafeSlips to * @param _safeTrancheAmount The amount of SafeTranche being borrowed against * Requirements: * - `msg.sender` must have `approved` appropriate amount of tranches of tokens to this contract - CBB must be reinitialized - must be enough stable tokens inside convertible bond box to borrow */ function borrow( address _borrower, address _lender, uint256 _safeTrancheAmount ) external; /** * @dev returns time-weighted current price for SafeSlip, with final price as $1.00 at maturity */ function currentPrice() external view returns (uint256); /** * @dev allows repayment of loan in exchange for proportional amount of SafeTranche and Z-tranche * @param _stableAmount The amount of stable-Tokens to repay with * Requirements: * - `msg.sender` must have `approved` `stableAmount` of stable tokens to this contract */ function repay(uint256 _stableAmount) external; /** * @dev allows repayment of loan in exchange for proportional amount of SafeTranche and Z-tranche * @param _riskSlipAmount The amount of riskSlips to be repaid * Requirements: * - `msg.sender` must have `approved` appropriate amount of stable tokens to this contract */ function repayMax(uint256 _riskSlipAmount) external; /** * @dev allows lender to redeem SafeSlips for SafeTranches * @param _safeSlipAmount The amount of safe-slips to redeem * Requirements: * - can only be called after Bond is Mature * - `msg.sender` must have `approved` `safeSlipAmount` of SafeSlip tokens to this contract */ function redeemSafeTranche(uint256 _safeSlipAmount) external; /** * @dev allows borrower to redeem RiskSlips for tranches (i.e. default) * @param _riskSlipAmount The amount of RiskSlips to redeem * Requirements: * - can only be called after Bond is Mature * - `msg.sender` must have `approved` `_riskSlipAmount` of RiskSlip tokens to this contract */ function redeemRiskTranche(uint256 _riskSlipAmount) external; /** * @dev allows lender to redeem SafeSlips for StableTokens * @param _safeSlipAmount The amount of SafeSlips to redeem * Requirements: * - `msg.sender` must have `approved` `safeSlipAmount` of safe-Slip tokens to this contract * - can only be called when StableTokens are present inside CBB */ function redeemStable(uint256 _safeSlipAmount) external; /** * @dev Updates the fee taken on redeem/repay to the given new fee * * Requirements * - `msg.sender` has admin role * - `newFeeBps` is in range [0, 50] */ function setFee(uint256 newFeeBps) external; /** * @dev Gets the start date */ function s_startDate() external view returns (uint256); /** * @dev Gets the total repaid safe slips to date */ function s_repaidSafeSlips() external view returns (uint256); /** * @dev Gets the tranche granularity constant */ function s_trancheGranularity() external view returns (uint256); /** * @dev Gets the penalty granularity constant */ function s_penaltyGranularity() external view returns (uint256); /** * @dev Gets the price granularity constant */ function s_priceGranularity() external view returns (uint256); /** * @dev Gets the fee basis points */ function feeBps() external view returns (uint256); /** * @dev Gets the basis points denominator constant. AKA a fee granularity constant */ function BPS() external view returns (uint256); /** * @dev Gets the max fee basis points constant. */ function maxFeeBPS() external view returns (uint256); /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) external; /** * @dev Gets the initialPrice of SafeSlip. */ function s_initialPrice() external view returns (uint256); }
pragma solidity 0.8.13; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @dev ERC20 token to represent a single slip for a bond box * */ interface ISlip is IERC20 { event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev returns the bond box address which owns this slip contract * It should have admin permissions to call mint, burn, and redeem functions */ function boxOwner() external view returns (address); /** * @dev Mint `amount` tokens to `to` * Only callable by the owner. * @param to the address to mint tokens to * @param amount The amount of tokens to mint */ function mint(address to, uint256 amount) external; /** * @dev Burn `amount` tokens from `from`'s balance * Only callable by the owner. * @param from The address to burn tokens from * @param amount The amount of tokens to burn */ function burn(address from, uint256 amount) external; /** * @dev allows owner to transfer ownership to a new owner. Implemented so that factory can transfer minting/burning ability to CBB after deployment * @param newOwner The address of the CBB */ function changeOwner(address newOwner) external; }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.13; import "../../utils/ISBImmutableArgs.sol"; interface IStagingBox is ISBImmutableArgs { event LendDeposit(address lender, uint256 lendAmount); event BorrowDeposit(address borrower, uint256 safeTrancheAmount); event LendWithdrawal(address lender, uint256 lendSlipAmount); event BorrowWithdrawal(address borrower, uint256 borrowSlipAmount); event RedeemBorrowSlip(address caller, uint256 borrowSlipAmount); event RedeemLendSlip(address caller, uint256 lendSlipAmount); event Initialized(address owner); error InitialPriceTooHigh(uint256 given, uint256 maxPrice); error InitialPriceIsZero(uint256 given, uint256 maxPrice); error WithdrawAmountTooHigh(uint256 requestAmount, uint256 maxAmount); error CBBReinitialized(bool state, bool requiredState); function s_reinitLendAmount() external view returns (uint256); /** * @dev Deposits collateral for BorrowSlips * @param _borrower The recipent address of the BorrowSlips * @param _borrowAmount The amount of stableTokens to be borrowed * Requirements: * - `msg.sender` must have `approved` `stableAmount` stable tokens to this contract */ function depositBorrow(address _borrower, uint256 _borrowAmount) external; /** * @dev deposit _lendAmount of stable-tokens for LendSlips * @param _lender The recipent address of the LenderSlips * @param _lendAmount The amount of stable tokens to deposit * Requirements: * - `msg.sender` must have `approved` `stableAmount` stable tokens to this contract */ function depositLend(address _lender, uint256 _lendAmount) external; /** * @dev Burns BorrowSlips for Collateral * @param _borrowSlipAmount The amount of borrowSlips to withdraw * Requirements: */ function withdrawBorrow(uint256 _borrowSlipAmount) external; /** * @dev burns LendSlips for Stables * @param _lendSlipAmount The amount of stable tokens to withdraw * Requirements: * - Cannot withdraw more than s_reinitLendAmount after reinitialization */ function withdrawLend(uint256 _lendSlipAmount) external; /** * @dev Exchanges BorrowSlips for RiskSlips + Stablecoin loan * @param _borrowSlipAmount amount of BorrowSlips to redeem RiskSlips and USDT with * Requirements: */ function redeemBorrowSlip(uint256 _borrowSlipAmount) external; /** * @dev Exchanges lendSlips for safeSlips * @param _lendSlipAmount amount of LendSlips to redeem SafeSlips with * Requirements: */ function redeemLendSlip(uint256 _lendSlipAmount) external; /** * @dev Transmits the the Reinitialization to the CBB * @param _lendOrBorrow boolean to indicate whether to initial deposit should be a 'borrow' or a 'lend' * Requirements: * - StagingBox must be the owner of the CBB to call this function * - Change owner of CBB to be the SB prior to calling this function if not already done */ function transmitReInit(bool _lendOrBorrow) external; /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) external; /** * @dev Transfers ownership of the CBB contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferCBBOwnership(address newOwner) external; }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.13; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "../src/interfaces/ISlip.sol"; import "@buttonwood-protocol/tranche/contracts/interfaces/IBondController.sol"; interface ICBBImmutableArgs { /** * @notice The bond that holds the tranches * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The underlying buttonwood bond */ function bond() external pure returns (IBondController); /** * @notice The safeSlip object * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The safeSlip Slip object */ function safeSlip() external pure returns (ISlip); /** * @notice The riskSlip object * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The riskSlip Slip object */ function riskSlip() external pure returns (ISlip); /** * @notice penalty for zslips * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The penalty ratio */ function penalty() external pure returns (uint256); /** * @notice The rebasing collateral token used to make bonds * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The rebasing collateral token object */ function collateralToken() external pure returns (IERC20); /** * @notice The stable token used to buy bonds * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The stable token object */ function stableToken() external pure returns (IERC20); /** * @notice The tranche index used to pick a safe tranche * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The index representing the tranche */ function trancheIndex() external pure returns (uint256); /** * @notice The maturity date of the underlying buttonwood bond * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The timestamp for the bond maturity */ function maturityDate() external pure returns (uint256); /** * @notice The safeTranche of the Convertible Bond Box * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The safeTranche tranche object */ function safeTranche() external pure returns (ITranche); /** * @notice The tranche ratio of the safeTranche * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The tranche ratio of the safeTranche */ function safeRatio() external pure returns (uint256); /** * @notice The riskTranche of the Convertible Bond Box * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The riskTranche tranche object */ function riskTranche() external pure returns (ITranche); /** * @notice The tranche ratio of the riskTranche * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The tranche ratio of the riskTranche */ function riskRatio() external pure returns (uint256); /** * @notice The decimals of tranche-tokens * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The decimals of tranche-tokens */ function trancheDecimals() external pure returns (uint256); /** * @notice The decimals of stable-tokens * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The decimals of stable-tokens */ function stableDecimals() external pure returns (uint256); }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.13; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "../src/interfaces/IConvertibleBondBox.sol"; interface ISBImmutableArgs { /** * @notice the lend slip object * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The lend slip object */ function lendSlip() external pure returns (ISlip); /** * @notice the borrow slip object * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The borrowSlip object */ function borrowSlip() external pure returns (ISlip); /** * @notice The convertible bond box object * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The convertible bond box object */ function convertibleBondBox() external pure returns (IConvertibleBondBox); /** * @notice The cnnvertible bond box object * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The convertible bond box object */ function initialPrice() external pure returns (uint256); /** * @notice The stable token used to buy bonds * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The stable token object */ function stableToken() external pure returns (IERC20); /** * @notice The safeTranche of the CBB * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The safeTranche object */ function safeTranche() external pure returns (ITranche); /** * @notice The address of the safeslip of the CBB * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The address of the safeslip of the CBB */ function safeSlipAddress() external pure returns (address); /** * @notice The tranche ratio of the safeTranche * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The tranche ratio of the safeTranche of the CBB */ function safeRatio() external pure returns (uint256); /** * @notice The riskTranche of the CBB * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The riskTranche tranche object */ function riskTranche() external pure returns (ITranche); /** * @notice The address of the riskSlip of the CBB * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The address of the riskSlip of the CBB */ function riskSlipAddress() external pure returns (address); /** * @notice The tranche ratio of the riskTranche * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The tranche ratio of the riskTranche of the CBB */ function riskRatio() external pure returns (uint256); /** * @notice The price granularity on the CBB * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The price granularity on the CBB */ function priceGranularity() external pure returns (uint256); /** * @notice The decimals of tranche-tokens * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The decimals of tranche-tokens */ function trancheDecimals() external pure returns (uint256); /** * @notice The decimals of stable-tokens * @dev using ClonesWithImmutableArgs pattern here to save gas * @dev https://github.com/wighawag/clones-with-immutable-args * @return The decimals of stable-tokens */ function stableDecimals() external pure returns (uint256); }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.13; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "clones-with-immutable-args/Clone.sol"; import "../src/interfaces/IConvertibleBondBox.sol"; import "./ISBImmutableArgs.sol"; /** * @notice Defines the immutable arguments for a CBB * @dev using the clones-with-immutable-args library * we fetch args from the code section */ contract SBImmutableArgs is Clone, ISBImmutableArgs { /** * @inheritdoc ISBImmutableArgs */ function lendSlip() public pure returns (ISlip) { return ISlip(_getArgAddress(0)); } /** * @inheritdoc ISBImmutableArgs */ function borrowSlip() public pure returns (ISlip) { return ISlip(_getArgAddress(20)); } /** * @inheritdoc ISBImmutableArgs */ function convertibleBondBox() public pure returns (IConvertibleBondBox) { return IConvertibleBondBox(_getArgAddress(40)); } /** * @inheritdoc ISBImmutableArgs */ function initialPrice() public pure returns (uint256) { return _getArgUint256(60); } /** * @inheritdoc ISBImmutableArgs */ function stableToken() public pure returns (IERC20) { return IERC20(_getArgAddress(92)); } /** * @inheritdoc ISBImmutableArgs */ function safeTranche() public pure returns (ITranche) { return ITranche(_getArgAddress(112)); } /** * @inheritdoc ISBImmutableArgs */ function safeSlipAddress() public pure returns (address) { return (_getArgAddress(132)); } /** * @inheritdoc ISBImmutableArgs */ function safeRatio() public pure returns (uint256) { return _getArgUint256(152); } /** * @inheritdoc ISBImmutableArgs */ function riskTranche() public pure returns (ITranche) { return ITranche(_getArgAddress(184)); } /** * @inheritdoc ISBImmutableArgs */ function riskSlipAddress() public pure returns (address) { return (_getArgAddress(204)); } /** * @inheritdoc ISBImmutableArgs */ function riskRatio() public pure returns (uint256) { return _getArgUint256(224); } /** * @inheritdoc ISBImmutableArgs */ function priceGranularity() public pure returns (uint256) { return _getArgUint256(256); } /** * @inheritdoc ISBImmutableArgs */ function trancheDecimals() public pure override returns (uint256) { return _getArgUint256(288); } /** * @inheritdoc ISBImmutableArgs */ function stableDecimals() public pure override returns (uint256) { return _getArgUint256(320); } }
{ "remappings": [ "@buttonwood-protocol/button-wrappers/=lib/button-wrappers/", "@buttonwood-protocol/tranche/=lib/tranche/", "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "@uniswap/lib/=lib/solidity-lib/", "button-wrappers/=lib/button-wrappers/contracts/", "clones-with-immutable-args/=lib/clones-with-immutable-args/src/", "ds-test/=lib/clones-with-immutable-args/lib/ds-test/src/", "forge-std/=lib/forge-std/src/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "solidity-lib/=lib/solidity-lib/contracts/", "solmate/=lib/solmate/src/", "tranche/=lib/tranche/contracts/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "bytecodeHash": "ipfs" }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "london", "libraries": {} }
[{"inputs":[{"internalType":"bool","name":"state","type":"bool"},{"internalType":"bool","name":"requiredState","type":"bool"}],"name":"CBBReinitialized","type":"error"},{"inputs":[{"internalType":"uint256","name":"given","type":"uint256"},{"internalType":"uint256","name":"maxPrice","type":"uint256"}],"name":"InitialPriceIsZero","type":"error"},{"inputs":[{"internalType":"uint256","name":"given","type":"uint256"},{"internalType":"uint256","name":"maxPrice","type":"uint256"}],"name":"InitialPriceTooHigh","type":"error"},{"inputs":[{"internalType":"uint256","name":"requestAmount","type":"uint256"},{"internalType":"uint256","name":"maxAmount","type":"uint256"}],"name":"WithdrawAmountTooHigh","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"safeTrancheAmount","type":"uint256"}],"name":"BorrowDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"borrowSlipAmount","type":"uint256"}],"name":"BorrowWithdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"lender","type":"address"},{"indexed":false,"internalType":"uint256","name":"lendAmount","type":"uint256"}],"name":"LendDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"lender","type":"address"},{"indexed":false,"internalType":"uint256","name":"lendSlipAmount","type":"uint256"}],"name":"LendWithdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"borrowSlipAmount","type":"uint256"}],"name":"RedeemBorrowSlip","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"lendSlipAmount","type":"uint256"}],"name":"RedeemLendSlip","type":"event"},{"inputs":[],"name":"borrowSlip","outputs":[{"internalType":"contract ISlip","name":"","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"convertibleBondBox","outputs":[{"internalType":"contract IConvertibleBondBox","name":"","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_borrower","type":"address"},{"internalType":"uint256","name":"_borrowAmount","type":"uint256"}],"name":"depositBorrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_lender","type":"address"},{"internalType":"uint256","name":"_lendAmount","type":"uint256"}],"name":"depositLend","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lendSlip","outputs":[{"internalType":"contract ISlip","name":"","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceGranularity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"_borrowSlipAmount","type":"uint256"}],"name":"redeemBorrowSlip","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lendSlipAmount","type":"uint256"}],"name":"redeemLendSlip","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"riskRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"riskSlipAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"riskTranche","outputs":[{"internalType":"contract ITranche","name":"","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"s_reinitLendAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"safeRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"safeSlipAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"safeTranche","outputs":[{"internalType":"contract ITranche","name":"","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"stableDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"stableToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"trancheDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferCBBOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_isLend","type":"bool"}],"name":"transmitReInit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_borrowSlipAmount","type":"uint256"}],"name":"withdrawBorrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lendSlipAmount","type":"uint256"}],"name":"withdrawLend","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50611ba1806100206000396000f3fe608060405234801561001057600080fd5b50600436106101a95760003560e01c80638da5cb5b116100f9578063c34b2a3511610097578063ea13e65311610071578063ea13e653146102f4578063edea9d6e146102fd578063f2fde38b14610305578063fa9bc0491461031857600080fd5b8063c34b2a35146102c6578063c4d66de8146102ce578063d293b9b9146102e157600080fd5b80639ef29d50116100d35780639ef29d501461029b578063a1eb27ff146102ae578063a9d75b2b146102b6578063b57f808a146102be57600080fd5b80638da5cb5b1461026f5780638eeb37bc14610280578063952cd3431461029357600080fd5b80633f8c59ee1161016657806359126926116101405780635912692614610239578063715018a61461024157806375dad54714610249578063796e86a71461025c57600080fd5b80633f8c59ee146102215780634f95d4a61461022957806351fd7d921461023157600080fd5b80631d0806ae146101ae5780632104d3fa146101c95780632acf68ed146101d15780632bad788d146101e65780633d13f81a146102065780633d9758261461020e575b600080fd5b6101b661032b565b6040519081526020015b60405180910390f35b6101b661033c565b6101e46101df366004611958565b610349565b005b6101ee610527565b6040516001600160a01b0390911681526020016101c0565b6101ee610533565b6101e461021c36600461198d565b61053f565b6101ee6107d9565b6101ee6107e5565b6101b66107f1565b6101b66107fd565b6101e4610809565b6101e461025736600461198d565b61081d565b6101e461026a3660046119b7565b610964565b6033546001600160a01b03166101ee565b6101e461028e366004611958565b6109d5565b6101ee610b6b565b6101e46102a9366004611958565b610b77565b6101b6610cc6565b6101ee610cd3565b6101ee610cdf565b6101ee610ceb565b6101e46102dc3660046119b7565b610cf7565b6101e46102ef3660046119e7565b610f2d565b6101b660655481565b6101b6611385565b6101e46103133660046119b7565b611392565b6101e4610326366004611958565b6113a6565b6000610337603c6115a5565b905090565b60006103376101406115a5565b610351610ceb565b6001600160a01b0316638cb59df66040518163ffffffff1660e01b8152600401602060405180830381865afa15801561038e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103b29190611a04565b1561046c5760006065546103c4610cd3565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa15801561040a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061042e9190611a04565b6104389190611a33565b90508082111561046a5760405163330b1fb360e01b815260048101839052602481018290526044015b60405180910390fd5b505b61047e610477610cd3565b33836115c7565b610486610cdf565b6001600160a01b0316639dc29fac33836040518363ffffffff1660e01b81526004016104b3929190611a4a565b600060405180830381600087803b1580156104cd57600080fd5b505af11580156104e1573d6000803e3d6000fd5b505050507f298bc5342d238ec139e76ee4f5ba76b563faaedb1d13e8d1fcd736500a78734961050d3390565b8260405161051c929190611a4a565b60405180910390a150565b600061033760846116f3565b600061033760b86116f3565b610547610ceb565b6001600160a01b0316638cb59df66040518163ffffffff1660e01b8152600401602060405180830381865afa158015610584573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a89190611a04565b156105cf57604051622dec7b60e81b81526001600482015260006024820152604401610461565b60006105d961033c565b6105e161032b565b6105e9610cc6565b6105f1611385565b6105fb9086611a63565b6106059190611a63565b61060f9190611a82565b6106199190611a82565b90506106236107e5565b6001600160a01b03166323b872dd3330846040518463ffffffff1660e01b815260040161065293929190611aa4565b6020604051808303816000875af1158015610671573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106959190611ac8565b5061069e610533565b6001600160a01b03166323b872dd33306106b66107fd565b6106be6107f1565b6106c89087611a63565b6106d29190611a82565b6040518463ffffffff1660e01b81526004016106f093929190611aa4565b6020604051808303816000875af115801561070f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107339190611ac8565b5061073c6107d9565b6001600160a01b03166340c10f1984846040518363ffffffff1660e01b8152600401610769929190611a4a565b600060405180830381600087803b15801561078357600080fd5b505af1158015610797573d6000803e3d6000fd5b505050507fe19c5d4769b3120371de492bfdd7591fb48e0acc5b1313daeb311a598a844a7883836040516107cc929190611a4a565b60405180910390a1505050565b600061033760146116f3565b600061033760706116f3565b600061033760e06115a5565b600061033760986115a5565b610811611718565b61081b6000611772565b565b610825610ceb565b6001600160a01b0316638cb59df66040518163ffffffff1660e01b8152600401602060405180830381865afa158015610862573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108869190611a04565b156108ad57604051622dec7b60e81b81526001600482015260006024820152604401610461565b6108c06108b8610cd3565b3330846117c4565b6108c8610cdf565b6001600160a01b03166340c10f1983836040518363ffffffff1660e01b81526004016108f5929190611a4a565b600060405180830381600087803b15801561090f57600080fd5b505af1158015610923573d6000803e3d6000fd5b505050507f73ab4c54ccf9ca174767856d696b48079332bf6730abe7dde98f14eb3ee17dc88282604051610958929190611a4a565b60405180910390a15050565b61096c611718565b610974610ceb565b60405163f2fde38b60e01b81526001600160a01b038381166004830152919091169063f2fde38b906024015b600060405180830381600087803b1580156109ba57600080fd5b505af11580156109ce573d6000803e3d6000fd5b5050505050565b80606560008282546109e79190611a33565b909155506109f59050610b6b565b6001600160a01b031663a9059cbb33610a0c61033c565b610a146107fd565b610a1c61032b565b610a24610cc6565b610a2c6107f1565b610a34611385565b610a3e908a611a63565b610a489190611a63565b610a529190611a63565b610a5c9190611a82565b610a669190611a82565b610a709190611a82565b6040518363ffffffff1660e01b8152600401610a8d929190611a4a565b6020604051808303816000875af1158015610aac573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad09190611ac8565b50610adc610477610cd3565b610ae46107d9565b6001600160a01b0316639dc29fac33836040518363ffffffff1660e01b8152600401610b11929190611a4a565b600060405180830381600087803b158015610b2b57600080fd5b505af1158015610b3f573d6000803e3d6000fd5b505050507ffe7765becca2d9000df418bbc2ef05f9026f5f7168a0a0dda2ac3d8204503a9961050d3390565b600061033760cc6116f3565b610b7f610527565b6001600160a01b031663a9059cbb33610b9661033c565b610b9e61032b565b610ba6610cc6565b610bae611385565b610bb89088611a63565b610bc29190611a63565b610bcc9190611a82565b610bd69190611a82565b6040518363ffffffff1660e01b8152600401610bf3929190611a4a565b6020604051808303816000875af1158015610c12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c369190611ac8565b50610c3f610cdf565b6001600160a01b0316639dc29fac33836040518363ffffffff1660e01b8152600401610c6c929190611a4a565b600060405180830381600087803b158015610c8657600080fd5b505af1158015610c9a573d6000803e3d6000fd5b505050507ff9316e4b01c5951bff533bb26191ba6eee68ee9e980b56a206b5c4c291b6a5d361050d3390565b60006103376101206115a5565b6000610337605c6116f3565b600061033760006116f3565b600061033760286116f3565b600054610100900460ff1615808015610d175750600054600160ff909116105b80610d315750303b158015610d31575060005460ff166001145b610d945760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610461565b6000805460ff191660011790558015610db7576000805461ff0019166101001790555b6001600160a01b038216610e175760405162461bcd60e51b815260206004820152602160248201527f53746167696e67426f783a20696e76616c6964206f776e6572206164647265736044820152607360f81b6064820152608401610461565b610e1f611385565b610e2761032b565b1115610e5f57610e3561032b565b610e3d611385565b604051631a5bb43560e01b815260048101929092526024820152604401610461565b610e6761032b565b600003610e9a576000610e78611385565b604051633176185360e01b815260048101929092526024820152604401610461565b610ea26118fe565b610eab82611392565b6040516001600160a01b03831681527f908408e307fc569b417f6cbec5d5a06f44a0a505ac0479b47d421a4b2fd6a1e69060200160405180910390a18015610f29576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001610958565b5050565b610f35611718565b610f3d6107e5565b6001600160a01b031663095ea7b3610f53610ceb565b6000196040518363ffffffff1660e01b8152600401610f73929190611a4a565b6020604051808303816000875af1158015610f92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb69190611ac8565b50610fbf610533565b6001600160a01b031663095ea7b3610fd5610ceb565b6000196040518363ffffffff1660e01b8152600401610ff5929190611a4a565b6020604051808303816000875af1158015611014573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110389190611ac8565b508015611197576000611049610cd3565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa15801561108f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110b39190611a04565b606581905590506110c2610ceb565b6001600160a01b031663ffb6c6b66110d861032b565b6040518263ffffffff1660e01b81526004016110f691815260200190565b600060405180830381600087803b15801561111057600080fd5b505af1158015611124573d6000803e3d6000fd5b50505050611130610ceb565b6001600160a01b03166305ec2d4d3030846040518463ffffffff1660e01b815260040161115f93929190611aa4565b600060405180830381600087803b15801561117957600080fd5b505af115801561118d573d6000803e3d6000fd5b5050505050611331565b60006111a16107e5565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa1580156111e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061120b9190611a04565b9050611215610cc6565b61121d611385565b61122561033c565b61122d61032b565b6112379085611a63565b6112419190611a63565b61124b9190611a82565b6112559190611a82565b606555611260610ceb565b6001600160a01b031663ffb6c6b661127661032b565b6040518263ffffffff1660e01b815260040161129491815260200190565b600060405180830381600087803b1580156112ae57600080fd5b505af11580156112c2573d6000803e3d6000fd5b505050506112ce610ceb565b6001600160a01b0316635224372c3030846040518463ffffffff1660e01b81526004016112fd93929190611aa4565b600060405180830381600087803b15801561131757600080fd5b505af115801561132b573d6000803e3d6000fd5b50505050505b611339610ceb565b6001600160a01b031663f2fde38b6113596033546001600160a01b031690565b6040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526024016109a0565b60006103376101006115a5565b61139a611718565b6113a381611772565b50565b60006113b061033c565b6113b861032b565b6113c0610cc6565b6113c8611385565b6113d29086611a63565b6113dc9190611a63565b6113e69190611a82565b6113f09190611a82565b90506113fa6107e5565b6001600160a01b031663a9059cbb33836040518363ffffffff1660e01b8152600401611427929190611a4a565b6020604051808303816000875af1158015611446573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061146a9190611ac8565b50611473610533565b6001600160a01b031663a9059cbb3361148a6107fd565b6114926107f1565b61149c9086611a63565b6114a69190611a82565b6040518363ffffffff1660e01b81526004016114c3929190611a4a565b6020604051808303816000875af11580156114e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115069190611ac8565b5061150f6107d9565b6001600160a01b0316639dc29fac33846040518363ffffffff1660e01b815260040161153c929190611a4a565b600060405180830381600087803b15801561155657600080fd5b505af115801561156a573d6000803e3d6000fd5b505050507fdc1460aa91a0426c19b0c031ff270bda61d39641f8f2e2da71fed382d755ded36115963390565b83604051610958929190611a4a565b6000806115bc600119368181013560f01c90030190565b929092013592915050565b600080846001600160a01b031663a9059cbb85856040516024016115ec929190611a4a565b6040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506040516116259190611ae5565b6000604051808303816000865af19150503d8060008114611662576040519150601f19603f3d011682016040523d82523d6000602084013e611667565b606091505b50915091508180156116915750805115806116915750808060200190518101906116919190611ac8565b6109ce5760405162461bcd60e51b815260206004820152602d60248201527f5472616e7366657248656c7065723a3a736166655472616e736665723a20747260448201526c185b9cd9995c8819985a5b1959609a1b6064820152608401610461565b60008061170a600119368181013560f01c90030190565b929092013560601c92915050565b6033546001600160a01b0316331461081b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610461565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600080856001600160a01b03166323b872dd8686866040516024016117eb93929190611aa4565b6040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506040516118249190611ae5565b6000604051808303816000865af19150503d8060008114611861576040519150601f19603f3d011682016040523d82523d6000602084013e611866565b606091505b50915091508180156118905750805115806118905750808060200190518101906118909190611ac8565b6118f65760405162461bcd60e51b815260206004820152603160248201527f5472616e7366657248656c7065723a3a7472616e7366657246726f6d3a207472604482015270185b9cd9995c919c9bdb4819985a5b1959607a1b6064820152608401610461565b505050505050565b600054610100900460ff166119255760405162461bcd60e51b815260040161046190611b20565b61081b600054610100900460ff1661194f5760405162461bcd60e51b815260040161046190611b20565b61081b33611772565b60006020828403121561196a57600080fd5b5035919050565b80356001600160a01b038116811461198857600080fd5b919050565b600080604083850312156119a057600080fd5b6119a983611971565b946020939093013593505050565b6000602082840312156119c957600080fd5b6119d282611971565b9392505050565b80151581146113a357600080fd5b6000602082840312156119f957600080fd5b81356119d2816119d9565b600060208284031215611a1657600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600082821015611a4557611a45611a1d565b500390565b6001600160a01b03929092168252602082015260400190565b6000816000190483118215151615611a7d57611a7d611a1d565b500290565b600082611a9f57634e487b7160e01b600052601260045260246000fd5b500490565b6001600160a01b039384168152919092166020820152604081019190915260600190565b600060208284031215611ada57600080fd5b81516119d2816119d9565b6000825160005b81811015611b065760208186018101518583015201611aec565b81811115611b15576000828501525b509190910192915050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fea2646970667358221220fedd009d03dd6decb5165d5e0f971598e734d8b5eff5397c25b0e2984bf4c35564736f6c634300080d0033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101a95760003560e01c80638da5cb5b116100f9578063c34b2a3511610097578063ea13e65311610071578063ea13e653146102f4578063edea9d6e146102fd578063f2fde38b14610305578063fa9bc0491461031857600080fd5b8063c34b2a35146102c6578063c4d66de8146102ce578063d293b9b9146102e157600080fd5b80639ef29d50116100d35780639ef29d501461029b578063a1eb27ff146102ae578063a9d75b2b146102b6578063b57f808a146102be57600080fd5b80638da5cb5b1461026f5780638eeb37bc14610280578063952cd3431461029357600080fd5b80633f8c59ee1161016657806359126926116101405780635912692614610239578063715018a61461024157806375dad54714610249578063796e86a71461025c57600080fd5b80633f8c59ee146102215780634f95d4a61461022957806351fd7d921461023157600080fd5b80631d0806ae146101ae5780632104d3fa146101c95780632acf68ed146101d15780632bad788d146101e65780633d13f81a146102065780633d9758261461020e575b600080fd5b6101b661032b565b6040519081526020015b60405180910390f35b6101b661033c565b6101e46101df366004611958565b610349565b005b6101ee610527565b6040516001600160a01b0390911681526020016101c0565b6101ee610533565b6101e461021c36600461198d565b61053f565b6101ee6107d9565b6101ee6107e5565b6101b66107f1565b6101b66107fd565b6101e4610809565b6101e461025736600461198d565b61081d565b6101e461026a3660046119b7565b610964565b6033546001600160a01b03166101ee565b6101e461028e366004611958565b6109d5565b6101ee610b6b565b6101e46102a9366004611958565b610b77565b6101b6610cc6565b6101ee610cd3565b6101ee610cdf565b6101ee610ceb565b6101e46102dc3660046119b7565b610cf7565b6101e46102ef3660046119e7565b610f2d565b6101b660655481565b6101b6611385565b6101e46103133660046119b7565b611392565b6101e4610326366004611958565b6113a6565b6000610337603c6115a5565b905090565b60006103376101406115a5565b610351610ceb565b6001600160a01b0316638cb59df66040518163ffffffff1660e01b8152600401602060405180830381865afa15801561038e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103b29190611a04565b1561046c5760006065546103c4610cd3565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa15801561040a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061042e9190611a04565b6104389190611a33565b90508082111561046a5760405163330b1fb360e01b815260048101839052602481018290526044015b60405180910390fd5b505b61047e610477610cd3565b33836115c7565b610486610cdf565b6001600160a01b0316639dc29fac33836040518363ffffffff1660e01b81526004016104b3929190611a4a565b600060405180830381600087803b1580156104cd57600080fd5b505af11580156104e1573d6000803e3d6000fd5b505050507f298bc5342d238ec139e76ee4f5ba76b563faaedb1d13e8d1fcd736500a78734961050d3390565b8260405161051c929190611a4a565b60405180910390a150565b600061033760846116f3565b600061033760b86116f3565b610547610ceb565b6001600160a01b0316638cb59df66040518163ffffffff1660e01b8152600401602060405180830381865afa158015610584573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a89190611a04565b156105cf57604051622dec7b60e81b81526001600482015260006024820152604401610461565b60006105d961033c565b6105e161032b565b6105e9610cc6565b6105f1611385565b6105fb9086611a63565b6106059190611a63565b61060f9190611a82565b6106199190611a82565b90506106236107e5565b6001600160a01b03166323b872dd3330846040518463ffffffff1660e01b815260040161065293929190611aa4565b6020604051808303816000875af1158015610671573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106959190611ac8565b5061069e610533565b6001600160a01b03166323b872dd33306106b66107fd565b6106be6107f1565b6106c89087611a63565b6106d29190611a82565b6040518463ffffffff1660e01b81526004016106f093929190611aa4565b6020604051808303816000875af115801561070f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107339190611ac8565b5061073c6107d9565b6001600160a01b03166340c10f1984846040518363ffffffff1660e01b8152600401610769929190611a4a565b600060405180830381600087803b15801561078357600080fd5b505af1158015610797573d6000803e3d6000fd5b505050507fe19c5d4769b3120371de492bfdd7591fb48e0acc5b1313daeb311a598a844a7883836040516107cc929190611a4a565b60405180910390a1505050565b600061033760146116f3565b600061033760706116f3565b600061033760e06115a5565b600061033760986115a5565b610811611718565b61081b6000611772565b565b610825610ceb565b6001600160a01b0316638cb59df66040518163ffffffff1660e01b8152600401602060405180830381865afa158015610862573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108869190611a04565b156108ad57604051622dec7b60e81b81526001600482015260006024820152604401610461565b6108c06108b8610cd3565b3330846117c4565b6108c8610cdf565b6001600160a01b03166340c10f1983836040518363ffffffff1660e01b81526004016108f5929190611a4a565b600060405180830381600087803b15801561090f57600080fd5b505af1158015610923573d6000803e3d6000fd5b505050507f73ab4c54ccf9ca174767856d696b48079332bf6730abe7dde98f14eb3ee17dc88282604051610958929190611a4a565b60405180910390a15050565b61096c611718565b610974610ceb565b60405163f2fde38b60e01b81526001600160a01b038381166004830152919091169063f2fde38b906024015b600060405180830381600087803b1580156109ba57600080fd5b505af11580156109ce573d6000803e3d6000fd5b5050505050565b80606560008282546109e79190611a33565b909155506109f59050610b6b565b6001600160a01b031663a9059cbb33610a0c61033c565b610a146107fd565b610a1c61032b565b610a24610cc6565b610a2c6107f1565b610a34611385565b610a3e908a611a63565b610a489190611a63565b610a529190611a63565b610a5c9190611a82565b610a669190611a82565b610a709190611a82565b6040518363ffffffff1660e01b8152600401610a8d929190611a4a565b6020604051808303816000875af1158015610aac573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad09190611ac8565b50610adc610477610cd3565b610ae46107d9565b6001600160a01b0316639dc29fac33836040518363ffffffff1660e01b8152600401610b11929190611a4a565b600060405180830381600087803b158015610b2b57600080fd5b505af1158015610b3f573d6000803e3d6000fd5b505050507ffe7765becca2d9000df418bbc2ef05f9026f5f7168a0a0dda2ac3d8204503a9961050d3390565b600061033760cc6116f3565b610b7f610527565b6001600160a01b031663a9059cbb33610b9661033c565b610b9e61032b565b610ba6610cc6565b610bae611385565b610bb89088611a63565b610bc29190611a63565b610bcc9190611a82565b610bd69190611a82565b6040518363ffffffff1660e01b8152600401610bf3929190611a4a565b6020604051808303816000875af1158015610c12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c369190611ac8565b50610c3f610cdf565b6001600160a01b0316639dc29fac33836040518363ffffffff1660e01b8152600401610c6c929190611a4a565b600060405180830381600087803b158015610c8657600080fd5b505af1158015610c9a573d6000803e3d6000fd5b505050507ff9316e4b01c5951bff533bb26191ba6eee68ee9e980b56a206b5c4c291b6a5d361050d3390565b60006103376101206115a5565b6000610337605c6116f3565b600061033760006116f3565b600061033760286116f3565b600054610100900460ff1615808015610d175750600054600160ff909116105b80610d315750303b158015610d31575060005460ff166001145b610d945760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610461565b6000805460ff191660011790558015610db7576000805461ff0019166101001790555b6001600160a01b038216610e175760405162461bcd60e51b815260206004820152602160248201527f53746167696e67426f783a20696e76616c6964206f776e6572206164647265736044820152607360f81b6064820152608401610461565b610e1f611385565b610e2761032b565b1115610e5f57610e3561032b565b610e3d611385565b604051631a5bb43560e01b815260048101929092526024820152604401610461565b610e6761032b565b600003610e9a576000610e78611385565b604051633176185360e01b815260048101929092526024820152604401610461565b610ea26118fe565b610eab82611392565b6040516001600160a01b03831681527f908408e307fc569b417f6cbec5d5a06f44a0a505ac0479b47d421a4b2fd6a1e69060200160405180910390a18015610f29576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001610958565b5050565b610f35611718565b610f3d6107e5565b6001600160a01b031663095ea7b3610f53610ceb565b6000196040518363ffffffff1660e01b8152600401610f73929190611a4a565b6020604051808303816000875af1158015610f92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb69190611ac8565b50610fbf610533565b6001600160a01b031663095ea7b3610fd5610ceb565b6000196040518363ffffffff1660e01b8152600401610ff5929190611a4a565b6020604051808303816000875af1158015611014573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110389190611ac8565b508015611197576000611049610cd3565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa15801561108f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110b39190611a04565b606581905590506110c2610ceb565b6001600160a01b031663ffb6c6b66110d861032b565b6040518263ffffffff1660e01b81526004016110f691815260200190565b600060405180830381600087803b15801561111057600080fd5b505af1158015611124573d6000803e3d6000fd5b50505050611130610ceb565b6001600160a01b03166305ec2d4d3030846040518463ffffffff1660e01b815260040161115f93929190611aa4565b600060405180830381600087803b15801561117957600080fd5b505af115801561118d573d6000803e3d6000fd5b5050505050611331565b60006111a16107e5565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa1580156111e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061120b9190611a04565b9050611215610cc6565b61121d611385565b61122561033c565b61122d61032b565b6112379085611a63565b6112419190611a63565b61124b9190611a82565b6112559190611a82565b606555611260610ceb565b6001600160a01b031663ffb6c6b661127661032b565b6040518263ffffffff1660e01b815260040161129491815260200190565b600060405180830381600087803b1580156112ae57600080fd5b505af11580156112c2573d6000803e3d6000fd5b505050506112ce610ceb565b6001600160a01b0316635224372c3030846040518463ffffffff1660e01b81526004016112fd93929190611aa4565b600060405180830381600087803b15801561131757600080fd5b505af115801561132b573d6000803e3d6000fd5b50505050505b611339610ceb565b6001600160a01b031663f2fde38b6113596033546001600160a01b031690565b6040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526024016109a0565b60006103376101006115a5565b61139a611718565b6113a381611772565b50565b60006113b061033c565b6113b861032b565b6113c0610cc6565b6113c8611385565b6113d29086611a63565b6113dc9190611a63565b6113e69190611a82565b6113f09190611a82565b90506113fa6107e5565b6001600160a01b031663a9059cbb33836040518363ffffffff1660e01b8152600401611427929190611a4a565b6020604051808303816000875af1158015611446573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061146a9190611ac8565b50611473610533565b6001600160a01b031663a9059cbb3361148a6107fd565b6114926107f1565b61149c9086611a63565b6114a69190611a82565b6040518363ffffffff1660e01b81526004016114c3929190611a4a565b6020604051808303816000875af11580156114e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115069190611ac8565b5061150f6107d9565b6001600160a01b0316639dc29fac33846040518363ffffffff1660e01b815260040161153c929190611a4a565b600060405180830381600087803b15801561155657600080fd5b505af115801561156a573d6000803e3d6000fd5b505050507fdc1460aa91a0426c19b0c031ff270bda61d39641f8f2e2da71fed382d755ded36115963390565b83604051610958929190611a4a565b6000806115bc600119368181013560f01c90030190565b929092013592915050565b600080846001600160a01b031663a9059cbb85856040516024016115ec929190611a4a565b6040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506040516116259190611ae5565b6000604051808303816000865af19150503d8060008114611662576040519150601f19603f3d011682016040523d82523d6000602084013e611667565b606091505b50915091508180156116915750805115806116915750808060200190518101906116919190611ac8565b6109ce5760405162461bcd60e51b815260206004820152602d60248201527f5472616e7366657248656c7065723a3a736166655472616e736665723a20747260448201526c185b9cd9995c8819985a5b1959609a1b6064820152608401610461565b60008061170a600119368181013560f01c90030190565b929092013560601c92915050565b6033546001600160a01b0316331461081b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610461565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600080856001600160a01b03166323b872dd8686866040516024016117eb93929190611aa4565b6040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506040516118249190611ae5565b6000604051808303816000865af19150503d8060008114611861576040519150601f19603f3d011682016040523d82523d6000602084013e611866565b606091505b50915091508180156118905750805115806118905750808060200190518101906118909190611ac8565b6118f65760405162461bcd60e51b815260206004820152603160248201527f5472616e7366657248656c7065723a3a7472616e7366657246726f6d3a207472604482015270185b9cd9995c919c9bdb4819985a5b1959607a1b6064820152608401610461565b505050505050565b600054610100900460ff166119255760405162461bcd60e51b815260040161046190611b20565b61081b600054610100900460ff1661194f5760405162461bcd60e51b815260040161046190611b20565b61081b33611772565b60006020828403121561196a57600080fd5b5035919050565b80356001600160a01b038116811461198857600080fd5b919050565b600080604083850312156119a057600080fd5b6119a983611971565b946020939093013593505050565b6000602082840312156119c957600080fd5b6119d282611971565b9392505050565b80151581146113a357600080fd5b6000602082840312156119f957600080fd5b81356119d2816119d9565b600060208284031215611a1657600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600082821015611a4557611a45611a1d565b500390565b6001600160a01b03929092168252602082015260400190565b6000816000190483118215151615611a7d57611a7d611a1d565b500290565b600082611a9f57634e487b7160e01b600052601260045260246000fd5b500490565b6001600160a01b039384168152919092166020820152604081019190915260600190565b600060208284031215611ada57600080fd5b81516119d2816119d9565b6000825160005b81811015611b065760208186018101518583015201611aec565b81811115611b15576000828501525b509190910192915050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fea2646970667358221220fedd009d03dd6decb5165d5e0f971598e734d8b5eff5397c25b0e2984bf4c35564736f6c634300080d0033
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.