Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0xD2F180d2...007d979D6 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
CurveLPPessimisticFeed
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 10000 runs
Other Settings:
shanghai EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import {ICurvePool} from "src/interfaces/ICurvePool.sol";
import {IChainlinkBasePriceFeed} from "src/interfaces/IChainlinkFeed.sol";
import {IERC20} from "src/interfaces/IERC20.sol";
contract CurveLPPessimisticFeed {
ICurvePool public immutable curvePool;
IChainlinkBasePriceFeed public immutable coin1Feed;
IChainlinkBasePriceFeed public immutable coin2Feed;
string public description;
constructor(
address _curvePool,
address _coin1Feed,
address _coin2Feed,
bool _oldCurveImpl
) {
curvePool = ICurvePool(_curvePool);
coin1Feed = IChainlinkBasePriceFeed(_coin1Feed);
coin2Feed = IChainlinkBasePriceFeed(_coin2Feed);
require(
coin1Feed.decimals() == coin2Feed.decimals() &&
coin1Feed.decimals() == 18,
"CurveLPPessimisticFeed: DECIMALS_MISMATCH"
);
if (_oldCurveImpl)
description = string(
abi.encodePacked(
IERC20(curvePool.lp_token()).symbol(),
" / USD"
)
);
else
description = string(
abi.encodePacked(curvePool.symbol(), " / USD")
);
}
/**
* @return roundId The round ID of the Chainlink price feed
* @return minLpUsdprice The latest LP token price in USD
* @return startedAt The timestamp when the latest round of Chainlink price feed started
* @return updatedAt The timestamp when the latest round of Chainlink price feed was updated
* @return answeredInRound The round ID in which the answer was computed
*/
function latestRoundData()
public
view
returns (uint80, int256, uint256, uint256, uint80)
{
(
uint80 roundId,
int256 usdPriceCoin1,
uint startedAt,
uint updatedAt,
uint80 answeredInRound
) = coin1Feed.latestRoundData();
(
uint80 roundIdCoin2,
int256 usdPriceCoin2,
uint startedAtCoin2,
uint updatedAtCoin2,
uint80 answeredInRoundCoin2
) = coin2Feed.latestRoundData();
int256 minLpUsdPrice;
// If coin1 price is lower than coin2 price, use coin1 price
if (usdPriceCoin1 < usdPriceCoin2) {
minLpUsdPrice =
(usdPriceCoin1 * int256(curvePool.get_virtual_price())) /
int256(10 ** decimals());
} else {
minLpUsdPrice =
(usdPriceCoin2 * int(curvePool.get_virtual_price())) /
int256(10 ** decimals());
}
if (updatedAtCoin2 < updatedAt) {
roundId = roundIdCoin2;
startedAt = startedAtCoin2;
updatedAt = updatedAtCoin2;
answeredInRound = answeredInRoundCoin2;
}
return (roundId, minLpUsdPrice, startedAt, updatedAt, answeredInRound);
}
/**
@notice Retrieves the latest price for LP token
@return price The latest price for LP token
*/
function latestAnswer() external view returns (int256) {
(, int256 price, , , ) = latestRoundData();
return price;
}
/**
* @notice Retrieves number of decimals for the LP token price feed
* @return decimals The number of decimals for the LP token price feed
*/
function decimals() public pure returns (uint8) {
return 18;
}
}pragma solidity ^0.8.13;
interface ICurvePool {
function price_oracle(uint256 k) external view returns (uint256);
function get_virtual_price() external view returns (uint256);
function price_oracle() external view returns (uint256);
function add_liquidity(
uint256[2] memory _amounts,
uint256 _min_mint_amount,
address _receiver
) external returns (uint256);
function add_liquidity(
uint256[] memory _amounts,
uint256 _min_mint_amount,
address _receiver
) external returns (uint256);
function add_liquidity(
uint256[2] memory _amounts,
uint256 _min_mint_amount
) external returns (uint256);
function add_liquidity(
uint256[] memory _amounts,
uint256 _min_mint_amount
) external returns (uint256);
function add_liquidity(
uint256[3] memory _amounts,
uint256 _min_mint_amount,
address _receiver
) external returns (uint256);
function add_liquidity(
uint256[3] memory _amounts,
uint256 _min_mint_amount
) external returns (uint256);
function remove_liquidity_one_coin(
uint256 _burn_amount,
int128 i,
uint256 _min_received,
address _receiver
) external returns (uint256);
function coins(uint index) external view returns (address);
function exchange(
uint i,
uint j,
uint dx,
uint min_dy,
bool use_eth,
address receiver
) external payable returns (uint);
function calc_token_amount(
uint256[2] memory _amounts,
bool _is_deposit
) external view returns (uint256);
function calc_token_amount(
uint256[] memory _amounts,
bool _is_deposit
) external view returns (uint256);
function calc_withdraw_one_coin(
uint256 _burn_amount,
int128 i
) external view returns (uint256);
function symbol() external view returns (string memory);
function lp_token() external view returns (address);
}pragma solidity ^0.8.13;
interface IChainlinkFeed {
function aggregator() external view returns (address aggregator);
function decimals() external view returns (uint8 decimals);
function latestRoundData()
external
view
returns (
uint80 roundId,
int256 crvUsdPrice,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
function latestAnswer() external view returns (int256 price);
function description() external view returns (string memory description);
}
interface IChainlinkBasePriceFeed is IChainlinkFeed {
function assetToUsd() external view returns (IChainlinkFeed);
function assetToUsdFallback() external view returns (IChainlinkFeed);
function assetToUsdHeartbeat() external view returns (uint256 heartbeat);
}pragma solidity ^0.8.13;
interface IERC20 {
function approve(address, uint) external;
function transfer(address, uint) external returns (bool);
function transferFrom(address, address, uint) external returns (bool);
function balanceOf(address) external view returns (uint);
function allowance(address from, address to) external view returns (uint);
function symbol() external view returns (string memory);
}
interface IMintable is IERC20 {
function mint(address, uint) external;
function burn(uint) external;
function addMinter(address minter) external;
}
interface IDelegateableERC20 is IERC20 {
function delegate(address delegatee) external;
function delegates(
address delegator
) external view returns (address delegatee);
}{
"remappings": [
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"solmate/=lib/solmate/src/",
"halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/"
],
"optimizer": {
"enabled": true,
"runs": 10000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "shanghai",
"viaIR": false,
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_curvePool","type":"address"},{"internalType":"address","name":"_coin1Feed","type":"address"},{"internalType":"address","name":"_coin2Feed","type":"address"},{"internalType":"bool","name":"_oldCurveImpl","type":"bool"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"coin1Feed","outputs":[{"internalType":"contract IChainlinkBasePriceFeed","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"coin2Feed","outputs":[{"internalType":"contract IChainlinkBasePriceFeed","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"curvePool","outputs":[{"internalType":"contract ICurvePool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"description","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestAnswer","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestRoundData","outputs":[{"internalType":"uint80","name":"","type":"uint80"},{"internalType":"int256","name":"","type":"int256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint80","name":"","type":"uint80"}],"stateMutability":"view","type":"function"}]Contract Creation Code
0x60e060405234801562000010575f80fd5b5060405162000fc338038062000fc38339810160408190526200003391620003b7565b6001600160a01b0380851660805283811660a052821660c08190526040805163313ce56760e01b8152905163313ce567916004808201926020929091908290030181865afa15801562000088573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620000ae919062000416565b60ff1660a0516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015620000f0573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000116919062000416565b60ff161480156200018e575060a0516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000161573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000187919062000416565b60ff166012145b620001f15760405162461bcd60e51b815260206004820152602960248201527f43757276654c5050657373696d6973746963466565643a20444543494d414c536044820152680be9a92a69a82a886960bb1b606482015260840160405180910390fd5b8015620002f8576080516001600160a01b03166382c630666040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000237573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200025d91906200043f565b6001600160a01b03166395d89b416040518163ffffffff1660e01b81526004015f60405180830381865afa15801562000298573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052620002c1919081019062000493565b604051602001620002d3919062000546565b6040516020818303038152906040525f9081620002f19190620005fd565b5062000391565b6080516001600160a01b03166395d89b416040518163ffffffff1660e01b81526004015f60405180830381865afa15801562000336573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526200035f919081019062000493565b60405160200162000371919062000546565b6040516020818303038152906040525f90816200038f9190620005fd565b505b50505050620006c5565b80516001600160a01b0381168114620003b2575f80fd5b919050565b5f805f8060808587031215620003cb575f80fd5b620003d6856200039b565b9350620003e6602086016200039b565b9250620003f6604086016200039b565b9150606085015180151581146200040b575f80fd5b939692955090935050565b5f6020828403121562000427575f80fd5b815160ff8116811462000438575f80fd5b9392505050565b5f6020828403121562000450575f80fd5b62000438826200039b565b634e487b7160e01b5f52604160045260245ffd5b5f5b838110156200048b57818101518382015260200162000471565b50505f910152565b5f60208284031215620004a4575f80fd5b81516001600160401b0380821115620004bb575f80fd5b818401915084601f830112620004cf575f80fd5b815181811115620004e457620004e46200045b565b604051601f8201601f19908116603f011681019083821181831017156200050f576200050f6200045b565b8160405282815287602084870101111562000528575f80fd5b6200053b8360208301602088016200046f565b979650505050505050565b5f8251620005598184602087016200046f565b65080bc81554d160d21b920191825250600601919050565b600181811c908216806200058657607f821691505b602082108103620005a557634e487b7160e01b5f52602260045260245ffd5b50919050565b601f821115620005f8575f81815260208120601f850160051c81016020861015620005d35750805b601f850160051c820191505b81811015620005f457828155600101620005df565b5050505b505050565b81516001600160401b038111156200061957620006196200045b565b62000631816200062a845462000571565b84620005ab565b602080601f83116001811462000667575f84156200064f5750858301515b5f19600386901b1c1916600185901b178555620005f4565b5f85815260208120601f198616915b82811015620006975788860151825594840194600190910190840162000676565b5085821015620006b557878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c0516108b86200070b5f395f818161010e01526102de01525f8181610135015261024201525f818160830152818161038a015261043e01526108b85ff3fe608060405234801561000f575f80fd5b506004361061007a575f3560e01c80637284e416116100585780637284e416146100f45780638c94cfd014610109578063faba60dd14610130578063feaf968c14610157575f80fd5b8063218751b21461007e578063313ce567146100cf57806350d25bcd146100de575b5f80fd5b6100a57f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b604051601281526020016100c6565b6100e6610196565b6040519081526020016100c6565b6100fc6101ab565b6040516100c6919061050e565b6100a57f000000000000000000000000000000000000000000000000000000000000000081565b6100a57f000000000000000000000000000000000000000000000000000000000000000081565b61015f610236565b6040805169ffffffffffffffffffff968716815260208101959095528401929092526060830152909116608082015260a0016100c6565b5f806101a0610236565b509195945050505050565b5f80546101b790610577565b80601f01602080910402602001604051908101604052809291908181526020018280546101e390610577565b801561022e5780601f106102055761010080835404028352916020019161022e565b820191905f5260205f20905b81548152906001019060200180831161021157829003601f168201915b505050505081565b5f805f805f805f805f807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa1580156102a9573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102cd91906105e6565b945094509450945094505f805f805f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610345573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061036991906105e6565b945094509450945094505f848a1215610430576103886012600a61077f565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663bb7b8b806040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103f1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104159190610794565b61041f908c6107ab565b61042991906107f6565b90506104e0565b61043c6012600a61077f565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663bb7b8b806040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104a5573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104c99190610794565b6104d390876107ab565b6104dd91906107f6565b90505b878310156104f557859a508398508297508196505b999f999e50969c50949a50929850959650505050505050565b5f6020808352835180828501525f5b818110156105395785810183015185820160400152820161051d565b505f6040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b600181811c9082168061058b57607f821691505b6020821081036105c2577f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b50919050565b805169ffffffffffffffffffff811681146105e1575f80fd5b919050565b5f805f805f60a086880312156105fa575f80fd5b610603866105c8565b9450602086015193506040860151925060608601519150610626608087016105c8565b90509295509295909350565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b600181815b808511156106b857817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561069e5761069e610632565b808516156106ab57918102915b93841c9390800290610664565b509250929050565b5f826106ce57506001610779565b816106da57505f610779565b81600181146106f057600281146106fa57610716565b6001915050610779565b60ff84111561070b5761070b610632565b50506001821b610779565b5060208310610133831016604e8410600b8410161715610739575081810a610779565b610743838361065f565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561077557610775610632565b0290505b92915050565b5f61078d60ff8416836106c0565b9392505050565b5f602082840312156107a4575f80fd5b5051919050565b8082025f82127f8000000000000000000000000000000000000000000000000000000000000000841416156107e2576107e2610632565b818105831482151761077957610779610632565b5f82610829577f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83147f80000000000000000000000000000000000000000000000000000000000000008314161561087d5761087d610632565b50059056fea2646970667358221220bd9068434452aaf2d62f6bc1171556499dcfb61da367645ac2be8d527b2609ab64736f6c634300081400330000000000000000000000008b83c4aa949254895507d09365229bc3a8c7f710000000000000000000000000070287a072cf7ead994f5b91d75fbdf92a5eafb70000000000000000000000005cb542eb054f81b8fa1760c077f44aa80271c75d0000000000000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x608060405234801561000f575f80fd5b506004361061007a575f3560e01c80637284e416116100585780637284e416146100f45780638c94cfd014610109578063faba60dd14610130578063feaf968c14610157575f80fd5b8063218751b21461007e578063313ce567146100cf57806350d25bcd146100de575b5f80fd5b6100a57f0000000000000000000000008b83c4aa949254895507d09365229bc3a8c7f71081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b604051601281526020016100c6565b6100e6610196565b6040519081526020016100c6565b6100fc6101ab565b6040516100c6919061050e565b6100a57f0000000000000000000000005cb542eb054f81b8fa1760c077f44aa80271c75d81565b6100a57f000000000000000000000000070287a072cf7ead994f5b91d75fbdf92a5eafb781565b61015f610236565b6040805169ffffffffffffffffffff968716815260208101959095528401929092526060830152909116608082015260a0016100c6565b5f806101a0610236565b509195945050505050565b5f80546101b790610577565b80601f01602080910402602001604051908101604052809291908181526020018280546101e390610577565b801561022e5780601f106102055761010080835404028352916020019161022e565b820191905f5260205f20905b81548152906001019060200180831161021157829003601f168201915b505050505081565b5f805f805f805f805f807f000000000000000000000000070287a072cf7ead994f5b91d75fbdf92a5eafb773ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa1580156102a9573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102cd91906105e6565b945094509450945094505f805f805f7f0000000000000000000000005cb542eb054f81b8fa1760c077f44aa80271c75d73ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610345573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061036991906105e6565b945094509450945094505f848a1215610430576103886012600a61077f565b7f0000000000000000000000008b83c4aa949254895507d09365229bc3a8c7f71073ffffffffffffffffffffffffffffffffffffffff1663bb7b8b806040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103f1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104159190610794565b61041f908c6107ab565b61042991906107f6565b90506104e0565b61043c6012600a61077f565b7f0000000000000000000000008b83c4aa949254895507d09365229bc3a8c7f71073ffffffffffffffffffffffffffffffffffffffff1663bb7b8b806040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104a5573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104c99190610794565b6104d390876107ab565b6104dd91906107f6565b90505b878310156104f557859a508398508297508196505b999f999e50969c50949a50929850959650505050505050565b5f6020808352835180828501525f5b818110156105395785810183015185820160400152820161051d565b505f6040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b600181811c9082168061058b57607f821691505b6020821081036105c2577f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b50919050565b805169ffffffffffffffffffff811681146105e1575f80fd5b919050565b5f805f805f60a086880312156105fa575f80fd5b610603866105c8565b9450602086015193506040860151925060608601519150610626608087016105c8565b90509295509295909350565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b600181815b808511156106b857817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561069e5761069e610632565b808516156106ab57918102915b93841c9390800290610664565b509250929050565b5f826106ce57506001610779565b816106da57505f610779565b81600181146106f057600281146106fa57610716565b6001915050610779565b60ff84111561070b5761070b610632565b50506001821b610779565b5060208310610133831016604e8410600b8410161715610739575081810a610779565b610743838361065f565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561077557610775610632565b0290505b92915050565b5f61078d60ff8416836106c0565b9392505050565b5f602082840312156107a4575f80fd5b5051919050565b8082025f82127f8000000000000000000000000000000000000000000000000000000000000000841416156107e2576107e2610632565b818105831482151761077957610779610632565b5f82610829577f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83147f80000000000000000000000000000000000000000000000000000000000000008314161561087d5761087d610632565b50059056fea2646970667358221220bd9068434452aaf2d62f6bc1171556499dcfb61da367645ac2be8d527b2609ab64736f6c63430008140033
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 33 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
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.