Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Updating docs with docgen-solidity #233

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 40 additions & 13 deletions docs/solidity-docgen/SwapFactory.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,22 @@ composed of:
- 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 asset. This address can be from an ERC20 or ERC721 contract.
- The `address` of the token asset.
- The `amount` or `id` of the asset. This amount can be the amount of ERC20 tokens
or the ID of an ERC721 token.

To use other standards, like ERC1155, you can wrap the ownership of the asset
in an a trusted contract and Swap as an ERC721. This way, you can tokenize any
on-chain execution and trade on Swaplace._
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

Expand All @@ -36,27 +39,51 @@ function makeAsset(address addr, uint256 amountOrId) public pure virtual returns

_See {ISwapFactory-makeAsset}._

### make1155Asset

```solidity
function make1155Asset(address addr, uint120 tokenId, uint120 tokenAmount) public pure virtual returns (struct ISwap.Asset)
```

_See {ISwapFactory-make1155Asset}._

### makeSwap

```solidity
function makeSwap(address owner, address allowed, uint256 expiry, struct ISwap.Asset[] biding, struct ISwap.Asset[] asking) public view virtual returns (struct ISwap.Swap)
function makeSwap(address owner, address allowed, uint32 expiry, uint8 recipient, uint56 value, struct ISwap.Asset[] biding, struct ISwap.Asset[] asking) public view virtual returns (struct ISwap.Swap)
```

_See {ISwapFactory-makeSwap}._

### packData
### encodeAsset

```solidity
function encodeAsset(uint120 tokenId, uint120 tokenAmount) public pure returns (uint256 amountAndId)
```

_See {ISwapFactory-encodeAsset}._

### decodeAsset

```solidity
function decodeAsset(uint256 amountOrId) public pure returns (uint16 tokenType, uint256 tokenId, uint256 tokenAmount)
```

_See {ISwapFactory-decodeAsset}._

### encodeConfig

```solidity
function packData(address allowed, uint256 expiry) public pure returns (uint256)
function encodeConfig(address allowed, uint32 expiry, uint8 recipient, uint56 value) public pure returns (uint256)
```

_See {ISwapFactory-packData}._
_See {ISwapFactory-encodeConfig}._

### parseData
### decodeConfig

```solidity
function parseData(uint256 config) public pure returns (address, uint256)
function decodeConfig(uint256 config) public pure returns (address, uint32, uint8, uint56)
```

_See {ISwapFactory-parseData}._
_See {ISwapFactory-decodeConfig}._

47 changes: 33 additions & 14 deletions docs/solidity-docgen/Swaplace.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,39 @@

## Swaplace

_Swaplace is a Decentralized Feeless DEX. It has no owners, it cannot be stopped.
Its cern is to facilitate swaps between virtual assets following the ERC standard.
_Swaplace is a decentralized and feeless DEX/OTC. Ownerless, it cannot be stopped.
It's core is to facilitate swaps between virtual assets using the ERC standard.
Users can propose or accept swaps by allowing Swaplace to move their assets using the
`approve` or `permit` function._
`approve`, `permit` or similar functions._

### getSwap

```solidity
function getSwap(uint256 swapId) public view returns (struct ISwap.Swap)
```

_See {ISwaplace-getSwap}._

### totalSwaps

```solidity
function totalSwaps() public view returns (uint256)
```

_Getter function for _totalSwaps._

### createSwap

```solidity
function createSwap(struct ISwap.Swap swap) public returns (uint256)
function createSwap(struct ISwap.Swap swap) public payable returns (uint256)
```

_See {ISwaplace-createSwap}._

### acceptSwap

```solidity
function acceptSwap(uint256 swapId, address receiver) public returns (bool)
function acceptSwap(uint256 swapId, address receiver) public payable returns (bool)
```

_See {ISwaplace-acceptSwap}._
Expand All @@ -31,27 +47,30 @@ function cancelSwap(uint256 swapId) public

_See {ISwaplace-cancelSwap}._

### getSwap
### _payNativeEth

```solidity
function getSwap(uint256 swapId) public view returns (struct ISwap.Swap)
function _payNativeEth(address receiver, uint256 value) internal
```

_See {ISwaplace-getSwap}._
_Send an amount of native Ether to the receiver address._

### supportsInterface
### _transferFrom

```solidity
function supportsInterface(bytes4 interfaceID) external pure returns (bool)
function _transferFrom(address from, address to, struct ISwap.Asset[] assets) internal
```

_See {IERC165-supportsInterface}._
_Transfer multiple 'assets' from 'from' to 'to'.

### totalSwaps
`0x23b872dd` - Selector of the `transferFrom` function (ERC20, ERC721).
`0xf242432a` - Selector of the `safeTransferFrom` function (ERC1155)._

### supportsInterface

```solidity
function totalSwaps() public view returns (uint256)
function supportsInterface(bytes4 interfaceID) external pure returns (bool)
```

_Getter function for _totalSwaps._
_See {IERC165-supportsInterface}._

34 changes: 0 additions & 34 deletions docs/solidity-docgen/echidna/TestSwapFactory.md

This file was deleted.

34 changes: 0 additions & 34 deletions docs/solidity-docgen/echidna/TestSwaplace.md

This file was deleted.

25 changes: 14 additions & 11 deletions docs/solidity-docgen/interfaces/IErrors.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,32 @@ _Errors only interface for the {Swaplace} implementations._
### InvalidAddress

```solidity
error InvalidAddress(address caller)
error InvalidAddress()
```

_Displayed when the caller is not the owner of the swap._

### InvalidAssetsLength
### InvalidExpiry

```solidity
error InvalidAssetsLength()
error InvalidExpiry()
```

_Displayed when the amount of {ISwap-Asset} has a length of zero.
_Displayed when the `expiry` date is in the past._

NOTE: The `biding` or `asking` array must not be empty to avoid mistakes
when creating a swap. Assuming one side of the swap is empty, the
correct approach should be the usage of {transferFrom} and we reinforce
this behavior by requiring the length of the array to be bigger than zero._
### InvalidValue

### InvalidExpiry
```solidity
error InvalidValue()
```

_Displayed when the `msg.value` doesn't match the swap request._

### InvalidCall

```solidity
error InvalidExpiry(uint256 timestamp)
error InvalidCall()
```

_Displayed when the `expiry` date is in the past._
_Displayed when a low level call failed to execute._

Loading
Loading