Verified contractExactSimPL-2.0
CureveDemo
Address0x6e6f17cbbbe99fc316f6ef6d218eaa5c0ba807f9
- Balance
0 ETH
- Transactions
3
- Compiler
solc 0.7.5
- Same code
Only this contract
Details
- Compiler
- solc 0.7.5+commit.eb77ed08
- Language
- solidity
- Optimization
- No
- EVM version
- istanbul
- License
- SimPL-2.0
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 11,404,635
- Creation transaction
- 0x76fac53854…9a04373143
browser/tests/CurveTest.sol
// SPDX-License-Identifier: SimPL-2.0
pragma solidity >=0.6.11;
interface ICurve {
function get_dy(int128 i, int128 j, uint256 dx) 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;
}
interface IERC20 {
function balanceOf(address owner) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
}
contract CureveDemo {
address private amountIn = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
address private amountOut = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
// address private usdtContract = 0x3B00Ef435fA4FcFF5C209a37d1f3dcff37c705aD;
// address private daiContract = 0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735;
address private curvePoolContract = 0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7;
address private owner;
int128 private curveUsdtIndex = 2;
int128 private curveDaiIndex = 0;
constructor() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function get_dy(int128 amoutIndex,int128 amountOutIndex,uint256 amount,address _pool) external view returns(uint256){
ICurve curve = ICurve(_pool);
return curve.get_dy(amoutIndex,amountOutIndex,amount);
}
function _withdrawAllOut(address _address) public {
IERC20 erc = IERC20(amountOut);
uint amount = erc.balanceOf(address(this));
erc.transfer(_address, amount);
}
function _withdrawAllIn(address _address)public {
IERC20 erc = IERC20(amountIn);
uint amount = erc.balanceOf(address(this));
erc.transfer(_address, amount);
}
function exchange(int128 amoutIndex,int128 amountOutIndex,address _pool,uint _amount) external {
IERC20 erc = IERC20(amountIn);
bool b = erc.approve(_pool, _amount);
require(b,"approve fail");
ICurve curve = ICurve(_pool);
curve.exchange(amoutIndex, amountOutIndex,_amount,0);
}
function exchange_underlying(int128 amoutIndex,int128 amountOutIndex,address _pool,uint _amount) external {
IERC20 erc = IERC20(amountIn);
bool b = erc.approve(_pool, _amount);
require(b,"approve fail");
ICurve curve = ICurve(_pool);
curve.exchange_underlying(amoutIndex, amountOutIndex,_amount,0);
}
function setAmoutIn(address _address) public{
amountIn = _address;
}
function setAmoutOut(address _address) public{
amountOut = _address;
}
}
Compiler settingsShow
{
"metadata": {
"bytecodeHash": "ipfs"
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": false
},
"evmVersion": "istanbul",
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.