Skip to content

Commit

Permalink
updateOrderPriceAndExpiry & tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
bokkypoobah committed Dec 11, 2021
1 parent 84d0efd commit 5e92fcd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
27 changes: 18 additions & 9 deletions contracts/Nix.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
pragma solidity ^0.8.0;

// ----------------------------------------------------------------------------
// Nix v0.8.4 testing
// Nix v0.8.5 testing to be deployed
//
// https://github.com/bokkypoobah/Nix
//
// Deployed to Rinkeby
// - Nix 0xB1eb96f752C624DC784D80961A1aCcfAf348C923
// - NixHelper 0x8aa752009F38F0b1C9306c7da2f9A146E2bAF56b
// - Nix
// - NixHelper
//
// SPDX-License-Identifier: MIT
//
Expand Down Expand Up @@ -151,12 +151,12 @@ contract Nix is Owned, ReentrancyGuard, ERC721TokenReceiver {
IRoyaltyEngineV1Partial public royaltyEngine;

address[] private tokensIndex;
mapping(address => Token) public tokens;
mapping(address => Token) private tokens;
Trade[] private trades;

event TokenAdded(address indexed token, uint indexed tokenIndex);
event OrderAdded(address indexed token, uint indexed orderIndex);
event OrderDisabled(address indexed token, uint indexed orderIndex);
event OrderPriceAndExpiryUpdated(address indexed token, uint indexed orderIndex);
event OrderUpdated(address indexed token, uint indexed orderIndex);
event OrderExecuted(address indexed token, uint indexed orderIndex, uint indexed tradeIndex, uint[] tokenIds);
event ThankYou(uint tip);
Expand Down Expand Up @@ -263,13 +263,22 @@ contract Nix is Owned, ReentrancyGuard, ERC721TokenReceiver {
/// @dev Disable order
/// @param token ERC-721 contract address
/// @param orderIndex Order index
/// @param price Price per NFT for Any. Price for all specified NFTs for All
/// @param expiry Expiry date. 0 = no expiry. 1 = disabled.
/// @param integrator Address of integrator, that will receive a portion of ETH tips
function disableOrder(address token, uint orderIndex, address integrator) external payable reentrancyGuard {
function updateOrderPriceAndExpiry(
address token,
uint orderIndex,
uint price,
uint expiry,
address integrator
) external payable reentrancyGuard {
bytes32 orderKey = tokens[token].ordersIndex[orderIndex];
Order storage order = tokens[token].orders[orderKey];
require(msg.sender == order.maker, "NotMaker");
order.expiry = uint64(1);
emit OrderDisabled(token, orderIndex);
order.price = price;
order.expiry = uint64(expiry);
emit OrderPriceAndExpiryUpdated(token, orderIndex);
handleTips(integrator);
}

Expand All @@ -279,7 +288,7 @@ contract Nix is Owned, ReentrancyGuard, ERC721TokenReceiver {
/// @param taker Specific address, or null for any taker
/// @param tokenIds [] (empty) for any, [tokenId1, tokenId2, ...] for specific tokenIds. Must not be empty for All
/// @param price Price per NFT for Any. Price for all specified NFTs for All
/// @param expiry Expiry date. 0 = no expiry.
/// @param expiry Expiry date. 0 = no expiry. 1 = disabled.
/// @param tradeMaxAdjustment Positive or negative number to adjust tradeMax. tradeMax must result in 0 or 1 for All, or the maximum number of NFTs for Any
/// @param royaltyFactor 0 to ROYALTYFACTOR_MAX, and will be applied as % when the maker sells the NFTs
/// @param integrator Address of integrator, that will receive a portion of ETH tips
Expand Down
18 changes: 9 additions & 9 deletions testIt.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Compilation finished successfully

Nix
--- Setup Accounts, WETH, NFT and Nix Contracts ---
> txFee Deployed Nix - gasUsed: 5401772 ~ ETH 0.453748848 ~ USD 1978
> txFee Deployed Nix - gasUsed: 5355662 ~ ETH 0.449875608 ~ USD 1961
> txFee Deployed NixHelper - gasUsed: 2406045 ~ ETH 0.20210778 ~ USD 881
--- Setup Completed. Nix bytecode ~25110, NixHelper bytecode ~11427 ---
--- Setup Completed. Nix bytecode ~24896, NixHelper bytecode ~11427 ---
Account ETH WETH NFTA (6) NFTB (6)
-------------------- -------------------- -------------------- ------------------------- -------------------------
deployer:0xf39F 9999.75981052 100.0 [] []
deployer:0xf39F 9999.7601794 100.0 [] []
maker0:0x7099 9999.99925244 100.0 [0,1,2] [0,1,2]
maker1:0x3C44 9999.99925244 100.0 [] []
taker0:0x90F7 9999.99925244 100.0 [3,4,5] [3,4,5]
Expand All @@ -35,7 +35,7 @@ Compilation finished successfully
--- After Maker Added Orders ---
Account ETH WETH NFTA (6) NFTB (6)
-------------------- -------------------- -------------------- ------------------------- -------------------------
deployer:0xf39F 9999.75981052 100.0 [] []
deployer:0xf39F 9999.7601794 100.0 [] []
maker0:0x7099 9999.992850648 100.0 [0,1,2] [0,1,2]
maker1:0x3C44 9999.99925244 100.0 [] []
taker0:0x90F7 9999.99925244 100.0 [3,4,5] [3,4,5]
Expand All @@ -50,7 +50,7 @@ Compilation finished successfully
# Maker Taker Price B/S Any/All Expiry Tx Count Tx Max RoyFac% Status TokenIds
--- -------------- -------------- -------------------- ---- ------- ------------------------ -------- -------- -------- -------------------- -----------------------
0 maker0:0x7099 null:0x0000 11.0 Buy Any (none) 0 5 100 Executable [3,4,5]
1 maker0:0x7099 null:0x0000 0.0011 Buy Any 2021-12-11T15:57:39.000Z 0 5 100 Executable []
1 maker0:0x7099 null:0x0000 0.0011 Buy Any 2021-12-12T03:03:49.000Z 0 5 100 Executable []

Orders for NFTB:0xDc64, ordersLength: 1, executed: 0, volumeToken: 0, volumeWeth: 0.0
# Maker Taker Price B/S Any/All Expiry Tx Count Tx Max RoyFac% Status TokenIds
Expand All @@ -75,7 +75,7 @@ Compilation finished successfully
--- After Taker Executed Orders ---
Account ETH WETH NFTA (6) NFTB (6)
-------------------- -------------------- -------------------- ------------------------- -------------------------
deployer:0xf39F 9999.75981052 100.0 [] []
deployer:0xf39F 9999.7601794 100.0 [] []
maker0:0x7099 9999.992850648 77.9989 [0,1,2,3,4,5] [0,1,2]
maker1:0x3C44 9999.99925244 100.0 [] []
taker0:0x90F7 9999.994413224 115.40077 [] [3,4,5]
Expand All @@ -90,7 +90,7 @@ Compilation finished successfully
# Maker Taker Price B/S Any/All Expiry Tx Count Tx Max RoyFac% Status TokenIds
--- -------------- -------------- -------------------- ---- ------- ------------------------ -------- -------- -------- -------------------- -----------------------
0 maker0:0x7099 null:0x0000 11.0 Buy Any (none) 2 5 100 Executable [3,4,5]
1 maker0:0x7099 null:0x0000 0.0011 Buy Any 2021-12-11T15:57:39.000Z 1 5 100 Executable []
1 maker0:0x7099 null:0x0000 0.0011 Buy Any 2021-12-12T03:03:49.000Z 1 5 100 Executable []

Orders for NFTB:0xDc64, ordersLength: 1, executed: 0, volumeToken: 0, volumeWeth: 0.0
# Maker Taker Price B/S Any/All Expiry Tx Count Tx Max RoyFac% Status TokenIds
Expand All @@ -99,8 +99,8 @@ Compilation finished successfully

tradesLength: 1
trades: ["0x90F79bf6EB2c4f870365E785982E1f101E93b906","100","37","0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9,0,0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9,1"]
✓ 00. Maker BuyAny Test (767ms)
✓ 00. Maker BuyAny Test (731ms)


1 passing (4s)
1 passing (3s)

0 comments on commit 5e92fcd

Please sign in to comment.