Allow affiliate fee to be split between multiple fee recipient addresses

This commit is contained in:
Amir Bandeali
2019-11-30 17:24:24 -08:00
parent b1929cb688
commit 79ea0bf9f4
3 changed files with 21 additions and 17 deletions

View File

@@ -64,14 +64,14 @@ contract MixinForwarderCore is
/// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset.
/// @param signatures Proofs that orders have been created by makers.
/// @param ethFeeAmount Amount of ETH, denominatoed in Wei, that is payed to feeRecipient.
/// @param feeRecipient Address that will receive ETH when orders are filled.
/// @param feeRecipients Addresses that will receive ETH when orders are filled.
/// @return wethSpentAmount Amount of WETH spent on the given set of orders.
/// @return makerAssetAcquiredAmount Amount of maker asset acquired from the given set of orders.
function marketSellOrdersWithEth(
LibOrder.Order[] memory orders,
bytes[] memory signatures,
uint256 ethFeeAmount,
address payable feeRecipient
address payable[] memory feeRecipients
)
public
payable
@@ -102,7 +102,7 @@ contract MixinForwarderCore is
_transferEthFeeAndRefund(
wethSpentAmount,
ethFeeAmount,
feeRecipient
feeRecipients
);
}
@@ -114,7 +114,7 @@ contract MixinForwarderCore is
/// @param makerAssetBuyAmount Desired amount of makerAsset to purchase.
/// @param signatures Proofs that orders have been created by makers.
/// @param ethFeeAmount Amount of ETH, denominatoed in Wei, that is payed to feeRecipient.
/// @param feeRecipient Address that will receive ETH when orders are filled.
/// @param feeRecipients Addresses that will receive ETH when orders are filled.
/// @return wethSpentAmount Amount of WETH spent on the given set of orders.
/// @return makerAssetAcquiredAmount Amount of maker asset acquired from the given set of orders.
function marketBuyOrdersWithEth(
@@ -122,7 +122,7 @@ contract MixinForwarderCore is
uint256 makerAssetBuyAmount,
bytes[] memory signatures,
uint256 ethFeeAmount,
address payable feeRecipient
address payable[] memory feeRecipients
)
public
payable
@@ -149,7 +149,7 @@ contract MixinForwarderCore is
_transferEthFeeAndRefund(
wethSpentAmount,
ethFeeAmount,
feeRecipient
feeRecipients
);
}
}

View File

@@ -55,12 +55,12 @@ contract MixinWeth is
/// Refunds any excess ETH to msg.sender.
/// @param wethSpent Amount of WETH spent when filling orders.
/// @param ethFeeAmount Amount of ETH, denominatoed in Wei, that is payed to feeRecipient.
/// @param feeRecipient Address that will receive ETH when orders are filled.
/// @param feeRecipients Addresses that will receive ETH when orders are filled.
/// @return ethFee Amount paid to feeRecipient as a percentage fee on the total WETH sold.
function _transferEthFeeAndRefund(
uint256 wethSpent,
uint256 ethFeeAmount,
address payable feeRecipient
address payable[] memory feeRecipients
)
internal
{
@@ -90,7 +90,11 @@ contract MixinWeth is
// Pay ETH to feeRecipient
if (ethFeeAmount > 0) {
feeRecipient.transfer(ethFeeAmount);
uint256 feeRecipientsLen = feeRecipients.length;
uint256 ethFeePerRecipient = ethFeeAmount.safeDiv(feeRecipientsLen);
for (uint256 i = 0; i != feeRecipientsLen; i++) {
feeRecipients[i].transfer(ethFeePerRecipient);
}
}
// Refund remaining ETH to msg.sender.

View File

@@ -29,15 +29,15 @@ contract IForwarderCore {
/// as possible, accounting for order and forwarder fees.
/// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset.
/// @param signatures Proofs that orders have been created by makers.
/// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient.
/// @param feeRecipient Address that will receive ETH when orders are filled.
/// @param ethFeeAmount Amount of ETH, denominatoed in Wei, that is payed to feeRecipient.
/// @param feeRecipients Addresses that will receive ETH when orders are filled.
/// @return wethSpentAmount Amount of WETH spent on the given set of orders.
/// @return makerAssetAcquiredAmount Amount of maker asset acquired from the given set of orders.
function marketSellOrdersWithEth(
LibOrder.Order[] memory orders,
bytes[] memory signatures,
uint256 feePercentage,
address payable feeRecipient
uint256 ethFeeAmount,
address payable[] memory feeRecipients
)
public
payable
@@ -53,16 +53,16 @@ contract IForwarderCore {
/// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset.
/// @param makerAssetBuyAmount Desired amount of makerAsset to purchase.
/// @param signatures Proofs that orders have been created by makers.
/// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient.
/// @param feeRecipient Address that will receive ETH when orders are filled.
/// @param ethFeeAmount Amount of ETH, denominatoed in Wei, that is payed to feeRecipient.
/// @param feeRecipients Addresses that will receive ETH when orders are filled.
/// @return wethSpentAmount Amount of WETH spent on the given set of orders.
/// @return makerAssetAcquiredAmount Amount of maker asset acquired from the given set of orders.
function marketBuyOrdersWithEth(
LibOrder.Order[] memory orders,
uint256 makerAssetBuyAmount,
bytes[] memory signatures,
uint256 feePercentage,
address payable feeRecipient
uint256 ethFeeAmount,
address payable[] memory feeRecipients
)
public
payable