Skip to content
Verified contractPartialAGPL-3.0

OneToOneAssetPricer

Address0xe0edb14ef8670d584804e25f97449d96a04f5463
Balance

0 ETH

 

Transactions

0

 

Compiler

solc 0.8.27

 

Same code

1 more contract

 

Details

Compiler
solc 0.8.27+commit.40a35a09
Language
solidity
Optimization
Yes, 100 runs
EVM version
prague
License
AGPL-3.0
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
25,904,602
Creation transaction
0xab82df6d26…007809ad2a

node_modules/@concrete-xyz/earn-v2-core/src/pricer/OneToOneAssetPricer.sol

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.24;

import {IERC20Metadata} from "@openzeppelin-contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {IAssetPricer} from "../interface/IAssetPricer.sol";

/**
 * @title OneToOneAssetPricer
 * @notice MVP asset pricer that treats one unit of the deposit asset as one unit of the base asset,
 *         adjusting only for the difference in token decimals. Suitable for assets that are
 *         economically 1:1 with the base asset (e.g. same-peg stablecoins).
 *
 * @author Blueprint Finance
 * @custom:protocol Concrete Earn V2
 * @custom:license AGPL-3.0
 *
 * @dev Stateless and permissionless: decimals are read live from each token via
 *      {IERC20Metadata-decimals}. Conversions round down, which is conservative for deposits (never
 *      over-values a deposit, favouring the vault). Tokens with mutable decimals are out of scope.
 */
contract OneToOneAssetPricer is IAssetPricer {
    /// @inheritdoc IAssetPricer
    function convertToBase(address depositAsset, address baseAsset, uint256 amount)
        external
        view
        returns (uint256 baseAmount)
    {
        if (amount == 0 || depositAsset == baseAsset) return amount;

        uint8 fromDecimals = IERC20Metadata(depositAsset).decimals();
        uint8 toDecimals = IERC20Metadata(baseAsset).decimals();

        if (fromDecimals == toDecimals) {
            return amount;
        }
        if (fromDecimals < toDecimals) {
            return amount * (10 ** (toDecimals - fromDecimals));
        }
        return amount / (10 ** (fromDecimals - toDecimals));
    }
}

node_modules/@concrete-xyz/earn-v2-core/src/interface/IAssetPricer.sol

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.24;

/**
 * @title IAssetPricer
 * @notice Converts an amount of a deposit asset into its equivalent value denominated in the
 *         vault's base asset. Used by multi-asset vaults to value non-base deposits in base units
 *         (e.g. USDC) while keeping base-asset accounting.
 * @dev Implementations may derive the conversion from decimals only (see {OneToOneAssetPricer}) or
 *      from external price feeds. Pricers are stateless with respect to a specific vault: both the
 *      source and base assets are passed explicitly so a single deployment can serve multiple
 *      vaults and assets.
 */
interface IAssetPricer {
    /**
     * @notice Converts `amount` of `depositAsset` into the equivalent amount of `baseAsset`.
     * @param depositAsset The non-base asset being valued.
     * @param baseAsset The base accounting asset to express the value in.
     * @param amount The amount of `depositAsset` to convert (in `depositAsset` units).
     * @return baseAmount The equivalent value expressed in `baseAsset` units.
     */
    function convertToBase(address depositAsset, address baseAsset, uint256 amount)
        external
        view
        returns (uint256 baseAmount);
}

node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
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);
}

node_modules/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC-20 standard.
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

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

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "runs": 100,
    "enabled": true
  },
  "evmVersion": "prague",
  "remappings": [
    "forge-std/=lib/forge-std/src/",
    "@openzeppelin-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/",
    "@openzeppelin-contracts/=node_modules/@openzeppelin/contracts/",
    "openzeppelin-foundry-upgrades/=node_modules/@openzeppelin/foundry-upgrades/",
    "solidity-bytes-utils/=node_modules/solidity-bytes-utils/",
    "@layerzerolabs/lz-evm-protocol-v2/=node_modules/@layerzerolabs/lz-evm-protocol-v2/",
    "@layerzerolabs/lz-evm-messagelib-v2/=node_modules/@layerzerolabs/lz-evm-messagelib-v2/",
    "@layerzerolabs/lz-evm-v1-0.7/=node_modules/@layerzerolabs/lz-evm-v1-0.7/",
    "@layerzerolabs/oapp-evm/=node_modules/@layerzerolabs/oapp-evm/",
    "@layerzerolabs/oapp-evm-upgradeable/=node_modules/@layerzerolabs/oapp-evm-upgradeable/",
    "earn-v2-core/=node_modules/@concrete-xyz/earn-v2-core/",
    "earn-v2-core-1.0.1/=node_modules/@blueprint-finance/earn-v2-core-1.0.1/",
    "earn-v2-core-1.0.2/=node_modules/@blueprint-finance/earn-v2-core-1.0.2/",
    "earn-v2-core-1.0.2-beta.0/=node_modules/@blueprint-finance/earn-v2-core-1.0.2-beta.0/",
    "earn-v2-core-1.1.0/=node_modules/@blueprint-finance/earn-v2-core-1.1.0/",
    "earn-v2-core-1.3.0/=node_modules/@concrete-xyz/earn-v2-core-1.3.0/",
    "earn-v2-core-1.4.2-beta.1/=node_modules/@concrete-xyz/earn-v2-core-1.4.2-beta.1/",
    "asset-cx/=node_modules/@concrete-xyz/asset-cx/",
    "@concrete-xyz/asset-cx/=node_modules/@concrete-xyz/asset-cx/",
    "@blueprint-finance/earn-v2-core/=node_modules/@concrete-xyz/earn-v2-core/",
    "@concrete-xyz/earn-v2-core/=node_modules/@concrete-xyz/earn-v2-core/",
    "@prb/math/=node_modules/@prb/math/",
    "node_modules/@dolomite-exchange/dolomite-margin/:@openzeppelin/=node_modules/@dolomite-exchange/dolomite-margin/node_modules/@openzeppelin/",
    "node_modules/@dolomite-exchange/dolomite-margin/:@openzeppelin/=node_modules/@dolomite-exchange/dolomite-margin/node_modules/@openzeppelin/",
    "node_modules/@uniswap/v3-periphery/:@openzeppelin/=node_modules/@uniswap/v3-periphery/node_modules/@openzeppelin/",
    "node_modules/@uniswap/v3-periphery/:@openzeppelin/=node_modules/@uniswap/v3-periphery/node_modules/@openzeppelin/",
    "@aave/=node_modules/@aave/",
    "@concrete-xyz/=node_modules/@concrete-xyz/",
    "@dolomite-exchange/=node_modules/@dolomite-exchange/",
    "@layerzerolabs/=node_modules/@layerzerolabs/",
    "@morpho-org/=node_modules/@morpho-org/",
    "@openzeppelin/=node_modules/@openzeppelin/",
    "@prb/=node_modules/@prb/",
    "@uniswap/=node_modules/@uniswap/",
    "base64-sol/=node_modules/base64-sol/",
    "canonical-weth/=node_modules/canonical-weth/",
    "clones-with-immutable-args/=node_modules/clones-with-immutable-args/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.