Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
SlippageAccounter
Compiler Version
v0.8.13+commit.abaa5c0e
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
/// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.13; import {Ownable} from "openzeppelin-contracts/access/Ownable.sol"; import {ISlippageAccounter} from "./interfaces/ISlippageAccounter.sol"; import {ICurvePool} from "gearbox_integrations/integrations/curve/ICurvePool.sol"; import {IPriceOracleV2} from "gearbox_core/interfaces/IPriceOracle.sol"; import {IAddressProvider} from "gearbox_core/interfaces/IAddressProvider.sol"; contract SlippageAccounter is ISlippageAccounter, Ownable { ICurvePool public curvePool = ICurvePool(0xDC24316b9AE028F1497c275EB9192a3Ea0f67022); address public FRAX = 0x853d955aCEf822Db058eb8505911ED77F175b99e; address public WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; uint256 public MAX_BPS = 1e4; uint256 public leverage = 2 * 1e4; address public addressProvider = 0xcF64698AFF7E5f27A11dff868AF228653ba53be0; constructor(uint256 _leverage) { leverage = _leverage; } function getSlippageAccountedAmount(uint256 amountIn) external view returns (uint256 amountOut) { if (leverage == 0) { return amountIn; } IPriceOracleV2 priceOracle = IPriceOracleV2( IAddressProvider(addressProvider).getPriceOracle() ); uint256 wethBorrowed = priceOracle.convert( (amountIn * leverage) / MAX_BPS, FRAX, WETH ); uint256 stETHReceivedOnCurve = curvePool.get_dy(0, 1, wethBorrowed); uint256 stETHReceivedOnLido = wethBorrowed - 1; uint256 stETHConverted = stETHReceivedOnLido > stETHReceivedOnCurve ? stETHReceivedOnLido : stETHReceivedOnCurve; uint256 wethReturned = curvePool.get_dy(1, 0, stETHConverted); uint256 slippageAmount = (amountIn * (wethBorrowed - wethReturned)) / (2 * wethBorrowed); // half to account for only deposit amountOut = amountIn - slippageAmount; } function setLeverage(uint256 _leverage) external onlyOwner { leverage = _leverage; } function setAddressProvider(address _addressProvider) external onlyOwner { addressProvider = _addressProvider; } }
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; import { IVersion } from "./IVersion.sol"; interface IAddressProviderEvents { /// @dev Emits when an address is set for a contract role event AddressSet(bytes32 indexed service, address indexed newAddress); } /// @title Optimised for front-end Address Provider interface interface IAddressProvider is IAddressProviderEvents, IVersion { /// @return Address of ACL contract function getACL() external view returns (address); /// @return Address of ContractsRegister function getContractsRegister() external view returns (address); /// @return Address of AccountFactory function getAccountFactory() external view returns (address); /// @return Address of DataCompressor function getDataCompressor() external view returns (address); /// @return Address of GEAR token function getGearToken() external view returns (address); /// @return Address of WETH token function getWethToken() external view returns (address); /// @return Address of WETH Gateway function getWETHGateway() external view returns (address); /// @return Address of PriceOracle function getPriceOracle() external view returns (address); /// @return Address of DAO Treasury Multisig function getTreasuryContract() external view returns (address); /// @return Address of PathFinder function getLeveragedActions() external view returns (address); }
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; import { IVersion } from "./IVersion.sol"; interface IPriceOracleV2Events { /// @dev Emits when a new price feed is added event NewPriceFeed(address indexed token, address indexed priceFeed); } interface IPriceOracleV2Exceptions { /// @dev Thrown if a price feed returns 0 error ZeroPriceException(); /// @dev Thrown if the last recorded result was not updated in the last round error ChainPriceStaleException(); /// @dev Thrown on attempting to get a result for a token that does not have a price feed error PriceOracleNotExistsException(); } /// @title Price oracle interface interface IPriceOracleV2 is IPriceOracleV2Events, IPriceOracleV2Exceptions, IVersion { /// @dev Converts a quantity of an asset to USD (decimals = 8). /// @param amount Amount to convert /// @param token Address of the token to be converted function convertToUSD(uint256 amount, address token) external view returns (uint256); /// @dev Converts a quantity of USD (decimals = 8) to an equivalent amount of an asset /// @param amount Amount to convert /// @param token Address of the token converted to function convertFromUSD(uint256 amount, address token) external view returns (uint256); /// @dev Converts one asset into another /// /// @param amount Amount to convert /// @param tokenFrom Address of the token to convert from /// @param tokenTo Address of the token to convert to function convert( uint256 amount, address tokenFrom, address tokenTo ) external view returns (uint256); /// @dev Returns collateral values for two tokens, required for a fast check /// @param amountFrom Amount of the outbound token /// @param tokenFrom Address of the outbound token /// @param amountTo Amount of the inbound token /// @param tokenTo Address of the inbound token /// @return collateralFrom Value of the outbound token amount in USD /// @return collateralTo Value of the inbound token amount in USD function fastCheck( uint256 amountFrom, address tokenFrom, uint256 amountTo, address tokenTo ) external view returns (uint256 collateralFrom, uint256 collateralTo); /// @dev Returns token's price in USD (8 decimals) /// @param token The token to compute the price for function getPrice(address token) external view returns (uint256); /// @dev Returns the price feed address for the passed token /// @param token Token to get the price feed for function priceFeeds(address token) external view returns (address priceFeed); /// @dev Returns the price feed for the passed token, /// with additional parameters /// @param token Token to get the price feed for function priceFeedsWithFlags(address token) external view returns ( address priceFeed, bool skipCheck, uint256 decimals ); } interface IPriceOracleV2Ext is IPriceOracleV2 { /// @dev Sets a price feed if it doesn't exist, or updates an existing one /// @param token Address of the token to set the price feed for /// @param priceFeed Address of a USD price feed adhering to Chainlink's interface function addPriceFeed(address token, address priceFeed) external; }
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; /// @title IVersion /// @dev Declares a version function which returns the contract's version interface IVersion { /// @dev Returns contract version function version() external view returns (uint256); }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.10; interface ICurvePool { function coins(uint256 i) external view returns (address); function underlying_coins(uint256 i) external view returns (address); function balances(uint256 i) external view returns (uint256); function coins(int128) external view returns (address); function underlying_coins(int128) external view returns (address); function balances(int128) external view returns (uint256); function exchange( int128 i, int128 j, uint256 dx, uint256 min_dy ) external; function exchange_underlying( int128 i, int128 j, uint256 dx, uint256 min_dy ) external; function get_dy_underlying( int128 i, int128 j, uint256 dx ) external view returns (uint256); function get_dy( int128 i, int128 j, uint256 dx ) external view returns (uint256); function get_virtual_price() external view returns (uint256); function token() external view returns (address); function remove_liquidity_one_coin( uint256 _token_amount, int128 i, uint256 min_amount ) external; function A() external view returns (uint256); function A_precise() external view returns (uint256); function calc_withdraw_one_coin(uint256 _burn_amount, int128 i) external view returns (uint256); function admin_balances(uint256 i) external view returns (uint256); function admin() external view returns (address); function fee() external view returns (uint256); function admin_fee() external view returns (uint256); function block_timestamp_last() external view returns (uint256); function initial_A() external view returns (uint256); function future_A() external view returns (uint256); function initial_A_time() external view returns (uint256); function future_A_time() external view returns (uint256); // Some pools implement ERC20 function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint256); function balanceOf(address) external view returns (uint256); function allowance(address, address) external view returns (uint256); function totalSupply() external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// 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; } }
/// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; interface ISlippageAccounter { function getSlippageAccountedAmount(uint256 amountIn) external returns (uint256); }
{ "remappings": [ "@chainlink/=lib/gearbox/node_modules/@chainlink/", "@ensdomains/=lib/gearbox/node_modules/@ensdomains/", "@gearbox-protocol/=lib/integrations-v2/node_modules/@gearbox-protocol/", "@openzeppelin/=lib/openzeppelin-contracts/", "@solbase/=lib/zolidity/lib/solbase/", "@std/=lib/zolidity/lib/forge-std/src/", "core-v2/=lib/core-v2/contracts/", "ds-test/=lib/forge-std/lib/ds-test/src/", "forge-std/=lib/forge-std/src/", "gearbox/=lib/gearbox/", "gearbox_core/=lib/core-v2/contracts/", "gearbox_integrations/=lib/integrations-v2/contracts/", "hardhat/=lib/gearbox/node_modules/hardhat/", "integrations-v2/=lib/integrations-v2/", "openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/", "solbase/=lib/zolidity/lib/solbase/src/", "zolidity/=lib/zolidity/src/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "bytecodeHash": "ipfs" }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "london", "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"uint256","name":"_leverage","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"FRAX","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_BPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"addressProvider","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"curvePool","outputs":[{"internalType":"contract ICurvePool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"}],"name":"getSlippageAccountedAmount","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"leverage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_addressProvider","type":"address"}],"name":"setAddressProvider","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_leverage","type":"uint256"}],"name":"setLeverage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
6080604052600180546001600160a01b031990811673dc24316b9ae028f1497c275eb9192a3ea0f670221790915560028054821673853d955acef822db058eb8505911ed77f175b99e17905560038054821673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2179055612710600455614e206005556006805490911673cf64698aff7e5f27a11dff868af228653ba53be01790553480156100a057600080fd5b506040516108243803806108248339810160408190526100bf91610120565b6100c8336100d0565b600555610139565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561013257600080fd5b5051919050565b6106dc806101486000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c80638da5cb5b116100715780638da5cb5b14610143578063ad5c464814610154578063b0e4556f14610167578063bc1c35351461017a578063f2fde38b1461018d578063fd967f47146101a057600080fd5b80631a5fa2e3146100b9578063218751b2146100ce5780632954018c146100fe5780632c86d98e14610111578063715018a61461012857806379575b2314610130575b600080fd5b6100cc6100c73660046105c5565b6101a9565b005b6001546100e1906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6006546100e1906001600160a01b031681565b61011a60055481565b6040519081526020016100f5565b6100cc6101d3565b6100cc61013e3660046105e9565b6101e7565b6000546001600160a01b03166100e1565b6003546100e1906001600160a01b031681565b6002546100e1906001600160a01b031681565b61011a6101883660046105e9565b6101f4565b6100cc61019b3660046105c5565b610488565b61011a60045481565b6101b1610506565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b6101db610506565b6101e56000610560565b565b6101ef610506565b600555565b6000600554600003610204575090565b60065460408051631f94a27560e31b815290516000926001600160a01b03169163fca513a89160048083019260209291908290030181865afa15801561024e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102729190610602565b90506000816001600160a01b031663b66102df600454600554876102969190610635565b6102a09190610654565b60025460035460405160e085901b6001600160e01b031916815260048101939093526001600160a01b039182166024840152166044820152606401602060405180830381865afa1580156102f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061031c9190610676565b60018054604051635e0d443f60e01b815260006004820181905260248201939093526044810184905292935090916001600160a01b0390911690635e0d443f90606401602060405180830381865afa15801561037c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a09190610676565b905060006103af60018461068f565b905060008282116103c057826103c2565b815b60018054604051635e0d443f60e01b81526004810192909252600060248301819052604483018490529293506001600160a01b031690635e0d443f90606401602060405180830381865afa15801561041e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104429190610676565b90506000610451866002610635565b61045b838861068f565b610465908b610635565b61046f9190610654565b905061047b818a61068f565b9998505050505050505050565b610490610506565b6001600160a01b0381166104fa5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b61050381610560565b50565b6000546001600160a01b031633146101e55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104f1565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b038116811461050357600080fd5b6000602082840312156105d757600080fd5b81356105e2816105b0565b9392505050565b6000602082840312156105fb57600080fd5b5035919050565b60006020828403121561061457600080fd5b81516105e2816105b0565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561064f5761064f61061f565b500290565b60008261067157634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561068857600080fd5b5051919050565b6000828210156106a1576106a161061f565b50039056fea2646970667358221220c8cdbb6de9ad174ca55f72015f29e5e6290c87143ac7db26e80145f74fab476464736f6c634300080d00330000000000000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c80638da5cb5b116100715780638da5cb5b14610143578063ad5c464814610154578063b0e4556f14610167578063bc1c35351461017a578063f2fde38b1461018d578063fd967f47146101a057600080fd5b80631a5fa2e3146100b9578063218751b2146100ce5780632954018c146100fe5780632c86d98e14610111578063715018a61461012857806379575b2314610130575b600080fd5b6100cc6100c73660046105c5565b6101a9565b005b6001546100e1906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6006546100e1906001600160a01b031681565b61011a60055481565b6040519081526020016100f5565b6100cc6101d3565b6100cc61013e3660046105e9565b6101e7565b6000546001600160a01b03166100e1565b6003546100e1906001600160a01b031681565b6002546100e1906001600160a01b031681565b61011a6101883660046105e9565b6101f4565b6100cc61019b3660046105c5565b610488565b61011a60045481565b6101b1610506565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b6101db610506565b6101e56000610560565b565b6101ef610506565b600555565b6000600554600003610204575090565b60065460408051631f94a27560e31b815290516000926001600160a01b03169163fca513a89160048083019260209291908290030181865afa15801561024e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102729190610602565b90506000816001600160a01b031663b66102df600454600554876102969190610635565b6102a09190610654565b60025460035460405160e085901b6001600160e01b031916815260048101939093526001600160a01b039182166024840152166044820152606401602060405180830381865afa1580156102f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061031c9190610676565b60018054604051635e0d443f60e01b815260006004820181905260248201939093526044810184905292935090916001600160a01b0390911690635e0d443f90606401602060405180830381865afa15801561037c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a09190610676565b905060006103af60018461068f565b905060008282116103c057826103c2565b815b60018054604051635e0d443f60e01b81526004810192909252600060248301819052604483018490529293506001600160a01b031690635e0d443f90606401602060405180830381865afa15801561041e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104429190610676565b90506000610451866002610635565b61045b838861068f565b610465908b610635565b61046f9190610654565b905061047b818a61068f565b9998505050505050505050565b610490610506565b6001600160a01b0381166104fa5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b61050381610560565b50565b6000546001600160a01b031633146101e55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104f1565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b038116811461050357600080fd5b6000602082840312156105d757600080fd5b81356105e2816105b0565b9392505050565b6000602082840312156105fb57600080fd5b5035919050565b60006020828403121561061457600080fd5b81516105e2816105b0565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561064f5761064f61061f565b500290565b60008261067157634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561068857600080fd5b5051919050565b6000828210156106a1576106a161061f565b50039056fea2646970667358221220c8cdbb6de9ad174ca55f72015f29e5e6290c87143ac7db26e80145f74fab476464736f6c634300080d0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _leverage (uint256): 0
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.