Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xA860fe124fDABD43672EAD85183daE6f2df0421d
Balance 0 ETH
Nonce 1
Code Size 6591 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

6591 bytes
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806367627b621161008c578063c760af5c11610066578063c760af5c1461023b578063edac520314610257578063fb00d51414610275578063ffa1ad7414610291576100ea565b806367627b62146101cf578063965fa21e146101ff578063a3f4df7e1461021d576100ea565b8063484267a4116100c8578063484267a41461014757806359011cd1146101775780635c833bfd1461019557806361d027b3146101b1576100ea565b80630c340a24146100ef5780631e9a69501461010d57806326ac1d5614610129575b600080fd5b6100f76102af565b60405161010491906111e6565b60405180910390f35b61012760048036038101906101229190610ee5565b610354565b005b6101316103c0565b60405161013e919061137e565b60405180910390f35b610161600480360381019061015c9190610e93565b6103c6565b60405161016e919061137e565b60405180910390f35b61017f61045f565b60405161018c919061137e565b60405180910390f35b6101af60048036038101906101aa9190610f21565b610465565b005b6101b96104cb565b6040516101c691906111e6565b60405180910390f35b6101e960048036038101906101e49190610ee5565b610570565b6040516101f6919061137e565b60405180910390f35b610207610646565b604051610214919061137e565b60405180910390f35b61022561064c565b604051610232919061127c565b60405180910390f35b61025560048036038101906102509190610f99565b610685565b005b61025f6107d4565b60405161026c9190611261565b60405180910390f35b61028f600480360381019061028a9190610f99565b6107f8565b005b610299610947565b6040516102a6919061127c565b60405180910390f35b60007f000000000000000000000000677ddbd918637e5f2c79e164d402454de7da861973ffffffffffffffffffffffffffffffffffffffff16630c340a246040518163ffffffff1660e01b815260040160206040518083038186803b15801561031757600080fd5b505afa15801561032b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061034f9190610ebc565b905090565b6002600054141561039a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103919061133e565b60405180910390fd5b60026000819055506103b482826103af610980565b610988565b60016000819055505050565b61271081565b60006103d06104cb565b73ffffffffffffffffffffffffffffffffffffffff1663ce513b6f836040518263ffffffff1660e01b815260040161040891906111e6565b60206040518083038186803b15801561042057600080fd5b505afa158015610434573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104589190610fc2565b9050919050565b60025481565b600260005414156104ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104a29061133e565b60405180910390fd5b60026000819055506104be838383610988565b6001600081905550505050565b60007f000000000000000000000000677ddbd918637e5f2c79e164d402454de7da861973ffffffffffffffffffffffffffffffffffffffff166361d027b36040518163ffffffff1660e01b815260040160206040518083038186803b15801561053357600080fd5b505afa158015610547573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061056b9190610ebc565b905090565b60008061057b6104cb565b90508073ffffffffffffffffffffffffffffffffffffffff1663ab37f486856040518263ffffffff1660e01b81526004016105b691906111e6565b60206040518083038186803b1580156105ce57600080fd5b505afa1580156105e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106069190610f70565b1561063a5760006106178585610aa6565b9050610622856103c6565b811161062e5780610631565b60005b92505050610640565b60009150505b92915050565b60015481565b6040518060400160405280600d81526020017f565553442d52656465656d65720000000000000000000000000000000000000081525081565b61068d6102af565b73ffffffffffffffffffffffffffffffffffffffff166106ab610980565b73ffffffffffffffffffffffffffffffffffffffff1614610701576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106f8906112de565b60405180910390fd5b612710811115610746576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161073d906112fe565b60405180910390fd5b6000600254905081811415610790576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107879061129e565b60405180910390fd5b816002819055507f3cb23ae97dcd603618548f333b96dbb9e41059b6fd0eb7face59058c5ac3b11b81836040516107c8929190611399565b60405180910390a15050565b7f000000000000000000000000677ddbd918637e5f2c79e164d402454de7da861981565b6108006102af565b73ffffffffffffffffffffffffffffffffffffffff1661081e610980565b73ffffffffffffffffffffffffffffffffffffffff1614610874576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161086b906112de565b60405180910390fd5b6127108111156108b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108b09061135e565b60405180910390fd5b6000600154905081811415610903576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108fa9061131e565b60405180910390fd5b816001819055507f78f68725a1b1a56a998dd7a8d279eb9bfbd45bc0fcee78f408200737275873e5818360405161093b929190611399565b60405180910390a15050565b6040518060400160405280600581526020017f312e342e3000000000000000000000000000000000000000000000000000000081525081565b600033905090565b60006109948484610aa6565b90507f000000000000000000000000677ddbd918637e5f2c79e164d402454de7da861973ffffffffffffffffffffffffffffffffffffffff166379cc67906109da610980565b856040518363ffffffff1660e01b81526004016109f8929190611201565b600060405180830381600087803b158015610a1257600080fd5b505af1158015610a26573d6000803e3d6000fd5b50505050610a326104cb565b73ffffffffffffffffffffffffffffffffffffffff166369328dec8583856040518463ffffffff1660e01b8152600401610a6e9392919061122a565b600060405180830381600087803b158015610a8857600080fd5b505af1158015610a9c573d6000803e3d6000fd5b5050505050505050565b600080610ab16104cb565b73ffffffffffffffffffffffffffffffffffffffff1663addd5099856040518263ffffffff1660e01b8152600401610ae991906111e6565b60206040518083038186803b158015610b0157600080fd5b505afa158015610b15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b399190610ebc565b905060008173ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610b8357600080fd5b505afa158015610b97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bbb9190611062565b9050600081600a610bcc91906114b8565b9050600061271060025483610be191906115d6565b610beb9190611434565b905060008183610bfb91906113de565b905060008284610c0b9190611630565b905060008673ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b158015610c5557600080fd5b505afa158015610c69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c8d9190610feb565b5050509150506000819050838111158015610ca85750828110155b610ce7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cde906112be565b60405180910390fd5b600086828c610cf691906115d6565b610d009190611434565b90506000600154905060008114610d38576127108183610d2091906115d6565b610d2a9190611434565b82610d359190611630565b91505b8c73ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610d7e57600080fd5b505afa158015610d92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db69190611062565b6012610dc29190611664565b600a610dce91906114b8565b82610dd99190611434565b9a505050505050505050505092915050565b600081359050610dfa816118ff565b92915050565b600081519050610e0f816118ff565b92915050565b600081519050610e2481611916565b92915050565b600081519050610e398161192d565b92915050565b600081359050610e4e81611944565b92915050565b600081519050610e6381611944565b92915050565b600081519050610e7881611972565b92915050565b600081519050610e8d8161195b565b92915050565b600060208284031215610ea557600080fd5b6000610eb384828501610deb565b91505092915050565b600060208284031215610ece57600080fd5b6000610edc84828501610e00565b91505092915050565b60008060408385031215610ef857600080fd5b6000610f0685828601610deb565b9250506020610f1785828601610e3f565b9150509250929050565b600080600060608486031215610f3657600080fd5b6000610f4486828701610deb565b9350506020610f5586828701610e3f565b9250506040610f6686828701610deb565b9150509250925092565b600060208284031215610f8257600080fd5b6000610f9084828501610e15565b91505092915050565b600060208284031215610fab57600080fd5b6000610fb984828501610e3f565b91505092915050565b600060208284031215610fd457600080fd5b6000610fe284828501610e54565b91505092915050565b600080600080600060a0868803121561100357600080fd5b600061101188828901610e69565b955050602061102288828901610e2a565b945050604061103388828901610e54565b935050606061104488828901610e54565b925050608061105588828901610e69565b9150509295509295909350565b60006020828403121561107457600080fd5b600061108284828501610e7e565b91505092915050565b61109481611698565b82525050565b6110a38161170d565b82525050565b60006110b4826113c2565b6110be81856113cd565b93506110ce818560208601611731565b6110d7816117c2565b840191505092915050565b60006110ef600e836113cd565b91506110fa826117e0565b602082019050919050565b60006111126018836113cd565b915061111d82611809565b602082019050919050565b6000611135601a836113cd565b915061114082611832565b602082019050919050565b6000611158601a836113cd565b91506111638261185b565b602082019050919050565b600061117b600f836113cd565b915061118682611884565b602082019050919050565b600061119e601f836113cd565b91506111a9826118ad565b602082019050919050565b60006111c16018836113cd565b91506111cc826118d6565b602082019050919050565b6111e0816116e0565b82525050565b60006020820190506111fb600083018461108b565b92915050565b6000604082019050611216600083018561108b565b61122360208301846111d7565b9392505050565b600060608201905061123f600083018661108b565b61124c60208301856111d7565b611259604083018461108b565b949350505050565b6000602082019050611276600083018461109a565b92915050565b6000602082019050818103600083015261129681846110a9565b905092915050565b600060208201905081810360008301526112b7816110e2565b9050919050565b600060208201905081810360008301526112d781611105565b9050919050565b600060208201905081810360008301526112f781611128565b9050919050565b600060208201905081810360008301526113178161114b565b9050919050565b600060208201905081810360008301526113378161116e565b9050919050565b6000602082019050818103600083015261135781611191565b9050919050565b60006020820190508181036000830152611377816111b4565b9050919050565b600060208201905061139360008301846111d7565b92915050565b60006040820190506113ae60008301856111d7565b6113bb60208301846111d7565b9392505050565b600081519050919050565b600082825260208201905092915050565b60006113e9826116e0565b91506113f4836116e0565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561142957611428611764565b5b828201905092915050565b600061143f826116e0565b915061144a836116e0565b92508261145a57611459611793565b5b828204905092915050565b6000808291508390505b60018511156114af5780860481111561148b5761148a611764565b5b600185161561149a5780820291505b80810290506114a8856117d3565b945061146f565b94509492505050565b60006114c3826116e0565b91506114ce836116ea565b92506114fb7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8484611503565b905092915050565b60008261151357600190506115cf565b8161152157600090506115cf565b8160018114611537576002811461154157611570565b60019150506115cf565b60ff84111561155357611552611764565b5b8360020a91508482111561156a57611569611764565b5b506115cf565b5060208310610133831016604e8410600b84101617156115a55782820a9050838111156115a05761159f611764565b5b6115cf565b6115b28484846001611465565b925090508184048111156115c9576115c8611764565b5b81810290505b9392505050565b60006115e1826116e0565b91506115ec836116e0565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561162557611624611764565b5b828202905092915050565b600061163b826116e0565b9150611646836116e0565b92508282101561165957611658611764565b5b828203905092915050565b600061166f826116ea565b915061167a836116ea565b92508282101561168d5761168c611764565b5b828203905092915050565b60006116a3826116c0565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600069ffffffffffffffffffff82169050919050565b60006117188261171f565b9050919050565b600061172a826116c0565b9050919050565b60005b8381101561174f578082015181840152602081019050611734565b8381111561175e576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000601f19601f8301169050919050565b60008160011c9050919050565b7f73616d652d746f6c6572616e6365000000000000000000000000000000000000600082015250565b7f70726963652d746f6c6572616e63652d65786365656465640000000000000000600082015250565b7f63616c6c65722d69732d6e6f742d7468652d676f7665726e6f72000000000000600082015250565b7f70726963652d746f6c6572616e63652d69732d696e76616c6964000000000000600082015250565b7f73616d652d72656465656d2d6665650000000000000000000000000000000000600082015250565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b7f72656465656d2d6665652d6c696d69742d726561636865640000000000000000600082015250565b61190881611698565b811461191357600080fd5b50565b61191f816116aa565b811461192a57600080fd5b50565b611936816116b6565b811461194157600080fd5b50565b61194d816116e0565b811461195857600080fd5b50565b611964816116ea565b811461196f57600080fd5b50565b61197b816116f7565b811461198657600080fd5b5056fea26469706673582212202e680656181b24d8e77a18f21f711bc1e37c2563ba22b187774e3b2c7d22ce0464736f6c63430008030033

