From f3f5dce1cd98190c35e1c6332e3df3cb43014b12 Mon Sep 17 00:00:00 2001 From: Rafael Sanches Date: Wed, 5 Jun 2024 15:58:15 -0300 Subject: [PATCH] first commit doc-gen generated files --- docs-docgen/CODE_OF_CONDUCT.md | 127 +++++++++++ docs-docgen/CONTRIBUTING.md | 76 +++++++ docs-docgen/SECURITY.md | 36 +++ docs-docgen/solidity-docgen/SwapFactory.md | 62 ++++++ docs-docgen/solidity-docgen/Swaplace.md | 57 +++++ .../echidna/TestSwapFactory.md | 34 +++ .../solidity-docgen/echidna/TestSwaplace.md | 34 +++ .../solidity-docgen/interfaces/IERC165.md | 25 +++ .../solidity-docgen/interfaces/IErrors.md | 35 +++ .../solidity-docgen/interfaces/ISwap.md | 26 +++ .../interfaces/ISwapFactory.md | 46 ++++ .../solidity-docgen/interfaces/ISwaplace.md | 97 +++++++++ .../solidity-docgen/interfaces/ITransfer.md | 18 ++ .../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-docgen/solidity-docgen/mock/MockERC20.md | 16 ++ .../solidity-docgen/mock/MockERC721.md | 22 ++ 19 files changed, 1237 insertions(+) create mode 100644 docs-docgen/CODE_OF_CONDUCT.md create mode 100644 docs-docgen/CONTRIBUTING.md create mode 100644 docs-docgen/SECURITY.md create mode 100644 docs-docgen/solidity-docgen/SwapFactory.md create mode 100644 docs-docgen/solidity-docgen/Swaplace.md create mode 100644 docs-docgen/solidity-docgen/echidna/TestSwapFactory.md create mode 100644 docs-docgen/solidity-docgen/echidna/TestSwaplace.md create mode 100644 docs-docgen/solidity-docgen/interfaces/IERC165.md create mode 100644 docs-docgen/solidity-docgen/interfaces/IErrors.md create mode 100644 docs-docgen/solidity-docgen/interfaces/ISwap.md create mode 100644 docs-docgen/solidity-docgen/interfaces/ISwapFactory.md create mode 100644 docs-docgen/solidity-docgen/interfaces/ISwaplace.md create mode 100644 docs-docgen/solidity-docgen/interfaces/ITransfer.md create mode 100644 docs-docgen/solidity-docgen/mock/ERC20/ERC20.md create mode 100644 docs-docgen/solidity-docgen/mock/ERC20/interfaces/IERC20.md create mode 100644 docs-docgen/solidity-docgen/mock/ERC20/interfaces/IERC20Errors.md create mode 100644 docs-docgen/solidity-docgen/mock/ERC20/interfaces/IERC20Permit.md create mode 100644 docs-docgen/solidity-docgen/mock/MockERC20.md create mode 100644 docs-docgen/solidity-docgen/mock/MockERC721.md diff --git a/docs-docgen/CODE_OF_CONDUCT.md b/docs-docgen/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..13c8929 --- /dev/null +++ b/docs-docgen/CODE_OF_CONDUCT.md @@ -0,0 +1,127 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +[Discord](https://discord.gg/B6uDmm7hvC) ``SUPPORT/open-a-ticket channel``. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. diff --git a/docs-docgen/CONTRIBUTING.md b/docs-docgen/CONTRIBUTING.md new file mode 100644 index 0000000..72318c7 --- /dev/null +++ b/docs-docgen/CONTRIBUTING.md @@ -0,0 +1,76 @@ +# Contribution Guidelines + +Thank you for your interest in contributing to Swaplace! The project is an open-source build by the community. We welcome any type of contribution, suggestion or improvement, no matter how small. + +### Contents + +- [Open Source Guideline](#how-to-contribute) +- [Opening an Issue](#opening-issue) +- [Writing Commit Messages](#writing-commit-messages) +- [Submitting Pull Requests](#submiting-pull-requests) +- [Code Review](#code-review) +- [Coding Style](#coding-style) +- [Get in touch](#get-in-touch) + +## How to Contribute + +There are many ways to contribute, but here are a few steps to start: + +1. Fork the repository in GitHub. +2. Check if you have any issue, suggestion or improvement to work on. + + - We manage all the issues using [GitHub Projects](https://github.com/orgs/blockful-io/projects/3) + +3. Send a message in the issue like + `I'm interested in this issue` or ask for more information such as `Hey, can you provide more information about this ... ?` The mantainers will then assign or provide more context about your issue. **After that, you are asigned to the issue.** + +4. If a task is already assigned but you believe you can expedite the process, feel free to comment, requesting to assist or speed up the task. Additionally, you may open a pull request directly because we prioritize both code efficiency and delivery speed. Thus, we encourage multiple individuals to review the same issues and debate together to enhance the code's security. + +### Congratulations ! You can now start working on the issue, and everyone is aware that you are assigned. + +## Opening An Issue + +Before opening an issue, please check if there is any issue already open. If there is, feel free to comment or suggest more details. We are always open to feedback and receptive to suggestions! + +- Before [creating an issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/creating-an-issue#creating-an-issue-from-a-project), check if your fork is updated. + +## Writing Commit Messages + +We are using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) + +Some examples below: + +- feat: adds or remove a new feature +- fix: fixes a bug +- refactor: rewrite/restructure your code +- chore: changes to the build process or auxiliary tools and libraries such as documentation generation +- style: changes do not affect the meaning (white-space, formatting, missing semi-colons, etc) +- test: add missing tests or correcting existing tests +- docs: affect documentation only + +## Submiting Pull Requests + +You can resolve an issue and after that submit a pull request fixing an issue and remember to [reference that issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword#linking-a-pull-request-to-an-issue-using-a-keyword). When submitting a PR, put the code below with the number of the issue you are closing +`Example: closes #1` + +## Code Review + +The maintainers will review your PR. If something is missing or a fix needs to be made, the maintainers will let you know in the PR comment. + +## Coding Style + +In Swaplace please use this .prettierrc.yml configuration to make the code standardized. + +``` +{ + trailingComma: "all" + singleQuote: false + printWidth: 80 + tabWidth: 2 + semi: true +} +``` + +## Get in Touch + +If you need to get in contact with the repository maintainers, please reach out in our [Discord](https://discord.gg/B6uDmm7hvC). diff --git a/docs-docgen/SECURITY.md b/docs-docgen/SECURITY.md new file mode 100644 index 0000000..92b01c0 --- /dev/null +++ b/docs-docgen/SECURITY.md @@ -0,0 +1,36 @@ +# Security Policy + +If you believe you have found a security vulnerability in the repository, please report it to us through coordinated disclosure. + +Please do not report security vulnerabilities through public **GitHub issues, discussions, or pull requests.** + +Instead, please open a ticket in ``SUPPORT/open-a-ticket channel`` on [Discord](https://discord.gg/B6uDmm7hvC). + + +## Supported Versions + + +| Version | Supported | +| ------- | ------------------ | +| 1.0.x | :x: | + +## Reporting a Vulnerability + +Please include as much of the information listed below as you can to help us better understand and resolve the issue: + +A full description of the issue. +The steps we will be taking to remedy the issue. +The patch(es), if any, that will be applied to contract. +The type of issue or type of vulnerability. +Full paths of source file(s) related to the manifestation of the issue +The location of the affected source code (tag/branch/commit or direct URL) +Any special configuration required to reproduce the issue +Step-by-step instructions to reproduce the issue +Proof-of-concept or exploit code (if possible) +Impact of the issue, including how an attacker might exploit the issue + +Tell them where to go, how often they can expect to get an update on a +reported vulnerability, what to expect if the vulnerability is accepted or +declined, etc. + +Please reach out to us ! Your contribution makes all the difference. diff --git a/docs-docgen/solidity-docgen/SwapFactory.md b/docs-docgen/solidity-docgen/SwapFactory.md new file mode 100644 index 0000000..2560a6d --- /dev/null +++ b/docs-docgen/solidity-docgen/SwapFactory.md @@ -0,0 +1,62 @@ +# Solidity API + +## 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 `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 `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._ + +### makeAsset + +```solidity +function makeAsset(address addr, uint256 amountOrId) public pure virtual returns (struct ISwap.Asset) +``` + +_See {ISwapFactory-makeAsset}._ + +### 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) +``` + +_See {ISwapFactory-makeSwap}._ + +### packData + +```solidity +function packData(address allowed, uint256 expiry) public pure returns (uint256) +``` + +_See {ISwapFactory-packData}._ + +### parseData + +```solidity +function parseData(uint256 config) public pure returns (address, uint256) +``` + +_See {ISwapFactory-parseData}._ + diff --git a/docs-docgen/solidity-docgen/Swaplace.md b/docs-docgen/solidity-docgen/Swaplace.md new file mode 100644 index 0000000..1a76ad9 --- /dev/null +++ b/docs-docgen/solidity-docgen/Swaplace.md @@ -0,0 +1,57 @@ +# Solidity API + +## 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. +Users can propose or accept swaps by allowing Swaplace to move their assets using the +`approve` or `permit` function._ + +### createSwap + +```solidity +function createSwap(struct ISwap.Swap swap) public returns (uint256) +``` + +_See {ISwaplace-createSwap}._ + +### acceptSwap + +```solidity +function acceptSwap(uint256 swapId, address receiver) public returns (bool) +``` + +_See {ISwaplace-acceptSwap}._ + +### cancelSwap + +```solidity +function cancelSwap(uint256 swapId) public +``` + +_See {ISwaplace-cancelSwap}._ + +### getSwap + +```solidity +function getSwap(uint256 swapId) public view returns (struct ISwap.Swap) +``` + +_See {ISwaplace-getSwap}._ + +### supportsInterface + +```solidity +function supportsInterface(bytes4 interfaceID) external pure returns (bool) +``` + +_See {IERC165-supportsInterface}._ + +### totalSwaps + +```solidity +function totalSwaps() public view returns (uint256) +``` + +_Getter function for _totalSwaps._ + diff --git a/docs-docgen/solidity-docgen/echidna/TestSwapFactory.md b/docs-docgen/solidity-docgen/echidna/TestSwapFactory.md new file mode 100644 index 0000000..19a47e6 --- /dev/null +++ b/docs-docgen/solidity-docgen/echidna/TestSwapFactory.md @@ -0,0 +1,34 @@ +# 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-docgen/solidity-docgen/echidna/TestSwaplace.md b/docs-docgen/solidity-docgen/echidna/TestSwaplace.md new file mode 100644 index 0000000..322734e --- /dev/null +++ b/docs-docgen/solidity-docgen/echidna/TestSwaplace.md @@ -0,0 +1,34 @@ +# 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-docgen/solidity-docgen/interfaces/IERC165.md b/docs-docgen/solidity-docgen/interfaces/IERC165.md new file mode 100644 index 0000000..eb67eeb --- /dev/null +++ b/docs-docgen/solidity-docgen/interfaces/IERC165.md @@ -0,0 +1,25 @@ +# Solidity API + +## IERC165 + +_Interface of the ERC165 standard, as defined in the +https://eips.ethereum.org/EIPS/eip-165[EIP]. + +Implementers can declare support of contract interfaces, which can then be +queried by others ({ERC165Checker}). + +For an implementation, see {ERC165}._ + +### supportsInterface + +```solidity +function supportsInterface(bytes4 interfaceId) external view returns (bool) +``` + +_Returns true if this contract implements the interface defined by +`interfaceId`. See the corresponding +https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] +to learn more about how these ids are created. + +This function call must use less than 30 000 gas._ + diff --git a/docs-docgen/solidity-docgen/interfaces/IErrors.md b/docs-docgen/solidity-docgen/interfaces/IErrors.md new file mode 100644 index 0000000..b30555a --- /dev/null +++ b/docs-docgen/solidity-docgen/interfaces/IErrors.md @@ -0,0 +1,35 @@ +# Solidity API + +## IErrors + +_Errors only interface for the {Swaplace} implementations._ + +### InvalidAddress + +```solidity +error InvalidAddress(address caller) +``` + +_Displayed when the caller is not the owner of the swap._ + +### InvalidAssetsLength + +```solidity +error InvalidAssetsLength() +``` + +_Displayed when the amount of {ISwap-Asset} has a length of zero. + +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._ + +### InvalidExpiry + +```solidity +error InvalidExpiry(uint256 timestamp) +``` + +_Displayed when the `expiry` date is in the past._ + diff --git a/docs-docgen/solidity-docgen/interfaces/ISwap.md b/docs-docgen/solidity-docgen/interfaces/ISwap.md new file mode 100644 index 0000000..0209bb6 --- /dev/null +++ b/docs-docgen/solidity-docgen/interfaces/ISwap.md @@ -0,0 +1,26 @@ +# Solidity API + +## ISwap + +_Interface for the Swap Struct, used in the {Swaplace} implementation._ + +### Asset + +```solidity +struct Asset { + address addr; + uint256 amountOrId; +} +``` + +### Swap + +```solidity +struct Swap { + address owner; + uint256 config; + struct ISwap.Asset[] biding; + struct ISwap.Asset[] asking; +} +``` + diff --git a/docs-docgen/solidity-docgen/interfaces/ISwapFactory.md b/docs-docgen/solidity-docgen/interfaces/ISwapFactory.md new file mode 100644 index 0000000..e90f35e --- /dev/null +++ b/docs-docgen/solidity-docgen/interfaces/ISwapFactory.md @@ -0,0 +1,46 @@ +# Solidity API + +## ISwapFactory + +_Interface of the {SwapFactory} implementation._ + +### makeAsset + +```solidity +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._ + +### makeSwap + +```solidity +function makeSwap(address owner, address allowed, uint256 expiry, 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._ + +### packData + +```solidity +function packData(address allowed, uint256 expiry) external pure returns (uint256) +``` + +_Packs `allowed` and the `expiry`. +This function returns the bitwise packing of `allowed` and `expiry` as a uint256._ + +### parseData + +```solidity +function parseData(uint256 config) external pure returns (address, uint256) +``` + +_Parsing the `config`. +This function returns the extracted values of `allowed` and `expiry`._ + diff --git a/docs-docgen/solidity-docgen/interfaces/ISwaplace.md b/docs-docgen/solidity-docgen/interfaces/ISwaplace.md new file mode 100644 index 0000000..04846c2 --- /dev/null +++ b/docs-docgen/solidity-docgen/interfaces/ISwaplace.md @@ -0,0 +1,97 @@ +# Solidity API + +## ISwaplace + +_Interface of the {Swaplace} implementation._ + +### SwapCreated + +```solidity +event SwapCreated(uint256 swapId, address owner, address allowed) +``` + +_Emitted when a new Swap is created._ + +### SwapAccepted + +```solidity +event SwapAccepted(uint256 swapId, address owner, address allowed) +``` + +_Emitted when a Swap is accepted._ + +### SwapCanceled + +```solidity +event SwapCanceled(uint256 swapId, address owner) +``` + +_Emitted when a Swap is canceled._ + +### createSwap + +```solidity +function createSwap(struct ISwap.Swap Swap) external returns (uint256) +``` + +_Allow users to create a Swap. Each new Swap self-increments its ID by one. + +Requirements: + +- `owner` must be the caller address. +- `expiry` should be bigger than timestamp. +- `biding` and `asking` must not be empty. + +Emits a {SwapCreated} event._ + +### acceptSwap + +```solidity +function acceptSwap(uint256 swapId, address receiver) external returns (bool) +``` + +_Accepts a Swap. Once the Swap is accepted, the expiry is set +to zero to avoid reutilization. + +Requirements: + +- `allowed` must be the zero address or match the caller address. +- `expiry` must be bigger than timestamp. +- `biding` assets must be allowed to transfer. +- `asking` assets must be allowed to transfer. + +Emits a {SwapAccepted} event. + +NOTE: The expiry is set to 0, because if the Swap is expired it +will revert, preventing reentrancy attacks._ + +### cancelSwap + +```solidity +function cancelSwap(uint256 swapId) external +``` + +_Cancels an active Swap by setting the expiry to zero. + +Expiry with 0 seconds means that the Swap doesn't exist +or is already canceled. + +Requirements: + +- `owner` must be the caller adress. +- `expiry` must be bigger than timestamp. + +Emits a {SwapCanceled} event._ + +### getSwap + +```solidity +function getSwap(uint256 swapId) external view returns (struct ISwap.Swap) +``` + +_Retrieves the details of a Swap based on the `swapId` provided. + +NOTE: If the Swaps doesn't exist, the values will be defaulted to 0. +You can check if a Swap exists by checking if the `owner` is the zero address. +If the `owner` is the zero address, then the Swap doesn't exist._ + diff --git a/docs-docgen/solidity-docgen/interfaces/ITransfer.md b/docs-docgen/solidity-docgen/interfaces/ITransfer.md new file mode 100644 index 0000000..b9e50de --- /dev/null +++ b/docs-docgen/solidity-docgen/interfaces/ITransfer.md @@ -0,0 +1,18 @@ +# 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-docgen/solidity-docgen/mock/ERC20/ERC20.md b/docs-docgen/solidity-docgen/mock/ERC20/ERC20.md new file mode 100644 index 0000000..1075c96 --- /dev/null +++ b/docs-docgen/solidity-docgen/mock/ERC20/ERC20.md @@ -0,0 +1,205 @@ +# 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-docgen/solidity-docgen/mock/ERC20/interfaces/IERC20.md b/docs-docgen/solidity-docgen/mock/ERC20/interfaces/IERC20.md new file mode 100644 index 0000000..d5bf51b --- /dev/null +++ b/docs-docgen/solidity-docgen/mock/ERC20/interfaces/IERC20.md @@ -0,0 +1,154 @@ +# 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-docgen/solidity-docgen/mock/ERC20/interfaces/IERC20Errors.md b/docs-docgen/solidity-docgen/mock/ERC20/interfaces/IERC20Errors.md new file mode 100644 index 0000000..b0f5ae6 --- /dev/null +++ b/docs-docgen/solidity-docgen/mock/ERC20/interfaces/IERC20Errors.md @@ -0,0 +1,98 @@ +# 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-docgen/solidity-docgen/mock/ERC20/interfaces/IERC20Permit.md b/docs-docgen/solidity-docgen/mock/ERC20/interfaces/IERC20Permit.md new file mode 100644 index 0000000..bf13c88 --- /dev/null +++ b/docs-docgen/solidity-docgen/mock/ERC20/interfaces/IERC20Permit.md @@ -0,0 +1,69 @@ +# 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-docgen/solidity-docgen/mock/MockERC20.md b/docs-docgen/solidity-docgen/mock/MockERC20.md new file mode 100644 index 0000000..c9e73d2 --- /dev/null +++ b/docs-docgen/solidity-docgen/mock/MockERC20.md @@ -0,0 +1,16 @@ +# Solidity API + +## MockERC20 + +### constructor + +```solidity +constructor() public +``` + +### mint + +```solidity +function mint(address to, uint256 amount) public +``` + diff --git a/docs-docgen/solidity-docgen/mock/MockERC721.md b/docs-docgen/solidity-docgen/mock/MockERC721.md new file mode 100644 index 0000000..411c4d3 --- /dev/null +++ b/docs-docgen/solidity-docgen/mock/MockERC721.md @@ -0,0 +1,22 @@ +# Solidity API + +## MockERC721 + +### totalSupply + +```solidity +uint256 totalSupply +``` + +### constructor + +```solidity +constructor() public +``` + +### mint + +```solidity +function mint(address to, uint256 id) public +``` +