mirror of
https://github.com/Instadapp/dsa-connectors-old.git
synced 2024-07-29 22:47:46 +00:00
Fixed bugs
This commit is contained in:
parent
2c8bad40fb
commit
05a89af757
|
@ -300,7 +300,7 @@ contract OneInchResolver is OneInchResolverHelpers {
|
||||||
uint feePercent,
|
uint feePercent,
|
||||||
uint setId
|
uint setId
|
||||||
) external payable {
|
) external payable {
|
||||||
require(feePercent > 0 && feePercent <= 2*10*16, "Fee more than 2%");
|
require(feePercent > 0 && feePercent <= 2 * 10 ** 16, "Fee more than 2%");
|
||||||
require(feeCollector != address(0), "feeCollector is not vaild address");
|
require(feeCollector != address(0), "feeCollector is not vaild address");
|
||||||
|
|
||||||
OneInchData memory oneInchData = OneInchData({
|
OneInchData memory oneInchData = OneInchData({
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
pragma solidity ^0.6.0;
|
pragma solidity ^0.6.0;
|
||||||
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
|
|
||||||
// import files from common directory
|
// import files from common directory
|
||||||
import { TokenInterface , MemoryInterface, EventInterface} from "../common/interfaces.sol";
|
import { TokenInterface , MemoryInterface, EventInterface} from "../common/interfaces.sol";
|
||||||
|
@ -53,7 +55,7 @@ contract OneHelpers is Stores, DSMath {
|
||||||
/**
|
/**
|
||||||
* @dev Return 1proto Address
|
* @dev Return 1proto Address
|
||||||
*/
|
*/
|
||||||
function getOneProtoAddress() internal pure returns (address payable) {
|
function getOneProtoAddress() internal virtual view returns (address payable) {
|
||||||
return 0x50FDA034C0Ce7a8f7EFDAebDA7Aa7cA21CC1267e;
|
return 0x50FDA034C0Ce7a8f7EFDAebDA7Aa7cA21CC1267e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,10 +114,11 @@ contract OneHelpers is Stores, DSMath {
|
||||||
if (feeCollector != address(0)) {
|
if (feeCollector != address(0)) {
|
||||||
feeAmount = wmul(amount, feePercent);
|
feeAmount = wmul(amount, feePercent);
|
||||||
leftAmt = sub(amount, feeAmount);
|
leftAmt = sub(amount, feeAmount);
|
||||||
uint feeCollectorAmt = wmul(feeAmount, 3 * 10 ** 17);
|
uint feeCollectorAmt = wmul(feeAmount, 7 * 10 ** 17); // 70% to feeCollector
|
||||||
uint restAmt = sub(feeAmount, feeCollectorAmt);
|
uint restAmt = sub(feeAmount, feeCollectorAmt); // rest 30%
|
||||||
_transfer(payable(feeCollector), IERC20(token), feeCollectorAmt);
|
IERC20 tokenContract = IERC20(token);
|
||||||
_transfer(payable(getReferralAddr()), IERC20(token), restAmt);
|
_transfer(payable(feeCollector), tokenContract, feeCollectorAmt);
|
||||||
|
_transfer(payable(getReferralAddr()), tokenContract, restAmt);
|
||||||
} else {
|
} else {
|
||||||
leftAmt = amount;
|
leftAmt = amount;
|
||||||
}
|
}
|
||||||
|
@ -153,8 +156,8 @@ contract Resolver is OneHelpers {
|
||||||
_sellAddr.approve(address(oneProtoContract), _sellAmt);
|
_sellAddr.approve(address(oneProtoContract), _sellAmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint initalBal = getTokenBal(_buyAddr);
|
|
||||||
|
|
||||||
|
uint initalBal = getTokenBal(_buyAddr);
|
||||||
oneProtoContract.swapWithReferral.value(ethAmt)(
|
oneProtoContract.swapWithReferral.value(ethAmt)(
|
||||||
_sellAddr,
|
_sellAddr,
|
||||||
_buyAddr,
|
_buyAddr,
|
||||||
|
@ -165,8 +168,8 @@ contract Resolver is OneHelpers {
|
||||||
getReferralAddr(),
|
getReferralAddr(),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
uint finalBal = getTokenBal(_buyAddr);
|
uint finalBal = getTokenBal(_buyAddr);
|
||||||
|
|
||||||
buyAmt = sub(finalBal, initalBal);
|
buyAmt = sub(finalBal, initalBal);
|
||||||
|
|
||||||
require(_slippageAmt <= buyAmt, "Too much slippage");
|
require(_slippageAmt <= buyAmt, "Too much slippage");
|
||||||
|
@ -232,8 +235,8 @@ contract OneProtoEventResolver is Resolver {
|
||||||
address indexed sellToken,
|
address indexed sellToken,
|
||||||
uint256 buyAmt,
|
uint256 buyAmt,
|
||||||
uint256 sellAmt,
|
uint256 sellAmt,
|
||||||
address indexed collector,
|
address indexed feeCollector,
|
||||||
uint256 fee,
|
uint256 feeAmount,
|
||||||
uint256 getId,
|
uint256 getId,
|
||||||
uint256 setId
|
uint256 setId
|
||||||
);
|
);
|
||||||
|
@ -274,7 +277,7 @@ contract OneProtoEventResolver is Resolver {
|
||||||
getId,
|
getId,
|
||||||
setId
|
setId
|
||||||
);
|
);
|
||||||
_eventCode = keccak256("LogSellFee(address,address,uint256,uint256,uint256,uint256)");
|
_eventCode = keccak256("LogSellFee(address,address,uint256,uint256,address,uint256,uint256,uint256)");
|
||||||
_eventParam = abi.encode(
|
_eventParam = abi.encode(
|
||||||
address(oneProtoData.buyToken),
|
address(oneProtoData.buyToken),
|
||||||
address(oneProtoData.sellToken),
|
address(oneProtoData.sellToken),
|
||||||
|
@ -303,8 +306,8 @@ contract OneProtoEventResolver is Resolver {
|
||||||
address indexed sellToken,
|
address indexed sellToken,
|
||||||
uint256 buyAmt,
|
uint256 buyAmt,
|
||||||
uint256 sellAmt,
|
uint256 sellAmt,
|
||||||
address indexed collector,
|
address indexed feeCollector,
|
||||||
uint256 fee,
|
uint256 feeAmount,
|
||||||
uint256 getId,
|
uint256 getId,
|
||||||
uint256 setId
|
uint256 setId
|
||||||
);
|
);
|
||||||
|
@ -345,7 +348,7 @@ contract OneProtoEventResolver is Resolver {
|
||||||
getId,
|
getId,
|
||||||
setId
|
setId
|
||||||
);
|
);
|
||||||
_eventCode = keccak256("LogSellFeeTwo(address,address,uint256,uint256,uint256,uint256)");
|
_eventCode = keccak256("LogSellFeeTwo(address,address,uint256,uint256,address,uint256,uint256,uint256)");
|
||||||
_eventParam = abi.encode(
|
_eventParam = abi.encode(
|
||||||
address(oneProtoData.buyToken),
|
address(oneProtoData.buyToken),
|
||||||
address(oneProtoData.sellToken),
|
address(oneProtoData.sellToken),
|
||||||
|
@ -376,8 +379,8 @@ contract OneProtoEventResolver is Resolver {
|
||||||
address indexed sellToken,
|
address indexed sellToken,
|
||||||
uint256 buyAmt,
|
uint256 buyAmt,
|
||||||
uint256 sellAmt,
|
uint256 sellAmt,
|
||||||
address indexed collector,
|
address indexed feeCollector,
|
||||||
uint256 fee,
|
uint256 feeAmount,
|
||||||
uint256 getId,
|
uint256 getId,
|
||||||
uint256 setId
|
uint256 setId
|
||||||
);
|
);
|
||||||
|
@ -421,7 +424,7 @@ contract OneProtoEventResolver is Resolver {
|
||||||
getId,
|
getId,
|
||||||
setId
|
setId
|
||||||
);
|
);
|
||||||
_eventCode = keccak256("LogSellFeeMulti(address[],address,address,uint256,uint256,uint256,uint256)");
|
_eventCode = keccak256("LogSellFeeMulti(address[],address,address,uint256,uint256,address,uint256,uint256,uint256)");
|
||||||
_eventParam = abi.encode(
|
_eventParam = abi.encode(
|
||||||
oneProtoData.tokens,
|
oneProtoData.tokens,
|
||||||
address(oneProtoData.buyToken),
|
address(oneProtoData.buyToken),
|
||||||
|
@ -446,7 +449,6 @@ contract OneProtoResolverHelpers is OneProtoEventResolver {
|
||||||
uint256 setId
|
uint256 setId
|
||||||
) internal {
|
) internal {
|
||||||
uint _sellAmt = getUint(getId, oneProtoData._sellAmt);
|
uint _sellAmt = getUint(getId, oneProtoData._sellAmt);
|
||||||
|
|
||||||
oneProtoData._sellAmt = _sellAmt == uint(-1) ?
|
oneProtoData._sellAmt = _sellAmt == uint(-1) ?
|
||||||
getTokenBal(oneProtoData.sellToken) :
|
getTokenBal(oneProtoData.sellToken) :
|
||||||
_sellAmt;
|
_sellAmt;
|
||||||
|
@ -466,7 +468,7 @@ contract OneProtoResolverHelpers is OneProtoEventResolver {
|
||||||
oneProtoData
|
oneProtoData
|
||||||
);
|
);
|
||||||
|
|
||||||
(uint feeAmount, uint leftBuyAmt) = takeFee(
|
(uint leftBuyAmt, uint feeAmount) = takeFee(
|
||||||
address(oneProtoData.buyToken),
|
address(oneProtoData.buyToken),
|
||||||
oneProtoData._buyAmt,
|
oneProtoData._buyAmt,
|
||||||
oneProtoData.feeCollector,
|
oneProtoData.feeCollector,
|
||||||
|
@ -496,12 +498,13 @@ contract OneProtoResolverHelpers is OneProtoEventResolver {
|
||||||
oneProtoData
|
oneProtoData
|
||||||
);
|
);
|
||||||
|
|
||||||
(uint feeAmount, uint leftBuyAmt) = takeFee(
|
(uint leftBuyAmt, uint feeAmount) = takeFee(
|
||||||
address(oneProtoData.buyToken),
|
address(oneProtoData.buyToken),
|
||||||
oneProtoData._buyAmt,
|
oneProtoData._buyAmt,
|
||||||
oneProtoData.feeCollector,
|
oneProtoData.feeCollector,
|
||||||
feePercent
|
feePercent
|
||||||
);
|
);
|
||||||
|
|
||||||
setUint(setId, leftBuyAmt);
|
setUint(setId, leftBuyAmt);
|
||||||
oneProtoData.feeAmount = feeAmount;
|
oneProtoData.feeAmount = feeAmount;
|
||||||
|
|
||||||
|
@ -521,8 +524,9 @@ contract OneProtoResolverHelpers is OneProtoEventResolver {
|
||||||
_sellAmt;
|
_sellAmt;
|
||||||
|
|
||||||
oneProtoData._buyAmt = oneProtoSwapMulti(oneProtoData);
|
oneProtoData._buyAmt = oneProtoSwapMulti(oneProtoData);
|
||||||
|
|
||||||
uint leftBuyAmt;
|
uint leftBuyAmt;
|
||||||
(oneProtoData.feeAmount, leftBuyAmt) = takeFee(
|
(leftBuyAmt, oneProtoData.feeAmount) = takeFee(
|
||||||
address(oneProtoData.buyToken),
|
address(oneProtoData.buyToken),
|
||||||
oneProtoData._buyAmt,
|
oneProtoData._buyAmt,
|
||||||
oneProtoData.feeCollector,
|
oneProtoData.feeCollector,
|
||||||
|
@ -555,10 +559,10 @@ contract OneProtoResolver is OneProtoResolverHelpers {
|
||||||
OneProtoData memory oneProtoData = OneProtoData({
|
OneProtoData memory oneProtoData = OneProtoData({
|
||||||
buyToken: TokenInterface(buyAddr),
|
buyToken: TokenInterface(buyAddr),
|
||||||
sellToken: TokenInterface(sellAddr),
|
sellToken: TokenInterface(sellAddr),
|
||||||
|
_sellAmt: sellAmt,
|
||||||
unitAmt: unitAmt,
|
unitAmt: unitAmt,
|
||||||
distribution: new uint[](0),
|
distribution: new uint[](0),
|
||||||
feeCollector: address(0),
|
feeCollector: address(0),
|
||||||
_sellAmt: sellAmt,
|
|
||||||
_buyAmt: 0,
|
_buyAmt: 0,
|
||||||
disableDexes: 0,
|
disableDexes: 0,
|
||||||
feeAmount: 0
|
feeAmount: 0
|
||||||
|
@ -588,16 +592,16 @@ contract OneProtoResolver is OneProtoResolverHelpers {
|
||||||
uint getId,
|
uint getId,
|
||||||
uint setId
|
uint setId
|
||||||
) external payable {
|
) external payable {
|
||||||
require(feePercent > 0 && feePercent <= 2*10*16, "Fee more than 2%");
|
require(feePercent > 0 && feePercent <= 2 * 10 ** 16, "Fee more than 2%");
|
||||||
require(feeCollector != address(0), "feeCollector is not vaild address");
|
require(feeCollector != address(0), "feeCollector is not vaild address");
|
||||||
|
|
||||||
OneProtoData memory oneProtoData = OneProtoData({
|
OneProtoData memory oneProtoData = OneProtoData({
|
||||||
buyToken: TokenInterface(buyAddr),
|
buyToken: TokenInterface(buyAddr),
|
||||||
sellToken: TokenInterface(sellAddr),
|
sellToken: TokenInterface(sellAddr),
|
||||||
|
_sellAmt: sellAmt,
|
||||||
unitAmt: unitAmt,
|
unitAmt: unitAmt,
|
||||||
distribution: new uint[](0),
|
distribution: new uint[](0),
|
||||||
feeCollector: feeCollector,
|
feeCollector: feeCollector,
|
||||||
_sellAmt: sellAmt,
|
|
||||||
_buyAmt: 0,
|
_buyAmt: 0,
|
||||||
disableDexes: 0,
|
disableDexes: 0,
|
||||||
feeAmount: 0
|
feeAmount: 0
|
||||||
|
@ -630,10 +634,10 @@ contract OneProtoResolver is OneProtoResolverHelpers {
|
||||||
OneProtoData memory oneProtoData = OneProtoData({
|
OneProtoData memory oneProtoData = OneProtoData({
|
||||||
buyToken: TokenInterface(buyAddr),
|
buyToken: TokenInterface(buyAddr),
|
||||||
sellToken: TokenInterface(sellAddr),
|
sellToken: TokenInterface(sellAddr),
|
||||||
|
_sellAmt: sellAmt,
|
||||||
unitAmt: unitAmt,
|
unitAmt: unitAmt,
|
||||||
distribution: distribution,
|
distribution: distribution,
|
||||||
disableDexes: disableDexes,
|
disableDexes: disableDexes,
|
||||||
_sellAmt: sellAmt,
|
|
||||||
feeCollector: address(0),
|
feeCollector: address(0),
|
||||||
_buyAmt: 0,
|
_buyAmt: 0,
|
||||||
feeAmount: 0
|
feeAmount: 0
|
||||||
|
@ -668,16 +672,16 @@ contract OneProtoResolver is OneProtoResolverHelpers {
|
||||||
uint getId,
|
uint getId,
|
||||||
uint setId
|
uint setId
|
||||||
) external payable {
|
) external payable {
|
||||||
require(feePercent > 0 && feePercent <= 2*10*16, "Fee more than 2%");
|
require(feePercent > 0 && feePercent <= 2 * 10 ** 16, "Fee more than 2%");
|
||||||
require(feeCollector != address(0), "feeCollector is not vaild address");
|
require(feeCollector != address(0), "feeCollector is not vaild address");
|
||||||
OneProtoData memory oneProtoData = OneProtoData({
|
OneProtoData memory oneProtoData = OneProtoData({
|
||||||
buyToken: TokenInterface(buyAddr),
|
buyToken: TokenInterface(buyAddr),
|
||||||
sellToken: TokenInterface(sellAddr),
|
sellToken: TokenInterface(sellAddr),
|
||||||
|
_sellAmt: sellAmt,
|
||||||
unitAmt: unitAmt,
|
unitAmt: unitAmt,
|
||||||
distribution: distribution,
|
distribution: distribution,
|
||||||
disableDexes: disableDexes,
|
disableDexes: disableDexes,
|
||||||
feeCollector: feeCollector,
|
feeCollector: feeCollector,
|
||||||
_sellAmt: sellAmt,
|
|
||||||
_buyAmt: 0,
|
_buyAmt: 0,
|
||||||
feeAmount: 0
|
feeAmount: 0
|
||||||
});
|
});
|
||||||
|
@ -743,18 +747,18 @@ contract OneProtoResolver is OneProtoResolverHelpers {
|
||||||
uint getId,
|
uint getId,
|
||||||
uint setId
|
uint setId
|
||||||
) external payable {
|
) external payable {
|
||||||
require(feePercent > 0 && feePercent <= 2*10*16, "Fee more than 2%");
|
require(feePercent > 0 && feePercent <= 2 * 10 ** 16, "Fee more than 2%");
|
||||||
require(feeCollector != address(0), "feeCollector is not vaild address");
|
require(feeCollector != address(0), "feeCollector is not vaild address");
|
||||||
TokenInterface buyToken = TokenInterface(address(tokens[tokens.length-1]));
|
TokenInterface buyToken = TokenInterface(address(tokens[tokens.length - 1]));
|
||||||
OneProtoMultiData memory oneProtoData = OneProtoMultiData({
|
OneProtoMultiData memory oneProtoData = OneProtoMultiData({
|
||||||
tokens: tokens,
|
tokens: tokens,
|
||||||
buyToken: buyToken,
|
buyToken: buyToken,
|
||||||
sellToken: TokenInterface(address(tokens[0])),
|
sellToken: TokenInterface(address(tokens[0])),
|
||||||
|
_sellAmt: sellAmt,
|
||||||
unitAmt: unitAmt,
|
unitAmt: unitAmt,
|
||||||
distribution: distribution,
|
distribution: distribution,
|
||||||
feeCollector: feeCollector,
|
|
||||||
disableDexes: disableDexes,
|
disableDexes: disableDexes,
|
||||||
_sellAmt: sellAmt,
|
feeCollector: feeCollector,
|
||||||
_buyAmt: 0,
|
_buyAmt: 0,
|
||||||
feeAmount: 0
|
feeAmount: 0
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user