mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
Update 1proto address
This commit is contained in:
parent
d1d7b31724
commit
e96fc601a0
|
@ -3,20 +3,13 @@ pragma solidity ^0.7.0;
|
||||||
import { TokenInterface } from "../../common/interfaces.sol";
|
import { TokenInterface } from "../../common/interfaces.sol";
|
||||||
import { DSMath } from "../../common/math.sol";
|
import { DSMath } from "../../common/math.sol";
|
||||||
import { Basic } from "../../common/basic.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 {
|
abstract contract Helpers is DSMath, Basic {
|
||||||
/**
|
/**
|
||||||
* @dev 1proto mapping Address
|
* @dev 1proto Address
|
||||||
*/
|
*/
|
||||||
OneProtoMappingInterface constant internal oneProtoMapping = OneProtoMappingInterface(0x8d0287AFa7755BB5f2eFe686AA8d4F0A7BC4AE7F);
|
OneProtoInterface constant internal oneProto = OneProtoInterface(0x50FDA034C0Ce7a8f7EFDAebDA7Aa7cA21CC1267e);
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev Return 1proto Address
|
|
||||||
*/
|
|
||||||
function getOneProtoAddress() internal virtual view returns (address payable) {
|
|
||||||
return payable(oneProtoMapping.oneProtoAddress());
|
|
||||||
}
|
|
||||||
|
|
||||||
function getSlippageAmt(
|
function getSlippageAmt(
|
||||||
TokenInterface _buyAddr,
|
TokenInterface _buyAddr,
|
||||||
|
|
|
@ -10,11 +10,9 @@ import { Events } from "./events.sol";
|
||||||
abstract contract OneProtoResolver is Helpers, Events {
|
abstract contract OneProtoResolver is Helpers, Events {
|
||||||
/**
|
/**
|
||||||
* @dev 1proto contract swap handler
|
* @dev 1proto contract swap handler
|
||||||
* @param oneProtoContract - 1 proto contract
|
|
||||||
* @param oneProtoData - Struct with swap data defined in interfaces.sol
|
* @param oneProtoData - Struct with swap data defined in interfaces.sol
|
||||||
*/
|
*/
|
||||||
function oneProtoSwap(
|
function oneProtoSwap(
|
||||||
OneProtoInterface oneProtoContract,
|
|
||||||
OneProtoData memory oneProtoData
|
OneProtoData memory oneProtoData
|
||||||
) internal returns (uint buyAmt) {
|
) internal returns (uint buyAmt) {
|
||||||
TokenInterface _sellAddr = oneProtoData.sellToken;
|
TokenInterface _sellAddr = oneProtoData.sellToken;
|
||||||
|
@ -27,12 +25,12 @@ abstract contract OneProtoResolver is Helpers, Events {
|
||||||
if (address(_sellAddr) == ethAddr) {
|
if (address(_sellAddr) == ethAddr) {
|
||||||
ethAmt = _sellAmt;
|
ethAmt = _sellAmt;
|
||||||
} else {
|
} else {
|
||||||
_sellAddr.approve(address(oneProtoContract), _sellAmt);
|
_sellAddr.approve(address(oneProto), _sellAmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint initalBal = getTokenBal(_buyAddr);
|
uint initalBal = getTokenBal(_buyAddr);
|
||||||
oneProtoContract.swap{value: ethAmt}(
|
oneProto.swap{value: ethAmt}(
|
||||||
_sellAddr,
|
_sellAddr,
|
||||||
_buyAddr,
|
_buyAddr,
|
||||||
_sellAmt,
|
_sellAmt,
|
||||||
|
@ -57,16 +55,15 @@ abstract contract OneProtoResolver is Helpers, Events {
|
||||||
uint _sellAmt = oneProtoData._sellAmt;
|
uint _sellAmt = oneProtoData._sellAmt;
|
||||||
uint _slippageAmt = getSlippageAmt(_buyAddr, _sellAddr, _sellAmt, oneProtoData.unitAmt);
|
uint _slippageAmt = getSlippageAmt(_buyAddr, _sellAddr, _sellAmt, oneProtoData.unitAmt);
|
||||||
|
|
||||||
OneProtoInterface oneSplitContract = OneProtoInterface(getOneProtoAddress());
|
|
||||||
uint ethAmt;
|
uint ethAmt;
|
||||||
if (address(_sellAddr) == ethAddr) {
|
if (address(_sellAddr) == ethAddr) {
|
||||||
ethAmt = _sellAmt;
|
ethAmt = _sellAmt;
|
||||||
} else {
|
} else {
|
||||||
_sellAddr.approve(address(oneSplitContract), _sellAmt);
|
_sellAddr.approve(address(oneProto), _sellAmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint initalBal = getTokenBal(_buyAddr);
|
uint initalBal = getTokenBal(_buyAddr);
|
||||||
oneSplitContract.swapMulti{value: ethAmt}(
|
oneProto.swapMulti{value: ethAmt}(
|
||||||
convertToTokenInterface(oneProtoData.tokens),
|
convertToTokenInterface(oneProtoData.tokens),
|
||||||
_sellAmt,
|
_sellAmt,
|
||||||
_slippageAmt,
|
_slippageAmt,
|
||||||
|
@ -99,10 +96,7 @@ abstract contract OneProtoResolverHelpers is OneProtoResolver {
|
||||||
getTokenBal(oneProtoData.sellToken) :
|
getTokenBal(oneProtoData.sellToken) :
|
||||||
_sellAmt;
|
_sellAmt;
|
||||||
|
|
||||||
oneProtoData._buyAmt = oneProtoSwap(
|
oneProtoData._buyAmt = oneProtoSwap(oneProtoData);
|
||||||
OneProtoInterface(getOneProtoAddress()),
|
|
||||||
oneProtoData
|
|
||||||
);
|
|
||||||
|
|
||||||
setUint(setId, oneProtoData._buyAmt);
|
setUint(setId, oneProtoData._buyAmt);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user