mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
commit
f126bfae1a
|
@ -6,6 +6,11 @@ import { Basic } from "../../common/basic.sol";
|
||||||
abstract contract FeeResolver is DSMath, Basic {
|
abstract contract FeeResolver is DSMath, Basic {
|
||||||
/**
|
/**
|
||||||
* @dev Calculate fee
|
* @dev Calculate fee
|
||||||
|
* @param amount token amount to caculate fee.
|
||||||
|
* @param fee fee percentage. Eg: 1% => 1e17, 100% => 1e18.
|
||||||
|
* @param getId Get token amount at this ID from `InstaMemory` Contract.
|
||||||
|
* @param setId Set total amount at this ID in `InstaMemory` Contract.
|
||||||
|
* @param setIdFee Set only fee amount at this ID in `InstaMemory` Contract.
|
||||||
*/
|
*/
|
||||||
function calculateFee(
|
function calculateFee(
|
||||||
uint amount,
|
uint amount,
|
||||||
|
@ -23,6 +28,30 @@ abstract contract FeeResolver is DSMath, Basic {
|
||||||
setUint(setId, totalAmt);
|
setUint(setId, totalAmt);
|
||||||
setUint(setIdFee, feeAmt);
|
setUint(setIdFee, feeAmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Calculate amount minus fee
|
||||||
|
* @param amount token amount to caculate fee.
|
||||||
|
* @param fee fee percentage. Eg: 1% => 1e17, 100% => 1e18.
|
||||||
|
* @param getId Get token amount at this ID from `InstaMemory` Contract.
|
||||||
|
* @param setIdAmtMinusFee Set amount minus fee amount at this ID in `InstaMemory` Contract.
|
||||||
|
* @param setIdFee Set only fee amount at this ID in `InstaMemory` Contract.
|
||||||
|
*/
|
||||||
|
function calculateAmtMinusFee(
|
||||||
|
uint amount,
|
||||||
|
uint fee,
|
||||||
|
uint getId,
|
||||||
|
uint setIdAmtMinusFee,
|
||||||
|
uint setIdFee
|
||||||
|
) external payable {
|
||||||
|
uint _amt = getUint(getId, amount);
|
||||||
|
|
||||||
|
uint feeAmt = wmul(_amt, fee);
|
||||||
|
uint amountMinusFee = sub(_amt, feeAmt);
|
||||||
|
|
||||||
|
setUint(setIdAmtMinusFee, amountMinusFee);
|
||||||
|
setUint(setIdFee, feeAmt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contract ConnectV2Fee is FeeResolver {
|
contract ConnectV2Fee is FeeResolver {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user