mirror of
https://github.com/Instadapp/smart-contract.git
synced 2024-07-29 22:08:07 +00:00
small change in Swap read
This commit is contained in:
parent
cc2fd9baa0
commit
f3830471bf
|
@ -272,17 +272,18 @@ contract MKRSwapper is LiquidityResolver {
|
|||
function getBestMkrSwap(address srcTknAddr, uint destMkrAmt) public view returns(uint bestEx, uint srcAmt) {
|
||||
uint oasisPrice = getOasisSwap(srcTknAddr, destMkrAmt);
|
||||
uint uniswapPrice = getUniswapSwap(srcTknAddr, destMkrAmt);
|
||||
require(oasisPrice != 0 && uniswapPrice != 0, "swap price 0");
|
||||
srcAmt = oasisPrice < uniswapPrice ? oasisPrice : uniswapPrice;
|
||||
bestEx = oasisPrice < uniswapPrice ? 0 : 1; // if 0 then use Oasis for Swap, if 1 then use Uniswap
|
||||
}
|
||||
|
||||
function getOasisSwap(address tokenAddr, uint destMkrAmt) internal view returns(uint srcAmt) {
|
||||
function getOasisSwap(address tokenAddr, uint destMkrAmt) public view returns(uint srcAmt) {
|
||||
TokenInterface mkr = TubInterface(getSaiTubAddress()).gov();
|
||||
address srcTknAddr = tokenAddr == getETHAddress() ? getWETHAddress() : tokenAddr;
|
||||
srcAmt = OtcInterface(getOtcAddress()).getPayAmount(srcTknAddr, address(mkr), destMkrAmt);
|
||||
}
|
||||
|
||||
function getUniswapSwap(address srcTknAddr, uint destMkrAmt) internal view returns(uint srcAmt) {
|
||||
function getUniswapSwap(address srcTknAddr, uint destMkrAmt) public view returns(uint srcAmt) {
|
||||
UniswapExchange mkrEx = UniswapExchange(getUniswapMKRExchange());
|
||||
if (srcTknAddr == getETHAddress()) {
|
||||
srcAmt = mkrEx.getEthToTokenOutputPrice(destMkrAmt);
|
||||
|
|
Loading…
Reference in New Issue
Block a user