Source Code
Cross-Chain Transactions
Loading...
Loading
Contract Name:
DStakeCollateralVault
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
pragma solidity ^0.8.20;
import { IERC20 } from "@openzeppelin/contracts-5/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts-5/token/ERC20/utils/SafeERC20.sol";
import { IDStakeCollateralVault } from "./interfaces/IDStakeCollateralVault.sol";
import { IDStableConversionAdapter } from "./interfaces/IDStableConversionAdapter.sol";
import { AccessControl } from "@openzeppelin/contracts-5/access/AccessControl.sol";
import { EnumerableSet } from "@openzeppelin/contracts-5/utils/structs/EnumerableSet.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts-5/utils/ReentrancyGuard.sol";
// ---------------------------------------------------------------------------
// Internal interface to query the router's public mapping without importing the
// full router contract (avoids circular dependencies).
// ---------------------------------------------------------------------------
interface IAdapterProvider {
function vaultAssetToAdapter(address) external view returns (address);
}
/**
* @title DStakeCollateralVault
* @notice Holds various yield-bearing/convertible ERC20 tokens (`vault assets`) managed by dSTAKE.
* @dev Calculates the total value of these assets in terms of the underlying dStable asset
* using registered adapters. This contract is non-upgradeable but replaceable via
* DStakeToken governance.
* Uses AccessControl for role-based access control.
*/
contract DStakeCollateralVault is IDStakeCollateralVault, AccessControl, ReentrancyGuard {
using SafeERC20 for IERC20;
using EnumerableSet for EnumerableSet.AddressSet;
// --- Roles ---
bytes32 public constant ROUTER_ROLE = keccak256("ROUTER_ROLE");
// --- Errors ---
error ZeroAddress();
error AssetNotSupported(address asset);
error AssetAlreadySupported(address asset);
error NonZeroBalance(address asset);
error CannotRescueRestrictedToken(address token);
error ETHTransferFailed(address receiver, uint256 amount);
// --- Events ---
event TokenRescued(address indexed token, address indexed receiver, uint256 amount);
event ETHRescued(address indexed receiver, uint256 amount);
// --- State ---
address public immutable dStakeToken; // The DStakeToken this vault serves
address public immutable dStable; // The underlying dStable asset address
address public router; // The DStakeRouter allowed to interact
EnumerableSet.AddressSet private _supportedAssets; // Set of supported vault assets
// --- Constructor ---
constructor(address _dStakeVaultShare, address _dStableAsset) {
if (_dStakeVaultShare == address(0) || _dStableAsset == address(0)) {
revert ZeroAddress();
}
dStakeToken = _dStakeVaultShare;
dStable = _dStableAsset;
// Set up the DEFAULT_ADMIN_ROLE initially to the contract deployer
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
// --- External Views (IDStakeCollateralVault Interface) ---
/**
* @inheritdoc IDStakeCollateralVault
*/
function totalValueInDStable() external view override returns (uint256 dStableValue) {
uint256 totalValue = 0;
uint256 len = _supportedAssets.length();
for (uint256 i = 0; i < len; i++) {
address vaultAsset = _supportedAssets.at(i);
address adapterAddress = IAdapterProvider(router).vaultAssetToAdapter(vaultAsset);
if (adapterAddress == address(0)) {
// If there is no adapter configured, simply skip this asset to
// preserve liveness. Anyone can dust this vault and we cannot
// enforce that all assets have adapters before removal
continue;
}
uint256 balance = IERC20(vaultAsset).balanceOf(address(this));
if (balance > 0) {
totalValue += IDStableConversionAdapter(adapterAddress).assetValueInDStable(vaultAsset, balance);
}
}
return totalValue;
}
// --- External Functions (Router Interactions) ---
/**
* @notice Transfers `amount` of `vaultAsset` from this vault to `recipient`.
* @dev Only callable by the registered router (ROUTER_ROLE).
*/
function sendAsset(address vaultAsset, uint256 amount, address recipient) external onlyRole(ROUTER_ROLE) {
if (!_isSupported(vaultAsset)) revert AssetNotSupported(vaultAsset);
IERC20(vaultAsset).safeTransfer(recipient, amount);
}
/**
* @notice Adds a new supported vault asset. Can only be invoked by the router.
*/
function addSupportedAsset(address vaultAsset) external onlyRole(ROUTER_ROLE) {
if (vaultAsset == address(0)) revert ZeroAddress();
if (_isSupported(vaultAsset)) revert AssetAlreadySupported(vaultAsset);
_supportedAssets.add(vaultAsset);
emit SupportedAssetAdded(vaultAsset);
}
/**
* @notice Removes a supported vault asset. Can only be invoked by the router.
*/
function removeSupportedAsset(address vaultAsset) external onlyRole(ROUTER_ROLE) {
if (!_isSupported(vaultAsset)) revert AssetNotSupported(vaultAsset);
// NOTE: Previously this function reverted if the vault still held a
// non-zero balance of the asset, causing a griefing / DoS vector:
// anyone could deposit 1 wei of the token to block removal. The
// check has been removed so governance can always delist an asset.
_supportedAssets.remove(vaultAsset);
emit SupportedAssetRemoved(vaultAsset);
}
// --- Governance Functions ---
/**
* @notice Sets the router address. Grants ROUTER_ROLE to new router and
* revokes it from the previous router.
*/
function setRouter(address _newRouter) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (_newRouter == address(0)) revert ZeroAddress();
// Revoke role from old router
if (router != address(0)) {
_revokeRole(ROUTER_ROLE, router);
}
_grantRole(ROUTER_ROLE, _newRouter);
router = _newRouter;
emit RouterSet(_newRouter);
}
// --- Internal Utilities ---
function _isSupported(address asset) private view returns (bool) {
return _supportedAssets.contains(asset);
}
// --- External Views ---
/**
* @notice Returns the vault asset at `index` from the internal supported set.
* Kept for backwards-compatibility with the previous public array getter.
*/
function supportedAssets(uint256 index) external view override returns (address) {
return _supportedAssets.at(index);
}
/**
* @notice Returns the entire list of supported vault assets. Useful for UIs & off-chain tooling.
*/
function getSupportedAssets() external view returns (address[] memory) {
return _supportedAssets.values();
}
// --- Recovery Functions ---
/**
* @notice Rescues tokens accidentally sent to the contract
* @dev Cannot rescue supported vault assets or the dStable token
* @param token Address of the token to rescue
* @param receiver Address to receive the rescued tokens
* @param amount Amount of tokens to rescue
*/
function rescueToken(
address token,
address receiver,
uint256 amount
) external onlyRole(DEFAULT_ADMIN_ROLE) nonReentrant {
if (receiver == address(0)) revert ZeroAddress();
// Check if token is a supported asset
if (_isSupported(token)) {
revert CannotRescueRestrictedToken(token);
}
// Check if token is the dStable token
if (token == dStable) {
revert CannotRescueRestrictedToken(token);
}
// Rescue the token
IERC20(token).safeTransfer(receiver, amount);
emit TokenRescued(token, receiver, amount);
}
/**
* @notice Rescues ETH accidentally sent to the contract
* @param receiver Address to receive the rescued ETH
* @param amount Amount of ETH to rescue
*/
function rescueETH(address receiver, uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE) nonReentrant {
if (receiver == address(0)) revert ZeroAddress();
(bool success, ) = receiver.call{ value: amount }("");
if (!success) revert ETHTransferFailed(receiver, amount);
emit ETHRescued(receiver, amount);
}
/**
* @notice Returns the list of tokens that cannot be rescued
* @return restrictedTokens Array of restricted token addresses
*/
function getRestrictedRescueTokens() external view returns (address[] memory) {
address[] memory assets = _supportedAssets.values();
address[] memory restrictedTokens = new address[](assets.length + 1);
// Add all supported assets
for (uint256 i = 0; i < assets.length; i++) {
restrictedTokens[i] = assets[i];
}
// Add dStable token
restrictedTokens[assets.length] = dStable;
return restrictedTokens;
}
/**
* @notice Allows the contract to receive ETH
*/
receive() external payable {}
}// 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) (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/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
pragma solidity ^0.8.20;
/**
* @title IDStableConversionAdapter Interface
* @notice Interface for contracts that handle the conversion between the core dStable asset
* and a specific yield-bearing or convertible ERC20 token (`vault asset`), as well as
* valuing that `vault asset` in terms of the dStable asset.
* @dev Implementations interact with specific protocols (lending pools, DEX LPs, wrappers, etc.).
*/
interface IDStableConversionAdapter {
/**
* @notice Converts a specified amount of the dStable asset into the specific `vaultAsset`
* managed by this adapter.
* @dev The adapter MUST pull `dStableAmount` of the dStable asset from the caller (expected to be the Router).
* @dev The resulting `vaultAsset` MUST be sent/deposited/minted directly to the `collateralVault` address provided during adapter setup or retrieved.
* @param dStableAmount The amount of dStable asset to convert.
* @return vaultAsset The address of the specific `vault asset` token managed by this adapter.
* @return vaultAssetAmount The amount of `vaultAsset` generated from the conversion.
*/
function convertToVaultAsset(uint256 dStableAmount) external returns (address vaultAsset, uint256 vaultAssetAmount);
/**
* @notice Converts a specific amount of `vaultAsset` back into the dStable asset.
* @dev The adapter MUST pull the required amount of `vaultAsset` from the caller (expected to be the Router).
* @dev The resulting dStable asset MUST be sent to the caller.
* @param vaultAssetAmount The amount of `vaultAsset` to convert.
* @return dStableAmount The amount of dStable asset sent to the caller.
*/
function convertFromVaultAsset(uint256 vaultAssetAmount) external returns (uint256 dStableAmount);
/**
* @notice Preview the result of converting a given dStable amount to vaultAsset (without state change).
* @param dStableAmount The amount of dStable asset to preview conversion for.
* @return vaultAsset The address of the specific `vault asset` token managed by this adapter.
* @return vaultAssetAmount The amount of `vaultAsset` that would be received.
*/
function previewConvertToVaultAsset(
uint256 dStableAmount
) external view returns (address vaultAsset, uint256 vaultAssetAmount);
/**
* @notice Preview the result of converting a given vaultAsset amount to dStable (without state change).
* @param vaultAssetAmount The amount of `vaultAsset` to preview conversion for.
* @return dStableAmount The amount of dStable asset that would be received.
*/
function previewConvertFromVaultAsset(uint256 vaultAssetAmount) external view returns (uint256 dStableAmount);
/**
* @notice Calculates the value of a given amount of the specific `vaultAsset` managed by this adapter
* in terms of the dStable asset.
* @param vaultAsset The address of the vault asset token (should match getVaultAsset()). Included for explicitness.
* @param vaultAssetAmount The amount of the `vaultAsset` to value.
* @return dStableValue The equivalent value in the dStable asset.
*/
function assetValueInDStable(
address vaultAsset,
uint256 vaultAssetAmount
) external view returns (uint256 dStableValue);
/**
* @notice Returns the address of the specific `vault asset` token managed by this adapter.
* @return The address of the `vault asset`.
*/
function vaultAsset() external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* @title IDStakeCollateralVault Interface
* @notice Defines the external functions of the DStakeCollateralVault required by other
* contracts in the dSTAKE system, primarily the DStakeToken.
*/
interface IDStakeCollateralVault {
/**
* @notice Calculates the total value of all managed `vault assets` held by the vault,
* denominated in the underlying dStable asset.
* @dev This is typically called by the DStakeToken's `totalAssets()` function.
* @return dStableValue The total value of managed assets in terms of the dStable asset.
*/
function totalValueInDStable() external view returns (uint256 dStableValue);
/**
* @notice Returns the address of the underlying dStable asset the vault operates with.
* @return The address of the dStable asset.
*/
function dStable() external view returns (address);
/**
* @notice The DStakeToken contract address this vault serves.
*/
function dStakeToken() external view returns (address);
/**
* @notice The DStakeRouter contract address allowed to interact.
*/
function router() external view returns (address);
/**
* @notice Returns the vault asset at `index` from the internal supported list.
*/
function supportedAssets(uint256 index) external view returns (address);
/**
* @notice Returns the entire list of supported vault assets. Convenient for UIs & off-chain analytics.
*/
function getSupportedAssets() external view returns (address[] memory);
/**
* @notice Transfers `amount` of `vaultAsset` from this vault to the `recipient`.
* @dev Only callable by the registered router.
* @param vaultAsset The address of the vault asset to send.
* @param amount The amount to send.
* @param recipient The address to receive the asset.
*/
function sendAsset(address vaultAsset, uint256 amount, address recipient) external;
/**
* @notice Sets the address of the DStakeRouter contract.
* @dev Only callable by an address with the DEFAULT_ADMIN_ROLE.
* @param _newRouter The address of the new router contract.
*/
function setRouter(address _newRouter) external;
/**
* @notice Adds a vault asset to the supported list. Callable only by the router.
*/
function addSupportedAsset(address vaultAsset) external;
/**
* @notice Removes a vault asset from the supported list. Callable only by the router.
*/
function removeSupportedAsset(address vaultAsset) external;
/**
* @notice Emitted when the router address is set.
* @param router The address of the new router.
*/
event RouterSet(address indexed router);
/**
* @notice Emitted when a new vault asset is added to the supported list.
*/
event SupportedAssetAdded(address indexed vaultAsset);
/**
* @notice Emitted when a vault asset is removed from the supported list.
*/
event SupportedAssetRemoved(address indexed vaultAsset);
}{
"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":"address","name":"_dStakeVaultShare","type":"address"},{"internalType":"address","name":"_dStableAsset","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":[{"internalType":"address","name":"asset","type":"address"}],"name":"AssetAlreadySupported","type":"error"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"AssetNotSupported","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"CannotRescueRestrictedToken","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ETHTransferFailed","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"NonZeroBalance","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ETHRescued","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":true,"internalType":"address","name":"router","type":"address"}],"name":"RouterSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"vaultAsset","type":"address"}],"name":"SupportedAssetAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"vaultAsset","type":"address"}],"name":"SupportedAssetRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TokenRescued","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROUTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"vaultAsset","type":"address"}],"name":"addSupportedAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"dStable","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dStakeToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRestrictedRescueTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSupportedAssets","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"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":"address","name":"vaultAsset","type":"address"}],"name":"removeSupportedAsset","outputs":[],"stateMutability":"nonpayable","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":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"rescueETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"rescueToken","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":[],"name":"router","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"vaultAsset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"sendAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newRouter","type":"address"}],"name":"setRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"supportedAssets","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalValueInDStable","outputs":[{"internalType":"uint256","name":"dStableValue","type":"uint256"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
60c034620000da57601f6200145638819003918201601f19168301916001600160401b03831184841017620000df578084926040948552833981010312620000da576200005a60206200005283620000f5565b9201620000f5565b60018055906001600160a01b0380821615908115620000ce575b50620000bc5760805260a0526200008b336200010a565b506040516112ba90816200019c8239608051816106a4015260a0518181816102500152818161074701526109ac0152f35b60405163d92e233d60e01b8152600490fd5b90508216153862000074565b600080fd5b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b0382168203620000da57565b6001600160a01b031660008181527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604081205490919060ff166200019757818052816020526040822081835260205260408220600160ff1982541617905533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8180a4600190565b509056fe60806040818152600480361015610021575b505050361561001f57600080fd5b005b600092833560e01c90816301ffc9a714610a9f57508063099a04e5146109db5780630cc2f8d2146109975780631c46bc6f1461090d578063248a9ca3146108e45780632f2ff15d146108bb57806330d643b51461089257806336568abe1461084b57806338ff92e6146107c6578063500fc434146106d35780635c47df421461068f57806391d148541461064a578063a217fddf1461062f578063c0d7865514610596578063c68dbb3714610560578063d547741f14610522578063e015e7061461031d578063e5406dbf146102f0578063e5711e8b146101e3578063f887ea40146101b65763fac09e870361001157346101b25760203660031901126101b25761012a610af3565b610132610c7b565b6001600160a01b03169182156101a557610159836000526004602052604060002054151590565b61019057505061016881611196565b507f3ebc37c7ad88888fc79c591d53847cf755b23698bc448d2c3f39cce8acbe492b8280a280f35b9160249251916303b6566d60e41b8352820152fd5b5163d92e233d60e01b8152fd5b8280fd5b5050346101df57816003193601126101df5760025490516001600160a01b039091168152602090f35b5080fd5b50346101b25760603660031901126101b2576101fd610af3565b91610206610b0e565b9060443591610213610c23565b61021b610ceb565b6001600160a01b038181169590949086156102e15785169461024a866000526004602052604060002054151590565b6102ca577f00000000000000000000000000000000000000000000000000000000000000001685146102b35750916020916102a7827f4143f7b5cb6ea007914c32b8a3e64cebc051d7f493fa0755454da1e47701e1259587610f35565b51908152a36001805580f35b82516341d6bb6960e01b8152908101859052602490fd5b83516341d6bb6960e01b8152808301879052602490fd5b50825163d92e233d60e01b8152fd5b5050346101df57816003193601126101df576103199061030e611126565b905191829182610b24565b0390f35b50823461051f578060031936011261051f576003805460025492936001600160a01b039391928592851690835b85811061035b576020888a51908152f35b8661036582610fef565b905490841b1c1689519063c8232bd760e01b82528086830152602090602492828185818a5afa90811561051557908b918a916104d7575b501680156104cb578c516370a0823160e01b815230898201529183838681845afa9283156104c1578a9361048e575b508d836103e3575b5050505050506001905b0161034a565b51633171fd4b60e21b81526001600160a01b03909116818a019081526020810193909352949b9491839183918290819060400103915afa918215610484578892610452575b5050820180921161044157509660018a8080808d6103d3565b634e487b7160e01b86526011855285fd5b90809250813d831161047d575b6104698183610b69565b8101031261047957518b80610428565b8680fd5b503d61045f565b8c513d8a823e3d90fd5b9092508381813d83116104ba575b6104a68183610b69565b810103126104b65751918e6103cb565b8980fd5b503d61049c565b8e513d8c823e3d90fd5b505050506001906103dd565b809250848092503d831161050e575b6104f08183610b69565b8101031261050a57518a8116810361050a578a908e61039c565b8880fd5b503d6104e6565b8d513d8b823e3d90fd5b80fd5b5090346101b257806003193601126101b25761055c91356105576001610546610b0e565b938387528660205286200154610cc5565b610ec0565b5080f35b50913461051f57602036600319011261051f575061058060209235610fef565b905491519160018060a01b039160031b1c168152f35b50346101b25760203660031901126101b2576105b0610af3565b906105b9610c23565b6001600160a01b038281169390919084156101a5575050906105e591600254168061061f575b50610d0e565b50600280546001600160a01b031916821790557fc6b438e6a8a59579ce6a4406cbd203b740e0d47b458aae6596339bcd40c40d158280a280f35b61062890610e27565b50386105df565b5050346101df57816003193601126101df5751908152602090f35b50346101b257816003193601126101b2578160209360ff9261066a610b0e565b903582528186528282206001600160a01b039091168252855220549151911615158152f35b5050346101df57816003193601126101df57517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b509190346101df57816003193601126101df576106ee611126565b805192600194600185018095116107b35750849061070b85610be1565b9461071885519687610b69565b808652610727601f1991610be1565b01366020870137905b61077b575b6103198484610745855183610bf9565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690525191829182610b24565b81518110156107ae57849081906001600160a01b0361079a8286610bf9565b51166107a68288610bf9565b520190610730565b610735565b634e487b7160e01b825260119052602490fd5b508290346101df5760603660031901126101df576107e2610af3565b604435906001600160a01b0390818316830361084757610800610c7b565b1691610819836000526004602052604060002054151590565b1561083057509061082d9160243591610f35565b80f35b8451632777a68f60e11b8152908101839052602490fd5b8480fd5b509190346101df57806003193601126101df57610866610b0e565b90336001600160a01b03831603610883575061055c919235610ec0565b5163334bd91960e11b81528390fd5b5050346101df57816003193601126101df57602090516000805160206112658339815191528152f35b5090346101b257806003193601126101b25761055c91356108df6001610546610b0e565b610dae565b50346101b25760203660031901126101b257816020936001923581528085522001549051908152f35b50346101b25760203660031901126101b257610927610af3565b61092f610c7b565b6001600160a01b03166000818152600460205260409020549092901561098257505061095a81611026565b507fd4d3143baa8e1f94a3d57c410b72e62213e8359b01fc752925f64aa59f4053c98280a280f35b916024925191632777a68f60e11b8352820152fd5b5050346101df57816003193601126101df57517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b5090346101b257806003193601126101b2576109f5610af3565b9060243591610a02610c23565b610a0a610ceb565b6001600160a01b038116938415610a91578580808087865af1610a2b610ba1565b5015610a645750507fb3579861130e4da8bb7b87c54d2d139937f23bcd6e4ebed9e75d0f78ab1cc1189160209151908152a26001805580f35b8251635e0a829b60e01b81526001600160a01b039092169082019081526020810184905281906040010390fd5b825163d92e233d60e01b8152fd5b925050346101b25760203660031901126101b2573563ffffffff60e01b81168091036101b25760209250637965db0b60e01b8114908115610ae2575b5015158152f35b6301ffc9a760e01b14905038610adb565b600435906001600160a01b0382168203610b0957565b600080fd5b602435906001600160a01b0382168203610b0957565b602090602060408183019282815285518094520193019160005b828110610b4c575050505090565b83516001600160a01b031685529381019392810192600101610b3e565b90601f8019910116810190811067ffffffffffffffff821117610b8b57604052565b634e487b7160e01b600052604160045260246000fd5b3d15610bdc573d9067ffffffffffffffff8211610b8b5760405191610bd0601f8201601f191660200184610b69565b82523d6000602084013e565b606090565b67ffffffffffffffff8111610b8b5760051b60200190565b8051821015610c0d5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604081205460ff1615610c5d5750565b6044906040519063e2517d3f60e01b82523360048301526024820152fd5b3360009081527fb5816a4d525ce17c45785e5fbae4518f6f00ef4e9d31d4d7bb129b76152ed32f60205260409020546000805160206112658339815191529060ff1615610c5d5750565b80600052600060205260406000203360005260205260ff6040600020541615610c5d5750565b600260015414610cfc576002600155565b604051633ee5aeb560e01b8152600490fd5b6001600160a01b031660008181527fb5816a4d525ce17c45785e5fbae4518f6f00ef4e9d31d4d7bb129b76152ed32f60205260408120549091906000805160206112658339815191529060ff16610da957808352826020526040832082845260205260408320600160ff198254161790557f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d339380a4600190565b505090565b9060009180835282602052604083209160018060a01b03169182845260205260ff60408420541615600014610da957808352826020526040832082845260205260408320600160ff198254161790557f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d339380a4600190565b6001600160a01b031660008181527fb5816a4d525ce17c45785e5fbae4518f6f00ef4e9d31d4d7bb129b76152ed32f60205260408120549091906000805160206112658339815191529060ff1615610da95780835282602052604083208284526020526040832060ff1981541690557ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b339380a4600190565b9060009180835282602052604083209160018060a01b03169182845260205260ff604084205416600014610da95780835282602052604083208284526020526040832060ff1981541690557ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b339380a4600190565b60405163a9059cbb60e01b602082019081526001600160a01b03939093166024820152604480820194909452928352610f9790610f73606485610b69565b60018060a01b031692600080938192519082875af1610f90610ba1565b9084611201565b908151918215159283610fc7575b505050610faf5750565b60249060405190635274afe760e01b82526004820152fd5b8192935090602091810103126101df57602001519081159182150361051f5750388080610fa5565b600354811015610c0d5760036000527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0190600090565b600090808252600490816020526040832054801515600014611120576000199080820181811161110d57600354908382019182116110fa578181036110b0575b505050600354801561109d5781019061107e82610fef565b909182549160031b1b1916905560035582526020526040812055600190565b634e487b7160e01b855260318452602485fd5b6110e56110bf6110ce93610fef565b90549060031b1c928392610fef565b819391549060031b91821b91600019901b19161790565b90558552836020526040852055388080611066565b634e487b7160e01b875260118652602487fd5b634e487b7160e01b865260118552602486fd5b50505090565b6040519060035480835282602091602082019060036000527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b936000905b82821061117c5750505061117a92500383610b69565b565b855484526001958601958895509381019390910190611164565b6000818152600460205260408120546111fc57600354680100000000000000008110156111e85790826111d46110ce84600160409601600355610fef565b905560035492815260046020522055600190565b634e487b7160e01b82526041600452602482fd5b905090565b90611228575080511561121657805190602001fd5b604051630a12f52160e11b8152600490fd5b8151158061125b575b611239575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b1561123156fe7a05a596cb0ce7fdea8a1e1ec73be300bdb35097c944ce1897202f7a13122eb2a264697066735822122057b94794b44a627af1e1354fc28c531bc29adf6bcbdde441e199c654eaec295c64736f6c6343000818003300000000000000000000000058acc2600835211dcb5847c5fa422791fd492409000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Deployed Bytecode
0x60806040818152600480361015610021575b505050361561001f57600080fd5b005b600092833560e01c90816301ffc9a714610a9f57508063099a04e5146109db5780630cc2f8d2146109975780631c46bc6f1461090d578063248a9ca3146108e45780632f2ff15d146108bb57806330d643b51461089257806336568abe1461084b57806338ff92e6146107c6578063500fc434146106d35780635c47df421461068f57806391d148541461064a578063a217fddf1461062f578063c0d7865514610596578063c68dbb3714610560578063d547741f14610522578063e015e7061461031d578063e5406dbf146102f0578063e5711e8b146101e3578063f887ea40146101b65763fac09e870361001157346101b25760203660031901126101b25761012a610af3565b610132610c7b565b6001600160a01b03169182156101a557610159836000526004602052604060002054151590565b61019057505061016881611196565b507f3ebc37c7ad88888fc79c591d53847cf755b23698bc448d2c3f39cce8acbe492b8280a280f35b9160249251916303b6566d60e41b8352820152fd5b5163d92e233d60e01b8152fd5b8280fd5b5050346101df57816003193601126101df5760025490516001600160a01b039091168152602090f35b5080fd5b50346101b25760603660031901126101b2576101fd610af3565b91610206610b0e565b9060443591610213610c23565b61021b610ceb565b6001600160a01b038181169590949086156102e15785169461024a866000526004602052604060002054151590565b6102ca577f000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a1685146102b35750916020916102a7827f4143f7b5cb6ea007914c32b8a3e64cebc051d7f493fa0755454da1e47701e1259587610f35565b51908152a36001805580f35b82516341d6bb6960e01b8152908101859052602490fd5b83516341d6bb6960e01b8152808301879052602490fd5b50825163d92e233d60e01b8152fd5b5050346101df57816003193601126101df576103199061030e611126565b905191829182610b24565b0390f35b50823461051f578060031936011261051f576003805460025492936001600160a01b039391928592851690835b85811061035b576020888a51908152f35b8661036582610fef565b905490841b1c1689519063c8232bd760e01b82528086830152602090602492828185818a5afa90811561051557908b918a916104d7575b501680156104cb578c516370a0823160e01b815230898201529183838681845afa9283156104c1578a9361048e575b508d836103e3575b5050505050506001905b0161034a565b51633171fd4b60e21b81526001600160a01b03909116818a019081526020810193909352949b9491839183918290819060400103915afa918215610484578892610452575b5050820180921161044157509660018a8080808d6103d3565b634e487b7160e01b86526011855285fd5b90809250813d831161047d575b6104698183610b69565b8101031261047957518b80610428565b8680fd5b503d61045f565b8c513d8a823e3d90fd5b9092508381813d83116104ba575b6104a68183610b69565b810103126104b65751918e6103cb565b8980fd5b503d61049c565b8e513d8c823e3d90fd5b505050506001906103dd565b809250848092503d831161050e575b6104f08183610b69565b8101031261050a57518a8116810361050a578a908e61039c565b8880fd5b503d6104e6565b8d513d8b823e3d90fd5b80fd5b5090346101b257806003193601126101b25761055c91356105576001610546610b0e565b938387528660205286200154610cc5565b610ec0565b5080f35b50913461051f57602036600319011261051f575061058060209235610fef565b905491519160018060a01b039160031b1c168152f35b50346101b25760203660031901126101b2576105b0610af3565b906105b9610c23565b6001600160a01b038281169390919084156101a5575050906105e591600254168061061f575b50610d0e565b50600280546001600160a01b031916821790557fc6b438e6a8a59579ce6a4406cbd203b740e0d47b458aae6596339bcd40c40d158280a280f35b61062890610e27565b50386105df565b5050346101df57816003193601126101df5751908152602090f35b50346101b257816003193601126101b2578160209360ff9261066a610b0e565b903582528186528282206001600160a01b039091168252855220549151911615158152f35b5050346101df57816003193601126101df57517f00000000000000000000000058acc2600835211dcb5847c5fa422791fd4924096001600160a01b03168152602090f35b509190346101df57816003193601126101df576106ee611126565b805192600194600185018095116107b35750849061070b85610be1565b9461071885519687610b69565b808652610727601f1991610be1565b01366020870137905b61077b575b6103198484610745855183610bf9565b7f000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a6001600160a01b031690525191829182610b24565b81518110156107ae57849081906001600160a01b0361079a8286610bf9565b51166107a68288610bf9565b520190610730565b610735565b634e487b7160e01b825260119052602490fd5b508290346101df5760603660031901126101df576107e2610af3565b604435906001600160a01b0390818316830361084757610800610c7b565b1691610819836000526004602052604060002054151590565b1561083057509061082d9160243591610f35565b80f35b8451632777a68f60e11b8152908101839052602490fd5b8480fd5b509190346101df57806003193601126101df57610866610b0e565b90336001600160a01b03831603610883575061055c919235610ec0565b5163334bd91960e11b81528390fd5b5050346101df57816003193601126101df57602090516000805160206112658339815191528152f35b5090346101b257806003193601126101b25761055c91356108df6001610546610b0e565b610dae565b50346101b25760203660031901126101b257816020936001923581528085522001549051908152f35b50346101b25760203660031901126101b257610927610af3565b61092f610c7b565b6001600160a01b03166000818152600460205260409020549092901561098257505061095a81611026565b507fd4d3143baa8e1f94a3d57c410b72e62213e8359b01fc752925f64aa59f4053c98280a280f35b916024925191632777a68f60e11b8352820152fd5b5050346101df57816003193601126101df57517f000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a6001600160a01b03168152602090f35b5090346101b257806003193601126101b2576109f5610af3565b9060243591610a02610c23565b610a0a610ceb565b6001600160a01b038116938415610a91578580808087865af1610a2b610ba1565b5015610a645750507fb3579861130e4da8bb7b87c54d2d139937f23bcd6e4ebed9e75d0f78ab1cc1189160209151908152a26001805580f35b8251635e0a829b60e01b81526001600160a01b039092169082019081526020810184905281906040010390fd5b825163d92e233d60e01b8152fd5b925050346101b25760203660031901126101b2573563ffffffff60e01b81168091036101b25760209250637965db0b60e01b8114908115610ae2575b5015158152f35b6301ffc9a760e01b14905038610adb565b600435906001600160a01b0382168203610b0957565b600080fd5b602435906001600160a01b0382168203610b0957565b602090602060408183019282815285518094520193019160005b828110610b4c575050505090565b83516001600160a01b031685529381019392810192600101610b3e565b90601f8019910116810190811067ffffffffffffffff821117610b8b57604052565b634e487b7160e01b600052604160045260246000fd5b3d15610bdc573d9067ffffffffffffffff8211610b8b5760405191610bd0601f8201601f191660200184610b69565b82523d6000602084013e565b606090565b67ffffffffffffffff8111610b8b5760051b60200190565b8051821015610c0d5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604081205460ff1615610c5d5750565b6044906040519063e2517d3f60e01b82523360048301526024820152fd5b3360009081527fb5816a4d525ce17c45785e5fbae4518f6f00ef4e9d31d4d7bb129b76152ed32f60205260409020546000805160206112658339815191529060ff1615610c5d5750565b80600052600060205260406000203360005260205260ff6040600020541615610c5d5750565b600260015414610cfc576002600155565b604051633ee5aeb560e01b8152600490fd5b6001600160a01b031660008181527fb5816a4d525ce17c45785e5fbae4518f6f00ef4e9d31d4d7bb129b76152ed32f60205260408120549091906000805160206112658339815191529060ff16610da957808352826020526040832082845260205260408320600160ff198254161790557f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d339380a4600190565b505090565b9060009180835282602052604083209160018060a01b03169182845260205260ff60408420541615600014610da957808352826020526040832082845260205260408320600160ff198254161790557f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d339380a4600190565b6001600160a01b031660008181527fb5816a4d525ce17c45785e5fbae4518f6f00ef4e9d31d4d7bb129b76152ed32f60205260408120549091906000805160206112658339815191529060ff1615610da95780835282602052604083208284526020526040832060ff1981541690557ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b339380a4600190565b9060009180835282602052604083209160018060a01b03169182845260205260ff604084205416600014610da95780835282602052604083208284526020526040832060ff1981541690557ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b339380a4600190565b60405163a9059cbb60e01b602082019081526001600160a01b03939093166024820152604480820194909452928352610f9790610f73606485610b69565b60018060a01b031692600080938192519082875af1610f90610ba1565b9084611201565b908151918215159283610fc7575b505050610faf5750565b60249060405190635274afe760e01b82526004820152fd5b8192935090602091810103126101df57602001519081159182150361051f5750388080610fa5565b600354811015610c0d5760036000527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0190600090565b600090808252600490816020526040832054801515600014611120576000199080820181811161110d57600354908382019182116110fa578181036110b0575b505050600354801561109d5781019061107e82610fef565b909182549160031b1b1916905560035582526020526040812055600190565b634e487b7160e01b855260318452602485fd5b6110e56110bf6110ce93610fef565b90549060031b1c928392610fef565b819391549060031b91821b91600019901b19161790565b90558552836020526040852055388080611066565b634e487b7160e01b875260118652602487fd5b634e487b7160e01b865260118552602486fd5b50505090565b6040519060035480835282602091602082019060036000527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b936000905b82821061117c5750505061117a92500383610b69565b565b855484526001958601958895509381019390910190611164565b6000818152600460205260408120546111fc57600354680100000000000000008110156111e85790826111d46110ce84600160409601600355610fef565b905560035492815260046020522055600190565b634e487b7160e01b82526041600452602482fd5b905090565b90611228575080511561121657805190602001fd5b604051630a12f52160e11b8152600490fd5b8151158061125b575b611239575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b1561123156fe7a05a596cb0ce7fdea8a1e1ec73be300bdb35097c944ce1897202f7a13122eb2a264697066735822122057b94794b44a627af1e1354fc28c531bc29adf6bcbdde441e199c654eaec295c64736f6c63430008180033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000058acc2600835211dcb5847c5fa422791fd492409000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
-----Decoded View---------------
Arg [0] : _dStakeVaultShare (address): 0x58AcC2600835211Dcb5847c5Fa422791Fd492409
Arg [1] : _dStableAsset (address): 0x788D96f655735f52c676A133f4dFC53cEC614d4A
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 00000000000000000000000058acc2600835211dcb5847c5fa422791fd492409
Arg [1] : 000000000000000000000000788d96f655735f52c676a133f4dfc53cec614d4a
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in FRAX
0
Token Allocations
FRAX
100.00%
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|---|---|---|---|---|
| FRAXTAL | 100.00% | $1.01 | 0.00000001047 | <$0.000001 |
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.