Overview
ETH Balance
0 ETH
Eth Value
$0.00Token Holdings
Latest 25 from a total of 28 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Rebalance | 18517841 | 374 days ago | IN | 0 ETH | 0.00637611 | ||||
Rebalance | 18391187 | 392 days ago | IN | 0 ETH | 0.00341818 | ||||
Rebalance | 18347957 | 398 days ago | IN | 0 ETH | 0.00175716 | ||||
Rebalance | 18293201 | 406 days ago | IN | 0 ETH | 0.00331967 | ||||
Rebalance | 18266246 | 410 days ago | IN | 0 ETH | 0.00313679 | ||||
Rebalance | 18044631 | 441 days ago | IN | 0 ETH | 0.00408746 | ||||
Rebalance | 17711304 | 487 days ago | IN | 0 ETH | 0.00429928 | ||||
Rebalance | 17521459 | 514 days ago | IN | 0 ETH | 0.00600655 | ||||
Rebalance | 17506390 | 516 days ago | IN | 0 ETH | 0.00073127 | ||||
Rebalance | 17506390 | 516 days ago | IN | 0 ETH | 0.00410098 | ||||
Rebalance | 17502595 | 517 days ago | IN | 0 ETH | 0.0040286 | ||||
Rebalance | 17481524 | 520 days ago | IN | 0 ETH | 0.0051344 | ||||
Rebalance | 17186957 | 561 days ago | IN | 0 ETH | 0.01911813 | ||||
Rebalance | 17060753 | 579 days ago | IN | 0 ETH | 0.00759088 | ||||
Rebalance | 17019317 | 585 days ago | IN | 0 ETH | 0.00925087 | ||||
Rebalance | 16949592 | 595 days ago | IN | 0 ETH | 0.00806623 | ||||
Rebalance | 16949575 | 595 days ago | IN | 0 ETH | 0.00699527 | ||||
Rebalance | 16949518 | 595 days ago | IN | 0 ETH | 0.01046464 | ||||
Rebalance | 16856274 | 608 days ago | IN | 0 ETH | 0.00469502 | ||||
Rebalance | 16803170 | 615 days ago | IN | 0 ETH | 0.07610155 | ||||
Wrap | 16750709 | 623 days ago | IN | 0 ETH | 0.00252016 | ||||
Rebalance | 16736051 | 625 days ago | IN | 0 ETH | 0.01131009 | ||||
Rebalance | 16581062 | 647 days ago | IN | 0 ETH | 0.00896997 | ||||
Rebalance | 16474127 | 662 days ago | IN | 0 ETH | 0.00406332 | ||||
Rebalance | 16473942 | 662 days ago | IN | 0 ETH | 0.00602565 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
TwoWayBatcher
Compiler Version
v0.8.17+commit.8df45f5f
Contract Source Code (Solidity Standard Json-Input format)
//SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.17; import "@equilibria/root/number/types/UFixed18.sol"; import "@equilibria/root/token/types/Token18.sol"; import "@equilibria/root/token/types/Token6.sol"; import "@equilibria/root/control/unstructured/UReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "../interfaces/ITwoWayBatcher.sol"; import "./Batcher.sol"; contract TwoWayBatcher is ITwoWayBatcher, UReentrancyGuard, Batcher, ERC20 { /** * @notice Initializes the TwoWayBatcher * @dev Called at implementation instantiate and constant for that implementation. * @param reserve EmptySet Reserve Aaddress * @param dsu DSU Token address * @param usdc USDC Token Address */ constructor(IEmptySetReserve reserve, Token18 dsu, Token6 usdc) Batcher(reserve, dsu, usdc) ERC20("Batcher Deposit", "BDEP") { __UReentrancyGuard__initialize(); } /** * @notice Deposits USDC for Batcher to use in unwrapping flows * @dev Reverts if `amount` has greater precision than 6 decimals * @param amount Amount of USDC to deposit */ function deposit(UFixed18 amount) external nonReentrant { if (!_validToken6Amount(amount)) revert TwoWayBatcherInvalidTokenAmount(amount); rebalance(); USDC.pull(msg.sender, amount, true); _mint(msg.sender, UFixed18.unwrap(amount)); emit Deposit(msg.sender, amount); } /** * @notice Withdraws USDC from Batcher * @dev Reverts if `amount` has greater precision than 6 decimals * @param amount Amount of USDC to withdraw */ function withdraw(UFixed18 amount) external nonReentrant { if (!_validToken6Amount(amount)) revert TwoWayBatcherInvalidTokenAmount(amount); rebalance(); _burn(msg.sender, UFixed18.unwrap(amount)); USDC.push(msg.sender, amount); emit Withdraw(msg.sender, amount); } /** * @notice Rebalances the Batcher to maintain a target balance of USDC and DSU * @dev Maintains a USDC balance of outstanding deposits. Excess USDC is minted as DSU * @param usdcBalance Current Batcher USDC balance */ function _rebalance(UFixed18 usdcBalance, UFixed18) override internal { UFixed18 totalDeposits = UFixed18.wrap(totalSupply()); uint256 balanceToTarget = usdcBalance.compare(totalDeposits); // totalDeposits == usdcBalance: Do nothing if (balanceToTarget == 1) return; // usdcBalance > totalDeposits: deposit excess USDC if (balanceToTarget == 2) return RESERVE.mint(usdcBalance.sub(totalDeposits)); // usdcBalance < totalDeposits: pull out more USDC so we have enough to cover deposits if (balanceToTarget == 0) return RESERVE.redeem(totalDeposits.sub(usdcBalance)); } /** * @notice Performs actions required to close the Batcher */ function _close() override internal { rebalance(); } /** * @notice Checks if the `amount` has a maximum precision of 6 decimals * @return true if the `amount` has a precision of 6 or less, otherwise false */ function _validToken6Amount(UFixed18 amount) internal pure returns (bool) { return UFixed18.unwrap(amount) % 1e12 == 0; } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.13; import "@openzeppelin/contracts/utils/Address.sol"; import "../../storage/UStorage.sol"; /** * @title UInitializable * @notice Library to manage the initialization lifecycle of upgradeable contracts * @dev `UInitializable` allows the creation of pseudo-constructors for upgradeable contracts. One * `initializer` should be declared per top-level contract. Child contracts can use the `onlyInitializer` * modifier to tag their internal initialization functions to ensure that they can only be called * from a top-level `initializer` or a constructor. */ abstract contract UInitializable { error UInitializableZeroVersionError(); error UInitializableAlreadyInitializedError(uint256 version); error UInitializableNotInitializingError(); /// @dev The initialized flag Uint256Storage private constant _version = Uint256Storage.wrap(keccak256("equilibria.root.UInitializable.version")); /// @dev The initializing flag BoolStorage private constant _initializing = BoolStorage.wrap(keccak256("equilibria.root.UInitializable.initializing")); /// @dev Can only be called once per version, `version` is 1-indexed modifier initializer(uint256 version) { if (version == 0) revert UInitializableZeroVersionError(); if (_version.read() >= version) revert UInitializableAlreadyInitializedError(version); _version.store(version); _initializing.store(true); _; _initializing.store(false); } /// @dev Can only be called from an initializer or constructor modifier onlyInitializer() { if (!_constructing() && !_initializing.read()) revert UInitializableNotInitializingError(); _; } /** * @notice Returns whether the contract is currently being constructed * @dev {Address.isContract} returns false for contracts currently in the process of being constructed * @return Whether the contract is currently being constructed */ function _constructing() private view returns (bool) { return !Address.isContract(address(this)); } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.13; import "./UInitializable.sol"; import "../../storage/UStorage.sol"; /** * @title UOwnable * @notice Library to manage the ownership lifecycle of upgradeable contracts. * @dev This contract has been extended from the Open Zeppelin library to include an * unstructured storage pattern so that it can be safely mixed in with upgradeable * contracts without affecting their storage patterns through inheritance. */ abstract contract UOwnable is UInitializable { event OwnerUpdated(address indexed newOwner); event PendingOwnerUpdated(address indexed newPendingOwner); error UOwnableNotOwnerError(address sender); error UOwnableNotPendingOwnerError(address sender); /// @dev The owner address AddressStorage private constant _owner = AddressStorage.wrap(keccak256("equilibria.root.UOwnable.owner")); function owner() public view returns (address) { return _owner.read(); } /// @dev The pending owner address AddressStorage private constant _pendingOwner = AddressStorage.wrap(keccak256("equilibria.root.UOwnable.pendingOwner")); function pendingOwner() public view returns (address) { return _pendingOwner.read(); } /** * @notice Initializes the contract setting `msg.sender` as the initial owner */ function __UOwnable__initialize() internal onlyInitializer { _updateOwner(msg.sender); } /** * @notice Updates the new pending owner * @dev Can only be called by the current owner * New owner does not take affect until that address calls `acceptOwner()` * @param newPendingOwner New pending owner address */ function updatePendingOwner(address newPendingOwner) public onlyOwner { _pendingOwner.store(newPendingOwner); emit PendingOwnerUpdated(newPendingOwner); } /** * @notice Accepts and transfers the ownership of the contract to the pending owner * @dev Can only be called by the pending owner to ensure correctness */ function acceptOwner() external { if (msg.sender != pendingOwner()) revert UOwnableNotPendingOwnerError(msg.sender); _updateOwner(pendingOwner()); updatePendingOwner(address(0)); } /** * @notice Updates the owner address * @param newOwner New owner address */ function _updateOwner(address newOwner) private { _owner.store(newOwner); emit OwnerUpdated(newOwner); } /// @dev Throws if called by any account other than the owner modifier onlyOwner() { if (owner() != msg.sender) revert UOwnableNotOwnerError(msg.sender); _; } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.13; import "./UInitializable.sol"; import "../../storage/UStorage.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. * * NOTE: This contract has been extended from the Open Zeppelin library to include an * unstructured storage pattern, so that it can be safely mixed in with upgradeable * contracts without affecting their storage patterns through inheritance. */ abstract contract UReentrancyGuard is UInitializable { error UReentrancyGuardReentrantCallError(); uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; /** * @dev unstructured storage slot for the reentrancy status */ Uint256Storage private constant _status = Uint256Storage.wrap(keccak256("equilibria.root.UReentrancyGuard.status")); /** * @dev Initializes the contract setting the status to _NOT_ENTERED. */ function __UReentrancyGuard__initialize() internal onlyInitializer { _status.store(_NOT_ENTERED); } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true if (_status.read() == _ENTERED) revert UReentrancyGuardReentrantCallError(); // Any calls to nonReentrant after this point will fail _status.store(_ENTERED); _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status.store(_NOT_ENTERED); } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.13; import "@openzeppelin/contracts/utils/math/SignedMath.sol"; import "./UFixed18.sol"; import "./PackedFixed18.sol"; /// @dev Fixed18 type type Fixed18 is int256; using Fixed18Lib for Fixed18 global; type Fixed18Storage is bytes32; using Fixed18StorageLib for Fixed18Storage global; /** * @title Fixed18Lib * @notice Library for the signed fixed-decimal type. */ library Fixed18Lib { error Fixed18OverflowError(uint256 value); error Fixed18PackingOverflowError(int256 value); error Fixed18PackingUnderflowError(int256 value); int256 private constant BASE = 1e18; Fixed18 public constant ZERO = Fixed18.wrap(0); Fixed18 public constant ONE = Fixed18.wrap(BASE); Fixed18 public constant NEG_ONE = Fixed18.wrap(-1 * BASE); Fixed18 public constant MAX = Fixed18.wrap(type(int256).max); Fixed18 public constant MIN = Fixed18.wrap(type(int256).min); /** * @notice Creates a signed fixed-decimal from an unsigned fixed-decimal * @param a Unsigned fixed-decimal * @return New signed fixed-decimal */ function from(UFixed18 a) internal pure returns (Fixed18) { uint256 value = UFixed18.unwrap(a); if (value > uint256(type(int256).max)) revert Fixed18OverflowError(value); return Fixed18.wrap(int256(value)); } /** * @notice Creates a signed fixed-decimal from a sign and an unsigned fixed-decimal * @param s Sign * @param m Unsigned fixed-decimal magnitude * @return New signed fixed-decimal */ function from(int256 s, UFixed18 m) internal pure returns (Fixed18) { if (s > 0) return from(m); if (s < 0) return Fixed18.wrap(-1 * Fixed18.unwrap(from(m))); return ZERO; } /** * @notice Creates a signed fixed-decimal from a signed integer * @param a Signed number * @return New signed fixed-decimal */ function from(int256 a) internal pure returns (Fixed18) { return Fixed18.wrap(a * BASE); } /** * @notice Creates a packed signed fixed-decimal from an signed fixed-decimal * @param a signed fixed-decimal * @return New packed signed fixed-decimal */ function pack(Fixed18 a) internal pure returns (PackedFixed18) { int256 value = Fixed18.unwrap(a); if (value > type(int128).max) revert Fixed18PackingOverflowError(value); if (value < type(int128).min) revert Fixed18PackingUnderflowError(value); return PackedFixed18.wrap(int128(value)); } /** * @notice Returns whether the signed fixed-decimal is equal to zero. * @param a Signed fixed-decimal * @return Whether the signed fixed-decimal is zero. */ function isZero(Fixed18 a) internal pure returns (bool) { return Fixed18.unwrap(a) == 0; } /** * @notice Adds two signed fixed-decimals `a` and `b` together * @param a First signed fixed-decimal * @param b Second signed fixed-decimal * @return Resulting summed signed fixed-decimal */ function add(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) { return Fixed18.wrap(Fixed18.unwrap(a) + Fixed18.unwrap(b)); } /** * @notice Subtracts signed fixed-decimal `b` from `a` * @param a Signed fixed-decimal to subtract from * @param b Signed fixed-decimal to subtract * @return Resulting subtracted signed fixed-decimal */ function sub(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) { return Fixed18.wrap(Fixed18.unwrap(a) - Fixed18.unwrap(b)); } /** * @notice Multiplies two signed fixed-decimals `a` and `b` together * @param a First signed fixed-decimal * @param b Second signed fixed-decimal * @return Resulting multiplied signed fixed-decimal */ function mul(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) { return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / BASE); } /** * @notice Divides signed fixed-decimal `a` by `b` * @param a Signed fixed-decimal to divide * @param b Signed fixed-decimal to divide by * @return Resulting divided signed fixed-decimal */ function div(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) { return Fixed18.wrap(Fixed18.unwrap(a) * BASE / Fixed18.unwrap(b)); } /** * @notice Divides unsigned fixed-decimal `a` by `b` * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0`, `MAX` for `n/0`, and `MIN` for `-n/0`. * @param a Unsigned fixed-decimal to divide * @param b Unsigned fixed-decimal to divide by * @return Resulting divided unsigned fixed-decimal */ function unsafeDiv(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) { if (isZero(b)) { if (gt(a, ZERO)) return MAX; if (lt(a, ZERO)) return MIN; return ONE; } else { return div(a, b); } } /** * @notice Computes a * b / c without loss of precision due to BASE conversion * @param a First signed fixed-decimal * @param b Signed number to multiply by * @param c Signed number to divide by * @return Resulting computation */ function muldiv(Fixed18 a, int256 b, int256 c) internal pure returns (Fixed18) { return muldiv(a, Fixed18.wrap(b), Fixed18.wrap(c)); } /** * @notice Computes a * b / c without loss of precision due to BASE conversion * @param a First signed fixed-decimal * @param b Signed fixed-decimal to multiply by * @param c Signed fixed-decimal to divide by * @return Resulting computation */ function muldiv(Fixed18 a, Fixed18 b, Fixed18 c) internal pure returns (Fixed18) { return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / Fixed18.unwrap(c)); } /** * @notice Returns whether signed fixed-decimal `a` is equal to `b` * @param a First signed fixed-decimal * @param b Second signed fixed-decimal * @return Whether `a` is equal to `b` */ function eq(Fixed18 a, Fixed18 b) internal pure returns (bool) { return compare(a, b) == 1; } /** * @notice Returns whether signed fixed-decimal `a` is greater than `b` * @param a First signed fixed-decimal * @param b Second signed fixed-decimal * @return Whether `a` is greater than `b` */ function gt(Fixed18 a, Fixed18 b) internal pure returns (bool) { return compare(a, b) == 2; } /** * @notice Returns whether signed fixed-decimal `a` is less than `b` * @param a First signed fixed-decimal * @param b Second signed fixed-decimal * @return Whether `a` is less than `b` */ function lt(Fixed18 a, Fixed18 b) internal pure returns (bool) { return compare(a, b) == 0; } /** * @notice Returns whether signed fixed-decimal `a` is greater than or equal to `b` * @param a First signed fixed-decimal * @param b Second signed fixed-decimal * @return Whether `a` is greater than or equal to `b` */ function gte(Fixed18 a, Fixed18 b) internal pure returns (bool) { return gt(a, b) || eq(a, b); } /** * @notice Returns whether signed fixed-decimal `a` is less than or equal to `b` * @param a First signed fixed-decimal * @param b Second signed fixed-decimal * @return Whether `a` is less than or equal to `b` */ function lte(Fixed18 a, Fixed18 b) internal pure returns (bool) { return lt(a, b) || eq(a, b); } /** * @notice Compares the signed fixed-decimals `a` and `b` * @dev Returns: 2 for greater than * 1 for equal to * 0 for less than * @param a First signed fixed-decimal * @param b Second signed fixed-decimal * @return Compare result of `a` and `b` */ function compare(Fixed18 a, Fixed18 b) internal pure returns (uint256) { (int256 au, int256 bu) = (Fixed18.unwrap(a), Fixed18.unwrap(b)); if (au > bu) return 2; if (au < bu) return 0; return 1; } /** * @notice Returns a signed fixed-decimal representing the ratio of `a` over `b` * @param a First signed number * @param b Second signed number * @return Ratio of `a` over `b` */ function ratio(int256 a, int256 b) internal pure returns (Fixed18) { return Fixed18.wrap(a * BASE / b); } /** * @notice Returns the minimum of signed fixed-decimals `a` and `b` * @param a First signed fixed-decimal * @param b Second signed fixed-decimal * @return Minimum of `a` and `b` */ function min(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) { return Fixed18.wrap(SignedMath.min(Fixed18.unwrap(a), Fixed18.unwrap(b))); } /** * @notice Returns the maximum of signed fixed-decimals `a` and `b` * @param a First signed fixed-decimal * @param b Second signed fixed-decimal * @return Maximum of `a` and `b` */ function max(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) { return Fixed18.wrap(SignedMath.max(Fixed18.unwrap(a), Fixed18.unwrap(b))); } /** * @notice Converts the signed fixed-decimal into an integer, truncating any decimal portion * @param a Signed fixed-decimal * @return Truncated signed number */ function truncate(Fixed18 a) internal pure returns (int256) { return Fixed18.unwrap(a) / BASE; } /** * @notice Returns the sign of the signed fixed-decimal * @dev Returns: -1 for negative * 0 for zero * 1 for positive * @param a Signed fixed-decimal * @return Sign of the signed fixed-decimal */ function sign(Fixed18 a) internal pure returns (int256) { if (Fixed18.unwrap(a) > 0) return 1; if (Fixed18.unwrap(a) < 0) return -1; return 0; } /** * @notice Returns the absolute value of the signed fixed-decimal * @param a Signed fixed-decimal * @return Absolute value of the signed fixed-decimal */ function abs(Fixed18 a) internal pure returns (UFixed18) { return UFixed18.wrap(SignedMath.abs(Fixed18.unwrap(a))); } } library Fixed18StorageLib { function read(Fixed18Storage self) internal view returns (Fixed18 value) { assembly { value := sload(self) } } function store(Fixed18Storage self, Fixed18 value) internal { assembly { sstore(self, value) } } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.13; import "./Fixed18.sol"; /// @dev PackedFixed18 type type PackedFixed18 is int128; using PackedFixed18Lib for PackedFixed18 global; /** * @title PackedFixed18Lib * @dev A packed version of the Fixed18 which takes up half the storage space (two PackedFixed18 can be packed * into a single slot). Only valid within the range -1.7014118e+20 <= x <= 1.7014118e+20. * @notice Library for the packed signed fixed-decimal type. */ library PackedFixed18Lib { PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max); PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min); /** * @notice Creates a signed fixed-decimal from a sign and an unsigned fixed-decimal * @param self Sign * @return New signed fixed-decimal */ function unpack(PackedFixed18 self) internal pure returns (Fixed18) { return Fixed18.wrap(int256(PackedFixed18.unwrap(self))); } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.13; import "./UFixed18.sol"; /// @dev PackedUFixed18 type type PackedUFixed18 is uint128; using PackedUFixed18Lib for PackedUFixed18 global; /** * @title PackedUFixed18Lib * @dev A packed version of the UFixed18 which takes up half the storage space (two PackedUFixed18 can be packed * into a single slot). Only valid within the range 0 <= x <= 3.4028237e+20. * @notice Library for the packed unsigned fixed-decimal type. */ library PackedUFixed18Lib { PackedUFixed18 public constant MAX = PackedUFixed18.wrap(type(uint128).max); /** * @notice Creates a signed fixed-decimal from a sign and an unsigned fixed-decimal * @param self Sign * @return New signed fixed-decimal */ function unpack(PackedUFixed18 self) internal pure returns (UFixed18) { return UFixed18.wrap(uint256(PackedUFixed18.unwrap(self))); } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.13; import "@openzeppelin/contracts/utils/math/Math.sol"; import "./Fixed18.sol"; import "./PackedUFixed18.sol"; /// @dev UFixed18 type type UFixed18 is uint256; using UFixed18Lib for UFixed18 global; type UFixed18Storage is bytes32; using UFixed18StorageLib for UFixed18Storage global; /** * @title UFixed18Lib * @notice Library for the unsigned fixed-decimal type. */ library UFixed18Lib { error UFixed18UnderflowError(int256 value); error UFixed18PackingOverflowError(uint256 value); uint256 private constant BASE = 1e18; UFixed18 public constant ZERO = UFixed18.wrap(0); UFixed18 public constant ONE = UFixed18.wrap(BASE); UFixed18 public constant MAX = UFixed18.wrap(type(uint256).max); /** * @notice Creates a unsigned fixed-decimal from a signed fixed-decimal * @param a Signed fixed-decimal * @return New unsigned fixed-decimal */ function from(Fixed18 a) internal pure returns (UFixed18) { int256 value = Fixed18.unwrap(a); if (value < 0) revert UFixed18UnderflowError(value); return UFixed18.wrap(uint256(value)); } /** * @notice Creates a unsigned fixed-decimal from a unsigned integer * @param a Unsigned number * @return New unsigned fixed-decimal */ function from(uint256 a) internal pure returns (UFixed18) { return UFixed18.wrap(a * BASE); } /** * @notice Creates a packed unsigned fixed-decimal from an unsigned fixed-decimal * @param a unsigned fixed-decimal * @return New packed unsigned fixed-decimal */ function pack(UFixed18 a) internal pure returns (PackedUFixed18) { uint256 value = UFixed18.unwrap(a); if (value > type(uint128).max) revert UFixed18PackingOverflowError(value); return PackedUFixed18.wrap(uint128(value)); } /** * @notice Returns whether the unsigned fixed-decimal is equal to zero. * @param a Unsigned fixed-decimal * @return Whether the unsigned fixed-decimal is zero. */ function isZero(UFixed18 a) internal pure returns (bool) { return UFixed18.unwrap(a) == 0; } /** * @notice Adds two unsigned fixed-decimals `a` and `b` together * @param a First unsigned fixed-decimal * @param b Second unsigned fixed-decimal * @return Resulting summed unsigned fixed-decimal */ function add(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) { return UFixed18.wrap(UFixed18.unwrap(a) + UFixed18.unwrap(b)); } /** * @notice Subtracts unsigned fixed-decimal `b` from `a` * @param a Unsigned fixed-decimal to subtract from * @param b Unsigned fixed-decimal to subtract * @return Resulting subtracted unsigned fixed-decimal */ function sub(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) { return UFixed18.wrap(UFixed18.unwrap(a) - UFixed18.unwrap(b)); } /** * @notice Multiplies two unsigned fixed-decimals `a` and `b` together * @param a First unsigned fixed-decimal * @param b Second unsigned fixed-decimal * @return Resulting multiplied unsigned fixed-decimal */ function mul(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) { return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / BASE); } /** * @notice Divides unsigned fixed-decimal `a` by `b` * @param a Unsigned fixed-decimal to divide * @param b Unsigned fixed-decimal to divide by * @return Resulting divided unsigned fixed-decimal */ function div(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) { return UFixed18.wrap(UFixed18.unwrap(a) * BASE / UFixed18.unwrap(b)); } /** * @notice Divides unsigned fixed-decimal `a` by `b` * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0` and `MAX` for `n/0`. * @param a Unsigned fixed-decimal to divide * @param b Unsigned fixed-decimal to divide by * @return Resulting divided unsigned fixed-decimal */ function unsafeDiv(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) { if (isZero(b)) { return isZero(a) ? ONE : MAX; } else { return div(a, b); } } /** * @notice Computes a * b / c without loss of precision due to BASE conversion * @param a First unsigned fixed-decimal * @param b Unsigned number to multiply by * @param c Unsigned number to divide by * @return Resulting computation */ function muldiv(UFixed18 a, uint256 b, uint256 c) internal pure returns (UFixed18) { return muldiv(a, UFixed18.wrap(b), UFixed18.wrap(c)); } /** * @notice Computes a * b / c without loss of precision due to BASE conversion * @param a First unsigned fixed-decimal * @param b Unsigned fixed-decimal to multiply by * @param c Unsigned fixed-decimal to divide by * @return Resulting computation */ function muldiv(UFixed18 a, UFixed18 b, UFixed18 c) internal pure returns (UFixed18) { return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / UFixed18.unwrap(c)); } /** * @notice Returns whether unsigned fixed-decimal `a` is equal to `b` * @param a First unsigned fixed-decimal * @param b Second unsigned fixed-decimal * @return Whether `a` is equal to `b` */ function eq(UFixed18 a, UFixed18 b) internal pure returns (bool) { return compare(a, b) == 1; } /** * @notice Returns whether unsigned fixed-decimal `a` is greater than `b` * @param a First unsigned fixed-decimal * @param b Second unsigned fixed-decimal * @return Whether `a` is greater than `b` */ function gt(UFixed18 a, UFixed18 b) internal pure returns (bool) { return compare(a, b) == 2; } /** * @notice Returns whether unsigned fixed-decimal `a` is less than `b` * @param a First unsigned fixed-decimal * @param b Second unsigned fixed-decimal * @return Whether `a` is less than `b` */ function lt(UFixed18 a, UFixed18 b) internal pure returns (bool) { return compare(a, b) == 0; } /** * @notice Returns whether unsigned fixed-decimal `a` is greater than or equal to `b` * @param a First unsigned fixed-decimal * @param b Second unsigned fixed-decimal * @return Whether `a` is greater than or equal to `b` */ function gte(UFixed18 a, UFixed18 b) internal pure returns (bool) { return gt(a, b) || eq(a, b); } /** * @notice Returns whether unsigned fixed-decimal `a` is less than or equal to `b` * @param a First unsigned fixed-decimal * @param b Second unsigned fixed-decimal * @return Whether `a` is less than or equal to `b` */ function lte(UFixed18 a, UFixed18 b) internal pure returns (bool) { return lt(a, b) || eq(a, b); } /** * @notice Compares the unsigned fixed-decimals `a` and `b` * @dev Returns: 2 for greater than * 1 for equal to * 0 for less than * @param a First unsigned fixed-decimal * @param b Second unsigned fixed-decimal * @return Compare result of `a` and `b` */ function compare(UFixed18 a, UFixed18 b) internal pure returns (uint256) { (uint256 au, uint256 bu) = (UFixed18.unwrap(a), UFixed18.unwrap(b)); if (au > bu) return 2; if (au < bu) return 0; return 1; } /** * @notice Returns a unsigned fixed-decimal representing the ratio of `a` over `b` * @param a First unsigned number * @param b Second unsigned number * @return Ratio of `a` over `b` */ function ratio(uint256 a, uint256 b) internal pure returns (UFixed18) { return UFixed18.wrap(a * BASE / b); } /** * @notice Returns the minimum of unsigned fixed-decimals `a` and `b` * @param a First unsigned fixed-decimal * @param b Second unsigned fixed-decimal * @return Minimum of `a` and `b` */ function min(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) { return UFixed18.wrap(Math.min(UFixed18.unwrap(a), UFixed18.unwrap(b))); } /** * @notice Returns the maximum of unsigned fixed-decimals `a` and `b` * @param a First unsigned fixed-decimal * @param b Second unsigned fixed-decimal * @return Maximum of `a` and `b` */ function max(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) { return UFixed18.wrap(Math.max(UFixed18.unwrap(a), UFixed18.unwrap(b))); } /** * @notice Converts the unsigned fixed-decimal into an integer, truncating any decimal portion * @param a Unsigned fixed-decimal * @return Truncated unsigned number */ function truncate(UFixed18 a) internal pure returns (uint256) { return UFixed18.unwrap(a) / BASE; } } library UFixed18StorageLib { function read(UFixed18Storage self) internal view returns (UFixed18 value) { assembly { value := sload(self) } } function store(UFixed18Storage self, UFixed18 value) internal { assembly { sstore(self, value) } } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.13; import "../number/types/UFixed18.sol"; type BoolStorage is bytes32; using BoolStorageLib for BoolStorage global; type Uint256Storage is bytes32; using Uint256StorageLib for Uint256Storage global; type Int256Storage is bytes32; using Int256StorageLib for Int256Storage global; type AddressStorage is bytes32; using AddressStorageLib for AddressStorage global; type Bytes32Storage is bytes32; using Bytes32StorageLib for Bytes32Storage global; library BoolStorageLib { function read(BoolStorage self) internal view returns (bool value) { assembly { value := sload(self) } } function store(BoolStorage self, bool value) internal { assembly { sstore(self, value) } } } library Uint256StorageLib { function read(Uint256Storage self) internal view returns (uint256 value) { assembly { value := sload(self) } } function store(Uint256Storage self, uint256 value) internal { assembly { sstore(self, value) } } } library Int256StorageLib { function read(Int256Storage self) internal view returns (int256 value) { assembly { value := sload(self) } } function store(Int256Storage self, int256 value) internal { assembly { sstore(self, value) } } } library AddressStorageLib { function read(AddressStorage self) internal view returns (address value) { assembly { value := sload(self) } } function store(AddressStorage self, address value) internal { assembly { sstore(self, value) } } } library Bytes32StorageLib { function read(Bytes32Storage self) internal view returns (bytes32 value) { assembly { value := sload(self) } } function store(Bytes32Storage self, bytes32 value) internal { assembly { sstore(self, value) } } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.13; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "../../number/types/UFixed18.sol"; /// @dev Token18 type Token18 is address; using Token18Lib for Token18 global; type Token18Storage is bytes32; using Token18StorageLib for Token18Storage global; /** * @title Token18Lib * @notice Library to manage 18-decimal ERC20s that is compliant with the fixed-decimal types. * @dev Maintains significant gas savings over other Token implementations since no conversion take place */ library Token18Lib { using SafeERC20 for IERC20; Token18 public constant ZERO = Token18.wrap(address(0)); /** * @notice Returns whether a token is the zero address * @param self Token to check for * @return Whether the token is the zero address */ function isZero(Token18 self) internal pure returns (bool) { return Token18.unwrap(self) == Token18.unwrap(ZERO); } /** * @notice Returns whether the two tokens are equal * @param a First token to compare * @param b Second token to compare * @return Whether the two tokens are equal */ function eq(Token18 a, Token18 b) internal pure returns (bool) { return Token18.unwrap(a) == Token18.unwrap(b); } /** * @notice Approves `grantee` to spend infinite tokens from the caller * @param self Token to transfer * @param grantee Address to allow spending */ function approve(Token18 self, address grantee) internal { IERC20(Token18.unwrap(self)).safeApprove(grantee, type(uint256).max); } /** * @notice Approves `grantee` to spend `amount` tokens from the caller * @param self Token to transfer * @param grantee Address to allow spending * @param amount Amount of tokens to approve to spend */ function approve(Token18 self, address grantee, UFixed18 amount) internal { IERC20(Token18.unwrap(self)).safeApprove(grantee, UFixed18.unwrap(amount)); } /** * @notice Transfers all held tokens from the caller to the `recipient` * @param self Token to transfer * @param recipient Address to receive the tokens */ function push(Token18 self, address recipient) internal { push(self, recipient, balanceOf(self, address(this))); } /** * @notice Transfers `amount` tokens from the caller to the `recipient` * @param self Token to transfer * @param recipient Address to transfer tokens to * @param amount Amount of tokens to transfer */ function push(Token18 self, address recipient, UFixed18 amount) internal { IERC20(Token18.unwrap(self)).safeTransfer(recipient, UFixed18.unwrap(amount)); } /** * @notice Transfers `amount` tokens from the `benefactor` to the caller * @dev Reverts if trying to pull Ether * @param self Token to transfer * @param benefactor Address to transfer tokens from * @param amount Amount of tokens to transfer */ function pull(Token18 self, address benefactor, UFixed18 amount) internal { IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, address(this), UFixed18.unwrap(amount)); } /** * @notice Transfers `amount` tokens from the `benefactor` to `recipient` * @dev Reverts if trying to pull Ether * @param self Token to transfer * @param benefactor Address to transfer tokens from * @param recipient Address to transfer tokens to * @param amount Amount of tokens to transfer */ function pullTo(Token18 self, address benefactor, address recipient, UFixed18 amount) internal { IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, recipient, UFixed18.unwrap(amount)); } /** * @notice Returns the name of the token * @param self Token to check for * @return Token name */ function name(Token18 self) internal view returns (string memory) { return IERC20Metadata(Token18.unwrap(self)).name(); } /** * @notice Returns the symbol of the token * @param self Token to check for * @return Token symbol */ function symbol(Token18 self) internal view returns (string memory) { return IERC20Metadata(Token18.unwrap(self)).symbol(); } /** * @notice Returns the `self` token balance of the caller * @param self Token to check for * @return Token balance of the caller */ function balanceOf(Token18 self) internal view returns (UFixed18) { return balanceOf(self, address(this)); } /** * @notice Returns the `self` token balance of `account` * @param self Token to check for * @param account Account to check * @return Token balance of the account */ function balanceOf(Token18 self, address account) internal view returns (UFixed18) { return UFixed18.wrap(IERC20(Token18.unwrap(self)).balanceOf(account)); } } library Token18StorageLib { function read(Token18Storage self) internal view returns (Token18 value) { assembly { value := sload(self) } } function store(Token18Storage self, Token18 value) internal { assembly { sstore(self, value) } } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.13; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; import "../../number/types/UFixed18.sol"; /// @dev Token6 type Token6 is address; using Token6Lib for Token6 global; type Token6Storage is bytes32; using Token6StorageLib for Token6Storage global; /** * @title Token6Lib * @notice Library to manage 6-decimal ERC20s that is compliant with the fixed-decimal types. * @dev Automatically converts from Base-6 token amounts to Base-18 UFixed18 amounts, with optional rounding */ library Token6Lib { using SafeERC20 for IERC20; Token6 public constant ZERO = Token6.wrap(address(0)); uint256 private constant OFFSET = 1e12; /** * @notice Returns whether a token is the zero address * @param self Token to check for * @return Whether the token is the zero address */ function isZero(Token6 self) internal pure returns (bool) { return Token6.unwrap(self) == Token6.unwrap(ZERO); } /** * @notice Returns whether the two tokens are equal * @param a First token to compare * @param b Second token to compare * @return Whether the two tokens are equal */ function eq(Token6 a, Token6 b) internal pure returns (bool) { return Token6.unwrap(a) == Token6.unwrap(b); } /** * @notice Approves `grantee` to spend infinite tokens from the caller * @param self Token to transfer * @param grantee Address to allow spending */ function approve(Token6 self, address grantee) internal { IERC20(Token6.unwrap(self)).safeApprove(grantee, type(uint256).max); } /** * @notice Approves `grantee` to spend `amount` tokens from the caller * @param self Token to transfer * @param grantee Address to allow spending * @param amount Amount of tokens to approve to spend */ function approve(Token6 self, address grantee, UFixed18 amount) internal { IERC20(Token6.unwrap(self)).safeApprove(grantee, toTokenAmount(amount, false)); } /** * @notice Approves `grantee` to spend `amount` tokens from the caller * @param self Token to transfer * @param grantee Address to allow spending * @param amount Amount of tokens to approve to spend * @param roundUp Whether to round decimal token amount up to the next unit */ function approve(Token6 self, address grantee, UFixed18 amount, bool roundUp) internal { IERC20(Token6.unwrap(self)).safeApprove(grantee, toTokenAmount(amount, roundUp)); } /** * @notice Transfers all held tokens from the caller to the `recipient` * @param self Token to transfer * @param recipient Address to receive the tokens */ function push(Token6 self, address recipient) internal { push(self, recipient, balanceOf(self, address(this))); } /** * @notice Transfers `amount` tokens from the caller to the `recipient` * @param self Token to transfer * @param recipient Address to transfer tokens to * @param amount Amount of tokens to transfer */ function push(Token6 self, address recipient, UFixed18 amount) internal { IERC20(Token6.unwrap(self)).safeTransfer(recipient, toTokenAmount(amount, false)); } /** * @notice Transfers `amount` tokens from the caller to the `recipient` * @param self Token to transfer * @param recipient Address to transfer tokens to * @param amount Amount of tokens to transfer * @param roundUp Whether to round decimal token amount up to the next unit */ function push(Token6 self, address recipient, UFixed18 amount, bool roundUp) internal { IERC20(Token6.unwrap(self)).safeTransfer(recipient, toTokenAmount(amount, roundUp)); } /** * @notice Transfers `amount` tokens from the `benefactor` to the caller * @dev Reverts if trying to pull Ether * @param self Token to transfer * @param benefactor Address to transfer tokens from * @param amount Amount of tokens to transfer */ function pull(Token6 self, address benefactor, UFixed18 amount) internal { IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, address(this), toTokenAmount(amount, false)); } /** * @notice Transfers `amount` tokens from the `benefactor` to the caller * @dev Reverts if trying to pull Ether * @param self Token to transfer * @param benefactor Address to transfer tokens from * @param amount Amount of tokens to transfer * @param roundUp Whether to round decimal token amount up to the next unit */ function pull(Token6 self, address benefactor, UFixed18 amount, bool roundUp) internal { IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, address(this), toTokenAmount(amount, roundUp)); } /** * @notice Transfers `amount` tokens from the `benefactor` to `recipient` * @dev Reverts if trying to pull Ether * @param self Token to transfer * @param benefactor Address to transfer tokens from * @param recipient Address to transfer tokens to * @param amount Amount of tokens to transfer */ function pullTo(Token6 self, address benefactor, address recipient, UFixed18 amount) internal { IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, recipient, toTokenAmount(amount, false)); } /** * @notice Transfers `amount` tokens from the `benefactor` to `recipient` * @dev Reverts if trying to pull Ether * @param self Token to transfer * @param benefactor Address to transfer tokens from * @param recipient Address to transfer tokens to * @param amount Amount of tokens to transfer * @param roundUp Whether to round decimal token amount up to the next unit */ function pullTo(Token6 self, address benefactor, address recipient, UFixed18 amount, bool roundUp) internal { IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, recipient, toTokenAmount(amount, roundUp)); } /** * @notice Returns the name of the token * @param self Token to check for * @return Token name */ function name(Token6 self) internal view returns (string memory) { return IERC20Metadata(Token6.unwrap(self)).name(); } /** * @notice Returns the symbol of the token * @param self Token to check for * @return Token symbol */ function symbol(Token6 self) internal view returns (string memory) { return IERC20Metadata(Token6.unwrap(self)).symbol(); } /** * @notice Returns the `self` token balance of the caller * @param self Token to check for * @return Token balance of the caller */ function balanceOf(Token6 self) internal view returns (UFixed18) { return balanceOf(self, address(this)); } /** * @notice Returns the `self` token balance of `account` * @param self Token to check for * @param account Account to check * @return Token balance of the account */ function balanceOf(Token6 self, address account) internal view returns (UFixed18) { return fromTokenAmount(IERC20(Token6.unwrap(self)).balanceOf(account)); } /** * @notice Converts the unsigned fixed-decimal amount into the token amount according to * it's defined decimals * @dev Provides the ability to "round up" the token amount which is useful in situations where * are swapping one token for another and don't want to give away "free" units due to rounding * errors in the favor of the user. * @param amount Amount to convert * @param roundUp Whether to round decimal token amount up to the next unit * @return Normalized token amount */ function toTokenAmount(UFixed18 amount, bool roundUp) private pure returns (uint256) { return roundUp ? Math.ceilDiv(UFixed18.unwrap(amount), OFFSET) : UFixed18.unwrap(amount) / OFFSET; } /** * @notice Converts the token amount into the unsigned fixed-decimal amount according to * it's defined decimals * @param amount Token amount to convert * @return Normalized unsigned fixed-decimal amount */ function fromTokenAmount(uint256 amount) private pure returns (UFixed18) { return UFixed18.wrap(amount * OFFSET); } } library Token6StorageLib { function read(Token6Storage self) internal view returns (Token6 value) { assembly { value := sload(self) } } function store(Token6Storage self, Token6 value) internal { assembly { sstore(self, value) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// 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 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [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 functionCall(target, data, "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"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(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) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason 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 { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a / b + (a % b == 0 ? 0 : 1); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
//SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.13; import "@equilibria/root/number/types/UFixed18.sol"; import "@equilibria/root/token/types/Token18.sol"; import "@equilibria/root/token/types/Token6.sol"; import "@equilibria/root/control/unstructured/UOwnable.sol"; import "../interfaces/IBatcher.sol"; import "../interfaces/IEmptySetReserve.sol"; abstract contract Batcher is IBatcher, UOwnable { /// @dev Reserve address IEmptySetReserve public immutable RESERVE; // solhint-disable-line var-name-mixedcase /// @dev DSU address Token18 public immutable DSU; // solhint-disable-line var-name-mixedcase /// @dev USDC address Token6 public immutable USDC; // solhint-disable-line var-name-mixedcase /** * @notice Initializes the Batcher * @dev Called at implementation instantiate and constant for that implementation. * @param reserve EmptySet Reserve Aaddress * @param dsu DSU Token address * @param usdc USDC Token Address */ constructor(IEmptySetReserve reserve, Token18 dsu, Token6 usdc) { RESERVE = reserve; DSU = dsu; USDC = usdc; DSU.approve(address(RESERVE)); USDC.approve(address(RESERVE)); __UOwnable__initialize(); } /** * @notice Total USDC and DSU balance of the Batcher * @return Balance of DSU + balance of USDC */ function totalBalance() public view returns (UFixed18) { return DSU.balanceOf().add(USDC.balanceOf()); } /** * @notice Wraps `amount` of USDC, returned DSU to `to` * @param amount Amount of USDC to wrap * @param to Receiving address of resulting DSU */ function wrap(UFixed18 amount, address to) external { _wrap(amount, to); emit Wrap(to, amount); } /** * @notice Pulls USDC from the `msg.sender` and pushes DSU to `to` * @dev Rounds USDC amount up if `amount` exceeds USDC decimal precision. Overrideable by implementation * @param amount Amount of USDC to pull * @param to Receiving address of resulting DSU */ function _wrap(UFixed18 amount, address to) virtual internal { USDC.pull(msg.sender, amount, true); DSU.push(to, amount); } /** * @notice Unwraps `amount` of DSU, returned USDC to `to` * @param amount Amount of DSU to unwrap * @param to Receiving address of resulting USDC */ function unwrap(UFixed18 amount, address to) external { _unwrap(amount, to); emit Unwrap(to, amount); } /** * @notice Pulls DSU from the `msg.sender` and pushes USDC to `to` * @dev Rounds USDC amount down if `amount` exceeds USDC decimal precision. Overrideable by implementation * @param amount Amount of DSU to pull * @param to Receiving address of resulting USDC */ function _unwrap(UFixed18 amount, address to) virtual internal { DSU.pull(msg.sender, amount); USDC.push(to, amount); } /** * @notice Rebalances the USDC and DSU in the Batcher to maintain target balances * @dev Reverts if the new total balance is less than before */ function rebalance() public { (UFixed18 usdcBalance, UFixed18 dsuBalance) = (USDC.balanceOf(), DSU.balanceOf()); _rebalance(usdcBalance, dsuBalance); UFixed18 newDsuBalance = DSU.balanceOf(); (UFixed18 oldBalance, UFixed18 newBalance) = (usdcBalance.add(dsuBalance), totalBalance()); if (oldBalance.gt(newBalance)) revert BatcherBalanceMismatchError(oldBalance, newBalance); emit Rebalance( newDsuBalance.gt(dsuBalance) ? newDsuBalance.sub(dsuBalance) : UFixed18Lib.ZERO, dsuBalance.gt(newDsuBalance) ? dsuBalance.sub(newDsuBalance) : UFixed18Lib.ZERO ); } /// @dev Hook for implementation for custom rebalance logic function _rebalance(UFixed18 usdcBalance, UFixed18 dsuBalance) virtual internal; /** * @notice Closes the Batcher. Repaying debt to Reserve and returning excess USDC to owner. */ function close() external onlyOwner { _close(); UFixed18 dsuBalance = DSU.balanceOf(); UFixed18 repayAmount = UFixed18Lib.min(RESERVE.debt(address(this)), dsuBalance); UFixed18 returnAmount = dsuBalance.sub(repayAmount); RESERVE.repay(address(this), repayAmount); // If there is any excess DSU, redeem it for USDC and send to the owner if (!returnAmount.isZero()) { RESERVE.redeem(returnAmount); USDC.push(owner(), returnAmount); } emit Close(dsuBalance); } /// @dev Hook for implementation for custom close logic function _close() virtual internal; }
//SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.13; import "@equilibria/root/number/types/UFixed18.sol"; import "@equilibria/root/token/types/Token18.sol"; import "@equilibria/root/token/types/Token6.sol"; import "../interfaces/IEmptySetReserve.sol"; interface IBatcher { event Wrap(address indexed to, UFixed18 amount); event Unwrap(address indexed to, UFixed18 amount); event Rebalance(UFixed18 newMinted, UFixed18 newRedeemed); event Close(UFixed18 amount); error BatcherNotImplementedError(); error BatcherBalanceMismatchError(UFixed18 oldBalance, UFixed18 newBalance); function RESERVE() external view returns (IEmptySetReserve); // solhint-disable-line func-name-mixedcase function USDC() external view returns (Token6); // solhint-disable-line func-name-mixedcase function DSU() external view returns (Token18); // solhint-disable-line func-name-mixedcase function totalBalance() external view returns (UFixed18); function wrap(UFixed18 amount, address to) external; function unwrap(UFixed18 amount, address to) external; function rebalance() external; }
//SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.13; import "@equilibria/root/number/types/UFixed18.sol"; interface IEmptySetReserve { event Redeem(address indexed account, uint256 costAmount, uint256 redeemAmount); event Mint(address indexed account, uint256 mintAmount, uint256 costAmount); event Repay(address indexed account, uint256 repayAmount); function debt(address borrower) external view returns (UFixed18); function repay(address borrower, UFixed18 amount) external; function mint(UFixed18 amount) external; function redeem(UFixed18 amount) external; }
//SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.13; import "@openzeppelin/contracts/interfaces/IERC20.sol"; import "./IBatcher.sol"; interface ITwoWayBatcher is IBatcher, IERC20 { /// @notice Event emitted on USDC deposit event Deposit(address indexed account, UFixed18 amount); /// @notice Event emitted on USDC withdraw event Withdraw(address indexed account, UFixed18 amount); /// @notice Error thrown on invalid USDC amount error TwoWayBatcherInvalidTokenAmount(UFixed18 amount); /// @notice Deposits USDC for Batcher to use in unwrapping flows function deposit(UFixed18 amount) external; /// @notice Withdraws USDC from Batcher function withdraw(UFixed18 amount) external; }
{ "evmVersion": "london", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 1000000 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract IEmptySetReserve","name":"reserve","type":"address"},{"internalType":"Token18","name":"dsu","type":"address"},{"internalType":"Token6","name":"usdc","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"UFixed18","name":"oldBalance","type":"uint256"},{"internalType":"UFixed18","name":"newBalance","type":"uint256"}],"name":"BatcherBalanceMismatchError","type":"error"},{"inputs":[],"name":"BatcherNotImplementedError","type":"error"},{"inputs":[{"internalType":"UFixed18","name":"amount","type":"uint256"}],"name":"TwoWayBatcherInvalidTokenAmount","type":"error"},{"inputs":[{"internalType":"uint256","name":"version","type":"uint256"}],"name":"UInitializableAlreadyInitializedError","type":"error"},{"inputs":[],"name":"UInitializableNotInitializingError","type":"error"},{"inputs":[],"name":"UInitializableZeroVersionError","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"UOwnableNotOwnerError","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"UOwnableNotPendingOwnerError","type":"error"},{"inputs":[],"name":"UReentrancyGuardReentrantCallError","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"UFixed18","name":"amount","type":"uint256"}],"name":"Close","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"UFixed18","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newPendingOwner","type":"address"}],"name":"PendingOwnerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"UFixed18","name":"newMinted","type":"uint256"},{"indexed":false,"internalType":"UFixed18","name":"newRedeemed","type":"uint256"}],"name":"Rebalance","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"UFixed18","name":"amount","type":"uint256"}],"name":"Unwrap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"UFixed18","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"UFixed18","name":"amount","type":"uint256"}],"name":"Wrap","type":"event"},{"inputs":[],"name":"DSU","outputs":[{"internalType":"Token18","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RESERVE","outputs":[{"internalType":"contract IEmptySetReserve","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USDC","outputs":[{"internalType":"Token6","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"close","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"UFixed18","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rebalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBalance","outputs":[{"internalType":"UFixed18","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"UFixed18","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"unwrap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newPendingOwner","type":"address"}],"name":"updatePendingOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"UFixed18","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"UFixed18","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"wrap","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60e06040523480156200001157600080fd5b50604051620031f0380380620031f08339810160408190526200003491620006c4565b604080518082018252600f81526e10985d18da195c8811195c1bdcda5d608a1b602080830191909152825180840190935260048352630424445560e41b838201526001600160a01b03808716608081905281871660a081905291861660c052929392879287928792620000b092620010bf6200011a821b17901c565b620000d760805160c0516001600160a01b03166200011a60201b620010bf1790919060201c565b620000e162000145565b5060039150620000f490508382620007bc565b506004620001038282620007bc565b5062000111915050620001ab565b5050506200093f565b6200014181600019846001600160a01b03166200023f60201b62001104179092919060201c565b5050565b6200014f62000392565b1580156200017f57506200017d600080516020620031d0833981519152620003b060201b620013091760201c565b155b156200019e57604051631a27c4a960e21b815260040160405180910390fd5b620001a933620003b4565b565b620001b562000392565b158015620001e55750620001e3600080516020620031d0833981519152620003b060201b620013091760201c565b155b156200020457604051631a27c4a960e21b815260040160405180910390fd5b620001a960017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d76200042560201b6200130d1790919060201c565b801580620002bd5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa15801562000295573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002bb919062000888565b155b620003355760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000060648201526084015b60405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b0390811663095ea7b360e01b179091526200038d9185916200042916565b505050565b6000620003aa306200050760201b620013111760201c565b15905090565b5490565b620003ee817fd520c4fc3bfc097da8746a8578e9e0417f5acfdd84a1de38ed670148cc1a349d6200042560201b6200130d1790919060201c565b6040516001600160a01b038216907f4ffd725fc4a22075e9ec71c59edf9c38cdeb588a91b24fc5b61388c5be41282b90600090a250565b9055565b600062000485826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166200051660201b6200132d179092919060201c565b8051909150156200038d5780806020019051810190620004a69190620008a2565b6200038d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016200032c565b6001600160a01b03163b151590565b606062000527848460008562000531565b90505b9392505050565b606082471015620005945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016200032c565b6001600160a01b0385163b620005ed5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016200032c565b600080866001600160a01b031685876040516200060b9190620008ec565b60006040518083038185875af1925050503d80600081146200064a576040519150601f19603f3d011682016040523d82523d6000602084013e6200064f565b606091505b509092509050620006628282866200066d565b979650505050505050565b606083156200067e5750816200052a565b8251156200068f5782518084602001fd5b8160405162461bcd60e51b81526004016200032c91906200090a565b6001600160a01b0381168114620006c157600080fd5b50565b600080600060608486031215620006da57600080fd5b8351620006e781620006ab565b6020850151909350620006fa81620006ab565b60408501519092506200070d81620006ab565b809150509250925092565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200074357607f821691505b6020821081036200076457634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200038d57600081815260208120601f850160051c81016020861015620007935750805b601f850160051c820191505b81811015620007b4578281556001016200079f565b505050505050565b81516001600160401b03811115620007d857620007d862000718565b620007f081620007e984546200072e565b846200076a565b602080601f8311600181146200082857600084156200080f5750858301515b600019600386901b1c1916600185901b178555620007b4565b600085815260208120601f198616915b82811015620008595788860151825594840194600190910190840162000838565b5085821015620008785787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6000602082840312156200089b57600080fd5b5051919050565b600060208284031215620008b557600080fd5b815180151581146200052a57600080fd5b60005b83811015620008e3578181015183820152602001620008c9565b50506000910152565b6000825162000900818460208701620008c6565b9190910192915050565b60208152600082518060208401526200092b816040850160208701620008c6565b601f01601f19169190910160400192915050565b60805160a05160c0516127e3620009ed600039600081816102b60152818161062d015281816109e101528181610a9a01528181610d7901528181610fa6015281816115110152611bbe0152600081816103390152818161076401528181610ad901528181610b2801528181610db8015281816115540152611b7d015260008181610312015281816107eb015281816108a20152818161094e01528181611c390152611cdd01526127e36000f3fe608060405234801561001057600080fd5b50600436106101a35760003560e01c806389a30271116100ee578063a9059cbb11610097578063b6b55f2511610071578063b6b55f251461039c578063dd62ed3e146103af578063e30c3978146103f5578063ebbc4965146103fd57600080fd5b8063a9059cbb1461036e578063ad7a672f14610381578063b5ee69551461038957600080fd5b80639d2cc436116100c85780639d2cc4361461030d578063a2060bcf14610334578063a457c2d71461035b57600080fd5b806389a30271146102b15780638da5cb5b146102fd57806395d89b411461030557600080fd5b8063313ce5671161015057806370a082311161012a57806370a08231146102605780637647691d146102965780637d7c2a1c146102a957600080fd5b8063313ce56714610236578063395093511461024557806343d726d61461025857600080fd5b806318160ddd1161018157806318160ddd146101fe57806323b872dd146102105780632e1a7d4d1461022357600080fd5b806306fdde03146101a8578063095ea7b3146101c657806313bac820146101e9575b600080fd5b6101b0610405565b6040516101bd91906124d6565b60405180910390f35b6101d96101d4366004612550565b610497565b60405190151581526020016101bd565b6101fc6101f736600461257a565b6104b1565b005b6002545b6040519081526020016101bd565b6101d961021e3660046125a6565b61050f565b6101fc6102313660046125e2565b610535565b604051601281526020016101bd565b6101d9610253366004612550565b6106b1565b6101fc6106fd565b61020261026e3660046125fb565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101fc6102a436600461257a565b610a40565b6101fc610a92565b6102d87f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101bd565b6102d8610c47565b6101b0610c76565b6102d87f000000000000000000000000000000000000000000000000000000000000000081565b6102d87f000000000000000000000000000000000000000000000000000000000000000081565b6101d9610369366004612550565b610c85565b6101d961037c366004612550565b610d61565b610202610d6f565b6101fc6103973660046125fb565b610df8565b6101fc6103aa3660046125e2565b610ebd565b6102026103bd366004612616565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6102d861100b565b6101fc611035565b60606003805461041490612640565b80601f016020809104026020016040519081016040528092919081815260200182805461044090612640565b801561048d5780601f106104625761010080835404028352916020019161048d565b820191906000526020600020905b81548152906001019060200180831161047057829003601f168201915b5050505050905090565b6000336104a5818585611344565b60019150505b92915050565b6104bb82826114f7565b8073ffffffffffffffffffffffffffffffffffffffff167fb61d00fdfee32467c7d81db64c811ae60c104c346debf36a14afe84b8fce59e58360405161050391815260200190565b60405180910390a25050565b60003361051d85828561157b565b610528858585611652565b60019150505b9392505050565b600261055f7f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03610596576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7556105c381611905565b610601576040517fbfae1872000000000000000000000000000000000000000000000000000000008152600481018290526024015b60405180910390fd5b610609610a92565b610613338261191d565b61065473ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163383611b0a565b60405181815233907f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364906020015b60405180910390a260017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75550565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104a590829086906106f89087906126c2565b611344565b33610706610c47565b73ffffffffffffffffffffffffffffffffffffffff1614610755576040517f9950d22a0000000000000000000000000000000000000000000000000000000081523360048201526024016105f8565b61075d611b37565b600061079e7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16611b3f565b6040517f9b6c56ec00000000000000000000000000000000000000000000000000000000815230600482015290915060009061085c9073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690639b6c56ec90602401602060405180830381865afa158015610832573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061085691906126d5565b83611b4b565b9050600061086a8383611b57565b6040517f22867d78000000000000000000000000000000000000000000000000000000008152306004820152602481018490529091507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906322867d7890604401600060405180830381600087803b1580156108fb57600080fd5b505af115801561090f573d6000803e3d6000fd5b5050505061091b811590565b610a08576040517fdb006a75000000000000000000000000000000000000000000000000000000008152600481018290527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063db006a7590602401600060405180830381600087803b1580156109a757600080fd5b505af11580156109bb573d6000803e3d6000fd5b50505050610a086109ca610c47565b73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169083611b0a565b6040518381527fbf67515a38ee520223d32c1266d52101c30d936ed1f3e436c8caeb0a43cb06bf9060200160405180910390a1505050565b610a4a8282611b63565b8073ffffffffffffffffffffffffffffffffffffffff167f5dd085b6070b4cae004f84daafd199fd55b0bdfa11c3a802baffe89c2419d8c28360405161050391815260200190565b600080610ad47f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16611be5565b610b137f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16611b3f565b91509150610b218282611bf1565b6000610b627f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16611b3f565b9050600080610b718585611d0c565b610b79610d6f565b9092509050610b888282611d18565b15610bc9576040517fa4840ff900000000000000000000000000000000000000000000000000000000815260048101839052602481018290526044016105f8565b7f0b33d39bbef101ecc4f5ef04e6d3a125c9fb745a418dac380e2a9460f8200dc8610bf48486611d18565b610bff576000610c09565b610c098486611b57565b610c138686611d18565b610c1e576000610c28565b610c288686611b57565b6040805192835260208301919091520160405180910390a15050505050565b6000610c717fd520c4fc3bfc097da8746a8578e9e0417f5acfdd84a1de38ed670148cc1a349d5490565b905090565b60606004805461041490612640565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610d49576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084016105f8565b610d568286868403611344565b506001949350505050565b6000336104a5818585611652565b6000610c71610db37f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16611be5565b610df27f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16611b3f565b90611d0c565b33610e01610c47565b73ffffffffffffffffffffffffffffffffffffffff1614610e50576040517f9950d22a0000000000000000000000000000000000000000000000000000000081523360048201526024016105f8565b610e797faabf80d370e1f8b862122cc5c4b30b4a8eb2d6b5dda0d437726c353765e1ed32829055565b60405173ffffffffffffffffffffffffffffffffffffffff8216907f69f201bc2089b9be6195d876d97a0136b4cf56bbf8986a52dcb50697f7d1cac590600090a250565b6002610ee77f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03610f1e576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755610f4b81611905565b610f84576040517fbfae1872000000000000000000000000000000000000000000000000000000008152600481018290526024016105f8565b610f8c610a92565b610fcf73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001633836001611d2e565b610fd93382611d5c565b60405181815233907fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c90602001610682565b6000610c717faabf80d370e1f8b862122cc5c4b30b4a8eb2d6b5dda0d437726c353765e1ed325490565b61103d61100b565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146110a3576040517f14f8fce70000000000000000000000000000000000000000000000000000000081523360048201526024016105f8565b6110b36110ae61100b565b611e7c565b6110bd6000610df8565b565b61110073ffffffffffffffffffffffffffffffffffffffff8316827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff611104565b5050565b8015806111a457506040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff838116602483015284169063dd62ed3e90604401602060405180830381865afa15801561117e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a291906126d5565b155b611230576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000060648201526084016105f8565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526113049084907f095ea7b300000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152611ee9565b505050565b5490565b9055565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b606061133c8484600085611ff5565b949350505050565b73ffffffffffffffffffffffffffffffffffffffff83166113e6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016105f8565b73ffffffffffffffffffffffffffffffffffffffff8216611489576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f737300000000000000000000000000000000000000000000000000000000000060648201526084016105f8565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b61153a73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001633846001611d2e565b61110073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016828461218b565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461164c578181101561163f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e636500000060448201526064016105f8565b61164c8484848403611344565b50505050565b73ffffffffffffffffffffffffffffffffffffffff83166116f5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f647265737300000000000000000000000000000000000000000000000000000060648201526084016105f8565b73ffffffffffffffffffffffffffffffffffffffff8216611798576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f657373000000000000000000000000000000000000000000000000000000000060648201526084016105f8565b73ffffffffffffffffffffffffffffffffffffffff83166000908152602081905260409020548181101561184e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e6365000000000000000000000000000000000000000000000000000060648201526084016105f8565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152602081905260408082208585039055918516815290812080548492906118929084906126c2565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516118f891815260200190565b60405180910390a361164c565b600061191664e8d4a510008361271d565b1592915050565b73ffffffffffffffffffffffffffffffffffffffff82166119c0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f730000000000000000000000000000000000000000000000000000000000000060648201526084016105f8565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090205481811015611a76576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f636500000000000000000000000000000000000000000000000000000000000060648201526084016105f8565b73ffffffffffffffffffffffffffffffffffffffff83166000908152602081905260408120838303905560028054849290611ab2908490612731565b909155505060405182815260009073ffffffffffffffffffffffffffffffffffffffff8516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b61130482611b198360006121ac565b73ffffffffffffffffffffffffffffffffffffffff861691906121d6565b6110bd610a92565b60006104ab823061222c565b600061052e83836122c0565b600061052e8284612731565b611ba473ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001633846122d6565b61110073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168284611b0a565b60006104ab82306122f8565b6000611bfc60025490565b90506000611c0a8483612394565b905080600103611c1a5750505050565b80600203611cbe5773ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001663a0712d68611c688685611b57565b6040518263ffffffff1660e01b8152600401611c8691815260200190565b600060405180830381600087803b158015611ca057600080fd5b505af1158015611cb4573d6000803e3d6000fd5b5050505050505050565b8060000361164c5773ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001663db006a75611c688487611b57565b600061052e82846126c2565b6000611d248383612394565b6002149392505050565b61164c8330611d3d85856121ac565b73ffffffffffffffffffffffffffffffffffffffff88169291906123be565b73ffffffffffffffffffffffffffffffffffffffff8216611dd9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016105f8565b8060026000828254611deb91906126c2565b909155505073ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604081208054839290611e259084906126c2565b909155505060405181815273ffffffffffffffffffffffffffffffffffffffff8316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b611ea57fd520c4fc3bfc097da8746a8578e9e0417f5acfdd84a1de38ed670148cc1a349d829055565b60405173ffffffffffffffffffffffffffffffffffffffff8216907f4ffd725fc4a22075e9ec71c59edf9c38cdeb588a91b24fc5b61388c5be41282b90600090a250565b6000611f4b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661132d9092919063ffffffff16565b8051909150156113045780806020019051810190611f699190612744565b611304576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016105f8565b606082471015612087576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016105f8565b73ffffffffffffffffffffffffffffffffffffffff85163b612105576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105f8565b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161212e9190612766565b60006040518083038185875af1925050503d806000811461216b576040519150601f19603f3d011682016040523d82523d6000602084013e612170565b606091505b509150915061218082828661241c565b979650505050505050565b61130473ffffffffffffffffffffffffffffffffffffffff841683836121d6565b6000816121c7576121c264e8d4a5100084612782565b61052e565b61052e8364e8d4a5100061246f565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526113049084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401611282565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152600091908416906370a0823190602401602060405180830381865afa15801561229c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052e91906126d5565b60008183106122cf578161052e565b5090919050565b61130473ffffffffffffffffffffffffffffffffffffffff84168330846123be565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff828116600483015260009161052e918516906370a0823190602401602060405180830381865afa15801561236b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061238f91906126d5565b6124a1565b60008282808211156123ab576002925050506104ab565b80821015610d56576000925050506104ab565b60405173ffffffffffffffffffffffffffffffffffffffff8085166024830152831660448201526064810182905261164c9085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401611282565b6060831561242b57508161052e565b82511561243b5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105f891906124d6565b600061247b828461271d565b1561248757600161248a565b60005b60ff166124978385612782565b61052e91906126c2565b60006104ab64e8d4a5100083612796565b60005b838110156124cd5781810151838201526020016124b5565b50506000910152565b60208152600082518060208401526124f58160408501602087016124b2565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461254b57600080fd5b919050565b6000806040838503121561256357600080fd5b61256c83612527565b946020939093013593505050565b6000806040838503121561258d57600080fd5b8235915061259d60208401612527565b90509250929050565b6000806000606084860312156125bb57600080fd5b6125c484612527565b92506125d260208501612527565b9150604084013590509250925092565b6000602082840312156125f457600080fd5b5035919050565b60006020828403121561260d57600080fd5b61052e82612527565b6000806040838503121561262957600080fd5b61263283612527565b915061259d60208401612527565b600181811c9082168061265457607f821691505b60208210810361268d577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104ab576104ab612693565b6000602082840312156126e757600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261272c5761272c6126ee565b500690565b818103818111156104ab576104ab612693565b60006020828403121561275657600080fd5b8151801515811461052e57600080fd5b600082516127788184602087016124b2565b9190910192915050565b600082612791576127916126ee565b500490565b80820281158282048414176104ab576104ab61269356fea2646970667358221220a556fb35975450efe39f9db04b9e755789c41b1914ee0c4d211a6d5253b1966a64736f6c63430008110033ad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c000000000000000000000000d05ace63789ccb35b9ce71d01e4d632a0486da4b000000000000000000000000605d26fbd5be761089281d5cec2ce86eea667109000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101a35760003560e01c806389a30271116100ee578063a9059cbb11610097578063b6b55f2511610071578063b6b55f251461039c578063dd62ed3e146103af578063e30c3978146103f5578063ebbc4965146103fd57600080fd5b8063a9059cbb1461036e578063ad7a672f14610381578063b5ee69551461038957600080fd5b80639d2cc436116100c85780639d2cc4361461030d578063a2060bcf14610334578063a457c2d71461035b57600080fd5b806389a30271146102b15780638da5cb5b146102fd57806395d89b411461030557600080fd5b8063313ce5671161015057806370a082311161012a57806370a08231146102605780637647691d146102965780637d7c2a1c146102a957600080fd5b8063313ce56714610236578063395093511461024557806343d726d61461025857600080fd5b806318160ddd1161018157806318160ddd146101fe57806323b872dd146102105780632e1a7d4d1461022357600080fd5b806306fdde03146101a8578063095ea7b3146101c657806313bac820146101e9575b600080fd5b6101b0610405565b6040516101bd91906124d6565b60405180910390f35b6101d96101d4366004612550565b610497565b60405190151581526020016101bd565b6101fc6101f736600461257a565b6104b1565b005b6002545b6040519081526020016101bd565b6101d961021e3660046125a6565b61050f565b6101fc6102313660046125e2565b610535565b604051601281526020016101bd565b6101d9610253366004612550565b6106b1565b6101fc6106fd565b61020261026e3660046125fb565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101fc6102a436600461257a565b610a40565b6101fc610a92565b6102d87f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101bd565b6102d8610c47565b6101b0610c76565b6102d87f000000000000000000000000d05ace63789ccb35b9ce71d01e4d632a0486da4b81565b6102d87f000000000000000000000000605d26fbd5be761089281d5cec2ce86eea66710981565b6101d9610369366004612550565b610c85565b6101d961037c366004612550565b610d61565b610202610d6f565b6101fc6103973660046125fb565b610df8565b6101fc6103aa3660046125e2565b610ebd565b6102026103bd366004612616565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6102d861100b565b6101fc611035565b60606003805461041490612640565b80601f016020809104026020016040519081016040528092919081815260200182805461044090612640565b801561048d5780601f106104625761010080835404028352916020019161048d565b820191906000526020600020905b81548152906001019060200180831161047057829003601f168201915b5050505050905090565b6000336104a5818585611344565b60019150505b92915050565b6104bb82826114f7565b8073ffffffffffffffffffffffffffffffffffffffff167fb61d00fdfee32467c7d81db64c811ae60c104c346debf36a14afe84b8fce59e58360405161050391815260200190565b60405180910390a25050565b60003361051d85828561157b565b610528858585611652565b60019150505b9392505050565b600261055f7f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03610596576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7556105c381611905565b610601576040517fbfae1872000000000000000000000000000000000000000000000000000000008152600481018290526024015b60405180910390fd5b610609610a92565b610613338261191d565b61065473ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48163383611b0a565b60405181815233907f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364906020015b60405180910390a260017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75550565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104a590829086906106f89087906126c2565b611344565b33610706610c47565b73ffffffffffffffffffffffffffffffffffffffff1614610755576040517f9950d22a0000000000000000000000000000000000000000000000000000000081523360048201526024016105f8565b61075d611b37565b600061079e7f000000000000000000000000605d26fbd5be761089281d5cec2ce86eea66710973ffffffffffffffffffffffffffffffffffffffff16611b3f565b6040517f9b6c56ec00000000000000000000000000000000000000000000000000000000815230600482015290915060009061085c9073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000d05ace63789ccb35b9ce71d01e4d632a0486da4b1690639b6c56ec90602401602060405180830381865afa158015610832573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061085691906126d5565b83611b4b565b9050600061086a8383611b57565b6040517f22867d78000000000000000000000000000000000000000000000000000000008152306004820152602481018490529091507f000000000000000000000000d05ace63789ccb35b9ce71d01e4d632a0486da4b73ffffffffffffffffffffffffffffffffffffffff16906322867d7890604401600060405180830381600087803b1580156108fb57600080fd5b505af115801561090f573d6000803e3d6000fd5b5050505061091b811590565b610a08576040517fdb006a75000000000000000000000000000000000000000000000000000000008152600481018290527f000000000000000000000000d05ace63789ccb35b9ce71d01e4d632a0486da4b73ffffffffffffffffffffffffffffffffffffffff169063db006a7590602401600060405180830381600087803b1580156109a757600080fd5b505af11580156109bb573d6000803e3d6000fd5b50505050610a086109ca610c47565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48169083611b0a565b6040518381527fbf67515a38ee520223d32c1266d52101c30d936ed1f3e436c8caeb0a43cb06bf9060200160405180910390a1505050565b610a4a8282611b63565b8073ffffffffffffffffffffffffffffffffffffffff167f5dd085b6070b4cae004f84daafd199fd55b0bdfa11c3a802baffe89c2419d8c28360405161050391815260200190565b600080610ad47f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4873ffffffffffffffffffffffffffffffffffffffff16611be5565b610b137f000000000000000000000000605d26fbd5be761089281d5cec2ce86eea66710973ffffffffffffffffffffffffffffffffffffffff16611b3f565b91509150610b218282611bf1565b6000610b627f000000000000000000000000605d26fbd5be761089281d5cec2ce86eea66710973ffffffffffffffffffffffffffffffffffffffff16611b3f565b9050600080610b718585611d0c565b610b79610d6f565b9092509050610b888282611d18565b15610bc9576040517fa4840ff900000000000000000000000000000000000000000000000000000000815260048101839052602481018290526044016105f8565b7f0b33d39bbef101ecc4f5ef04e6d3a125c9fb745a418dac380e2a9460f8200dc8610bf48486611d18565b610bff576000610c09565b610c098486611b57565b610c138686611d18565b610c1e576000610c28565b610c288686611b57565b6040805192835260208301919091520160405180910390a15050505050565b6000610c717fd520c4fc3bfc097da8746a8578e9e0417f5acfdd84a1de38ed670148cc1a349d5490565b905090565b60606004805461041490612640565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610d49576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084016105f8565b610d568286868403611344565b506001949350505050565b6000336104a5818585611652565b6000610c71610db37f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4873ffffffffffffffffffffffffffffffffffffffff16611be5565b610df27f000000000000000000000000605d26fbd5be761089281d5cec2ce86eea66710973ffffffffffffffffffffffffffffffffffffffff16611b3f565b90611d0c565b33610e01610c47565b73ffffffffffffffffffffffffffffffffffffffff1614610e50576040517f9950d22a0000000000000000000000000000000000000000000000000000000081523360048201526024016105f8565b610e797faabf80d370e1f8b862122cc5c4b30b4a8eb2d6b5dda0d437726c353765e1ed32829055565b60405173ffffffffffffffffffffffffffffffffffffffff8216907f69f201bc2089b9be6195d876d97a0136b4cf56bbf8986a52dcb50697f7d1cac590600090a250565b6002610ee77f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03610f1e576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755610f4b81611905565b610f84576040517fbfae1872000000000000000000000000000000000000000000000000000000008152600481018290526024016105f8565b610f8c610a92565b610fcf73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb481633836001611d2e565b610fd93382611d5c565b60405181815233907fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c90602001610682565b6000610c717faabf80d370e1f8b862122cc5c4b30b4a8eb2d6b5dda0d437726c353765e1ed325490565b61103d61100b565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146110a3576040517f14f8fce70000000000000000000000000000000000000000000000000000000081523360048201526024016105f8565b6110b36110ae61100b565b611e7c565b6110bd6000610df8565b565b61110073ffffffffffffffffffffffffffffffffffffffff8316827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff611104565b5050565b8015806111a457506040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff838116602483015284169063dd62ed3e90604401602060405180830381865afa15801561117e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a291906126d5565b155b611230576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000060648201526084016105f8565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526113049084907f095ea7b300000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152611ee9565b505050565b5490565b9055565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b606061133c8484600085611ff5565b949350505050565b73ffffffffffffffffffffffffffffffffffffffff83166113e6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016105f8565b73ffffffffffffffffffffffffffffffffffffffff8216611489576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f737300000000000000000000000000000000000000000000000000000000000060648201526084016105f8565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b61153a73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb481633846001611d2e565b61110073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000605d26fbd5be761089281d5cec2ce86eea66710916828461218b565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461164c578181101561163f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e636500000060448201526064016105f8565b61164c8484848403611344565b50505050565b73ffffffffffffffffffffffffffffffffffffffff83166116f5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f647265737300000000000000000000000000000000000000000000000000000060648201526084016105f8565b73ffffffffffffffffffffffffffffffffffffffff8216611798576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f657373000000000000000000000000000000000000000000000000000000000060648201526084016105f8565b73ffffffffffffffffffffffffffffffffffffffff83166000908152602081905260409020548181101561184e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e6365000000000000000000000000000000000000000000000000000060648201526084016105f8565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152602081905260408082208585039055918516815290812080548492906118929084906126c2565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516118f891815260200190565b60405180910390a361164c565b600061191664e8d4a510008361271d565b1592915050565b73ffffffffffffffffffffffffffffffffffffffff82166119c0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f730000000000000000000000000000000000000000000000000000000000000060648201526084016105f8565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090205481811015611a76576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f636500000000000000000000000000000000000000000000000000000000000060648201526084016105f8565b73ffffffffffffffffffffffffffffffffffffffff83166000908152602081905260408120838303905560028054849290611ab2908490612731565b909155505060405182815260009073ffffffffffffffffffffffffffffffffffffffff8516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b61130482611b198360006121ac565b73ffffffffffffffffffffffffffffffffffffffff861691906121d6565b6110bd610a92565b60006104ab823061222c565b600061052e83836122c0565b600061052e8284612731565b611ba473ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000605d26fbd5be761089281d5cec2ce86eea6671091633846122d6565b61110073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48168284611b0a565b60006104ab82306122f8565b6000611bfc60025490565b90506000611c0a8483612394565b905080600103611c1a5750505050565b80600203611cbe5773ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000d05ace63789ccb35b9ce71d01e4d632a0486da4b1663a0712d68611c688685611b57565b6040518263ffffffff1660e01b8152600401611c8691815260200190565b600060405180830381600087803b158015611ca057600080fd5b505af1158015611cb4573d6000803e3d6000fd5b5050505050505050565b8060000361164c5773ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000d05ace63789ccb35b9ce71d01e4d632a0486da4b1663db006a75611c688487611b57565b600061052e82846126c2565b6000611d248383612394565b6002149392505050565b61164c8330611d3d85856121ac565b73ffffffffffffffffffffffffffffffffffffffff88169291906123be565b73ffffffffffffffffffffffffffffffffffffffff8216611dd9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016105f8565b8060026000828254611deb91906126c2565b909155505073ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604081208054839290611e259084906126c2565b909155505060405181815273ffffffffffffffffffffffffffffffffffffffff8316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b611ea57fd520c4fc3bfc097da8746a8578e9e0417f5acfdd84a1de38ed670148cc1a349d829055565b60405173ffffffffffffffffffffffffffffffffffffffff8216907f4ffd725fc4a22075e9ec71c59edf9c38cdeb588a91b24fc5b61388c5be41282b90600090a250565b6000611f4b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661132d9092919063ffffffff16565b8051909150156113045780806020019051810190611f699190612744565b611304576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016105f8565b606082471015612087576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016105f8565b73ffffffffffffffffffffffffffffffffffffffff85163b612105576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105f8565b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161212e9190612766565b60006040518083038185875af1925050503d806000811461216b576040519150601f19603f3d011682016040523d82523d6000602084013e612170565b606091505b509150915061218082828661241c565b979650505050505050565b61130473ffffffffffffffffffffffffffffffffffffffff841683836121d6565b6000816121c7576121c264e8d4a5100084612782565b61052e565b61052e8364e8d4a5100061246f565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526113049084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401611282565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152600091908416906370a0823190602401602060405180830381865afa15801561229c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052e91906126d5565b60008183106122cf578161052e565b5090919050565b61130473ffffffffffffffffffffffffffffffffffffffff84168330846123be565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff828116600483015260009161052e918516906370a0823190602401602060405180830381865afa15801561236b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061238f91906126d5565b6124a1565b60008282808211156123ab576002925050506104ab565b80821015610d56576000925050506104ab565b60405173ffffffffffffffffffffffffffffffffffffffff8085166024830152831660448201526064810182905261164c9085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401611282565b6060831561242b57508161052e565b82511561243b5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105f891906124d6565b600061247b828461271d565b1561248757600161248a565b60005b60ff166124978385612782565b61052e91906126c2565b60006104ab64e8d4a5100083612796565b60005b838110156124cd5781810151838201526020016124b5565b50506000910152565b60208152600082518060208401526124f58160408501602087016124b2565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461254b57600080fd5b919050565b6000806040838503121561256357600080fd5b61256c83612527565b946020939093013593505050565b6000806040838503121561258d57600080fd5b8235915061259d60208401612527565b90509250929050565b6000806000606084860312156125bb57600080fd5b6125c484612527565b92506125d260208501612527565b9150604084013590509250925092565b6000602082840312156125f457600080fd5b5035919050565b60006020828403121561260d57600080fd5b61052e82612527565b6000806040838503121561262957600080fd5b61263283612527565b915061259d60208401612527565b600181811c9082168061265457607f821691505b60208210810361268d577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104ab576104ab612693565b6000602082840312156126e757600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261272c5761272c6126ee565b500690565b818103818111156104ab576104ab612693565b60006020828403121561275657600080fd5b8151801515811461052e57600080fd5b600082516127788184602087016124b2565b9190910192915050565b600082612791576127916126ee565b500490565b80820281158282048414176104ab576104ab61269356fea2646970667358221220a556fb35975450efe39f9db04b9e755789c41b1914ee0c4d211a6d5253b1966a64736f6c63430008110033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000d05ace63789ccb35b9ce71d01e4d632a0486da4b000000000000000000000000605d26fbd5be761089281d5cec2ce86eea667109000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
-----Decoded View---------------
Arg [0] : reserve (address): 0xD05aCe63789cCb35B9cE71d01e4d632a0486Da4B
Arg [1] : dsu (address): 0x605D26FBd5be761089281d5cec2Ce86eeA667109
Arg [2] : usdc (address): 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000d05ace63789ccb35b9ce71d01e4d632a0486da4b
Arg [1] : 000000000000000000000000605d26fbd5be761089281d5cec2ce86eea667109
Arg [2] : 000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ 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.