✧ 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 owner of the Swap is the address that created the Swap.

  • The allowed address is the address that can accept the Swap. If the allowed address is the zero address, then anyone can accept the Swap.

  • The expiry date is the timestamp that the Swap will be available to accept.

  • The recipient 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.

  • The value 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.

  • The biding are the assets that the owner is offering.

  • The asking are 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 address of the token asset.

  • The amount or id of the asset. This amount can be the amount of ERC20 tokens or the NFT ID of an ERC721.

  • The amount and id can 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