Verified Source Code Full Match

Compiler: v0.8.3+commit.8d00100c EVM: istanbul Optimization: No
ReentrancyGuard.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @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;

    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() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @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);
}
IERC20Metadata.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}
draft-IERC20Permit.sol 60 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @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.
 */
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].
     */
    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);
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}
Redeemer.sol 149 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.3;

import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "./interfaces/chainlink/IAggregatorV3.sol";
import "./interfaces/IVUSD.sol";
import "./interfaces/ITreasury.sol";

/// @title VUSD Redeemer, User can redeem their VUSD with any supported tokens
contract Redeemer is Context, ReentrancyGuard {
    string public constant NAME = "VUSD-Redeemer";
    string public constant VERSION = "1.4.0";

    IVUSD public immutable vusd;

    uint256 public redeemFee = 30; // Default 0.3% fee
    uint256 public constant MAX_REDEEM_FEE = 10_000; // 10_000 = 100%
    uint256 public priceTolerance = 100; // Default 1% based on BPS

    event UpdatedRedeemFee(uint256 previousRedeemFee, uint256 newRedeemFee);
    event UpdatedPriceTolerance(uint256 previousTolerance, uint256 newTolerance);

    constructor(address _vusd) {
        require(_vusd != address(0), "vusd-address-is-zero");
        vusd = IVUSD(_vusd);
    }

    modifier onlyGovernor() {
        require(_msgSender() == governor(), "caller-is-not-the-governor");
        _;
    }

    ////////////////////////////// Only Governor //////////////////////////////

    /// @notice Update redeem fee
    function updateRedeemFee(uint256 _newRedeemFee) external onlyGovernor {
        require(_newRedeemFee <= MAX_REDEEM_FEE, "redeem-fee-limit-reached");
        uint256 _previousRedeemFee = redeemFee;
        require(_previousRedeemFee != _newRedeemFee, "same-redeem-fee");
        redeemFee = _newRedeemFee;
        emit UpdatedRedeemFee(_previousRedeemFee, _newRedeemFee);
    }

    /// @notice Update price tolerance
    function updatePriceTolerance(uint256 _newTolerance) external onlyGovernor {
        require(_newTolerance <= MAX_REDEEM_FEE, "price-tolerance-is-invalid");
        uint256 _previousTolerance = priceTolerance;
        require(_previousTolerance != _newTolerance, "same-tolerance");
        priceTolerance = _newTolerance;
        emit UpdatedPriceTolerance(_previousTolerance, _newTolerance);
    }

    ///////////////////////////////////////////////////////////////////////////

    /**
     * @notice Redeem token and burn VUSD amount less redeem fee, if any.
     * @param _token Token to redeem, it should be 1 of the supported tokens from treasury.
     * @param _vusdAmount VUSD amount to burn
     */
    function redeem(address _token, uint256 _vusdAmount) external nonReentrant {
        _redeem(_token, _vusdAmount, _msgSender());
    }

    /**
     * @notice Redeem token and burn VUSD amount less redeem fee, if any.
     * @param _token Token to redeem, it should be 1 of the supported tokens from treasury.
     * @param _vusdAmount VUSD amount to burn. VUSD will be burnt from caller
     * @param _tokenReceiver Address of token receiver
     */
    function redeem(
        address _token,
        uint256 _vusdAmount,
        address _tokenReceiver
    ) external nonReentrant {
        _redeem(_token, _vusdAmount, _tokenReceiver);
    }

    /**
     * @notice Current redeemable amount for given token and vusdAmount.
     * If token is not supported by treasury it will return 0.
     * If vusdAmount is higher than current total redeemable of token it will return 0.
     * @param _token Token to redeem
     * @param _vusdAmount VUSD amount to burn
     */
    function redeemable(address _token, uint256 _vusdAmount) external view returns (uint256) {
        ITreasury _treasury = ITreasury(treasury());
        if (_treasury.isWhitelistedToken(_token)) {
            uint256 _redeemable = _calculateRedeemable(_token, _vusdAmount);
            return _redeemable > redeemable(_token) ? 0 : _redeemable;
        }
        return 0;
    }

    /// @dev Current redeemable amount for given token
    function redeemable(address _token) public view returns (uint256) {
        return ITreasury(treasury()).withdrawable(_token);
    }

    /// @dev Governor is defined in VUSD token contract only
    function governor() public view returns (address) {
        return vusd.governor();
    }

    /// @dev Treasury is defined in VUSD token contract only
    function treasury() public view returns (address) {
        return vusd.treasury();
    }

    function _redeem(
        address _token,
        uint256 _vusdAmount,
        address _tokenReceiver
    ) internal {
        uint256 _redeemable = _calculateRedeemable(_token, _vusdAmount);
        vusd.burnFrom(_msgSender(), _vusdAmount);
        ITreasury(treasury()).withdraw(_token, _redeemable, _tokenReceiver);
    }

    /**
     * @notice Calculate redeemable amount based on oracle price and redeemFee, if any.
     * Also covert 18 decimal VUSD amount to _token defined decimal amount.
     * @return Token amount that user will get after burning vusdAmount
     */
    function _calculateRedeemable(address _token, uint256 _vusdAmount) internal view returns (uint256) {
        IAggregatorV3 _oracle = IAggregatorV3(ITreasury(treasury()).oracles(_token));
        uint8 _oracleDecimal = IAggregatorV3(_oracle).decimals();

        // Token is expected to be stable coin only. Ideal price is 1 USD
        uint256 _oneUSD = 10**_oracleDecimal;
        uint256 _tolerance = (_oneUSD * priceTolerance) / MAX_REDEEM_FEE;
        uint256 _priceUpperBound = _oneUSD + _tolerance;
        uint256 _priceLowerBound = _oneUSD - _tolerance;

        (, int256 _price, , , ) = IAggregatorV3(_oracle).latestRoundData();
        uint256 _latestPrice = uint256(_price);
        require(_latestPrice <= _priceUpperBound && _latestPrice >= _priceLowerBound, "price-tolerance-exceeded");

        uint256 _redeemable = (_vusdAmount * _latestPrice) / _oneUSD;
        uint256 _redeemFee = redeemFee;
        if (_redeemFee != 0) {
            _redeemable -= (_redeemable * _redeemFee) / MAX_REDEEM_FEE;
        }
        // convert redeemable to _token defined decimal
        return _redeemable / 10**(18 - IERC20Metadata(_token).decimals());
    }
}
ITreasury.sol 23 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.3;

