Update 1proto address

This commit is contained in:
Mubaris NK 2021-03-21 19:10:37 +05:30
parent d1d7b31724
commit e96fc601a0
No known key found for this signature in database
GPG Key ID: 9AC09AD0F8D68561
2 changed files with 8 additions and 21 deletions

View File

@ -3,20 +3,13 @@ pragma solidity ^0.7.0;
import { TokenInterface } from "../../common/interfaces.sol";
import { DSMath } from "../../common/math.sol";
import { Basic } from "../../common/basic.sol";
import { TokenInterface, OneProtoMappingInterface } from "./interface.sol";
import { TokenInterface, OneProtoInterface } from "./interface.sol";
abstract contract Helpers is DSMath, Basic {
/**
* @dev 1proto mapping Address
* @dev 1proto Address
*/
OneProtoMappingInterface constant internal oneProtoMapping = OneProtoMappingInterface(0x8d0287AFa7755BB5f2eFe686AA8d4F0A7BC4AE7F);
/**
* @dev Return 1proto Address
*/
function getOneProtoAddress() internal virtual view returns (address payable) {
return payable(oneProtoMapping.oneProtoAddress());
}
OneProtoInterface constant internal oneProto = OneProtoInterface(0x50FDA034C0Ce7a8f7EFDAebDA7Aa7cA21CC1267e);
function getSlippageAmt(
TokenInterface _buyAddr,

View File

@ -10,11 +10,9 @@ import { Events } from "./events.sol";
abstract contract OneProtoResolver is Helpers, Events {
/**
* @dev 1proto contract swap handler
* @param oneProtoContract - 1 proto contract
* @param oneProtoData - Struct with swap data defined in interfaces.sol
*/
function oneProtoSwap(
OneProtoInterface oneProtoContract,
OneProtoData memory oneProtoData
) internal returns (uint buyAmt) {
TokenInterface _sellAddr = oneProtoData.sellToken;
@ -27,12 +25,12 @@ abstract contract OneProtoResolver is Helpers, Events {
if (address(_sellAddr) == ethAddr) {
ethAmt = _sellAmt;
} else {
_sellAddr.approve(address(oneProtoContract), _sellAmt);
_sellAddr.approve(address(oneProto), _sellAmt);
}
uint initalBal = getTokenBal(_buyAddr);
oneProtoContract.swap{value: ethAmt}(
oneProto.swap{value: ethAmt}(
_sellAddr,
_buyAddr,
_sellAmt,
@ -57,16 +55,15 @@ abstract contract OneProtoResolver is Helpers, Events {
uint _sellAmt = oneProtoData._sellAmt;
uint _slippageAmt = getSlippageAmt(_buyAddr, _sellAddr, _sellAmt, oneProtoData.unitAmt);
OneProtoInterface oneSplitContract = OneProtoInterface(getOneProtoAddress());
uint ethAmt;
if (address(_sellAddr) == ethAddr) {
ethAmt = _sellAmt;
} else {
_sellAddr.approve(address(oneSplitContract), _sellAmt);
_sellAddr.approve(address(oneProto), _sellAmt);
}
uint initalBal = getTokenBal(_buyAddr);
oneSplitContract.swapMulti{value: ethAmt}(
oneProto.swapMulti{value: ethAmt}(
convertToTokenInterface(oneProtoData.tokens),
_sellAmt,
_slippageAmt,
@ -99,10 +96,7 @@ abstract contract OneProtoResolverHelpers is OneProtoResolver {
getTokenBal(oneProtoData.sellToken) :
_sellAmt;
oneProtoData._buyAmt = oneProtoSwap(
OneProtoInterface(getOneProtoAddress()),
oneProtoData
);
oneProtoData._buyAmt = oneProtoSwap(oneProtoData);
setUint(setId, oneProtoData._buyAmt);