diff --git a/docs/SamWitchOrderBook.md b/docs/SamWitchOrderBook.md new file mode 100644 index 0000000..55da6c2 --- /dev/null +++ b/docs/SamWitchOrderBook.md @@ -0,0 +1,1163 @@ +# SamWitchOrderBook + +*Sam Witch (PaintSwap & Estfor Kingdom)0xDoubleSharp* + +> SamWitchOrderBook (SWOB) + +This efficient ERC1155 order book is an upgradeable UUPS proxy contract. It has functions for bulk placing limit orders, cancelling limit orders, and claiming NFTs and tokens from filled or partially filled orders. It suppports ERC2981 royalties, and optional dev & burn fees on successful trades. + + + +## Methods + +### UPGRADE_INTERFACE_VERSION + +```solidity +function UPGRADE_INTERFACE_VERSION() external view returns (string) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### allOrdersAtPrice + +```solidity +function allOrdersAtPrice(enum ISamWitchOrderBook.OrderSide _side, uint256 _tokenId, uint72 _price) external view returns (struct ISamWitchOrderBook.OrderBookEntryHelper[]) +``` + +Get all orders at a specific price level + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _side | enum ISamWitchOrderBook.OrderSide | The side of the order book to get orders from | +| _tokenId | uint256 | The token ID to get orders for | +| _price | uint72 | The price level to get orders for | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | ISamWitchOrderBook.OrderBookEntryHelper[] | undefined | + +### cancelOrders + +```solidity +function cancelOrders(uint256[] _orderIds, ISamWitchOrderBook.CancelOrder[] _orders) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _orderIds | uint256[] | undefined | +| _orders | ISamWitchOrderBook.CancelOrder[] | undefined | + +### claimAll + +```solidity +function claimAll(uint256[] _brushOrderIds, uint256[] _nftOrderIds, uint256[] _tokenIds) external nonpayable +``` + +Convience function to claim both tokens and nfts in filled or partially filled orders. Must be the maker of these orders. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _brushOrderIds | uint256[] | Array of order IDs from which to claim tokens | +| _nftOrderIds | uint256[] | Array of order IDs from which to claim NFTs | +| _tokenIds | uint256[] | Array of token IDs to claim NFTs for | + +### claimNFTs + +```solidity +function claimNFTs(uint256[] _orderIds, uint256[] _tokenIds) external nonpayable +``` + +Claim NFTs associated with filled or partially filled orders Must be the maker of these orders. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _orderIds | uint256[] | Array of order IDs from which to claim NFTs | +| _tokenIds | uint256[] | Array of token IDs to claim NFTs for | + +### claimTokens + +```solidity +function claimTokens(uint256[] _orderIds) external nonpayable +``` + +Claim NFTs associated with filled or partially filled orders. Must be the maker of these orders. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _orderIds | uint256[] | Array of order IDs from which to claim NFTs | + +### getHighestBid + +```solidity +function getHighestBid(uint256 _tokenId) external view returns (uint72) +``` + +Get the highest bid for a specific token ID + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _tokenId | uint256 | The token ID to get the highest bid for | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint72 | undefined | + +### getLowestAsk + +```solidity +function getLowestAsk(uint256 _tokenId) external view returns (uint72) +``` + +Get the lowest ask for a specific token ID + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _tokenId | uint256 | The token ID to get the lowest ask for | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint72 | undefined | + +### getMinAmount + +```solidity +function getMinAmount(uint256 _tokenId) external view returns (uint256) +``` + +The minimum amount that can be added to the order book for a specific token ID, to keep the order book healthy + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _tokenId | uint256 | The token ID to get the minimum quantity for | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### getNode + +```solidity +function getNode(enum ISamWitchOrderBook.OrderSide _side, uint256 _tokenId, uint72 _price) external view returns (struct BokkyPooBahsRedBlackTreeLibrary.Node) +``` + +Get the order book entry for a specific order ID + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _side | enum ISamWitchOrderBook.OrderSide | The side of the order book to get the order from | +| _tokenId | uint256 | The token ID to get the order for | +| _price | uint72 | The price level to get the order for | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | BokkyPooBahsRedBlackTreeLibrary.Node | undefined | + +### getTick + +```solidity +function getTick(uint256 _tokenId) external view returns (uint256) +``` + +Get the tick size for a specific token ID + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _tokenId | uint256 | The token ID to get the tick size for | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### initialize + +```solidity +function initialize(contract IERC1155 _nft, address _token, address _devAddr, uint16 _devFee, uint8 _burntFee, uint16 _maxOrdersPerPrice) external payable +``` + +Initialize the contract as part of the proxy contract deployment + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _nft | contract IERC1155 | Address of the nft | +| _token | address | The quote token | +| _devAddr | address | The address to receive trade fees | +| _devFee | uint16 | The fee to send to the dev address (max 10%) | +| _burntFee | uint8 | The fee to burn (max 2.55%) | +| _maxOrdersPerPrice | uint16 | The maximum number of orders allowed at each price level | + +### limitOrders + +```solidity +function limitOrders(ISamWitchOrderBook.LimitOrder[] _orders) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _orders | ISamWitchOrderBook.LimitOrder[] | undefined | + +### nextOrderId + +```solidity +function nextOrderId() external view returns (uint40) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint40 | undefined | + +### nftsClaimable + +```solidity +function nftsClaimable(uint40[] _orderIds, uint256[] _tokenIds) external view returns (uint256[] amounts_) +``` + +Get the amount of NFTs claimable for these orders + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _orderIds | uint40[] | The order IDs to get the claimable NFTs for | +| _tokenIds | uint256[] | The token IDs to get the claimable NFTs for | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| amounts_ | uint256[] | undefined | + +### nodeExists + +```solidity +function nodeExists(enum ISamWitchOrderBook.OrderSide _side, uint256 _tokenId, uint72 _price) external view returns (bool) +``` + +Check if the node exists + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _side | enum ISamWitchOrderBook.OrderSide | The side of the order book to get the order from | +| _tokenId | uint256 | The token ID to get the order for | +| _price | uint72 | The price level to get the order for | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### onERC1155BatchReceived + +```solidity +function onERC1155BatchReceived(address, address, uint256[], uint256[], bytes) external nonpayable returns (bytes4) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | +| _1 | address | undefined | +| _2 | uint256[] | undefined | +| _3 | uint256[] | undefined | +| _4 | bytes | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bytes4 | undefined | + +### onERC1155Received + +```solidity +function onERC1155Received(address, address, uint256, uint256, bytes) external nonpayable returns (bytes4) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | +| _1 | address | undefined | +| _2 | uint256 | undefined | +| _3 | uint256 | undefined | +| _4 | bytes | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bytes4 | undefined | + +### owner + +```solidity +function owner() external view returns (address) +``` + + + +*Returns the address of the current owner.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +### proxiableUUID + +```solidity +function proxiableUUID() external view returns (bytes32) +``` + + + +*Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the implementation. It is used to validate the implementation's compatibility when performing an upgrade. IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bytes32 | undefined | + +### renounceOwnership + +```solidity +function renounceOwnership() external nonpayable +``` + + + +*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.* + + +### setMaxOrdersPerPrice + +```solidity +function setMaxOrdersPerPrice(uint16 _maxOrdersPerPrice) external payable +``` + +The maximum amount of orders allowed at a specific price level + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _maxOrdersPerPrice | uint16 | The new maximum amount of orders allowed at a specific price level | + +### setTokenIdInfos + +```solidity +function setTokenIdInfos(uint256[] _tokenIds, ISamWitchOrderBook.TokenIdInfo[] _tokenIdInfos) external payable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _tokenIds | uint256[] | undefined | +| _tokenIdInfos | ISamWitchOrderBook.TokenIdInfo[] | undefined | + +### supportsInterface + +```solidity +function supportsInterface(bytes4 interfaceId) external view returns (bool) +``` + + + +*See {IERC165-supportsInterface}.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| interfaceId | bytes4 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### tokenIdInfos + +```solidity +function tokenIdInfos(uint256 tokenId) external view returns (uint128 tick, uint128 minQuantity) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| tokenId | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| tick | uint128 | undefined | +| minQuantity | uint128 | undefined | + +### tokensClaimable + +```solidity +function tokensClaimable(uint40[] _orderIds, bool takeAwayFees) external view returns (uint256 amount_) +``` + +Get the amount of tokens claimable for these orders + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _orderIds | uint40[] | The order IDs to get the claimable tokens for | +| takeAwayFees | bool | Whether to take away the fees from the claimable amount | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| amount_ | uint256 | undefined | + +### transferOwnership + +```solidity +function transferOwnership(address newOwner) external nonpayable +``` + + + +*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newOwner | address | undefined | + +### updateRoyaltyFee + +```solidity +function updateRoyaltyFee() external nonpayable +``` + +When the nft royalty changes this updates the fee and recipient. Assumes all token ids have the same royalty + + + + +### upgradeToAndCall + +```solidity +function upgradeToAndCall(address newImplementation, bytes data) external payable +``` + + + +*Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call encoded in `data`. Calls {_authorizeUpgrade}. Emits an {Upgraded} event.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newImplementation | address | undefined | +| data | bytes | undefined | + + + +## Events + +### AddedToBook + +```solidity +event AddedToBook(address maker, enum ISamWitchOrderBook.OrderSide side, uint256 orderId, uint256 tokenId, uint256 price, uint256 quantity) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| maker | address | undefined | +| side | enum ISamWitchOrderBook.OrderSide | undefined | +| orderId | uint256 | undefined | +| tokenId | uint256 | undefined | +| price | uint256 | undefined | +| quantity | uint256 | undefined | + +### ClaimedNFTs + +```solidity +event ClaimedNFTs(address user, uint256[] orderIds, uint256[] tokenIds, uint256[] amounts) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| user | address | undefined | +| orderIds | uint256[] | undefined | +| tokenIds | uint256[] | undefined | +| amounts | uint256[] | undefined | + +### ClaimedTokens + +```solidity +event ClaimedTokens(address user, uint256[] orderIds, uint256 amount, uint256 fees) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| user | address | undefined | +| orderIds | uint256[] | undefined | +| amount | uint256 | undefined | +| fees | uint256 | undefined | + +### FailedToAddToBook + +```solidity +event FailedToAddToBook(address maker, enum ISamWitchOrderBook.OrderSide side, uint256 tokenId, uint256 price, uint256 quantity) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| maker | address | undefined | +| side | enum ISamWitchOrderBook.OrderSide | undefined | +| tokenId | uint256 | undefined | +| price | uint256 | undefined | +| quantity | uint256 | undefined | + +### Initialized + +```solidity +event Initialized(uint64 version) +``` + + + +*Triggered when the contract has been initialized or reinitialized.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| version | uint64 | undefined | + +### OrdersCancelled + +```solidity +event OrdersCancelled(address maker, uint256[] orderIds) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| maker | address | undefined | +| orderIds | uint256[] | undefined | + +### OrdersMatched + +```solidity +event OrdersMatched(address taker, uint256[] orderIds, uint256[] quantities) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| taker | address | undefined | +| orderIds | uint256[] | undefined | +| quantities | uint256[] | undefined | + +### OwnershipTransferred + +```solidity +event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| previousOwner `indexed` | address | undefined | +| newOwner `indexed` | address | undefined | + +### SetMaxOrdersPerPriceLevel + +```solidity +event SetMaxOrdersPerPriceLevel(uint256 maxOrdersPerPrice) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| maxOrdersPerPrice | uint256 | undefined | + +### SetTokenIdInfos + +```solidity +event SetTokenIdInfos(uint256[] tokenIds, ISamWitchOrderBook.TokenIdInfo[] tokenIdInfos) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| tokenIds | uint256[] | undefined | +| tokenIdInfos | ISamWitchOrderBook.TokenIdInfo[] | undefined | + +### Upgraded + +```solidity +event Upgraded(address indexed implementation) +``` + + + +*Emitted when the implementation is upgraded.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| implementation `indexed` | address | undefined | + + + +## Errors + +### AddressEmptyCode + +```solidity +error AddressEmptyCode(address target) +``` + + + +*There's no code at `target` (it is not a contract).* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| target | address | undefined | + +### AddressInsufficientBalance + +```solidity +error AddressInsufficientBalance(address account) +``` + + + +*The ETH balance of the account is not enough to perform the operation.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| account | address | undefined | + +### DeadlineExpired + +```solidity +error DeadlineExpired(uint256 deadline) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| deadline | uint256 | undefined | + +### DevFeeNotSet + +```solidity +error DevFeeNotSet() +``` + + + + + + +### ERC1967InvalidImplementation + +```solidity +error ERC1967InvalidImplementation(address implementation) +``` + + + +*The `implementation` of the proxy is invalid.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| implementation | address | undefined | + +### ERC1967NonPayable + +```solidity +error ERC1967NonPayable() +``` + + + +*An upgrade function sees `msg.value > 0` that may be lost.* + + +### FailedInnerCall + +```solidity +error FailedInnerCall() +``` + + + +*A call to an address target failed. The target may have reverted.* + + +### InvalidInitialization + +```solidity +error InvalidInitialization() +``` + + + +*The contract is already initialized.* + + +### InvalidNonce + +```solidity +error InvalidNonce(uint256 invalid, uint256 nonce) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| invalid | uint256 | undefined | +| nonce | uint256 | undefined | + +### InvalidSignature + +```solidity +error InvalidSignature(address sender, address recoveredAddress) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| sender | address | undefined | +| recoveredAddress | address | undefined | + +### LengthMismatch + +```solidity +error LengthMismatch() +``` + + + + + + +### NoQuantity + +```solidity +error NoQuantity() +``` + + + + + + +### NotERC1155 + +```solidity +error NotERC1155() +``` + + + + + + +### NotInitializing + +```solidity +error NotInitializing() +``` + + + +*The contract is not initializing.* + + +### NotMaker + +```solidity +error NotMaker() +``` + + + + + + +### NothingToClaim + +```solidity +error NothingToClaim() +``` + + + + + + +### OrderNotFound + +```solidity +error OrderNotFound(uint256 orderId, uint256 price) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| orderId | uint256 | undefined | +| price | uint256 | undefined | + +### OrderNotFoundInTree + +```solidity +error OrderNotFoundInTree(uint256 orderId, uint256 price) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| orderId | uint256 | undefined | +| price | uint256 | undefined | + +### OwnableInvalidOwner + +```solidity +error OwnableInvalidOwner(address owner) +``` + + + +*The owner is not a valid owner account. (eg. `address(0)`)* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | + +### OwnableUnauthorizedAccount + +```solidity +error OwnableUnauthorizedAccount(address account) +``` + + + +*The caller account is not authorized to perform an operation.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| account | address | undefined | + +### PriceNotMultipleOfTick + +```solidity +error PriceNotMultipleOfTick(uint256 tick) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| tick | uint256 | undefined | + +### PriceZero + +```solidity +error PriceZero() +``` + + + + + + +### SafeERC20FailedOperation + +```solidity +error SafeERC20FailedOperation(address token) +``` + + + +*An operation with an ERC20 token failed.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| token | address | undefined | + +### TokenDoesntExist + +```solidity +error TokenDoesntExist(uint256 tokenId) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| tokenId | uint256 | undefined | + +### TooManyOrdersHit + +```solidity +error TooManyOrdersHit() +``` + + + + + + +### UUPSUnauthorizedCallContext + +```solidity +error UUPSUnauthorizedCallContext() +``` + + + +*The call is from an unauthorized context.* + + +### UUPSUnsupportedProxiableUUID + +```solidity +error UUPSUnsupportedProxiableUUID(bytes32 slot) +``` + + + +*The storage `slot` is unsupported as a UUID.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| slot | bytes32 | undefined | + +### ZeroAddress + +```solidity +error ZeroAddress() +``` + + + + + + + diff --git a/docs/interfaces/IBrushToken.md b/docs/interfaces/IBrushToken.md new file mode 100644 index 0000000..4cd9d13 --- /dev/null +++ b/docs/interfaces/IBrushToken.md @@ -0,0 +1,202 @@ +# IBrushToken + + + + + + + + + +## Methods + +### allowance + +```solidity +function allowance(address owner, address spender) external view returns (uint256) +``` + + + +*Returns the remaining number of tokens that `spender` will be allowed to spend on behalf of `owner` through {transferFrom}. This is zero by default. This value changes when {approve} or {transferFrom} are called.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | +| spender | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### approve + +```solidity +function approve(address spender, uint256 value) external nonpayable returns (bool) +``` + + + +*Sets a `value` amount of tokens as the allowance of `spender` over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 Emits an {Approval} event.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| spender | address | undefined | +| value | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### balanceOf + +```solidity +function balanceOf(address account) external view returns (uint256) +``` + + + +*Returns the value of tokens owned by `account`.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| account | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### burn + +```solidity +function burn(uint256 _amount) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _amount | uint256 | undefined | + +### totalSupply + +```solidity +function totalSupply() external view returns (uint256) +``` + + + +*Returns the value of tokens in existence.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### transfer + +```solidity +function transfer(address to, uint256 value) external nonpayable returns (bool) +``` + + + +*Moves a `value` amount of tokens from the caller's account to `to`. Returns a boolean value indicating whether the operation succeeded. Emits a {Transfer} event.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| to | address | undefined | +| value | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### transferFrom + +```solidity +function transferFrom(address from, address to, uint256 value) external nonpayable returns (bool) +``` + + + +*Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism. `value` is then deducted from the caller's allowance. Returns a boolean value indicating whether the operation succeeded. Emits a {Transfer} event.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from | address | undefined | +| to | address | undefined | +| value | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + + + +## Events + +### Approval + +```solidity +event Approval(address indexed owner, address indexed spender, uint256 value) +``` + + + +*Emitted when the allowance of a `spender` for an `owner` is set by a call to {approve}. `value` is the new allowance.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner `indexed` | address | undefined | +| spender `indexed` | address | undefined | +| value | uint256 | undefined | + +### Transfer + +```solidity +event Transfer(address indexed from, address indexed to, uint256 value) +``` + + + +*Emitted when `value` tokens are moved from one account (`from`) to another (`to`). Note that `value` may be zero.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| value | uint256 | undefined | + + + diff --git a/docs/interfaces/ISamWitchOrderBook.md b/docs/interfaces/ISamWitchOrderBook.md new file mode 100644 index 0000000..4844b59 --- /dev/null +++ b/docs/interfaces/ISamWitchOrderBook.md @@ -0,0 +1,747 @@ +# ISamWitchOrderBook + + + + + + + + + +## Methods + +### allOrdersAtPrice + +```solidity +function allOrdersAtPrice(enum ISamWitchOrderBook.OrderSide _side, uint256 _tokenId, uint72 _price) external view returns (struct ISamWitchOrderBook.OrderBookEntryHelper[] orderBookEntries) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _side | enum ISamWitchOrderBook.OrderSide | undefined | +| _tokenId | uint256 | undefined | +| _price | uint72 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| orderBookEntries | ISamWitchOrderBook.OrderBookEntryHelper[] | undefined | + +### cancelOrders + +```solidity +function cancelOrders(uint256[] _orderIds, ISamWitchOrderBook.CancelOrder[] _cancelOrderInfos) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _orderIds | uint256[] | undefined | +| _cancelOrderInfos | ISamWitchOrderBook.CancelOrder[] | undefined | + +### claimAll + +```solidity +function claimAll(uint256[] _brushOrderIds, uint256[] _nftOrderIds, uint256[] _tokenIds) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _brushOrderIds | uint256[] | undefined | +| _nftOrderIds | uint256[] | undefined | +| _tokenIds | uint256[] | undefined | + +### claimNFTs + +```solidity +function claimNFTs(uint256[] _orderIds, uint256[] _tokenIds) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _orderIds | uint256[] | undefined | +| _tokenIds | uint256[] | undefined | + +### claimTokens + +```solidity +function claimTokens(uint256[] _orderIds) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _orderIds | uint256[] | undefined | + +### getHighestBid + +```solidity +function getHighestBid(uint256 _tokenId) external view returns (uint72) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _tokenId | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint72 | undefined | + +### getLowestAsk + +```solidity +function getLowestAsk(uint256 _tokenId) external view returns (uint72) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _tokenId | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint72 | undefined | + +### getMinAmount + +```solidity +function getMinAmount(uint256 _tokenId) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _tokenId | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### getNode + +```solidity +function getNode(enum ISamWitchOrderBook.OrderSide _side, uint256 _tokenId, uint72 _price) external view returns (struct BokkyPooBahsRedBlackTreeLibrary.Node) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _side | enum ISamWitchOrderBook.OrderSide | undefined | +| _tokenId | uint256 | undefined | +| _price | uint72 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | BokkyPooBahsRedBlackTreeLibrary.Node | undefined | + +### getTick + +```solidity +function getTick(uint256 _tokenId) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _tokenId | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### limitOrders + +```solidity +function limitOrders(ISamWitchOrderBook.LimitOrder[] _orders) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _orders | ISamWitchOrderBook.LimitOrder[] | undefined | + +### nftsClaimable + +```solidity +function nftsClaimable(uint40[] _orderIds, uint256[] _tokenIds) external view returns (uint256[] amounts) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _orderIds | uint40[] | undefined | +| _tokenIds | uint256[] | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| amounts | uint256[] | undefined | + +### nodeExists + +```solidity +function nodeExists(enum ISamWitchOrderBook.OrderSide _side, uint256 _tokenId, uint72 _price) external view returns (bool) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _side | enum ISamWitchOrderBook.OrderSide | undefined | +| _tokenId | uint256 | undefined | +| _price | uint72 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### onERC1155BatchReceived + +```solidity +function onERC1155BatchReceived(address operator, address from, uint256[] ids, uint256[] values, bytes data) external nonpayable returns (bytes4) +``` + + + +*Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a `safeBatchTransferFrom` after the balances have been updated. NOTE: To accept the transfer(s), this must return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81, or its own function selector).* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| operator | address | The address which initiated the batch transfer (i.e. msg.sender) | +| from | address | The address which previously owned the token | +| ids | uint256[] | An array containing ids of each token being transferred (order and length must match values array) | +| values | uint256[] | An array containing amounts of each token being transferred (order and length must match ids array) | +| data | bytes | Additional data with no specified format | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bytes4 | `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed | + +### onERC1155Received + +```solidity +function onERC1155Received(address operator, address from, uint256 id, uint256 value, bytes data) external nonpayable returns (bytes4) +``` + + + +*Handles the receipt of a single ERC1155 token type. This function is called at the end of a `safeTransferFrom` after the balance has been updated. NOTE: To accept the transfer, this must return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61, or its own function selector).* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| operator | address | The address which initiated the transfer (i.e. msg.sender) | +| from | address | The address which previously owned the token | +| id | uint256 | The ID of the token being transferred | +| value | uint256 | The amount of tokens being transferred | +| data | bytes | Additional data with no specified format | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bytes4 | `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed | + +### supportsInterface + +```solidity +function supportsInterface(bytes4 interfaceId) external view returns (bool) +``` + + + +*Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| interfaceId | bytes4 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### tokensClaimable + +```solidity +function tokensClaimable(uint40[] _orderIds, bool takeAwayFees) external view returns (uint256 amount) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _orderIds | uint40[] | undefined | +| takeAwayFees | bool | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| amount | uint256 | undefined | + + + +## Events + +### AddedToBook + +```solidity +event AddedToBook(address maker, enum ISamWitchOrderBook.OrderSide side, uint256 orderId, uint256 tokenId, uint256 price, uint256 quantity) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| maker | address | undefined | +| side | enum ISamWitchOrderBook.OrderSide | undefined | +| orderId | uint256 | undefined | +| tokenId | uint256 | undefined | +| price | uint256 | undefined | +| quantity | uint256 | undefined | + +### ClaimedNFTs + +```solidity +event ClaimedNFTs(address user, uint256[] orderIds, uint256[] tokenIds, uint256[] amounts) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| user | address | undefined | +| orderIds | uint256[] | undefined | +| tokenIds | uint256[] | undefined | +| amounts | uint256[] | undefined | + +### ClaimedTokens + +```solidity +event ClaimedTokens(address user, uint256[] orderIds, uint256 amount, uint256 fees) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| user | address | undefined | +| orderIds | uint256[] | undefined | +| amount | uint256 | undefined | +| fees | uint256 | undefined | + +### FailedToAddToBook + +```solidity +event FailedToAddToBook(address maker, enum ISamWitchOrderBook.OrderSide side, uint256 tokenId, uint256 price, uint256 quantity) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| maker | address | undefined | +| side | enum ISamWitchOrderBook.OrderSide | undefined | +| tokenId | uint256 | undefined | +| price | uint256 | undefined | +| quantity | uint256 | undefined | + +### OrdersCancelled + +```solidity +event OrdersCancelled(address maker, uint256[] orderIds) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| maker | address | undefined | +| orderIds | uint256[] | undefined | + +### OrdersMatched + +```solidity +event OrdersMatched(address taker, uint256[] orderIds, uint256[] quantities) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| taker | address | undefined | +| orderIds | uint256[] | undefined | +| quantities | uint256[] | undefined | + +### SetMaxOrdersPerPriceLevel + +```solidity +event SetMaxOrdersPerPriceLevel(uint256 maxOrdersPerPrice) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| maxOrdersPerPrice | uint256 | undefined | + +### SetTokenIdInfos + +```solidity +event SetTokenIdInfos(uint256[] tokenIds, ISamWitchOrderBook.TokenIdInfo[] tokenIdInfos) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| tokenIds | uint256[] | undefined | +| tokenIdInfos | ISamWitchOrderBook.TokenIdInfo[] | undefined | + + + +## Errors + +### DeadlineExpired + +```solidity +error DeadlineExpired(uint256 deadline) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| deadline | uint256 | undefined | + +### DevFeeNotSet + +```solidity +error DevFeeNotSet() +``` + + + + + + +### InvalidNonce + +```solidity +error InvalidNonce(uint256 invalid, uint256 nonce) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| invalid | uint256 | undefined | +| nonce | uint256 | undefined | + +### InvalidSignature + +```solidity +error InvalidSignature(address sender, address recoveredAddress) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| sender | address | undefined | +| recoveredAddress | address | undefined | + +### LengthMismatch + +```solidity +error LengthMismatch() +``` + + + + + + +### NoQuantity + +```solidity +error NoQuantity() +``` + + + + + + +### NotERC1155 + +```solidity +error NotERC1155() +``` + + + + + + +### NotMaker + +```solidity +error NotMaker() +``` + + + + + + +### NothingToClaim + +```solidity +error NothingToClaim() +``` + + + + + + +### OrderNotFound + +```solidity +error OrderNotFound(uint256 orderId, uint256 price) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| orderId | uint256 | undefined | +| price | uint256 | undefined | + +### OrderNotFoundInTree + +```solidity +error OrderNotFoundInTree(uint256 orderId, uint256 price) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| orderId | uint256 | undefined | +| price | uint256 | undefined | + +### PriceNotMultipleOfTick + +```solidity +error PriceNotMultipleOfTick(uint256 tick) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| tick | uint256 | undefined | + +### PriceZero + +```solidity +error PriceZero() +``` + + + + + + +### TokenDoesntExist + +```solidity +error TokenDoesntExist(uint256 tokenId) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| tokenId | uint256 | undefined | + +### TooManyOrdersHit + +```solidity +error TooManyOrdersHit() +``` + + + + + + +### ZeroAddress + +```solidity +error ZeroAddress() +``` + + + + + + + diff --git a/hardhat.config.ts b/hardhat.config.ts index 88dc35c..562bfa8 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -5,6 +5,7 @@ import "hardhat-abi-exporter"; import "hardhat-contract-sizer"; import "hardhat-storage-layout"; import "solidity-coverage"; +import "@primitivefi/hardhat-dodoc"; import {SolcUserConfig} from "hardhat/types"; import "dotenv/config"; @@ -76,6 +77,9 @@ const config: HardhatUserConfig = { runOnCompile: true, disambiguatePaths: false, }, + dodoc: { + include: ["IBrushToken.sol", "ISamWitchOrderBook.sol", "SamWitchOrderBook.sol"], + }, networks: { hardhat: { gasPrice: 0, diff --git a/package.json b/package.json index 05f3b7a..496a937 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@openzeppelin/contracts": "^5.0.1", "@openzeppelin/contracts-upgradeable": "^5.0.1", "@openzeppelin/hardhat-upgrades": "^3.0.2", + "@primitivefi/hardhat-dodoc": "^0.2.3", "@typechain/ethers-v6": "^0.5.1", "@typechain/hardhat": "^9.1.0", "@types/chai": "^4.3.11", diff --git a/yarn.lock b/yarn.lock index 7a6b5b7..b02a57d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -868,6 +868,13 @@ proper-lockfile "^4.1.1" solidity-ast "^0.4.51" +"@primitivefi/hardhat-dodoc@^0.2.3": + version "0.2.3" + resolved "https://registry.yarnpkg.com/@primitivefi/hardhat-dodoc/-/hardhat-dodoc-0.2.3.tgz#76aebbfa70de2d6454af29e166b1430583b54c5c" + integrity sha512-ver9uHa79LTDTeebOKZ/eOVRL/FP1k0s0x/5Bo/8ZaDdLWFVClKqZyZYVjjW4CJqTPCt8uU9b9p71P2vzH4O9A== + dependencies: + squirrelly "^8.0.8" + "@scure/base@~1.1.0": version "1.1.5" resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.5.tgz#1d85d17269fe97694b9c592552dd9e5e33552157" @@ -4366,6 +4373,11 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== +squirrelly@^8.0.8: + version "8.0.8" + resolved "https://registry.yarnpkg.com/squirrelly/-/squirrelly-8.0.8.tgz#d6704650b2170b8040d5de5bff9fa69cb62b5e0f" + integrity sha512-7dyZJ9Gw86MmH0dYLiESsjGOTj6KG8IWToTaqBuB6LwPI+hyNb6mbQaZwrfnAQ4cMDnSWMUvX/zAYDLTSWLk/w== + stacktrace-parser@^0.1.10: version "0.1.10" resolved "https://registry.yarnpkg.com/stacktrace-parser/-/stacktrace-parser-0.1.10.tgz#29fb0cae4e0d0b85155879402857a1639eb6051a"