✧ ISwapFactory
Last updated
Last updated
Interface of the {SwapFactory} implementation.
Make an {ISwap-Asset} struct to work with token standards.
addr
address
is the address of the token asset.
amountOrId
uint256
is the amount of tokens or the ID of the NFT.
Make an {ISwap-Asset} struct to work with token standards.
addr
address
is the address of the token asset.
tokenId
uint120
is the ID of the ERC1155 token.
tokenAmount
uint120
is the amount of the ERC1155 token.
Build a swap struct to use in the {Swaplace-createSwap} function.
Requirements:
expiry
cannot be in the past.
owner
address
is the address that created the Swap.
allowed
address
is the address that can accept the Swap. If the allowed address is the zero address, then anyone can accept the Swap.
expiry
uint32
is the timestamp that the Swap will be available to accept.
recipient
uint8
is the address that will receive the ETH. 0
for the acceptee and 1<>255
for the owner.
value
uint56
is the amount of ETH that the recipient will receive. Maximum of 6 decimals (0.000001 ETH). The contract will fill the value up to 18 decimals.
assets
struct ISwap.Asset[]
asking
struct ISwap.Asset[]
Encode tokenId
and tokenAmount
into a single uint256 while adding a flag to indicate that it's an ERC1155 token.
tokenId
uint120
is the ID of the ERC1155 token.
tokenAmount
uint120
is the amount of the ERC1155 token.
Decode amountOrId
returning the first 4 bytes to try match with 0xFFFFFFFF. If the flag is set to 0xFFFFFFFF, then it's an ERC1155 standard, otherwise it's assumed to be an ERC20 or ERC721.
WARNING
Swaplace cannot handle ERC1155 tokens where the ID or the amount is greater than 120 bits.
amountAndId
uint256
is the amount of tokens and the ID of the ERC1155 token.
tokenType
uint16
is the flag to indicate the token standard.
tokenId
uint256
is the ID of the ERC1155 token.
tokenAmount
uint256
is the amount of the ERC1155 token.
This function uses bitwise to return an encoded uint256 of the following parameters.
allowed
address
address is the address that can accept the Swap. If the allowed address is the zero address, then anyone can accept the Swap.
expiry
uint32
date is the timestamp that the Swap will be available to accept.
recipient
uint8
is the address that will receive the ETH as type uint8. If the recipient is equals to 0, the acceptee will receive the ETH. If the recipient is between 1<>255 then the recipient will be the owner of the Swap.
value
uint56
is the amount of ETH that the recipient will receive with a maximum of 6 decimals (0.000001 ETH). The contract will fill the value up to 18 decimals.
Decode config
into their respective variables.
config
uint256
is the encoded uint256 configuration of the Swap.