Skip to content

Commit

Permalink
Little hack to deal with unprecise Math
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoavf committed Jul 14, 2023
1 parent d5b6412 commit b2a8cb1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions contracts/bridges/Gamma/GammaDepositBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,17 @@ contract GammaDepositBridge is IGammaDeposit {
hypervisorAddress,
tokens[1],
amountsIn[1]
);

);

// * 9999 / 10000 is a hack to deal with unprecise math and avoid "improper ratio bug")
if (startA > amountsIn[0]) {
return (amountsIn[0], Math.min(amountsIn[1], endB));
return (amountsIn[0], Math.min(amountsIn[1], endB * 9999/10000 ));
}
else if (startB > amountsIn[1]) {
return (Math.min(amountsIn[0], endA), amountsIn[1]);
return (Math.min(amountsIn[0], endA * 9999/10000 ), amountsIn[1]);
}
else {
return (Math.min(amountsIn[0], endA), Math.min(amountsIn[1], endB));
return (Math.min(amountsIn[0], endA * 9999/10000 ), Math.min(amountsIn[1], endB * 9999/10000 ));
}
}
}

0 comments on commit b2a8cb1

Please sign in to comment.