mirror of
https://github.com/Instadapp/smart-contract.git
synced 2024-07-29 22:08:07 +00:00
get best kyber and uniswap
This commit is contained in:
parent
53f68c8c9d
commit
a6e17dba3a
|
@ -157,10 +157,30 @@ contract SplitHelper is AdminStuffs {
|
||||||
uint eth2DaiPrice = getRateEth2Dai(src, dest, finalSrcAmt);
|
uint eth2DaiPrice = getRateEth2Dai(src, dest, finalSrcAmt);
|
||||||
uint kyberPrice = getRateKyber(src, dest, finalSrcAmt);
|
uint kyberPrice = getRateKyber(src, dest, finalSrcAmt);
|
||||||
uint uniswapPrice = getRateUniswap(src, dest, finalSrcAmt);
|
uint uniswapPrice = getRateUniswap(src, dest, finalSrcAmt);
|
||||||
if (eth2DaiPrice > kyberPrice) {
|
if (eth2DaiPrice > kyberPrice && eth2DaiPrice >= uniswapPrice) {
|
||||||
destAmt = eth2DaiPrice;
|
destAmt = eth2DaiPrice;
|
||||||
bestExchange = 0;
|
bestExchange = 0;
|
||||||
} else if (kyberPrice >= eth2DaiPrice) {
|
} else if (kyberPrice >= eth2DaiPrice && kyberPrice >= uniswapPrice) {
|
||||||
|
destAmt = kyberPrice;
|
||||||
|
bestExchange = 1;
|
||||||
|
} else {
|
||||||
|
destAmt = uniswapPrice;
|
||||||
|
bestExchange = 2;
|
||||||
|
}
|
||||||
|
if (dest == daiAddr) {
|
||||||
|
destAmt = wmul(destAmt, cut);
|
||||||
|
}
|
||||||
|
require(destAmt != 0, "Dest Amt = 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBestUniswapKyber(address src, address dest, uint srcAmt) public view returns (uint bestExchange, uint destAmt) {
|
||||||
|
uint finalSrcAmt = srcAmt;
|
||||||
|
if (src == daiAddr) {
|
||||||
|
finalSrcAmt = wmul(srcAmt, cut);
|
||||||
|
}
|
||||||
|
uint kyberPrice = getRateKyber(src, dest, finalSrcAmt);
|
||||||
|
uint uniswapPrice = getRateUniswap(src, dest, finalSrcAmt);
|
||||||
|
if (kyberPrice >= uniswapPrice) {
|
||||||
destAmt = kyberPrice;
|
destAmt = kyberPrice;
|
||||||
bestExchange = 1;
|
bestExchange = 1;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user