updated the setFeeAmount bug

This commit is contained in:
Samyak Jain 2020-07-18 02:29:38 +10:00
parent c5078d6a71
commit fefbeba589

View File

@ -154,12 +154,13 @@ contract LiquidityHelpers is Helpers {
return 0x06cB7C24990cBE6b9F99982f975f9147c000fec6; // TODO - change return 0x06cB7C24990cBE6b9F99982f975f9147c000fec6; // TODO - change
} }
function calculateTotalFeeAmt(uint amt) internal view returns (uint totalAmt) { function calculateTotalFeeAmt(address token, uint amt) internal view returns (uint totalAmt) {
uint fee = InstaPoolFeeInterface(getInstaPoolFeeAddr()).fee(); uint fee = InstaPoolFeeInterface(getInstaPoolFeeAddr()).fee();
if(fee == 0) { uint flashAmt = liquidityContract.borrowedToken(token);
if (fee == 0) {
totalAmt = amt; totalAmt = amt;
} else { } else {
uint feeAmt = wmul(amt, fee); uint feeAmt = wmul(flashAmt, fee);
totalAmt = add(amt, feeAmt); totalAmt = add(amt, feeAmt);
} }
} }
@ -312,10 +313,10 @@ contract LiquidityAccessHelper is EventHelpers {
* @param getId Get token amount at this ID from `InstaMemory` Contract. * @param getId Get token amount at this ID from `InstaMemory` Contract.
* @param setId Set token amount at this ID in `InstaMemory` Contract. * @param setId Set token amount at this ID in `InstaMemory` Contract.
*/ */
function setFeeAmount(uint amt, uint getId, uint setId) external payable { function setFeeAmount(address token, uint amt, uint getId, uint setId) external payable {
_amt = getUint(getId, amt); _amt = getUint(getId, amt);
require(_amt != 0, "amt-is-0"); require(_amt != 0, "amt-is-0");
uint totalFee = calculateTotalFeeAmt(_amt); uint totalFee = calculateTotalFeeAmt(token, _amt);
setUint(setId, totalFee); setUint(setId, totalFee);
} }