interface ITreasury {
    function withdraw(address _token, uint256 _amount) external;

    function withdraw(
        address _token,
        uint256 _amount,
        address _tokenReceiver
    ) external;

    function isWhitelistedToken(address _address) external view returns (bool);

    function oracles(address _token) external view returns (address);

    function withdrawable(address _token) external view returns (uint256);

    function whitelistedTokens() external view returns (address[] memory);

    function vusd() external view returns (address);
}
IVUSD.sol 24 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.3;

import "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IVUSD is IERC20, IERC20Permit {
    function burnFrom(address _user, uint256 _amount) external;

    function mint(address _to, uint256 _amount) external;

    function multiTransfer(address[] memory _recipients, uint256[] memory _amounts) external returns (bool);

    function updateMinter(address _newMinter) external;

    function updateTreasury(address _newTreasury) external;

    function governor() external view returns (address _governor);

    function minter() external view returns (address _minter);

    function treasury() external view returns (address _treasury);
}
IAggregatorV3.sol 35 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.3;

interface IAggregatorV3 {
    function decimals() external view returns (uint8);

    function description() external view returns (string memory);

    function version() external view returns (uint256);

    // getRoundData and latestRoundData should both raise "No data present"
    // if they do not have data to report, instead of returning unset values
    // which could be misinterpreted as actual reported values.
    function getRoundData(uint80 _roundId)
        external
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        );

    function latestRoundData()
        external
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        );
}

Read Contract

MAX_REDEEM_FEE 0x26ac1d56 → uint256
NAME 0xa3f4df7e → string
VERSION 0xffa1ad74 → string
governor 0x0c340a24 → address
priceTolerance 0x59011cd1 → uint256
redeemFee 0x965fa21e → uint256
redeemable 0x484267a4 → uint256
redeemable 0x67627b62 → uint256
treasury 0x61d027b3 → address
vusd 0xedac5203 → address

Write Contract 4 functions

These functions modify contract state and require a wallet transaction to execute.

redeem 0x1e9a6950
address _token
uint256 _vusdAmount
redeem 0x5c833bfd
address _token
uint256 _vusdAmount
address _tokenReceiver
updatePriceTolerance 0xc760af5c
uint256 _newTolerance
updateRedeemFee 0xfb00d514
uint256 _newRedeemFee

Recent Transactions

No transactions found for this address