From 9764e07b1bdee693fcc59e0af04f154a8b964335 Mon Sep 17 00:00:00 2001 From: Rafael Sanches Date: Thu, 6 Jun 2024 11:35:03 -0300 Subject: [PATCH] Updating docs with docgen-solidity --- docs/solidity-docgen/SwapFactory.md | 53 +++-- docs/solidity-docgen/Swaplace.md | 47 ++-- .../echidna/TestSwapFactory.md | 34 --- docs/solidity-docgen/echidna/TestSwaplace.md | 34 --- docs/solidity-docgen/interfaces/IErrors.md | 25 ++- .../interfaces/ISwapFactory.md | 124 +++++++++-- docs/solidity-docgen/interfaces/ISwaplace.md | 4 +- docs/solidity-docgen/interfaces/ITransfer.md | 18 -- docs/solidity-docgen/mock/ERC20/ERC20.md | 205 ------------------ .../mock/ERC20/interfaces/IERC20.md | 154 ------------- .../mock/ERC20/interfaces/IERC20Errors.md | 98 --------- .../mock/ERC20/interfaces/IERC20Permit.md | 69 ------ docs/solidity-docgen/mock/MockERC20.md | 15 -- docs/solidity-docgen/mock/MockERC721.md | 21 -- 14 files changed, 200 insertions(+), 701 deletions(-) delete mode 100644 docs/solidity-docgen/echidna/TestSwapFactory.md delete mode 100644 docs/solidity-docgen/echidna/TestSwaplace.md delete mode 100644 docs/solidity-docgen/interfaces/ITransfer.md delete mode 100644 docs/solidity-docgen/mock/ERC20/ERC20.md delete mode 100644 docs/solidity-docgen/mock/ERC20/interfaces/IERC20.md delete mode 100644 docs/solidity-docgen/mock/ERC20/interfaces/IERC20Errors.md delete mode 100644 docs/solidity-docgen/mock/ERC20/interfaces/IERC20Permit.md delete mode 100644 docs/solidity-docgen/mock/MockERC20.md delete mode 100644 docs/solidity-docgen/mock/MockERC721.md diff --git a/docs/solidity-docgen/SwapFactory.md b/docs/solidity-docgen/SwapFactory.md index 2560a6d..e26aff6 100644 --- a/docs/solidity-docgen/SwapFactory.md +++ b/docs/solidity-docgen/SwapFactory.md @@ -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 @@ -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}._ diff --git a/docs/solidity-docgen/Swaplace.md b/docs/solidity-docgen/Swaplace.md index 1a76ad9..5025de7 100644 --- a/docs/solidity-docgen/Swaplace.md +++ b/docs/solidity-docgen/Swaplace.md @@ -2,15 +2,31 @@ ## 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}._ @@ -18,7 +34,7 @@ _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}._ @@ -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}._ diff --git a/docs/solidity-docgen/echidna/TestSwapFactory.md b/docs/solidity-docgen/echidna/TestSwapFactory.md deleted file mode 100644 index 19a47e6..0000000 --- a/docs/solidity-docgen/echidna/TestSwapFactory.md +++ /dev/null @@ -1,34 +0,0 @@ -# Solidity API - -## TestFactory - -### has_values - -```solidity -function has_values() public -``` - -### make_asset_array - -```solidity -function make_asset_array(address addr, uint256 amountOrId) public pure returns (struct ISwap.Asset[]) -``` - -### make_valid_swap - -```solidity -function make_valid_swap(address owner, address addr, uint256 amountOrId) public view returns (struct ISwap.Swap) -``` - -### echidna_revert_invalid_expiry - -```solidity -function echidna_revert_invalid_expiry() public view -``` - -### echidna_revert_invalid_length - -```solidity -function echidna_revert_invalid_length() public view -``` - diff --git a/docs/solidity-docgen/echidna/TestSwaplace.md b/docs/solidity-docgen/echidna/TestSwaplace.md deleted file mode 100644 index 322734e..0000000 --- a/docs/solidity-docgen/echidna/TestSwaplace.md +++ /dev/null @@ -1,34 +0,0 @@ -# Solidity API - -## TestSwaplace - -### constructor - -```solidity -constructor() public -``` - -### echidna_create_swap - -```solidity -function echidna_create_swap() public returns (bool) -``` - -### echidna_accept_swap - -```solidity -function echidna_accept_swap() public returns (bool) -``` - -### echidna_id_overflow - -```solidity -function echidna_id_overflow() public view returns (bool) -``` - -### echidna_id_never_zero_after_init - -```solidity -function echidna_id_never_zero_after_init() public view returns (bool) -``` - diff --git a/docs/solidity-docgen/interfaces/IErrors.md b/docs/solidity-docgen/interfaces/IErrors.md index b30555a..4b1b1bc 100644 --- a/docs/solidity-docgen/interfaces/IErrors.md +++ b/docs/solidity-docgen/interfaces/IErrors.md @@ -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._ diff --git a/docs/solidity-docgen/interfaces/ISwapFactory.md b/docs/solidity-docgen/interfaces/ISwapFactory.md index e90f35e..076fe9a 100644 --- a/docs/solidity-docgen/interfaces/ISwapFactory.md +++ b/docs/solidity-docgen/interfaces/ISwapFactory.md @@ -10,37 +10,135 @@ _Interface of the {SwapFactory} implementation._ function makeAsset(address addr, uint256 amountOrId) external pure returns (struct ISwap.Asset) ``` -_Constructs an asset struct that works for ERC20 or ERC721. -This function is a utility to easily create an `Asset` struct on-chain or off-chain._ +_Make an {ISwap-Asset} struct to work with token standards._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| addr | address | is the address of the token asset. | +| amountOrId | uint256 | is the amount of tokens or the ID of the NFT. | + +### make1155Asset + +```solidity +function make1155Asset(address addr, uint120 tokenId, uint120 tokenAmount) external pure returns (struct ISwap.Asset) +``` + +_Make an {ISwap-Asset} struct to work with token standards. + +NOTE: Different from the {makeAsset} function, this function is used to +encode the token ID and token amount into a single uint256. This is made +to work with the ERC1155 standard._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| 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. | ### makeSwap ```solidity -function makeSwap(address owner, address allowed, uint256 expiry, struct ISwap.Asset[] assets, struct ISwap.Asset[] asking) external view returns (struct ISwap.Swap) +function makeSwap(address owner, address allowed, uint32 expiry, uint8 recipient, uint56 value, struct ISwap.Asset[] assets, struct ISwap.Asset[] asking) external view returns (struct ISwap.Swap) ``` _Build a swap struct to use in the {Swaplace-createSwap} function. Requirements: -- `expiry` cannot be in the past timestamp. -- `biding` and `asking` cannot be empty._ +- `expiry` cannot be in the past._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| 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[] | | -### packData +### encodeAsset ```solidity -function packData(address allowed, uint256 expiry) external pure returns (uint256) +function encodeAsset(uint120 tokenId, uint120 tokenAmount) external pure returns (uint256 amountAndId) ``` -_Packs `allowed` and the `expiry`. -This function returns the bitwise packing of `allowed` and `expiry` as a uint256._ +_Encode `tokenId` and `tokenAmount` into a single uint256 while adding a flag +to indicate that it's an ERC1155 token. + +NOTE: The flag is set to 0xFFFFFFFF._ + +#### Parameters -### parseData +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenId | uint120 | is the ID of the ERC1155 token. | +| tokenAmount | uint120 | is the amount of the ERC1155 token. | + +### decodeAsset ```solidity -function parseData(uint256 config) external pure returns (address, uint256) +function decodeAsset(uint256 amountAndId) external pure returns (uint16 tokenType, uint256 tokenId, uint256 tokenAmount) ``` -_Parsing the `config`. -This function returns the extracted values of `allowed` and `expiry`._ +_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. + +NOTE: If it's an ERC1155 token, then the next 120 bits are the token ID and the next +120 bits are the token amount. + +WARNING: Swaplace cannot handle ERC1155 tokens where the ID or the amount is greater +than 120 bits._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| amountAndId | uint256 | is the amount of tokens and the ID of the ERC1155 token. | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| 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. | + +### encodeConfig + +```solidity +function encodeConfig(address allowed, uint32 expiry, uint8 recipient, uint56 value) external pure returns (uint256 config) +``` + +_This function uses bitwise to return an encoded uint256 of the following parameters._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| 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. | + +### decodeConfig + +```solidity +function decodeConfig(uint256 config) external pure returns (address allowed, uint32 expiry, uint8 recipient, uint56 value) +``` + +_Decode `config` into their respective variables._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| config | uint256 | is the encoded uint256 configuration of the Swap. | diff --git a/docs/solidity-docgen/interfaces/ISwaplace.md b/docs/solidity-docgen/interfaces/ISwaplace.md index 04846c2..e2ee438 100644 --- a/docs/solidity-docgen/interfaces/ISwaplace.md +++ b/docs/solidity-docgen/interfaces/ISwaplace.md @@ -31,7 +31,7 @@ _Emitted when a Swap is canceled._ ### createSwap ```solidity -function createSwap(struct ISwap.Swap Swap) external returns (uint256) +function createSwap(struct ISwap.Swap Swap) external payable returns (uint256) ``` _Allow users to create a Swap. Each new Swap self-increments its ID by one. @@ -47,7 +47,7 @@ Emits a {SwapCreated} event._ ### acceptSwap ```solidity -function acceptSwap(uint256 swapId, address receiver) external returns (bool) +function acceptSwap(uint256 swapId, address receiver) external payable returns (bool) ``` _Accepts a Swap. Once the Swap is accepted, the expiry is set diff --git a/docs/solidity-docgen/interfaces/ITransfer.md b/docs/solidity-docgen/interfaces/ITransfer.md deleted file mode 100644 index b9e50de..0000000 --- a/docs/solidity-docgen/interfaces/ITransfer.md +++ /dev/null @@ -1,18 +0,0 @@ -# Solidity API - -## ITransfer - -_Generalized Interface for {IERC20} and {IERC721} `transferFrom` functions._ - -### transferFrom - -```solidity -function transferFrom(address from, address to, uint256 amountOrId) external -``` - -_See {IERC20-transferFrom} or {IERC721-transferFrom}. - -Moves an `amount` for ERC20 or `tokenId` for ERC721 from `from` to `to`. - -Emits a {Transfer} event._ - diff --git a/docs/solidity-docgen/mock/ERC20/ERC20.md b/docs/solidity-docgen/mock/ERC20/ERC20.md deleted file mode 100644 index 1075c96..0000000 --- a/docs/solidity-docgen/mock/ERC20/ERC20.md +++ /dev/null @@ -1,205 +0,0 @@ -# Solidity API - -## ERC20 - -_Lightweight ERC20 with Permit extension._ - -### constructor - -```solidity -constructor(string name_, string symbol_) internal -``` - -_Sets the values for {name} and {symbol}._ - -### name - -```solidity -function name() public view virtual returns (string) -``` - -_Returns the name of the token._ - -### symbol - -```solidity -function symbol() public view virtual returns (string) -``` - -_Returns the symbol of the token, usually a shorter version of the -name._ - -### decimals - -```solidity -function decimals() public view virtual returns (uint8) -``` - -_Returns the number of decimals used to get its user representation. -For example, if `decimals` equals `2`, a balance of `505` tokens should -be displayed to a user as `5.05` (`505 / 10 ** 2`). - -Tokens usually opt for a value of 18, imitating the relationship between -Ether and Wei. This is the default value returned by this function, unless -it's overridden. - -NOTE: This information is only used for _display_ purposes: it in -no way affects any of the arithmetic of the contract, including -{IERC20-balanceOf} and {IERC20-transfer}._ - -### totalSupply - -```solidity -function totalSupply() public view virtual returns (uint256) -``` - -_See {IERC20-totalSupply}._ - -### balanceOf - -```solidity -function balanceOf(address account) public view virtual returns (uint256) -``` - -_See {IERC20-balanceOf}._ - -### allowance - -```solidity -function allowance(address owner, address spender) public view virtual returns (uint256) -``` - -_See {IERC20-allowance}._ - -### nonces - -```solidity -function nonces(address owner) public view virtual returns (uint256) -``` - -_Returns the current nonce of an address._ - -### DOMAIN_SEPARATOR - -```solidity -function DOMAIN_SEPARATOR() public view virtual returns (bytes32) -``` - -_See {IERC20Permit-DOMAIN_SEPARATOR}._ - -### approve - -```solidity -function approve(address spender, uint256 value) public virtual returns (bool) -``` - -_See {IERC20-approve}. - -NOTE: If `value` is the maximum `uint256`, the allowance is not updated on -`transferFrom`. This is semantically equivalent to an infinite approval._ - -### increaseAllowance - -```solidity -function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) -``` - -_See {IERC20-increaseAllowance}._ - -### decreaseAllowance - -```solidity -function decreaseAllowance(address spender, uint256 requestedDecrease) public virtual returns (bool) -``` - -_See {IERC20-decreaseAllowance}. - -Requirements: - -- `spender` must have allowance for the caller of at least -`requestedDecrease`._ - -### permit - -```solidity -function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public virtual returns (bool) -``` - -_See {IERC20Permit-permit}. - -Requirements: - -- `spender` cannot be the zero address. -- `deadline` must be a timestamp in the future. -- `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` -over the EIP712-formatted function arguments. -- the signature must use ``owner``'s current nonce (see {IERC20Permit-nonces})._ - -### _mint - -```solidity -function _mint(address to, uint256 value) internal -``` - -_Creates an `value` of tokens and assigns them to `to` by creating supply. - -Emits a {Transfer} event with `from` set to the zero address._ - -### _burn - -```solidity -function _burn(address from, uint256 value) internal -``` - -_Destroys an `value` of tokens from `from` by lowering the total supply. - -Requirements: - -- `from` must have a balance of at least `value`. - -Emits a {Transfer} event with `to` set to the zero address._ - -### transfer - -```solidity -function transfer(address to, uint256 value) public virtual returns (bool) -``` - -_See {IERC20-transfer}. - -Requirements: - -- the caller must have a balance of at least `value`._ - -### transferFrom - -```solidity -function transferFrom(address from, address to, uint256 value) public virtual returns (bool) -``` - -_See {IERC20-transferFrom}. - -Requirements: - -- `from` must have a balance of at least `value`. -- the caller must have allowance for `from`'s tokens of at least -`value`. - -NOTE: Does not update the allowance if the current allowance -is the maximum `uint256`._ - -### permitTransfer - -```solidity -function permitTransfer(address from, address to, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public virtual returns (bool) -``` - -_See {IERC20Permit-permitTransfer}. - -Requirements: - -- `deadline` must be a timestamp in the future. -- `v`, `r` and `s` must be a valid `secp256k1` signature from `from` -over the EIP712-formatted function arguments. -- the signature must use `from`'s current nonce (see {IERC20Permit-nonces})._ - diff --git a/docs/solidity-docgen/mock/ERC20/interfaces/IERC20.md b/docs/solidity-docgen/mock/ERC20/interfaces/IERC20.md deleted file mode 100644 index d5bf51b..0000000 --- a/docs/solidity-docgen/mock/ERC20/interfaces/IERC20.md +++ /dev/null @@ -1,154 +0,0 @@ -# Solidity API - -## IERC20 - -_Interface of the ERC20 standard as defined in the EIP._ - -### Approval - -```solidity -event Approval(address owner, address 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._ - -### Transfer - -```solidity -event Transfer(address from, address to, uint256 value) -``` - -_Emitted when `value` tokens are moved from `from` to `to`. - -NOTE: `value` can be zero._ - -### name - -```solidity -function name() external view returns (string) -``` - -_Returns the name of the token._ - -### symbol - -```solidity -function symbol() external view returns (string) -``` - -_Returns the symbol of the token._ - -### decimals - -```solidity -function decimals() external view returns (uint8) -``` - -_Returns the decimals places of the token._ - -### totalSupply - -```solidity -function totalSupply() external view returns (uint256) -``` - -_Returns the value of tokens in existence._ - -### balanceOf - -```solidity -function balanceOf(address account) external view returns (uint256) -``` - -_Returns the value of tokens owned by `account`._ - -### 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. - -NOTE: If `value` is the maximum `uint256`, the allowance is not updated on -`transferFrom`. This is semantically equivalent to an infinite approval._ - -### approve - -```solidity -function approve(address spender, uint256 value) external 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._ - -### increaseAllowance - -```solidity -function increaseAllowance(address spender, uint256 addedValue) external returns (bool) -``` - -_Atomically increases the allowance granted to `spender` by the caller. - -This is an alternative to {approve} that can be used as a mitigation for -problems described in {IERC20-approve}. - -Emits an {IERC20-Approval} event indicating the updated allowance._ - -### decreaseAllowance - -```solidity -function decreaseAllowance(address spender, uint256 requestedDecrease) external returns (bool) -``` - -_Atomically decreases the allowance granted to `spender` by the caller. - -This is an alternative to {approve} that can be used as a mitigation for -problems described in {IERC20-approve}. - -Emits an {Approval} event indicating the updated allowance. - -NOTE: Although this function is designed to avoid double spending with {approval}, -it can still be frontrunned, preventing any attempt of allowance reduction._ - -### transfer - -```solidity -function transfer(address to, uint256 value) external 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._ - -### transferFrom - -```solidity -function transferFrom(address from, address to, uint256 value) external 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._ - diff --git a/docs/solidity-docgen/mock/ERC20/interfaces/IERC20Errors.md b/docs/solidity-docgen/mock/ERC20/interfaces/IERC20Errors.md deleted file mode 100644 index b0f5ae6..0000000 --- a/docs/solidity-docgen/mock/ERC20/interfaces/IERC20Errors.md +++ /dev/null @@ -1,98 +0,0 @@ -# Solidity API - -## IERC20Errors - -_Standard ERC20 Errors_ - -### ERC20InsufficientBalance - -```solidity -error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed) -``` - -_Indicates an error related to the current `balance` of a `sender`. Used in transfers._ - -#### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| sender | address | Address whose tokens are being transferred. | -| balance | uint256 | Current balance for the interacting account. | -| needed | uint256 | Minimum amount required to perform a transfer. | - -### ERC20InsufficientAllowance - -```solidity -error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed) -``` - -_Indicates a failure with the `spender`’s `allowance`. Used in transfers._ - -#### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| spender | address | Address that may be allowed to operate on tokens without being their owner. | -| allowance | uint256 | Amount of tokens a `spender` is allowed to operate with. | -| needed | uint256 | Minimum amount required to perform a transfer. | - -### ERC20FailedDecreaseAllowance - -```solidity -error ERC20FailedDecreaseAllowance(address spender, uint256 allowance, uint256 needed) -``` - -_Indicates a failed `decreaseAllowance` request._ - -#### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| spender | address | Address that may be allowed to operate on tokens without being their owner. | -| allowance | uint256 | Amount of tokens a `spender` want to operate with. | -| needed | uint256 | Amount required to decrease the allowance. | - -### ERC20PermitInvalidNonce - -```solidity -error ERC20PermitInvalidNonce(address account, uint256 nonce) -``` - -_Indicates the nonce used for an `account` is not the expected current nonce._ - -#### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| account | address | Address whose nonce is being checked. | -| nonce | uint256 | Expected nonce for the given `account`. | - -### ERC2612ExpiredSignature - -```solidity -error ERC2612ExpiredSignature(uint256 deadline) -``` - -_Indicates the expiration of a permit to be used._ - -#### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| deadline | uint256 | Expiration time limit in seconds. | - -### ERC2612InvalidSigner - -```solidity -error ERC2612InvalidSigner(address signer, address owner) -``` - -_Indicates the mismatched owner when validating the signature._ - -#### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| signer | address | Address of the signer recovered. | -| owner | address | Address of the owner expected to match `signer`. | - diff --git a/docs/solidity-docgen/mock/ERC20/interfaces/IERC20Permit.md b/docs/solidity-docgen/mock/ERC20/interfaces/IERC20Permit.md deleted file mode 100644 index bf13c88..0000000 --- a/docs/solidity-docgen/mock/ERC20/interfaces/IERC20Permit.md +++ /dev/null @@ -1,69 +0,0 @@ -# Solidity API - -## IERC20Permit - -_Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in -https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. - -Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by -presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't -need to send a transaction, and thus is not required to hold Ether at all._ - -### nonces - -```solidity -function nonces(address owner) external view returns (uint256) -``` - -_Returns the current nonce for `owner`. This value must be -included whenever a signature is generated for {permit}. - -Every successful call to {permit} increases `owner`'s nonce by one. -This prevents a signature from being used multiple times._ - -### DOMAIN_SEPARATOR - -```solidity -function DOMAIN_SEPARATOR() external view returns (bytes32) -``` - -_Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}._ - -### permit - -```solidity -function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external returns (bool) -``` - -_Sets `value` as the allowance of `spender` over `owner`'s tokens, -given `owner`'s signed approval. - -IMPORTANT: The same issues {IERC20-approve} has related to transaction -ordering also apply here. - -Emits an {IERC20-Approval} event. - -NOTE: `spender` can be the zero address. Checking this on-chain is a bad -usage of gas. For more information on the signature format, see the -https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIPsection]._ - -### permitTransfer - -```solidity -function permitTransfer(address from, address to, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external returns (bool) -``` - -_Allows {IERC20-transferFrom} to be used with the `owner`'s signature. -Similar to permit but changing the scope to handle the balance instead of -allowance. - -Requires less gas than regular {permit} and {IERC20-transferFrom}. - -IMPORTANT: `owner` works as `from` and `spender` as `to` (see {IERC20Permit-permit}). - -Emits an {IERC20-Transfer} event. - -NOTE: Realize that {PERMIT_TYPEHASH} is different from the one in {permit}. -This is because the arguments name differ. But won't result in a different -output as long as it is encoded following the EIP712 and ERC20Permit specs._ - diff --git a/docs/solidity-docgen/mock/MockERC20.md b/docs/solidity-docgen/mock/MockERC20.md deleted file mode 100644 index 3a8e0f6..0000000 --- a/docs/solidity-docgen/mock/MockERC20.md +++ /dev/null @@ -1,15 +0,0 @@ -# Solidity API - -## MockERC20 - -### constructor - -```solidity -constructor() public -``` - -### mint - -```solidity -function mint(address to, uint256 amount) public -``` diff --git a/docs/solidity-docgen/mock/MockERC721.md b/docs/solidity-docgen/mock/MockERC721.md deleted file mode 100644 index 3e7f2de..0000000 --- a/docs/solidity-docgen/mock/MockERC721.md +++ /dev/null @@ -1,21 +0,0 @@ -# Solidity API - -## MockERC721 - -### totalSupply - -```solidity -uint256 totalSupply -``` - -### constructor - -```solidity -constructor() public -``` - -### mint - -```solidity -function mint(address to, uint256 id) public -```