aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-12-05 08:15:35 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-12-19 05:36:05 +0800
commit14c97b3ec368904d2e072f4603ab41ea8458aebb (patch)
tree3f37efe421750aae41ceaba41c7ebc72bfad1469 /packages
parent58a382d9b69eedc5f618c8d29d130151ba0ed740 (diff)
downloaddexon-sol-tools-14c97b3ec368904d2e072f4603ab41ea8458aebb.tar
dexon-sol-tools-14c97b3ec368904d2e072f4603ab41ea8458aebb.tar.gz
dexon-sol-tools-14c97b3ec368904d2e072f4603ab41ea8458aebb.tar.bz2
dexon-sol-tools-14c97b3ec368904d2e072f4603ab41ea8458aebb.tar.lz
dexon-sol-tools-14c97b3ec368904d2e072f4603ab41ea8458aebb.tar.xz
dexon-sol-tools-14c97b3ec368904d2e072f4603ab41ea8458aebb.tar.zst
dexon-sol-tools-14c97b3ec368904d2e072f4603ab41ea8458aebb.zip
Include threshold balance in constructor of BalanceThresholdFilter contract
Diffstat (limited to 'packages')
-rw-r--r--packages/contracts/contracts/extensions/BalanceThresholdFilter/BalanceThresholdFilter.sol11
-rw-r--r--packages/contracts/contracts/extensions/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol3
-rw-r--r--packages/contracts/contracts/extensions/BalanceThresholdFilter/mixins/MBalanceThresholdFilterCore.sol7
-rw-r--r--packages/contracts/test/extensions/balance_threshold_filter.ts2
4 files changed, 21 insertions, 2 deletions
diff --git a/packages/contracts/contracts/extensions/BalanceThresholdFilter/BalanceThresholdFilter.sol b/packages/contracts/contracts/extensions/BalanceThresholdFilter/BalanceThresholdFilter.sol
index ce3e925fe..bf4a94509 100644
--- a/packages/contracts/contracts/extensions/BalanceThresholdFilter/BalanceThresholdFilter.sol
+++ b/packages/contracts/contracts/extensions/BalanceThresholdFilter/BalanceThresholdFilter.sol
@@ -26,10 +26,19 @@ import "./MixinBalanceThresholdFilterCore.sol";
contract BalanceThresholdFilter is MixinBalanceThresholdFilterCore {
- constructor(address exchange, address thresholdAsset)
+ /// @dev Constructs BalanceThresholdFilter.
+ /// @param exchange Address of 0x exchange.
+ /// @param thresholdAsset The asset that must be held by makers/takers.
+ /// @param thresholdBalance The minimum balance of `thresholdAsset` that must be held by makers/takers.
+ constructor(
+ address exchange,
+ address thresholdAsset,
+ uint256 thresholdBalance
+ )
public
{
EXCHANGE = IExchange(exchange);
THRESHOLD_ASSET = IThresholdAsset(thresholdAsset);
+ THRESHOLD_BALANCE = thresholdBalance;
}
} \ No newline at end of file
diff --git a/packages/contracts/contracts/extensions/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol b/packages/contracts/contracts/extensions/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol
index fe4a50a29..51b3b9736 100644
--- a/packages/contracts/contracts/extensions/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol
+++ b/packages/contracts/contracts/extensions/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol
@@ -263,6 +263,7 @@ contract MixinBalanceThresholdFilterCore is MBalanceThresholdFilterCore {
// Validate addresses
let thresholdAssetAddress := sload(THRESHOLD_ASSET_slot)
+ let thresholdBalance := sload(THRESHOLD_BALANCE_slot)
for {let addressToValidate := addressesToValidateElementPtr} lt(addressToValidate, addressesToValidateElementEndPtr) {addressToValidate := add(addressToValidate, 0x20)} {
// Construct calldata for `THRESHOLD_ASSET.balanceOf`
mstore(freeMemPtr, 0x70a0823100000000000000000000000000000000000000000000000000000000)
@@ -294,7 +295,7 @@ contract MixinBalanceThresholdFilterCore is MBalanceThresholdFilterCore {
// Revert if balance not held
let addressBalance := mload(freeMemPtr)
- if eq(addressBalance, 0) {
+ if lt(addressBalance, thresholdBalance) {
// Revert with `Error("AT_LEAST_ONE_ADDRESS_DOES_NOT_MEET_BALANCE_THRESHOLD")`
mstore(0x00, 0x08c379a000000000000000000000000000000000000000000000000000000000)
mstore(0x20, 0x0000002000000000000000000000000000000000000000000000000000000000)
diff --git a/packages/contracts/contracts/extensions/BalanceThresholdFilter/mixins/MBalanceThresholdFilterCore.sol b/packages/contracts/contracts/extensions/BalanceThresholdFilter/mixins/MBalanceThresholdFilterCore.sol
index ecebaa31b..046caecdd 100644
--- a/packages/contracts/contracts/extensions/BalanceThresholdFilter/mixins/MBalanceThresholdFilterCore.sol
+++ b/packages/contracts/contracts/extensions/BalanceThresholdFilter/mixins/MBalanceThresholdFilterCore.sol
@@ -25,9 +25,16 @@ import "../interfaces/IThresholdAsset.sol";
contract MBalanceThresholdFilterCore {
+ // Points to 0x exchange contract
IExchange internal EXCHANGE;
+
+ // The asset that must be held by makers/takers
IThresholdAsset internal THRESHOLD_ASSET;
+ // The minimum balance of `THRESHOLD_ASSET` that must be held by makers/takers
+ uint256 internal THRESHOLD_BALANCE;
+
+ // Addresses that hold at least `THRESHOLD_BALANCE` of `THRESHOLD_ASSET`
event ValidatedAddresses (
address[] addresses
);
diff --git a/packages/contracts/test/extensions/balance_threshold_filter.ts b/packages/contracts/test/extensions/balance_threshold_filter.ts
index 50fd79439..db4fea77a 100644
--- a/packages/contracts/test/extensions/balance_threshold_filter.ts
+++ b/packages/contracts/test/extensions/balance_threshold_filter.ts
@@ -126,12 +126,14 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
const privateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(compliantMakerAddress)];
orderFactory = new OrderFactory(privateKey, defaultOrderParams);
// Deploy Compliant Forwarder
+ const erc721BalanceThreshold = new BigNumber(1);
compliantForwarderInstance = await BalanceThresholdFilterContract.deployFrom0xArtifactAsync(
artifacts.BalanceThresholdFilter,
provider,
txDefaults,
exchangeInstance.address,
yesTokenInstance.address,
+ erc721BalanceThreshold
);
/*
const compliantForwarderContract = new BalanceThresholdFilterContract(