✧ SwapFactory
SwapFactory is a helper for creating Swaps and making asset structs.
This helper can be used on and off-chain to easily create a Swap struct to be used in the {Swaplace-createSwap} function.
Swaplace uses a {ISwap-Swap} struct to represent a Swap. This struct is composed of:
The
ownerof the Swap is the address that created the Swap.The
allowedaddress is the address that can accept the Swap. If the allowed address is the zero address, then anyone can accept the Swap.The
expirydate is the timestamp that the Swap will be available to accept.The
recipientis 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.The
valueis 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.The
bidingare the assets that the owner is offering.The
askingare the assets that the owner wants in exchange.
The Swap struct uses an {Asset} struct to represent the asset. This struct is composed of:
The
addressof the token asset.The
amountoridof the asset. This amount can be the amount of ERC20 tokens or the NFT ID of an ERC721.The
amountandidcan be encoded together in a single uint256, allowing the ERC1155 tokens to be swapped.
makeAsset()
See {ISwapFactory-makeAsset}.
make1155Asset()
See {ISwapFactory-make1155Asset}.
makeSwap()
See {ISwapFactory-makeSwap}.
encodeAsset()
See {ISwapFactory-encodeAsset}.
decodeAsset()
See {ISwapFactory-decodeAsset}.
encodeConfig()
See {ISwapFactory-encodeConfig}.
decodeConfig()
See {ISwapFactory-decodeConfig}.
Last updated