Source Code
Advanced mode: Intended for advanced users or developers and will display all Internal Transactions including zero value transfers.
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Block | From | To | ||||
|---|---|---|---|---|---|---|---|
| 31100363 | 5 days ago | 0 FRAX | |||||
| 31100363 | 5 days ago | 0 FRAX | |||||
| 31100363 | 5 days ago | 0 FRAX | |||||
| 31100363 | 5 days ago | 0 FRAX | |||||
| 31100363 | 5 days ago | 0 FRAX | |||||
| 31100363 | 5 days ago | 0 FRAX | |||||
| 31100363 | 5 days ago | 0 FRAX | |||||
| 31100363 | 5 days ago | 0 FRAX | |||||
| 31100363 | 5 days ago | 0 FRAX | |||||
| 31100363 | 5 days ago | 0 FRAX | |||||
| 31100363 | 5 days ago | 0 FRAX | |||||
| 31100363 | 5 days ago | 0 FRAX | |||||
| 31100363 | 5 days ago | 0 FRAX | |||||
| 31100363 | 5 days ago | 0 FRAX | |||||
| 31100363 | 5 days ago | 0 FRAX | |||||
| 29575997 | 40 days ago | 0 FRAX | |||||
| 29575997 | 40 days ago | 0 FRAX | |||||
| 29575997 | 40 days ago | 0 FRAX | |||||
| 29575997 | 40 days ago | 0 FRAX | |||||
| 29575997 | 40 days ago | 0 FRAX | |||||
| 29575997 | 40 days ago | 0 FRAX | |||||
| 29575997 | 40 days ago | 0 FRAX | |||||
| 29575997 | 40 days ago | 0 FRAX | |||||
| 29575997 | 40 days ago | 0 FRAX | |||||
| 29575997 | 40 days ago | 0 FRAX |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
AmoManagerV2
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.20;
import "@openzeppelin/contracts-5/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts-5/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts-5/token/ERC20/extensions/IERC20Metadata.sol";
import "@openzeppelin/contracts-5/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts-5/token/ERC20/extensions/IERC20Permit.sol";
import "@openzeppelin/contracts-5/utils/math/Math.sol";
import "contracts/lending/core/interfaces/IPriceOracleGetter.sol";
import "contracts/dusd/OracleAware.sol";
import "contracts/dusd/CollateralVault.sol";
import "contracts/dusd/AmoDebtToken.sol";
import "contracts/token/IERC20Stablecoin.sol";
import "contracts/common/BasisPointConstants.sol";
/**
* @title AmoManagerV2
* @notice Unified AMO operations manager for both stable AMO (dUSD mint/burn) and collateral AMO (borrow/repay)
* @dev Provides atomic operations with invariant checks and unified debt token accounting
*/
contract AmoManagerV2 is OracleAware, ReentrancyGuard {
using SafeERC20 for IERC20Metadata;
using EnumerableSet for EnumerableSet.AddressSet;
/* Core state */
AmoDebtToken public immutable debtToken;
IERC20Stablecoin public immutable dusd;
address public collateralVault;
EnumerableSet.AddressSet private _allowedAmoWallets;
uint256 public tolerance;
uint256 public pegDeviationBps;
/* Roles */
bytes32 public constant AMO_INCREASE_ROLE = keccak256("AMO_INCREASE_ROLE");
bytes32 public constant AMO_DECREASE_ROLE = keccak256("AMO_DECREASE_ROLE");
/* Events */
event Borrowed(
address indexed vault,
address indexed wallet,
address indexed asset,
uint256 collateralAmount,
uint256 debtMinted
);
event Repaid(
address indexed vault,
address indexed wallet,
address indexed asset,
uint256 collateralAmount,
uint256 debtBurned
);
event CollateralVaultSet(address indexed oldVault, address indexed newVault);
event AmoWalletAllowedSet(address indexed wallet, bool allowed);
event ToleranceSet(uint256 oldTolerance, uint256 newTolerance);
event PegDeviationBpsSet(uint256 oldDeviationBps, uint256 newDeviationBps);
/* Errors */
error UnsupportedVault(address vault);
error UnsupportedCollateral(address asset);
error UnsupportedAmoWallet(address wallet);
error DebtTokenProhibited();
error InvariantViolation(uint256 expected, uint256 actual);
error SlippageDebtMintTooLow(uint256 actualDebtMinted, uint256 minDebtMinted);
error SlippageDebtBurnTooHigh(uint256 actualDebtBurned, uint256 maxDebtBurned);
error PegDeviationExceeded(address asset, uint256 price, uint256 baseUnit, uint256 maxDeviationBps);
error PegDeviationOutOfRange(uint256 requested, uint256 maxAllowed);
error PermitFailed();
/**
* @notice Initializes the AmoManagerV2 contract
* @param _oracle The oracle for price feeds
* @param _debtToken The AMO debt token for unified accounting
* @param _dusd The dUSD stablecoin token
* @param _collateralVault The single accounting collateral vault address
*/
constructor(
IPriceOracleGetter _oracle,
AmoDebtToken _debtToken,
IERC20Stablecoin _dusd,
address _collateralVault
) OracleAware(_oracle, _oracle.BASE_CURRENCY_UNIT()) {
debtToken = _debtToken;
dusd = _dusd;
// Set tolerance to 1 base unit to allow for minimal rounding differences independent of decimals
tolerance = 1;
// Default peg deviation guard to 1% to surface oracle drift or decimal mismatches
pegDeviationBps = BasisPointConstants.ONE_PERCENT_BPS;
if (_collateralVault == address(0)) {
revert UnsupportedVault(_collateralVault);
}
collateralVault = _collateralVault;
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_ensurePegGuard();
}
/* Stable AMO Operations */
/**
* @notice Increases AMO supply by minting dUSD to a wallet and equal debt tokens to the vault atomically
* @param amount The amount of dUSD to mint (debt tokens minted will equal this in base value)
* @param wallet The AMO wallet to receive minted dUSD
* @dev Only callable by AMO_INCREASE_ROLE. Ensures debt minted equals dUSD value
*/
function increaseAmoSupply(uint256 amount, address wallet) external onlyRole(AMO_INCREASE_ROLE) nonReentrant {
if (!_allowedAmoWallets.contains(wallet)) {
revert UnsupportedAmoWallet(wallet);
}
_ensurePegGuard();
// Convert dUSD amount to base value for debt token minting
uint256 dusdBaseValue = dusdAmountToBaseValue(amount);
uint256 debtAmount = baseToDebtUnits(dusdBaseValue);
// Record initial supplies
uint256 preDebtSupply = debtToken.totalSupply();
uint256 preDusdSupply = dusd.totalSupply();
// Mint debt tokens to the accounting vault
debtToken.mintToVault(collateralVault, debtAmount);
// Mint dUSD to the AMO wallet
dusd.mint(wallet, amount);
// Verify the supplies increased correctly
uint256 postDebtSupply = debtToken.totalSupply();
uint256 postDusdSupply = dusd.totalSupply();
// Invariant: debt token increase must match dUSD increase in base value terms
uint256 actualDebtIncrease = postDebtSupply - preDebtSupply;
uint256 actualDusdIncrease = postDusdSupply - preDusdSupply;
uint256 expectedDebtFromDusd = baseToDebtUnits(dusdAmountToBaseValue(actualDusdIncrease));
if (_outsideTolerance(actualDebtIncrease, expectedDebtFromDusd)) {
revert InvariantViolation(expectedDebtFromDusd, actualDebtIncrease);
}
}
/**
* @notice Decreases AMO supply by pulling dUSD from a wallet and burning equal debt tokens atomically
* @param amount The amount of dUSD to burn (debt tokens burned will equal this in base value)
* @param wallet The AMO wallet to pull dUSD from (must approve manager)
* @dev Only callable by AMO_DECREASE_ROLE. Ensures debt burned equals dUSD value
*/
function decreaseAmoSupply(uint256 amount, address wallet) external onlyRole(AMO_DECREASE_ROLE) nonReentrant {
if (!_allowedAmoWallets.contains(wallet)) {
revert UnsupportedAmoWallet(wallet);
}
_ensurePegGuard();
// Convert dUSD amount to base value for debt token burning
uint256 dusdBaseValue = dusdAmountToBaseValue(amount);
uint256 debtAmount = baseToDebtUnits(dusdBaseValue);
// Record initial supplies
uint256 preDebtSupply = debtToken.totalSupply();
uint256 preDusdSupply = dusd.totalSupply();
// Pull dUSD from the AMO wallet to this manager (requires prior approval)
IERC20Metadata(address(dusd)).safeTransferFrom(wallet, address(this), amount);
// Burn dUSD from manager's own balance
dusd.burn(amount);
// Withdraw debt tokens from the vault to this manager and burn them
CollateralVault(collateralVault).withdrawTo(address(this), debtAmount, address(debtToken));
debtToken.burn(debtAmount);
// Verify the supplies decreased correctly
uint256 postDebtSupply = debtToken.totalSupply();
uint256 postDusdSupply = dusd.totalSupply();
// Invariant: debt token decrease must match dUSD decrease in base value terms
uint256 actualDebtDecrease = preDebtSupply - postDebtSupply;
uint256 actualDusdDecrease = preDusdSupply - postDusdSupply;
uint256 expectedDebtFromDusd = baseToDebtUnits(dusdAmountToBaseValue(actualDusdDecrease));
if (_outsideTolerance(actualDebtDecrease, expectedDebtFromDusd)) {
revert InvariantViolation(expectedDebtFromDusd, actualDebtDecrease);
}
}
/* Collateral AMO Operations */
/**
* @notice Borrows collateral from vault to endpoint with invariant checks
* @param wallet The AMO wallet to receive the borrowed collateral
* @param asset The collateral asset to borrow
* @param amount The amount of collateral to borrow
* @param minDebtMinted Minimum debt token amount expected (slippage protection)
* @dev Enforces value conservation: vault total value must remain unchanged within tolerance
*/
function borrowTo(
address wallet,
address asset,
uint256 amount,
uint256 minDebtMinted
) external onlyRole(AMO_INCREASE_ROLE) nonReentrant {
if (!_allowedAmoWallets.contains(wallet)) {
revert UnsupportedAmoWallet(wallet);
}
if (!CollateralVault(collateralVault).isCollateralSupported(asset)) {
revert UnsupportedCollateral(asset);
}
if (asset == address(debtToken)) {
revert DebtTokenProhibited();
}
_ensurePegGuard();
uint256 preValue = CollateralVault(collateralVault).totalValue();
// Calculate debt amount to mint (equal to asset value)
uint256 assetValue = CollateralVault(collateralVault).assetValueFromAmount(amount, asset);
uint256 debtAmount = baseToDebtUnits(assetValue);
if (debtAmount < minDebtMinted) {
revert SlippageDebtMintTooLow(debtAmount, minDebtMinted);
}
// Mint debt tokens to the vault
debtToken.mintToVault(collateralVault, debtAmount);
// Withdraw collateral to endpoint
CollateralVault(collateralVault).withdrawTo(wallet, amount, asset);
uint256 postValue = CollateralVault(collateralVault).totalValue();
if (postValue + tolerance < preValue) {
revert InvariantViolation(preValue, postValue);
}
emit Borrowed(collateralVault, wallet, asset, amount, debtAmount);
}
/**
* @notice Repays borrowed collateral from endpoint to vault with invariant checks
* @param wallet The AMO wallet providing the collateral for repayment
* @param asset The collateral asset being repaid
* @param amount The amount of collateral to repay
* @param maxDebtBurned Maximum debt amount acceptable to burn (slippage protection)
* @dev Enforces value conservation: vault total value must remain unchanged within tolerance
*/
function repayFrom(
address wallet,
address asset,
uint256 amount,
uint256 maxDebtBurned
) public onlyRole(AMO_DECREASE_ROLE) nonReentrant {
if (!_allowedAmoWallets.contains(wallet)) {
revert UnsupportedAmoWallet(wallet);
}
if (!CollateralVault(collateralVault).isCollateralSupported(asset)) {
revert UnsupportedCollateral(asset);
}
if (asset == address(debtToken)) {
revert DebtTokenProhibited();
}
_ensurePegGuard();
uint256 preValue = CollateralVault(collateralVault).totalValue();
// Calculate debt amount to burn (equal to asset value)
uint256 assetValue = CollateralVault(collateralVault).assetValueFromAmount(amount, asset);
uint256 debtAmount = baseToDebtUnits(assetValue);
if (debtAmount > maxDebtBurned) {
revert SlippageDebtBurnTooHigh(debtAmount, maxDebtBurned);
}
// Transfer collateral from endpoint to vault
IERC20Metadata(asset).safeTransferFrom(wallet, collateralVault, amount);
// Withdraw debt tokens from the vault to this manager and burn them
CollateralVault(collateralVault).withdrawTo(address(this), debtAmount, address(debtToken));
debtToken.burn(debtAmount);
uint256 postValue = CollateralVault(collateralVault).totalValue();
if (postValue + tolerance < preValue) {
revert InvariantViolation(preValue, postValue);
}
emit Repaid(collateralVault, wallet, asset, amount, debtAmount);
}
/**
* @notice Repay using EIP-2612 permit for collateral tokens that support it
* @dev Skips the permit call if allowance already covers the amount.
*/
function repayWithPermit(
address wallet,
address asset,
uint256 amount,
uint256 maxDebtBurned,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external onlyRole(AMO_DECREASE_ROLE) nonReentrant {
if (!_hasSufficientAllowance(wallet, asset, amount)) {
try IERC20Permit(asset).permit(wallet, address(this), amount, deadline, v, r, s) {} catch {
if (!_hasSufficientAllowance(wallet, asset, amount)) {
revert PermitFailed();
}
}
}
repayFrom(wallet, asset, amount, maxDebtBurned);
}
/* Helper Functions */
/**
* @notice Converts base value to debt token units
* @param baseValue The base value to convert
* @return The equivalent amount in debt token units
*/
function baseToDebtUnits(uint256 baseValue) public view returns (uint256) {
uint8 debtDecimals = debtToken.decimals();
return Math.mulDiv(baseValue, 10 ** debtDecimals, baseCurrencyUnit);
}
/**
* @notice Converts dUSD amount to base value
* @param dusdAmount The dUSD amount to convert
* @return The equivalent base value
*/
function dusdAmountToBaseValue(uint256 dusdAmount) public view returns (uint256) {
uint8 dusdDecimals = IERC20Metadata(address(dusd)).decimals();
return Math.mulDiv(dusdAmount, baseCurrencyUnit, 10 ** dusdDecimals);
}
/* Admin Functions */
/**
* @notice Sets the single accounting collateral vault
* @param newVault The new collateral vault address
* @dev Only callable by DEFAULT_ADMIN_ROLE
*/
function setCollateralVault(address newVault) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (newVault == address(0)) {
revert UnsupportedVault(newVault);
}
address oldVault = collateralVault;
collateralVault = newVault;
emit CollateralVaultSet(oldVault, newVault);
}
/**
* @notice Sets AMO wallet allowed status
* @param wallet The AMO wallet address
* @param allowed Whether the wallet should be allowed
* @dev Only callable by DEFAULT_ADMIN_ROLE
*/
function setAmoWalletAllowed(address wallet, bool allowed) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (allowed) {
_allowedAmoWallets.add(wallet);
} else {
_allowedAmoWallets.remove(wallet);
}
emit AmoWalletAllowedSet(wallet, allowed);
}
/**
* @notice Sets the tolerance for invariant checks
* @param newTolerance The new tolerance value in base units
* @dev Only callable by DEFAULT_ADMIN_ROLE
*/
function setTolerance(uint256 newTolerance) external onlyRole(DEFAULT_ADMIN_ROLE) {
uint256 oldTolerance = tolerance;
tolerance = newTolerance;
emit ToleranceSet(oldTolerance, newTolerance);
}
/**
* @notice Sets the maximum allowed peg deviation in basis points
* @param newPegDeviationBps The new deviation tolerance in basis points
* @dev Only callable by DEFAULT_ADMIN_ROLE
*/
function setPegDeviationBps(uint256 newPegDeviationBps) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (newPegDeviationBps > BasisPointConstants.ONE_HUNDRED_PERCENT_BPS) {
revert PegDeviationOutOfRange(newPegDeviationBps, BasisPointConstants.ONE_HUNDRED_PERCENT_BPS);
}
uint256 oldPegDeviationBps = pegDeviationBps;
pegDeviationBps = newPegDeviationBps;
emit PegDeviationBpsSet(oldPegDeviationBps, newPegDeviationBps);
}
function _hasSufficientAllowance(address wallet, address asset, uint256 amount) private view returns (bool) {
return IERC20Metadata(asset).allowance(wallet, address(this)) >= amount;
}
/* View Functions */
/**
* @notice Returns all allowed AMO wallets
* @return Array of allowed wallet addresses
*/
function getAllowedAmoWallets() external view returns (address[] memory) {
return _allowedAmoWallets.values();
}
/**
* @notice Checks if an AMO wallet is allowed
* @param wallet The wallet address to check
* @return Whether the wallet is allowed
*/
function isAmoWalletAllowed(address wallet) external view returns (bool) {
return _allowedAmoWallets.contains(wallet);
}
/**
* @notice Returns the number of allowed AMO wallets
* @return The count of allowed wallets
*/
function getAllowedAmoWalletsLength() external view returns (uint256) {
return _allowedAmoWallets.length();
}
/**
* @notice Ensures we don't issue debt while dUSD is significantly off-peg
*/
function _ensurePegGuard() internal view {
uint256 guardBps = pegDeviationBps;
if (guardBps == 0) {
return;
}
_enforcePegForAsset(address(dusd), guardBps);
_enforcePegForAsset(address(debtToken), guardBps);
}
/**
* @notice Checks a specific asset oracle price against the base unit within allowed deviation
* @param asset The asset address to validate
* @param guardBps The maximum deviation allowed in basis points
*/
function _enforcePegForAsset(address asset, uint256 guardBps) internal view {
uint256 baseUnit = baseCurrencyUnit;
uint256 price = oracle.getAssetPrice(asset);
uint256 diff = price >= baseUnit ? price - baseUnit : baseUnit - price;
uint256 deviation = Math.mulDiv(diff, BasisPointConstants.ONE_HUNDRED_PERCENT_BPS, baseUnit);
if (deviation > guardBps) {
revert PegDeviationExceeded(asset, price, baseUnit, guardBps);
}
}
/**
* @notice Returns total debt token supply for telemetry
* @return The total supply of debt tokens
*/
function totalDebtSupply() external view returns (uint256) {
return debtToken.totalSupply();
}
function _outsideTolerance(uint256 actual, uint256 expected) internal view returns (bool) {
uint256 tol = tolerance;
if (actual + tol < expected) return true;
if (actual > expected + tol) return true;
return false;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
mapping(bytes32 role => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
return _roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
if (!hasRole(role, account)) {
_roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
if (hasRole(role, account)) {
_roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)
pragma solidity ^0.8.20;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.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}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* 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.
*/
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* 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 returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual 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 default value returned by this function, unless
* it's 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 returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual 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 `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` 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 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
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 `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* 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.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` 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.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
* ```
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @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 value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev 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);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @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 or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* 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.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @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`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Muldiv operation overflow.
*/
error MathOverflowedMulDiv();
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @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 towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
return a / b;
}
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
if (denominator <= prod1) {
revert MathOverflowedMulDiv();
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.20;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position is the index of the value in the `values` array plus 1.
// Position 0 is used to mean a value is not in the set.
mapping(bytes32 value => uint256) _positions;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._positions[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We cache the value's position to prevent multiple reads from the same storage slot
uint256 position = set._positions[value];
if (position != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 valueIndex = position - 1;
uint256 lastIndex = set._values.length - 1;
if (valueIndex != lastIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the lastValue to the index where the value to delete is
set._values[valueIndex] = lastValue;
// Update the tracked position of the lastValue (that was just moved)
set._positions[lastValue] = position;
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the tracked position for the deleted slot
delete set._positions[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._positions[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}// SPDX-License-Identifier: MIT
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.20;
library BasisPointConstants {
// Shared definitions of how we represent percentages and basis points
uint16 public constant ONE_BPS = 100; // 1 basis point with 2 decimals
uint32 public constant ONE_PERCENT_BPS = ONE_BPS * 100;
uint32 public constant ONE_HUNDRED_PERCENT_BPS = ONE_PERCENT_BPS * 100;
}// SPDX-License-Identifier: MIT
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.20;
import "@openzeppelin/contracts-5/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts-5/access/AccessControl.sol";
import "@openzeppelin/contracts-5/utils/structs/EnumerableSet.sol";
/**
* @title AmoDebtToken
* @notice ERC20 receipt token for AMO operations with transfer restrictions via allowlist
* @dev Transfer-restricted ERC20 that only allows allowlisted addresses to send/receive tokens.
* Used for unified accounting of AMO debt across collateral and stable AMO operations.
* Token name is "dTRINITY AMO Receipt" with symbol "amo-dUSD" or chain-specific variant.
*/
contract AmoDebtToken is ERC20, AccessControl {
using EnumerableSet for EnumerableSet.AddressSet;
/* Core state */
EnumerableSet.AddressSet private _allowlist;
/* Roles */
bytes32 public constant AMO_MANAGER_ROLE = keccak256("AMO_MANAGER_ROLE");
/* Events */
event AllowlistSet(address indexed account, bool isAllowlisted);
/* Errors */
error NotAllowlisted(address account);
error InvalidVault(address vault);
/**
* @notice Initializes the AmoDebtToken with name and symbol
* @param name The token name (e.g., "dTRINITY AMO Receipt")
* @param symbol The token symbol (e.g., "amo-dUSD")
* @dev Grants DEFAULT_ADMIN_ROLE to the deployer
*/
constructor(string memory name, string memory symbol) ERC20(name, symbol) {
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
/**
* @notice Returns 18 decimals for unified debt accounting
* @return The number of decimals (18)
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @notice Sets the allowlist status for an address
* @param account The address to set allowlist status for
* @param allowed Whether the address should be allowlisted
* @dev Only callable by DEFAULT_ADMIN_ROLE
*/
function setAllowlisted(address account, bool allowed) public onlyRole(DEFAULT_ADMIN_ROLE) {
if (allowed) {
_allowlist.add(account);
} else {
_allowlist.remove(account);
}
emit AllowlistSet(account, allowed);
}
/**
* @notice Checks if an address is allowlisted
* @param account The address to check
* @return Whether the address is allowlisted
*/
function isAllowlisted(address account) public view returns (bool) {
return _allowlist.contains(account);
}
/**
* @notice Returns all allowlisted addresses
* @return Array of allowlisted addresses
*/
function getAllowlist() public view returns (address[] memory) {
return _allowlist.values();
}
/**
* @notice Returns the number of allowlisted addresses
* @return The count of allowlisted addresses
*/
function getAllowlistLength() public view returns (uint256) {
return _allowlist.length();
}
/**
* @notice Mints debt tokens to an allowlisted vault
* @param vault The vault address to mint tokens to
* @param amount The amount of tokens to mint
* @dev Only callable by AMO_MANAGER_ROLE and vault must be allowlisted
*/
function mintToVault(address vault, uint256 amount) public onlyRole(AMO_MANAGER_ROLE) {
if (!_allowlist.contains(vault)) {
revert InvalidVault(vault);
}
_mint(vault, amount);
}
/**
* @notice Burns debt tokens from an allowlisted vault
* @param vault The vault address to burn tokens from
* @param amount The amount of tokens to burn
* @dev Only callable by AMO_MANAGER_ROLE and vault must be allowlisted
*/
function burnFromVault(address vault, uint256 amount) public onlyRole(AMO_MANAGER_ROLE) {
if (!_allowlist.contains(vault)) {
revert InvalidVault(vault);
}
_burn(vault, amount);
}
/**
* @notice Burns debt tokens held by the caller
* @param amount The amount of tokens to burn
* @dev Only callable by AMO_MANAGER_ROLE. Intended for manager after withdrawing debt tokens
*/
function burn(uint256 amount) public onlyRole(AMO_MANAGER_ROLE) {
_burn(msg.sender, amount);
}
/**
* @notice Override _update to enforce allowlist restrictions
* @param from The address tokens are transferred from (zero address for minting)
* @param to The address tokens are transferred to (zero address for burning)
* @param value The amount of tokens being transferred
* @dev Reverts if either sender or recipient is not allowlisted (except for mint/burn)
*/
function _update(address from, address to, uint256 value) internal override {
// Allow minting (from == address(0)) and burning (to == address(0))
if (from != address(0) && !_allowlist.contains(from)) {
revert NotAllowlisted(from);
}
if (to != address(0) && !_allowlist.contains(to)) {
revert NotAllowlisted(to);
}
super._update(from, to, value);
}
/**
* @notice Override transferFrom to also check msg.sender allowlist
* @param from The address to transfer tokens from
* @param to The address to transfer tokens to
* @param value The amount of tokens to transfer
* @return Success boolean
* @dev Reverts if msg.sender is not allowlisted
*/
function transferFrom(address from, address to, uint256 value) public override returns (bool) {
// Check that msg.sender (the spender) is also allowlisted
if (!_allowlist.contains(msg.sender)) {
revert NotAllowlisted(msg.sender);
}
return super.transferFrom(from, to, value);
}
}// SPDX-License-Identifier: MIT
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.20;
import "@openzeppelin/contracts-5/access/AccessControl.sol";
import "@openzeppelin/contracts-5/token/ERC20/extensions/IERC20Metadata.sol";
import "@openzeppelin/contracts-5/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts-5/utils/structs/EnumerableSet.sol";
import "contracts/shared/Constants.sol";
import "contracts/lending/core/interfaces/IPriceOracleGetter.sol";
import "contracts/dusd/OracleAware.sol";
/**
* @title CollateralVault
* @notice Abstract contract for any contract that manages collateral assets
\ */
abstract contract CollateralVault is AccessControl, OracleAware {
using SafeERC20 for IERC20Metadata;
using EnumerableSet for EnumerableSet.AddressSet;
/* Core state */
EnumerableSet.AddressSet internal _supportedCollaterals;
/* Events */
event CollateralAllowed(address indexed collateralAsset);
event CollateralDisallowed(address indexed collateralAsset);
/* Roles */
bytes32 public constant COLLATERAL_MANAGER_ROLE = keccak256("COLLATERAL_MANAGER_ROLE");
bytes32 public constant COLLATERAL_STRATEGY_ROLE = keccak256("COLLATERAL_STRATEGY_ROLE");
bytes32 public constant COLLATERAL_WITHDRAWER_ROLE = keccak256("COLLATERAL_WITHDRAWER_ROLE");
/* Errors */
error UnsupportedCollateral(address collateralAsset);
error CollateralAlreadyAllowed(address collateralAsset);
error NoOracleSupport(address collateralAsset);
error FailedToAddCollateral(address collateralAsset);
error CollateralNotSupported(address collateralAsset);
error MustSupportAtLeastOneCollateral();
error FailedToRemoveCollateral(address collateralAsset);
/**
* @notice Initializes the vault with an oracle and sets up initial roles
* @dev Grants all roles to the contract deployer initially
* @param oracle The price oracle to use for collateral valuation
*/
constructor(IPriceOracleGetter oracle) OracleAware(oracle, Constants.ORACLE_BASE_CURRENCY_UNIT) {
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender); // This is the super admin
grantRole(COLLATERAL_MANAGER_ROLE, msg.sender);
grantRole(COLLATERAL_WITHDRAWER_ROLE, msg.sender);
grantRole(COLLATERAL_STRATEGY_ROLE, msg.sender);
}
/* Deposit */
/**
* @notice Deposit collateral into the vault
* @param collateralAmount The amount of collateral to deposit
* @param collateralAsset The address of the collateral asset
*/
function deposit(uint256 collateralAmount, address collateralAsset) public {
if (!_supportedCollaterals.contains(collateralAsset)) {
revert UnsupportedCollateral(collateralAsset);
}
IERC20Metadata(collateralAsset).safeTransferFrom(msg.sender, address(this), collateralAmount);
}
/* Withdrawal */
/**
* @notice Withdraws collateral from the vault
* @param collateralAmount The amount of collateral to withdraw
* @param collateralAsset The address of the collateral asset
*/
function withdraw(uint256 collateralAmount, address collateralAsset) public onlyRole(COLLATERAL_WITHDRAWER_ROLE) {
return _withdraw(msg.sender, collateralAmount, collateralAsset);
}
/**
* @notice Withdraws collateral from the vault to a specific address
* @param recipient The address receiving the collateral
* @param collateralAmount The amount of collateral to withdraw
* @param collateralAsset The address of the collateral asset
*/
function withdrawTo(
address recipient,
uint256 collateralAmount,
address collateralAsset
) public onlyRole(COLLATERAL_WITHDRAWER_ROLE) {
return _withdraw(recipient, collateralAmount, collateralAsset);
}
/**
* @notice Internal function to withdraw collateral from the vault
* @param withdrawer The address withdrawing the collateral
* @param collateralAmount The amount of collateral to withdraw
* @param collateralAsset The address of the collateral asset
*/
function _withdraw(address withdrawer, uint256 collateralAmount, address collateralAsset) internal {
IERC20Metadata(collateralAsset).safeTransfer(withdrawer, collateralAmount);
}
/* Collateral Info */
/**
* @notice Calculates the total value of all assets in the vault
* @return usdValue The total value of all assets in USD
*/
function totalValue() public view virtual returns (uint256 usdValue);
/**
* @notice Calculates the USD value of a given amount of an asset
* @param assetAmount The amount of the asset
* @param asset The address of the asset
* @return usdValue The USD value of the asset
*/
function assetValueFromAmount(uint256 assetAmount, address asset) public view returns (uint256 usdValue) {
uint256 assetPrice = oracle.getAssetPrice(asset);
uint8 assetDecimals = IERC20Metadata(asset).decimals();
return (assetPrice * assetAmount) / (10 ** assetDecimals);
}
/**
* @notice Calculates the amount of an asset that corresponds to a given USD value
* @param usdValue The USD value
* @param asset The address of the asset
* @return assetAmount The amount of the asset
*/
function assetAmountFromValue(uint256 usdValue, address asset) public view returns (uint256 assetAmount) {
uint256 assetPrice = oracle.getAssetPrice(asset);
uint8 assetDecimals = IERC20Metadata(asset).decimals();
return (usdValue * (10 ** assetDecimals)) / assetPrice;
}
/* Collateral management */
/**
* @notice Allows a new collateral asset
* @param collateralAsset The address of the collateral asset
*/
function allowCollateral(address collateralAsset) public onlyRole(COLLATERAL_MANAGER_ROLE) {
if (_supportedCollaterals.contains(collateralAsset)) {
revert CollateralAlreadyAllowed(collateralAsset);
}
if (oracle.getAssetPrice(collateralAsset) == 0) {
revert NoOracleSupport(collateralAsset);
}
if (!_supportedCollaterals.add(collateralAsset)) {
revert FailedToAddCollateral(collateralAsset);
}
emit CollateralAllowed(collateralAsset);
}
/**
* @notice Disallows a previously supported collateral asset
* @dev Requires at least one collateral asset to remain supported
* @param collateralAsset The address of the collateral asset to disallow
*/
function disallowCollateral(address collateralAsset) public onlyRole(COLLATERAL_MANAGER_ROLE) {
if (!_supportedCollaterals.contains(collateralAsset)) {
revert CollateralNotSupported(collateralAsset);
}
if (_supportedCollaterals.length() <= 1) {
revert MustSupportAtLeastOneCollateral();
}
if (!_supportedCollaterals.remove(collateralAsset)) {
revert FailedToRemoveCollateral(collateralAsset);
}
emit CollateralDisallowed(collateralAsset);
}
/**
* @notice Checks if a given asset is supported as collateral
* @param collateralAsset The address of the collateral asset to check
* @return bool True if the asset is supported, false otherwise
*/
function isCollateralSupported(address collateralAsset) public view returns (bool) {
return _supportedCollaterals.contains(collateralAsset);
}
/**
* @notice Returns a list of all supported collateral assets
* @return address[] Array of collateral asset addresses
*/
function listCollateral() public view returns (address[] memory) {
return _supportedCollaterals.values();
}
/**
* @notice Calculates the total USD value of all supported collateral assets in the vault
* @dev Iterates through all supported collaterals and sums their USD values
* @return uint256 The total value in USD
*/
function _totalValueOfSupportedCollaterals() internal view returns (uint256) {
uint256 totalUsdValue = 0;
for (uint256 i = 0; i < _supportedCollaterals.length(); i++) {
address collateral = _supportedCollaterals.at(i);
uint256 collateralPrice = oracle.getAssetPrice(collateral);
uint8 collateralDecimals = IERC20Metadata(collateral).decimals();
uint256 collateralValue = (collateralPrice * IERC20Metadata(collateral).balanceOf(address(this))) /
(10 ** collateralDecimals);
totalUsdValue += collateralValue;
}
return totalUsdValue;
}
}// SPDX-License-Identifier: MIT
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.20;
import "@openzeppelin/contracts-5/access/AccessControl.sol";
import "contracts/lending/core/interfaces/IPriceOracleGetter.sol";
/**
* @title OracleAware
* @notice Abstract contract that provides oracle functionality to other contracts
*/
abstract contract OracleAware is AccessControl {
/* Core state */
IPriceOracleGetter public oracle;
uint256 public baseCurrencyUnit;
/* Events */
event OracleSet(address indexed newOracle);
/* Errors */
error IncorrectBaseCurrencyUnit(uint256 baseCurrencyUnit);
/**
* @notice Initializes the contract with an oracle and base currency unit
* @param initialOracle The initial oracle to use for price feeds
* @param _baseCurrencyUnit The base currency unit for price calculations
* @dev Sets up the initial oracle and base currency unit values
*/
constructor(IPriceOracleGetter initialOracle, uint256 _baseCurrencyUnit) {
oracle = initialOracle;
baseCurrencyUnit = _baseCurrencyUnit;
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
/**
* @notice Sets the oracle to use for collateral valuation
* @param newOracle The new oracle to use
*/
function setOracle(IPriceOracleGetter newOracle) public onlyRole(DEFAULT_ADMIN_ROLE) {
if (newOracle.BASE_CURRENCY_UNIT() != baseCurrencyUnit) {
revert IncorrectBaseCurrencyUnit(baseCurrencyUnit);
}
oracle = newOracle;
emit OracleSet(address(newOracle));
}
/**
* @notice Updates the base currency unit used for price calculations
* @param _newBaseCurrencyUnit The new base currency unit to set
* @dev Only used if the oracle's base currency unit changes
*/
function setBaseCurrencyUnit(uint256 _newBaseCurrencyUnit) public onlyRole(DEFAULT_ADMIN_ROLE) {
baseCurrencyUnit = _newBaseCurrencyUnit;
}
}// SPDX-License-Identifier: AGPL-3.0
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.0;
/**
* @title IPriceOracleGetter
* @author Aave
* @notice Interface for the Aave price oracle.
*/
interface IPriceOracleGetter {
/**
* @notice Returns the base currency address
* @dev Address 0x0 is reserved for USD as base currency.
* @return Returns the base currency address.
*/
function BASE_CURRENCY() external view returns (address);
/**
* @notice Returns the base currency unit
* @dev 1 ether for ETH, 1e8 for USD.
* @return Returns the base currency unit.
*/
function BASE_CURRENCY_UNIT() external view returns (uint256);
/**
* @notice Returns the asset price in the base currency
* @param asset The address of the asset
* @return The price of the asset
*/
function getAssetPrice(address asset) external view returns (uint256);
}// SPDX-License-Identifier: MIT
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.0;
library Constants {
// Shared definitions of how we represent percentages and basis points
uint16 public constant ONE_BPS = 100; // 1 basis point with 2 decimals
uint32 public constant ONE_PERCENT_BPS = ONE_BPS * 100;
uint32 public constant ONE_HUNDRED_PERCENT_BPS = ONE_PERCENT_BPS * 100;
uint32 public constant ORACLE_BASE_CURRENCY_UNIT = 1e8;
}// SPDX-License-Identifier: Unlicense
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.20;
import "@openzeppelin/contracts-5/token/ERC20/IERC20.sol";
interface IERC20Stablecoin is IERC20 {
function mint(address to, uint256 amount) external;
function burn(uint256 amount) external;
function burnFrom(address account, uint256 amount) external;
function decimals() external view returns (uint8);
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"viaIR": true,
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"contract IPriceOracleGetter","name":"_oracle","type":"address"},{"internalType":"contract AmoDebtToken","name":"_debtToken","type":"address"},{"internalType":"contract IERC20Stablecoin","name":"_dusd","type":"address"},{"internalType":"address","name":"_collateralVault","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"DebtTokenProhibited","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"uint256","name":"baseCurrencyUnit","type":"uint256"}],"name":"IncorrectBaseCurrencyUnit","type":"error"},{"inputs":[{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"actual","type":"uint256"}],"name":"InvariantViolation","type":"error"},{"inputs":[],"name":"MathOverflowedMulDiv","type":"error"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"baseUnit","type":"uint256"},{"internalType":"uint256","name":"maxDeviationBps","type":"uint256"}],"name":"PegDeviationExceeded","type":"error"},{"inputs":[{"internalType":"uint256","name":"requested","type":"uint256"},{"internalType":"uint256","name":"maxAllowed","type":"uint256"}],"name":"PegDeviationOutOfRange","type":"error"},{"inputs":[],"name":"PermitFailed","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"uint256","name":"actualDebtBurned","type":"uint256"},{"internalType":"uint256","name":"maxDebtBurned","type":"uint256"}],"name":"SlippageDebtBurnTooHigh","type":"error"},{"inputs":[{"internalType":"uint256","name":"actualDebtMinted","type":"uint256"},{"internalType":"uint256","name":"minDebtMinted","type":"uint256"}],"name":"SlippageDebtMintTooLow","type":"error"},{"inputs":[{"internalType":"address","name":"wallet","type":"address"}],"name":"UnsupportedAmoWallet","type":"error"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"UnsupportedCollateral","type":"error"},{"inputs":[{"internalType":"address","name":"vault","type":"address"}],"name":"UnsupportedVault","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":false,"internalType":"bool","name":"allowed","type":"bool"}],"name":"AmoWalletAllowedSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"vault","type":"address"},{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateralAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"debtMinted","type":"uint256"}],"name":"Borrowed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldVault","type":"address"},{"indexed":true,"internalType":"address","name":"newVault","type":"address"}],"name":"CollateralVaultSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newOracle","type":"address"}],"name":"OracleSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldDeviationBps","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newDeviationBps","type":"uint256"}],"name":"PegDeviationBpsSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"vault","type":"address"},{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateralAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"debtBurned","type":"uint256"}],"name":"Repaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldTolerance","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTolerance","type":"uint256"}],"name":"ToleranceSet","type":"event"},{"inputs":[],"name":"AMO_DECREASE_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"AMO_INCREASE_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseCurrencyUnit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"baseValue","type":"uint256"}],"name":"baseToDebtUnits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"wallet","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"minDebtMinted","type":"uint256"}],"name":"borrowTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"collateralVault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"debtToken","outputs":[{"internalType":"contract AmoDebtToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"wallet","type":"address"}],"name":"decreaseAmoSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"dusd","outputs":[{"internalType":"contract IERC20Stablecoin","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dusdAmount","type":"uint256"}],"name":"dusdAmountToBaseValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllowedAmoWallets","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllowedAmoWalletsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"wallet","type":"address"}],"name":"increaseAmoSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"wallet","type":"address"}],"name":"isAmoWalletAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oracle","outputs":[{"internalType":"contract IPriceOracleGetter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pegDeviationBps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"wallet","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"maxDebtBurned","type":"uint256"}],"name":"repayFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"wallet","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"maxDebtBurned","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"repayWithPermit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"wallet","type":"address"},{"internalType":"bool","name":"allowed","type":"bool"}],"name":"setAmoWalletAllowed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newBaseCurrencyUnit","type":"uint256"}],"name":"setBaseCurrencyUnit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newVault","type":"address"}],"name":"setCollateralVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPriceOracleGetter","name":"newOracle","type":"address"}],"name":"setOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newPegDeviationBps","type":"uint256"}],"name":"setPegDeviationBps","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newTolerance","type":"uint256"}],"name":"setTolerance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tolerance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalDebtSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60c060409080825234620001b45760808162002ac28038038091620000258285620001cd565b833981010312620001b45780516001600160a01b039182821691829003620001b45760208101518381168103620001b45784820151918483168303620001b45760600151938416809403620001b4578451638c89b64f60e01b8152602081600481875afa908115620001c25760009162000185575b50600180546001600160a01b03199081169095179055600255620000be3362000207565b50600160035560805260a052600160075561271060085581156200016e576004541617600455620000ef3362000207565b50620000fa62000298565b5161262990816200049982396080518181816101e1015281816102370152818161044c01528181610ccc01528181611083015281816113cc015281816117d001528181611d050152612035015260a0518181816102f101528181610d1f0152818161140b01528181611c30015261200d0152f35b506024915190635e10ffb360e01b82526004820152fd5b90506020813d602011620001b9575b81620001a360209383620001cd565b81010312620001b45751386200009a565b600080fd5b3d915062000194565b86513d6000823e3d90fd5b601f909101601f19168101906001600160401b03821190821017620001f157604052565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b031660008181527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604081205490919060ff166200029457818052816020526040822081835260205260408220600160ff1982541617905533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8180a4600190565b5090565b6008548015620002ca57620002c89060018060a01b03620002be828260a05116620002f1565b60805116620002f1565b565b50565b91908203918211620002db57565b634e487b7160e01b600052601160045260246000fd5b60025460015460405163b3596f0760e01b81526001600160a01b03938416600482018190529493909160209183916024918391165afa908115620003da576000916200039f575b508181106200038d57826200035983620003538185620002cd565b620003e6565b11620003655750505050565b6084945060405193630907397b60e21b85526004850152602484015260448301526064820152fd5b826200035983620003538482620002cd565b906020823d602011620003d1575b81620003bc60209383620001cd565b81010312620003ce5750513862000338565b80fd5b3d9150620003ad565b6040513d6000823e3d90fd5b620f4240918183029160001984820993838086109503948086039514620004735784831115620004615782910981600003821680920460028082600302188083028203028083028203028083028203028083028203028083028203028092029003029360018380600003040190848311900302920304170290565b60405163227bc15360e01b8152600490fd5b50508092501562000482570490565b634e487b7160e01b600052601260045260246000fdfe608060408181526004918236101561001657600080fd5b600092833560e01c91826301ffc9a714611ad6575081630bece79c14611aae5781631489f10b14611a8e5781631921a00414611a115781631b57927a146119f2578163248a9ca3146119c857816329d1ff7b1461174e5781632f2ff15d1461172457816336568abe146116de5781633c5fd982146116895781633f4c555c1461135357816343ce5ecb14610ffa5781634a0bbabb14610fd85781635e570c8014610c6157816364192f2a14610c3a57816368a806c414610bb35781637a96fa9514610b6d5781637adbf97314610a7c5781637dc0d1d014610a5357816391d1485414610a0e5781639f7aee8314610971578163a217fddf14610956578163ac906e751461091b578163beab6e94146108fc578163caf5a3971461083d578163d2c2e7c014610382578163d547741f1461033f578163dce52dfa14610320578163de1409ce146102dc578163f3bddde1146102bd578163f6300bf51461021057508063f8d89898146101cd5763fe1bf3241461019057600080fd5b346101c957816003193601126101c957602090517f855d04232aa491f9e84353b3958a225d6be593571f1d863256669b6e8229525d8152f35b5080fd5b50346101c957816003193601126101c957517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b8383346101c957816003193601126101c95780516318160ddd60e01b8152926020908490817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa9182156102b25791610278575b6020925051908152f35b90506020823d6020116102aa575b8161029360209383611bb8565b810103126102a557602091519061026e565b600080fd5b3d9150610286565b9051903d90823e3d90fd5b5050346101c957816003193601126101c9576020906002549051908152f35b5050346101c957816003193601126101c957517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b5050346101c957816003193601126101c9576020906007549051908152f35b9190503461037e578060031936011261037e5761037a91356103756001610364611b29565b938387528660205286200154611fa9565b6121e6565b5080f35b8280fd5b90503461037e5761010036600319011261037e5761039e611b3f565b6103a6611b29565b9260443560643560a43560ff8116809103610839576103c3611ef1565b6103cb611fcf565b6103d683888761228f565b15610790575b506103e5611ef1565b6103ed611fcf565b6001600160a01b0384811660008181526006602052604090205490969015610779578181541697855192637d35e97760e11b8452808216998a848601526020948581602481855afa90811561076f578d91610742575b501561072b57817f00000000000000000000000000000000000000000000000000000000000000001690818c1461071b5761047c611ff2565b8851998d6306a61f7560e51b95868d52888d8981875afa9c8d1561071157829d6106dc575b508b5163e00cb4a560e01b81528881018c81526001600160a01b03909216602083015291908990839081906040010381875afa9081156106d157906106a2575b6104eb9150611cef565b978089116106865750888e9392610502928f61205f565b82855416803b1561037e57895163627160f360e11b815230818801908152602081018a90526001600160a01b03841660408201529091849183919082908490829060600103925af1801561067c57908391610668575b5050803b156101c95781809160248b5180948193630852cd8d60e31b83528c8b8401525af1801561065e57610646575b5050825416968651918252838284818b5afa91821561063c578b9261060d575b50806105b660075484611cd5565b106105f25750508451938452508201527f54d05ce5149ffe32f556bf78597c93c53f8a03ccaef629c485236f3e7c2229bb9190a4600160035580f35b8651638a21b25f60e01b815292830152602482015260449150fd5b9091508381813d8311610635575b6106258183611bb8565b810103126102a5575190386105a8565b503d61061b565b87513d8d823e3d90fd5b61064f90611b8e565b61065a578a38610588565b8a80fd5b89513d84823e3d90fd5b61067190611b8e565b6101c9578138610558565b8a513d85823e3d90fd5b866044918a8d5192633288636560e01b84528301526024820152fd5b508781813d83116106ca575b6106b88183611bb8565b810103126102a5576104eb90516104e1565b503d6106ae565b8c51903d90823e3d90fd5b8980929d9e508193503d831161070a575b6106f78183611bb8565b810103126102a557519a998e90886104a1565b503d6106ed565b8c513d84823e3d90fd5b885163c908adb560e01b81528590fd5b8751632762993f60e11b81528085018c9052602490fd5b6107629150863d8811610768575b61075a8183611bb8565b810190611cbd565b38610443565b503d610750565b89513d8f823e3d90fd5b84516332184be360e21b8152908101879052602490fd5b876001600160a01b0388811690813b1561037e5760e4888480948c978b51988996879563d505accf60e01b875216908501523060248501528a60448501526084356064850152608484015260c43560a4840152833560c48401525af19182610825575b50506108205761080482878661228f565b15610810575b386103dc565b825163b78cb0dd60e01b81528590fd5b61080a565b61082e90611b8e565b6108395787386107f3565b8780fd5b8284346108f957806003193601126108f9579080519182906005549182855260208095018093600584527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db090845b8181106108e557505050816108a1910382611bb8565b83519485948186019282875251809352850193925b8281106108c557505050500390f35b83516001600160a01b0316855286955093810193928101926001016108b6565b82548452928801926001928301920161088b565b80fd5b5050346101c957816003193601126101c9576020906005549051908152f35b5050346101c957816003193601126101c957602090517f9d6bad8599e4b9d405228287b23a6b0b8ce3cd1a8a88dd6f33fbba48615b4f558152f35b5050346101c957816003193601126101c95751908152602090f35b5050346101c957806003193601126101c95761098b611b3f565b9060243580151592838203610a0a577f4d1bcba22909ed929b2123a5d5c9a270f58fb0db0ecd28fe603d90eaacb42f2d926020926109c7611e99565b156109f2576109de6001600160a01b038316612525565b505b519384526001600160a01b031692a280f35b610a046001600160a01b038316612429565b506109e0565b8480fd5b90503461037e578160031936011261037e5781602093610a2c611b29565b92358152808552209060018060a01b0316600052825260ff81600020541690519015158152f35b5050346101c957816003193601126101c95760015490516001600160a01b039091168152602090f35b90503461037e57602036600319011261037e5780356001600160a01b0381169290839003610b6957610aac611e99565b8051638c89b64f60e01b8152906020828481875afa918215610b5f578592610b2b575b50600254809203610b16575050600180546001600160a01b03191683179055507f3f32684a32a11dabdbb8c0177de80aa3ae36a004d75210335b49e544e48cd0aa8280a280f35b51639b6812b960e01b81529182015260249150fd5b9091506020813d602011610b57575b81610b4760209383611bb8565b810103126102a557519038610acf565b3d9150610b3a565b81513d87823e3d90fd5b8380fd5b5050346101c95760203660031901126101c957602090610baa6001600160a01b03610b96611b3f565b166000526006602052604060002054151590565b90519015158152f35b90503461037e57602036600319011261037e57610bce611b3f565b90610bd7611e99565b6001600160a01b03918216928315610c24575080546001600160a01b031981168417909155167f2c9b4f5a59006f173f084ddbe758822a07431d43f4ef400a955472ddf8f91d0c8380a380f35b51635e10ffb360e01b8152908101839052602490fd5b8284346108f95760203660031901126108f95750610c5a60209235611cef565b9051908152f35b90503461037e578160031936011261037e57803591610c7e611b29565b90610c87611f4d565b610c8f611fcf565b6001600160a01b0382811660008181526006602052604090205415610fc25750610cb7611ff2565b610cc8610cc386611c1a565b611cef565b90807f00000000000000000000000000000000000000000000000000000000000000001695835196886318160ddd60e01b92838a52602097888b8b81875afa968715610fb8578a9b849b999a9b98610f82575b50867f000000000000000000000000000000000000000000000000000000000000000016968b8b51809b898252818b5afa998a15610f7857859a610f45575b508c5416853b15610a0a578a51631fa6592360e11b81526001600160a01b03909116818e01908152602081019290925290849082908190604001038183895af18015610f3b57908491610f27575b5050853b1561037e5788516340c10f1960e01b81526001600160a01b03909116818c01908152602081019290925290829082908190604001038183895af18015610f1d57918a959493918a93610efd575b50508751948580928582525afa928315610ef3579087918a94610ec2575b508887518094819382525afa958615610eb8578896610e84575b5050610e5292610e47610cc393610e4d93611ce2565b95611ce2565b611c1a565b90610e5d828461225b565b610e6a5784600160035580f35b51638a21b25f60e01b815292830152602482015260449150fd5b908093929650813d8311610eb1575b610e9d8183611bb8565b810103126102a55790519382610e47610e31565b503d610e93565b85513d8a823e3d90fd5b8281939295503d8311610eec575b610eda8183611bb8565b810103126102a5578690519238610e17565b503d610ed0565b86513d8b823e3d90fd5b909250610f0b919550611b8e565b610f19578688938a38610df9565b8880fd5b88513d84823e3d90fd5b610f3090611b8e565b61037e578238610da8565b8a513d86823e3d90fd5b8c80929b508196503d8311610f71575b610f5f8183611bb8565b810103126102a5578c93519838610d5a565b503d610f55565b8b513d87823e3d90fd5b9350965096508882813d8311610fb1575b610f9d8183611bb8565b810103126102a55789968b92519638610d1b565b503d610f93565b88513d85823e3d90fd5b846024918451916332184be360e21b8352820152fd5b8390346101c95760203660031901126101c957610ff3611e99565b3560025580f35b90503461037e5761100a36611b55565b61101695929395611f4d565b61101e611fcf565b60018060a01b039384871695611041876000526006602052604060002054151590565b15610779578581541695855192637d35e97760e11b8452818116998a8486015260209485816024818d5afa90811561076f578d91611336575b501561072b57827f00000000000000000000000000000000000000000000000000000000000000001698898c1461071b57908c9392916110b8611ff2565b89519a6306a61f7560e51b95868d52888d8981865afa9c8d1561132a57819d6112f6575b508b5163e00cb4a560e01b81528089018c81526001600160a01b03871660208201529091908a90839081906040010381875afa9081156112eb57906112bc575b6111269150611cef565b98808a106112a0575090818f9493923b15610a0a578b51631fa6592360e11b81526001600160a01b03909216828901908152602081018b90528591839182908490829060400103925af1801561129657908491611282575b50508386541690813b15610b69578a5163627160f360e11b81526001600160a01b03918216818901908152602081018c90529190931660408201528391839182908490829060600103925af1801561065e5761126e575b5050825416968651918252838284818b5afa91821561063c578b9261123f575b508061120360075484611cd5565b106105f25750508451938452508201527f8d2cf1d80f06f87e6690c4e9bbe4750f3f8affc42dea16d0d82687c849c4f4229190a4600160035580f35b9091508381813d8311611267575b6112578183611bb8565b810103126102a5575190386111f5565b503d61124d565b61127790611b8e565b61065a578a386111d5565b61128b90611b8e565b61037e57823861117e565b8b513d86823e3d90fd5b876044918b8e5192638ce27f3160e01b84528301526024820152fd5b508881813d83116112e4575b6112d28183611bb8565b810103126102a557611126905161111c565b503d6112c8565b8d51903d90823e3d90fd5b809c9d50898092503d8311611323575b6113108183611bb8565b810103126102a55799519a998e846110dc565b503d611306565b508b51903d90823e3d90fd5b61134d9150863d88116107685761075a8183611bb8565b3861107a565b90503461037e578160031936011261037e57803591611370611b29565b611378611ef1565b611380611fcf565b6001600160a01b038181166000818152600660205260409020549192911561167357506113ab611ff2565b6113b7610cc386611c1a565b83516318160ddd60e01b8082529096602093927f00000000000000000000000000000000000000000000000000000000000000008616918a91868b8b81875afa978815611669578a9b8499611633575b50807f00000000000000000000000000000000000000000000000000000000000000001696888b51809d898252818b5afa9b8c15610f7857859c6115fe575b50836114549130908a61205f565b863b15610b69578951630852cd8d60e31b938482528d8201528481602481838c5af18015610f78579085916115ea575b50508b5416803b15610b6957895163627160f360e11b815230818e01908152602081018490526001600160a01b03871660408201529091859183919082908490829060600103925af18015610f3b579084916115d6575b5050833b1561037e5788519182528a820152818160248183875af18015610f1d57918a9594939187936115ba575b50508751948580928582525afa928315610ef3579084918a94611589575b508887518094819382525afa928315610eb8578893611557575b5050610cc391610e47610e4d92610e5295611ce2565b90809350813d8311611582575b61156e8183611bb8565b810103126102a55790519082610e47611541565b503d611564565b8281939295503d83116115b3575b6115a18183611bb8565b810103126102a5578390519238611527565b503d611597565b9092506115c8919550611b8e565b610f19578388938a38611509565b6115df90611b8e565b61037e5782386114db565b6115f390611b8e565b610b69578338611484565b8980929d508196503d831161162c575b6116188183611bb8565b810103126102a5579251998c939083611446565b503d61160e565b9350975098508582813d8311611662575b61164e8183611bb8565b810103126102a55789988b92519738611407565b503d611644565b89513d85823e3d90fd5b846024918551916332184be360e21b8352820152fd5b9190503461037e57602036600319011261037e577f5711bde41b4f4146c2148af54d749f794c7016f066897809f58d83b338bb6e0391356116c8611e99565b600754908060075582519182526020820152a180f35b8383346101c957806003193601126101c9576116f8611b29565b90336001600160a01b03831603611715575061037a9192356121e6565b5163334bd91960e11b81528390fd5b9190503461037e578060031936011261037e5761037a91356117496001610364611b29565b612168565b90503461037e5761175e36611b55565b611769959295611ef1565b611771611fcf565b6001600160a01b0384811660008181526006602052604090205490969015610779578181541697855192637d35e97760e11b8452808216998a848601526020948581602481855afa90811561076f578d916119ab575b501561072b57817f00000000000000000000000000000000000000000000000000000000000000001690818c1461071b57611800611ff2565b8851998d6306a61f7560e51b95868d52888d8981875afa9c8d1561071157829d611978575b508b5163e00cb4a560e01b81528881018c81526001600160a01b03909216602083015291908990839081906040010381875afa9081156106d15790611945575b61186f9150611cef565b9780891161068657506118849189918e61205f565b818454168c813b156108f957895163627160f360e11b815230878201908152602081018a90526001600160a01b03851660408201529092839182908490829060600103925af1801561076f57611932575b50808c913b156101c95781809160248b5180948193630852cd8d60e31b83528c8b8401525af1801561065e57610646575050825416968651918252838284818b5afa91821561063c578b9261060d5750806105b660075484611cd5565b61193e909c919c611b8e565b9a386118d5565b508781813d8311611971575b61195b8183611bb8565b8101031261196d5761186f9051611865565b8e80fd5b503d611951565b9b9c5090888c813d83116119a4575b6119918183611bb8565b810103126108f9579a519b9a9088611825565b503d611987565b6119c29150863d88116107685761075a8183611bb8565b386117c7565b90503461037e57602036600319011261037e57816020936001923581528085522001549051908152f35b5050346101c957816003193601126101c9576020906008549051908152f35b8383346101c95760203660031901126101c9578235611a2e611e99565b620f4240808211611a735750907fa7988e31f84de01a1549a4220748e0900a4584640effc2b72696fb8a4db88a0291600854908060085582519182526020820152a180f35b8491604493519263228a16b560e01b84528301526024820152fd5b8284346108f95760203660031901126108f95750610c5a60209235611c1a565b90503461037e578260031936011261037e575490516001600160a01b03909116815260209150f35b84913461037e57602036600319011261037e573563ffffffff60e01b811680910361037e5760209250637965db0b60e01b8114908115611b18575b5015158152f35b6301ffc9a760e01b14905083611b11565b602435906001600160a01b03821682036102a557565b600435906001600160a01b03821682036102a557565b60809060031901126102a5576001600160a01b039060043582811681036102a5579160243590811681036102a557906044359060643590565b67ffffffffffffffff8111611ba257604052565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff821117611ba257604052565b908160209103126102a5575160ff811681036102a55790565b60ff16604d8111611c0457600a0a90565b634e487b7160e01b600052601160045260246000fd5b60405163313ce56760e01b8152906020826004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa8015611cb157611c7f92600091611c82575b50611c7960025491611bf3565b91611e23565b90565b611ca4915060203d602011611caa575b611c9c8183611bb8565b810190611bda565b38611c6c565b503d611c92565b6040513d6000823e3d90fd5b908160209103126102a5575180151581036102a55790565b91908201809211611c0457565b91908203918211611c0457565b60405163313ce56760e01b8152906020826004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa918215611cb157611c7f92611d4c91600091611d55575b50611bf3565b60025491611e23565b611d6e915060203d602011611caa57611c9c8183611bb8565b38611d46565b620f4240918183029160001984820993838086109503948086039514611dff5784831115611ded5782910981600003821680920460028082600302188083028203028083028203028083028203028083028203028083028203028092029003029360018380600003040190848311900302920304170290565b60405163227bc15360e01b8152600490fd5b505080925015611e0d570490565b634e487b7160e01b600052601260045260246000fd5b90918282029160001984820993838086109503948086039514611dff5784831115611ded5782910981600003821680920460028082600302188083028203028083028203028083028203028083028203028083028203028092029003029360018380600003040190848311900302920304170290565b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604081205460ff1615611ed35750565b6044906040519063e2517d3f60e01b82523360048301526024820152fd5b3360009081527f1c025d3a48b273ee95b866673d455ded2354b3fec99fd245da369c419654b09d60205260409020547f9d6bad8599e4b9d405228287b23a6b0b8ce3cd1a8a88dd6f33fbba48615b4f559060ff1615611ed35750565b3360009081527fdd7f85de517f2aa32b3532e7e369f65c4c2e6dcda6cd3ec83972be7965ca7aa060205260409020547f855d04232aa491f9e84353b3958a225d6be593571f1d863256669b6e8229525d9060ff1615611ed35750565b80600052600060205260406000203360005260205260ff6040600020541615611ed35750565b600260035414611fe0576002600355565b604051633ee5aeb560e01b8152600490fd5b600854801561205c5761205a906001600160a01b03612033827f00000000000000000000000000000000000000000000000000000000000000008316612307565b7f000000000000000000000000000000000000000000000000000000000000000016612307565b565b50565b6040516323b872dd60e01b602082019081526001600160a01b039384166024830152938316604482015260648082019590955293845267ffffffffffffffff919060a0850183811186821017611ba2576040521692600080938192519082875af1903d1561215a573d908111612146576040516120fd9392916120ec601f8201601f191660200183611bb8565b8152809260203d92013e5b83612590565b805190811515918261212b575b50506121135750565b60249060405190635274afe760e01b82526004820152fd5b61213e9250602080918301019101611cbd565b15388061210a565b634e487b7160e01b83526041600452602483fd5b506120fd91506060906120f7565b9060009180835282602052604083209160018060a01b03169182845260205260ff604084205416156000146121e157808352826020526040832082845260205260408320600160ff198254161790557f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d339380a4600190565b505090565b9060009180835282602052604083209160018060a01b03169182845260205260ff6040842054166000146121e15780835282602052604083208284526020526040832060ff1981541690557ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b339380a4600190565b906007548161226a8285611cd5565b106122875761227891611cd5565b1061228257600090565b600190565b505050600190565b604051636eb1769f60e11b81526001600160a01b0391821660048201523060248201529160209183916044918391165afa908115611cb1576000916122d5575b50101590565b90506020813d6020116122ff575b816122f060209383611bb8565b810103126102a55751386122cf565b3d91506122e3565b60025460015460405163b3596f0760e01b81526001600160a01b03938416600482018190529493909160209183916024918391165afa908115611cb1576000916123aa575b5081811061239b5782612368836123638185611ce2565b611d74565b116123735750505050565b6084945060405193630907397b60e21b85526004850152602484015260448301526064820152fd5b82612368836123638482611ce2565b906020823d6020116123d4575b816123c460209383611bb8565b810103126108f95750513861234c565b3d91506123b7565b6005548110156124135760056000527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db00190600090565b634e487b7160e01b600052603260045260246000fd5b60008181526006602052604081205490919080156121e1576000199080820181811161251157600554908382019182116124fd578181036124b2575b505050600554801561249e5781019061247d826123dc565b909182549160031b1b19169055600555815260066020526040812055600190565b634e487b7160e01b84526031600452602484fd5b6124e76124c16124d0936123dc565b90549060031b1c9283926123dc565b819391549060031b91821b91600019901b19161790565b9055845260066020526040842055388080612465565b634e487b7160e01b86526011600452602486fd5b634e487b7160e01b85526011600452602485fd5b60008181526006602052604081205461258b57600554680100000000000000008110156125775790826125636124d0846001604096016005556123dc565b905560055492815260066020522055600190565b634e487b7160e01b82526041600452602482fd5b905090565b906125b757508051156125a557805190602001fd5b604051630a12f52160e11b8152600490fd5b815115806125ea575b6125c8575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b156125c056fea26469706673582212202e62e583bc18dc20f9744c5c81ce3890899448c72fd07dbcfae5c65755bd74fe64736f6c63430008180033000000000000000000000000fa7560956807d95dcef22990ddd92e38dbaf5cdd0000000000000000000000003e17fd53fcb2dbd409b92f4860326b8b880e3c28000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000624e12de7a97b8cfc1ad1f050a1c9263b1f4febc
Deployed Bytecode
0x608060408181526004918236101561001657600080fd5b600092833560e01c91826301ffc9a714611ad6575081630bece79c14611aae5781631489f10b14611a8e5781631921a00414611a115781631b57927a146119f2578163248a9ca3146119c857816329d1ff7b1461174e5781632f2ff15d1461172457816336568abe146116de5781633c5fd982146116895781633f4c555c1461135357816343ce5ecb14610ffa5781634a0bbabb14610fd85781635e570c8014610c6157816364192f2a14610c3a57816368a806c414610bb35781637a96fa9514610b6d5781637adbf97314610a7c5781637dc0d1d014610a5357816391d1485414610a0e5781639f7aee8314610971578163a217fddf14610956578163ac906e751461091b578163beab6e94146108fc578163caf5a3971461083d578163d2c2e7c014610382578163d547741f1461033f578163dce52dfa14610320578163de1409ce146102dc578163f3bddde1146102bd578163f6300bf51461021057508063f8d89898146101cd5763fe1bf3241461019057600080fd5b346101c957816003193601126101c957602090517f855d04232aa491f9e84353b3958a225d6be593571f1d863256669b6e8229525d8152f35b5080fd5b50346101c957816003193601126101c957517f0000000000000000000000003e17fd53fcb2dbd409b92f4860326b8b880e3c286001600160a01b03168152602090f35b8383346101c957816003193601126101c95780516318160ddd60e01b8152926020908490817f0000000000000000000000003e17fd53fcb2dbd409b92f4860326b8b880e3c286001600160a01b03165afa9182156102b25791610278575b6020925051908152f35b90506020823d6020116102aa575b8161029360209383611bb8565b810103126102a557602091519061026e565b600080fd5b3d9150610286565b9051903d90823e3d90fd5b5050346101c957816003193601126101c9576020906002549051908152f35b5050346101c957816003193601126101c957517f000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a6001600160a01b03168152602090f35b5050346101c957816003193601126101c9576020906007549051908152f35b9190503461037e578060031936011261037e5761037a91356103756001610364611b29565b938387528660205286200154611fa9565b6121e6565b5080f35b8280fd5b90503461037e5761010036600319011261037e5761039e611b3f565b6103a6611b29565b9260443560643560a43560ff8116809103610839576103c3611ef1565b6103cb611fcf565b6103d683888761228f565b15610790575b506103e5611ef1565b6103ed611fcf565b6001600160a01b0384811660008181526006602052604090205490969015610779578181541697855192637d35e97760e11b8452808216998a848601526020948581602481855afa90811561076f578d91610742575b501561072b57817f0000000000000000000000003e17fd53fcb2dbd409b92f4860326b8b880e3c281690818c1461071b5761047c611ff2565b8851998d6306a61f7560e51b95868d52888d8981875afa9c8d1561071157829d6106dc575b508b5163e00cb4a560e01b81528881018c81526001600160a01b03909216602083015291908990839081906040010381875afa9081156106d157906106a2575b6104eb9150611cef565b978089116106865750888e9392610502928f61205f565b82855416803b1561037e57895163627160f360e11b815230818801908152602081018a90526001600160a01b03841660408201529091849183919082908490829060600103925af1801561067c57908391610668575b5050803b156101c95781809160248b5180948193630852cd8d60e31b83528c8b8401525af1801561065e57610646575b5050825416968651918252838284818b5afa91821561063c578b9261060d575b50806105b660075484611cd5565b106105f25750508451938452508201527f54d05ce5149ffe32f556bf78597c93c53f8a03ccaef629c485236f3e7c2229bb9190a4600160035580f35b8651638a21b25f60e01b815292830152602482015260449150fd5b9091508381813d8311610635575b6106258183611bb8565b810103126102a5575190386105a8565b503d61061b565b87513d8d823e3d90fd5b61064f90611b8e565b61065a578a38610588565b8a80fd5b89513d84823e3d90fd5b61067190611b8e565b6101c9578138610558565b8a513d85823e3d90fd5b866044918a8d5192633288636560e01b84528301526024820152fd5b508781813d83116106ca575b6106b88183611bb8565b810103126102a5576104eb90516104e1565b503d6106ae565b8c51903d90823e3d90fd5b8980929d9e508193503d831161070a575b6106f78183611bb8565b810103126102a557519a998e90886104a1565b503d6106ed565b8c513d84823e3d90fd5b885163c908adb560e01b81528590fd5b8751632762993f60e11b81528085018c9052602490fd5b6107629150863d8811610768575b61075a8183611bb8565b810190611cbd565b38610443565b503d610750565b89513d8f823e3d90fd5b84516332184be360e21b8152908101879052602490fd5b876001600160a01b0388811690813b1561037e5760e4888480948c978b51988996879563d505accf60e01b875216908501523060248501528a60448501526084356064850152608484015260c43560a4840152833560c48401525af19182610825575b50506108205761080482878661228f565b15610810575b386103dc565b825163b78cb0dd60e01b81528590fd5b61080a565b61082e90611b8e565b6108395787386107f3565b8780fd5b8284346108f957806003193601126108f9579080519182906005549182855260208095018093600584527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db090845b8181106108e557505050816108a1910382611bb8565b83519485948186019282875251809352850193925b8281106108c557505050500390f35b83516001600160a01b0316855286955093810193928101926001016108b6565b82548452928801926001928301920161088b565b80fd5b5050346101c957816003193601126101c9576020906005549051908152f35b5050346101c957816003193601126101c957602090517f9d6bad8599e4b9d405228287b23a6b0b8ce3cd1a8a88dd6f33fbba48615b4f558152f35b5050346101c957816003193601126101c95751908152602090f35b5050346101c957806003193601126101c95761098b611b3f565b9060243580151592838203610a0a577f4d1bcba22909ed929b2123a5d5c9a270f58fb0db0ecd28fe603d90eaacb42f2d926020926109c7611e99565b156109f2576109de6001600160a01b038316612525565b505b519384526001600160a01b031692a280f35b610a046001600160a01b038316612429565b506109e0565b8480fd5b90503461037e578160031936011261037e5781602093610a2c611b29565b92358152808552209060018060a01b0316600052825260ff81600020541690519015158152f35b5050346101c957816003193601126101c95760015490516001600160a01b039091168152602090f35b90503461037e57602036600319011261037e5780356001600160a01b0381169290839003610b6957610aac611e99565b8051638c89b64f60e01b8152906020828481875afa918215610b5f578592610b2b575b50600254809203610b16575050600180546001600160a01b03191683179055507f3f32684a32a11dabdbb8c0177de80aa3ae36a004d75210335b49e544e48cd0aa8280a280f35b51639b6812b960e01b81529182015260249150fd5b9091506020813d602011610b57575b81610b4760209383611bb8565b810103126102a557519038610acf565b3d9150610b3a565b81513d87823e3d90fd5b8380fd5b5050346101c95760203660031901126101c957602090610baa6001600160a01b03610b96611b3f565b166000526006602052604060002054151590565b90519015158152f35b90503461037e57602036600319011261037e57610bce611b3f565b90610bd7611e99565b6001600160a01b03918216928315610c24575080546001600160a01b031981168417909155167f2c9b4f5a59006f173f084ddbe758822a07431d43f4ef400a955472ddf8f91d0c8380a380f35b51635e10ffb360e01b8152908101839052602490fd5b8284346108f95760203660031901126108f95750610c5a60209235611cef565b9051908152f35b90503461037e578160031936011261037e57803591610c7e611b29565b90610c87611f4d565b610c8f611fcf565b6001600160a01b0382811660008181526006602052604090205415610fc25750610cb7611ff2565b610cc8610cc386611c1a565b611cef565b90807f0000000000000000000000003e17fd53fcb2dbd409b92f4860326b8b880e3c281695835196886318160ddd60e01b92838a52602097888b8b81875afa968715610fb8578a9b849b999a9b98610f82575b50867f000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a16968b8b51809b898252818b5afa998a15610f7857859a610f45575b508c5416853b15610a0a578a51631fa6592360e11b81526001600160a01b03909116818e01908152602081019290925290849082908190604001038183895af18015610f3b57908491610f27575b5050853b1561037e5788516340c10f1960e01b81526001600160a01b03909116818c01908152602081019290925290829082908190604001038183895af18015610f1d57918a959493918a93610efd575b50508751948580928582525afa928315610ef3579087918a94610ec2575b508887518094819382525afa958615610eb8578896610e84575b5050610e5292610e47610cc393610e4d93611ce2565b95611ce2565b611c1a565b90610e5d828461225b565b610e6a5784600160035580f35b51638a21b25f60e01b815292830152602482015260449150fd5b908093929650813d8311610eb1575b610e9d8183611bb8565b810103126102a55790519382610e47610e31565b503d610e93565b85513d8a823e3d90fd5b8281939295503d8311610eec575b610eda8183611bb8565b810103126102a5578690519238610e17565b503d610ed0565b86513d8b823e3d90fd5b909250610f0b919550611b8e565b610f19578688938a38610df9565b8880fd5b88513d84823e3d90fd5b610f3090611b8e565b61037e578238610da8565b8a513d86823e3d90fd5b8c80929b508196503d8311610f71575b610f5f8183611bb8565b810103126102a5578c93519838610d5a565b503d610f55565b8b513d87823e3d90fd5b9350965096508882813d8311610fb1575b610f9d8183611bb8565b810103126102a55789968b92519638610d1b565b503d610f93565b88513d85823e3d90fd5b846024918451916332184be360e21b8352820152fd5b8390346101c95760203660031901126101c957610ff3611e99565b3560025580f35b90503461037e5761100a36611b55565b61101695929395611f4d565b61101e611fcf565b60018060a01b039384871695611041876000526006602052604060002054151590565b15610779578581541695855192637d35e97760e11b8452818116998a8486015260209485816024818d5afa90811561076f578d91611336575b501561072b57827f0000000000000000000000003e17fd53fcb2dbd409b92f4860326b8b880e3c281698898c1461071b57908c9392916110b8611ff2565b89519a6306a61f7560e51b95868d52888d8981865afa9c8d1561132a57819d6112f6575b508b5163e00cb4a560e01b81528089018c81526001600160a01b03871660208201529091908a90839081906040010381875afa9081156112eb57906112bc575b6111269150611cef565b98808a106112a0575090818f9493923b15610a0a578b51631fa6592360e11b81526001600160a01b03909216828901908152602081018b90528591839182908490829060400103925af1801561129657908491611282575b50508386541690813b15610b69578a5163627160f360e11b81526001600160a01b03918216818901908152602081018c90529190931660408201528391839182908490829060600103925af1801561065e5761126e575b5050825416968651918252838284818b5afa91821561063c578b9261123f575b508061120360075484611cd5565b106105f25750508451938452508201527f8d2cf1d80f06f87e6690c4e9bbe4750f3f8affc42dea16d0d82687c849c4f4229190a4600160035580f35b9091508381813d8311611267575b6112578183611bb8565b810103126102a5575190386111f5565b503d61124d565b61127790611b8e565b61065a578a386111d5565b61128b90611b8e565b61037e57823861117e565b8b513d86823e3d90fd5b876044918b8e5192638ce27f3160e01b84528301526024820152fd5b508881813d83116112e4575b6112d28183611bb8565b810103126102a557611126905161111c565b503d6112c8565b8d51903d90823e3d90fd5b809c9d50898092503d8311611323575b6113108183611bb8565b810103126102a55799519a998e846110dc565b503d611306565b508b51903d90823e3d90fd5b61134d9150863d88116107685761075a8183611bb8565b3861107a565b90503461037e578160031936011261037e57803591611370611b29565b611378611ef1565b611380611fcf565b6001600160a01b038181166000818152600660205260409020549192911561167357506113ab611ff2565b6113b7610cc386611c1a565b83516318160ddd60e01b8082529096602093927f0000000000000000000000003e17fd53fcb2dbd409b92f4860326b8b880e3c288616918a91868b8b81875afa978815611669578a9b8499611633575b50807f000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a1696888b51809d898252818b5afa9b8c15610f7857859c6115fe575b50836114549130908a61205f565b863b15610b69578951630852cd8d60e31b938482528d8201528481602481838c5af18015610f78579085916115ea575b50508b5416803b15610b6957895163627160f360e11b815230818e01908152602081018490526001600160a01b03871660408201529091859183919082908490829060600103925af18015610f3b579084916115d6575b5050833b1561037e5788519182528a820152818160248183875af18015610f1d57918a9594939187936115ba575b50508751948580928582525afa928315610ef3579084918a94611589575b508887518094819382525afa928315610eb8578893611557575b5050610cc391610e47610e4d92610e5295611ce2565b90809350813d8311611582575b61156e8183611bb8565b810103126102a55790519082610e47611541565b503d611564565b8281939295503d83116115b3575b6115a18183611bb8565b810103126102a5578390519238611527565b503d611597565b9092506115c8919550611b8e565b610f19578388938a38611509565b6115df90611b8e565b61037e5782386114db565b6115f390611b8e565b610b69578338611484565b8980929d508196503d831161162c575b6116188183611bb8565b810103126102a5579251998c939083611446565b503d61160e565b9350975098508582813d8311611662575b61164e8183611bb8565b810103126102a55789988b92519738611407565b503d611644565b89513d85823e3d90fd5b846024918551916332184be360e21b8352820152fd5b9190503461037e57602036600319011261037e577f5711bde41b4f4146c2148af54d749f794c7016f066897809f58d83b338bb6e0391356116c8611e99565b600754908060075582519182526020820152a180f35b8383346101c957806003193601126101c9576116f8611b29565b90336001600160a01b03831603611715575061037a9192356121e6565b5163334bd91960e11b81528390fd5b9190503461037e578060031936011261037e5761037a91356117496001610364611b29565b612168565b90503461037e5761175e36611b55565b611769959295611ef1565b611771611fcf565b6001600160a01b0384811660008181526006602052604090205490969015610779578181541697855192637d35e97760e11b8452808216998a848601526020948581602481855afa90811561076f578d916119ab575b501561072b57817f0000000000000000000000003e17fd53fcb2dbd409b92f4860326b8b880e3c281690818c1461071b57611800611ff2565b8851998d6306a61f7560e51b95868d52888d8981875afa9c8d1561071157829d611978575b508b5163e00cb4a560e01b81528881018c81526001600160a01b03909216602083015291908990839081906040010381875afa9081156106d15790611945575b61186f9150611cef565b9780891161068657506118849189918e61205f565b818454168c813b156108f957895163627160f360e11b815230878201908152602081018a90526001600160a01b03851660408201529092839182908490829060600103925af1801561076f57611932575b50808c913b156101c95781809160248b5180948193630852cd8d60e31b83528c8b8401525af1801561065e57610646575050825416968651918252838284818b5afa91821561063c578b9261060d5750806105b660075484611cd5565b61193e909c919c611b8e565b9a386118d5565b508781813d8311611971575b61195b8183611bb8565b8101031261196d5761186f9051611865565b8e80fd5b503d611951565b9b9c5090888c813d83116119a4575b6119918183611bb8565b810103126108f9579a519b9a9088611825565b503d611987565b6119c29150863d88116107685761075a8183611bb8565b386117c7565b90503461037e57602036600319011261037e57816020936001923581528085522001549051908152f35b5050346101c957816003193601126101c9576020906008549051908152f35b8383346101c95760203660031901126101c9578235611a2e611e99565b620f4240808211611a735750907fa7988e31f84de01a1549a4220748e0900a4584640effc2b72696fb8a4db88a0291600854908060085582519182526020820152a180f35b8491604493519263228a16b560e01b84528301526024820152fd5b8284346108f95760203660031901126108f95750610c5a60209235611c1a565b90503461037e578260031936011261037e575490516001600160a01b03909116815260209150f35b84913461037e57602036600319011261037e573563ffffffff60e01b811680910361037e5760209250637965db0b60e01b8114908115611b18575b5015158152f35b6301ffc9a760e01b14905083611b11565b602435906001600160a01b03821682036102a557565b600435906001600160a01b03821682036102a557565b60809060031901126102a5576001600160a01b039060043582811681036102a5579160243590811681036102a557906044359060643590565b67ffffffffffffffff8111611ba257604052565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff821117611ba257604052565b908160209103126102a5575160ff811681036102a55790565b60ff16604d8111611c0457600a0a90565b634e487b7160e01b600052601160045260246000fd5b60405163313ce56760e01b8152906020826004817f000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a6001600160a01b03165afa8015611cb157611c7f92600091611c82575b50611c7960025491611bf3565b91611e23565b90565b611ca4915060203d602011611caa575b611c9c8183611bb8565b810190611bda565b38611c6c565b503d611c92565b6040513d6000823e3d90fd5b908160209103126102a5575180151581036102a55790565b91908201809211611c0457565b91908203918211611c0457565b60405163313ce56760e01b8152906020826004817f0000000000000000000000003e17fd53fcb2dbd409b92f4860326b8b880e3c286001600160a01b03165afa918215611cb157611c7f92611d4c91600091611d55575b50611bf3565b60025491611e23565b611d6e915060203d602011611caa57611c9c8183611bb8565b38611d46565b620f4240918183029160001984820993838086109503948086039514611dff5784831115611ded5782910981600003821680920460028082600302188083028203028083028203028083028203028083028203028083028203028092029003029360018380600003040190848311900302920304170290565b60405163227bc15360e01b8152600490fd5b505080925015611e0d570490565b634e487b7160e01b600052601260045260246000fd5b90918282029160001984820993838086109503948086039514611dff5784831115611ded5782910981600003821680920460028082600302188083028203028083028203028083028203028083028203028083028203028092029003029360018380600003040190848311900302920304170290565b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604081205460ff1615611ed35750565b6044906040519063e2517d3f60e01b82523360048301526024820152fd5b3360009081527f1c025d3a48b273ee95b866673d455ded2354b3fec99fd245da369c419654b09d60205260409020547f9d6bad8599e4b9d405228287b23a6b0b8ce3cd1a8a88dd6f33fbba48615b4f559060ff1615611ed35750565b3360009081527fdd7f85de517f2aa32b3532e7e369f65c4c2e6dcda6cd3ec83972be7965ca7aa060205260409020547f855d04232aa491f9e84353b3958a225d6be593571f1d863256669b6e8229525d9060ff1615611ed35750565b80600052600060205260406000203360005260205260ff6040600020541615611ed35750565b600260035414611fe0576002600355565b604051633ee5aeb560e01b8152600490fd5b600854801561205c5761205a906001600160a01b03612033827f000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a8316612307565b7f0000000000000000000000003e17fd53fcb2dbd409b92f4860326b8b880e3c2816612307565b565b50565b6040516323b872dd60e01b602082019081526001600160a01b039384166024830152938316604482015260648082019590955293845267ffffffffffffffff919060a0850183811186821017611ba2576040521692600080938192519082875af1903d1561215a573d908111612146576040516120fd9392916120ec601f8201601f191660200183611bb8565b8152809260203d92013e5b83612590565b805190811515918261212b575b50506121135750565b60249060405190635274afe760e01b82526004820152fd5b61213e9250602080918301019101611cbd565b15388061210a565b634e487b7160e01b83526041600452602483fd5b506120fd91506060906120f7565b9060009180835282602052604083209160018060a01b03169182845260205260ff604084205416156000146121e157808352826020526040832082845260205260408320600160ff198254161790557f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d339380a4600190565b505090565b9060009180835282602052604083209160018060a01b03169182845260205260ff6040842054166000146121e15780835282602052604083208284526020526040832060ff1981541690557ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b339380a4600190565b906007548161226a8285611cd5565b106122875761227891611cd5565b1061228257600090565b600190565b505050600190565b604051636eb1769f60e11b81526001600160a01b0391821660048201523060248201529160209183916044918391165afa908115611cb1576000916122d5575b50101590565b90506020813d6020116122ff575b816122f060209383611bb8565b810103126102a55751386122cf565b3d91506122e3565b60025460015460405163b3596f0760e01b81526001600160a01b03938416600482018190529493909160209183916024918391165afa908115611cb1576000916123aa575b5081811061239b5782612368836123638185611ce2565b611d74565b116123735750505050565b6084945060405193630907397b60e21b85526004850152602484015260448301526064820152fd5b82612368836123638482611ce2565b906020823d6020116123d4575b816123c460209383611bb8565b810103126108f95750513861234c565b3d91506123b7565b6005548110156124135760056000527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db00190600090565b634e487b7160e01b600052603260045260246000fd5b60008181526006602052604081205490919080156121e1576000199080820181811161251157600554908382019182116124fd578181036124b2575b505050600554801561249e5781019061247d826123dc565b909182549160031b1b19169055600555815260066020526040812055600190565b634e487b7160e01b84526031600452602484fd5b6124e76124c16124d0936123dc565b90549060031b1c9283926123dc565b819391549060031b91821b91600019901b19161790565b9055845260066020526040842055388080612465565b634e487b7160e01b86526011600452602486fd5b634e487b7160e01b85526011600452602485fd5b60008181526006602052604081205461258b57600554680100000000000000008110156125775790826125636124d0846001604096016005556123dc565b905560055492815260066020522055600190565b634e487b7160e01b82526041600452602482fd5b905090565b906125b757508051156125a557805190602001fd5b604051630a12f52160e11b8152600490fd5b815115806125ea575b6125c8575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b156125c056fea26469706673582212202e62e583bc18dc20f9744c5c81ce3890899448c72fd07dbcfae5c65755bd74fe64736f6c63430008180033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000fa7560956807d95dcef22990ddd92e38dbaf5cdd0000000000000000000000003e17fd53fcb2dbd409b92f4860326b8b880e3c28000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a000000000000000000000000624e12de7a97b8cfc1ad1f050a1c9263b1f4febc
-----Decoded View---------------
Arg [0] : _oracle (address): 0xFA7560956807d95DCeF22990DdD92e38DbAf5cDd
Arg [1] : _debtToken (address): 0x3E17fd53FcB2Dbd409B92f4860326B8b880e3c28
Arg [2] : _dusd (address): 0x788D96f655735f52c676A133f4dFC53cEC614d4A
Arg [3] : _collateralVault (address): 0x624E12dE7a97B8cFc1AD1F050a1c9263b1f4FeBC
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000fa7560956807d95dcef22990ddd92e38dbaf5cdd
Arg [1] : 0000000000000000000000003e17fd53fcb2dbd409b92f4860326b8b880e3c28
Arg [2] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Arg [3] : 000000000000000000000000624e12de7a97b8cfc1ad1f050a1c9263b1f4febc
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in FRAX
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
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.