fix4
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
pragma solidity 0.6.9;
|
pragma solidity 0.6.9;
|
||||||
|
|
||||||
import {IDODOAdapter} from "../intf/IDODOAdapter.sol";
|
import {IDODOAdapter} from "../intf/IDODOAdapter.sol";
|
||||||
import {ICurve} from "../intf/IDepth.sol";
|
import {ICurve} from "../intf/ICurve.sol";
|
||||||
import {IERC20} from "../../intf/IERC20.sol";
|
import {IERC20} from "../../intf/IERC20.sol";
|
||||||
import {SafeMath} from "../../lib/SafeMath.sol";
|
import {SafeMath} from "../../lib/SafeMath.sol";
|
||||||
import {UniversalERC20} from "../lib/UniversalERC20.sol";
|
import {UniversalERC20} from "../lib/UniversalERC20.sol";
|
||||||
@@ -21,14 +21,14 @@ contract CurveUnderlyingAdapter is IDODOAdapter {
|
|||||||
//fromToken == token[0], underlying
|
//fromToken == token[0], underlying
|
||||||
function sellBase(address to, address pool, bytes memory moreInfo) external override {
|
function sellBase(address to, address pool, bytes memory moreInfo) external override {
|
||||||
(address fromToken, address toToken, int128 i, int128 j) = abi.decode(moreInfo, (address, address, int128, int128));
|
(address fromToken, address toToken, int128 i, int128 j) = abi.decode(moreInfo, (address, address, int128, int128));
|
||||||
require(fromToken == IDepth(pool).underlying_coins(i), 'DepthAdapter: WRONG_TOKEN');
|
require(fromToken == ICurve(pool).underlying_coins(i), 'DepthAdapter: WRONG_TOKEN');
|
||||||
require(toToken == IDepth(pool).underlying_coins(j), 'DepthAdapter: WRONG_TOKEN');
|
require(toToken == ICurve(pool).underlying_coins(j), 'DepthAdapter: WRONG_TOKEN');
|
||||||
uint256 sellBaseAmount = IERC20(fromToken).balanceOf(address(this));
|
uint256 sellBaseAmount = IERC20(fromToken).balanceOf(address(this));
|
||||||
|
|
||||||
// approve
|
// approve
|
||||||
IERC20(fromToken).approve(pool, sellBaseAmount);
|
IERC20(fromToken).approve(pool, sellBaseAmount);
|
||||||
// swap
|
// swap
|
||||||
IDepth(pool).exchange_underlying(i, j, sellBaseAmount, 0);
|
ICurve(pool).exchange_underlying(i, j, sellBaseAmount, 0);
|
||||||
if(to != address(this)) {
|
if(to != address(this)) {
|
||||||
SafeERC20.safeTransfer(IERC20(toToken), to, IERC20(toToken).balanceOf(address(this)));
|
SafeERC20.safeTransfer(IERC20(toToken), to, IERC20(toToken).balanceOf(address(this)));
|
||||||
}
|
}
|
||||||
@@ -37,14 +37,14 @@ contract CurveUnderlyingAdapter is IDODOAdapter {
|
|||||||
//fromToken == token[1], underlying
|
//fromToken == token[1], underlying
|
||||||
function sellQuote(address to, address pool, bytes memory moreInfo) external override {
|
function sellQuote(address to, address pool, bytes memory moreInfo) external override {
|
||||||
(address fromToken, address toToken, int128 i, int128 j) = abi.decode(moreInfo, (address, address, int128, int128));
|
(address fromToken, address toToken, int128 i, int128 j) = abi.decode(moreInfo, (address, address, int128, int128));
|
||||||
require(fromToken == IDepth(pool).underlying_coins(i), 'DepthAdapter: WRONG_TOKEN');
|
require(fromToken == ICurve(pool).underlying_coins(i), 'DepthAdapter: WRONG_TOKEN');
|
||||||
require(toToken == IDepth(pool).underlying_coins(j), 'DepthAdapter: WRONG_TOKEN');
|
require(toToken == ICurve(pool).underlying_coins(j), 'DepthAdapter: WRONG_TOKEN');
|
||||||
uint256 sellQuoteAmount = IERC20(toToken).balanceOf(address(this));
|
uint256 sellQuoteAmount = IERC20(toToken).balanceOf(address(this));
|
||||||
|
|
||||||
// approve
|
// approve
|
||||||
IERC20(toToken).approve(pool, sellQuoteAmount);
|
IERC20(toToken).approve(pool, sellQuoteAmount);
|
||||||
// swap
|
// swap
|
||||||
IDepth(pool).exchange_underlying(i, j, sellQuoteAmount, 0);
|
ICurve(pool).exchange_underlying(i, j, sellQuoteAmount, 0);
|
||||||
if(to != address(this)) {
|
if(to != address(this)) {
|
||||||
SafeERC20.safeTransfer(IERC20(fromToken), to, IERC20(fromToken).balanceOf(address(this)));
|
SafeERC20.safeTransfer(IERC20(fromToken), to, IERC20(fromToken).balanceOf(address(this)));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user