fromRoute static method
Implementation
static Price fromRoute(Route route) {
List<Price> prices = [];
for (int i = 0; i < route.pairs.length; i++) {
prices.add(route.path[i] == route.pairs[i].token0
? Price.fromContractor(
route.pairs[i].reserve0.currency,
route.pairs[i].reserve1.currency,
route.pairs[i].reserve0.raw,
route.pairs[i].reserve1.raw)
: Price.fromContractor(
route.pairs[i].reserve1.currency,
route.pairs[i].reserve0.currency,
route.pairs[i].reserve1.raw,
route.pairs[i].reserve0.raw));
}
Price itemPrice = prices[0];
if(prices.length>1){
prices = prices.sublist(1);
for (final ele in prices) {
itemPrice = itemPrice * ele;
}
}
return itemPrice;
}