niftyswap

所属分类:以太坊
开发工具:TypeScript
文件大小:517KB
下载次数:0
上传日期:2023-05-07 22:46:26
上 传 者sh-1993
说明:  Niftyswap-ERC-1155代币的去中心化交换协议,灵感来自Uniswap
(Niftyswap - decentralized swap protocol for ERC-1155 tokens, inspired by Uniswap)

文件列表:
.eslintignore (21, 2023-04-06)
.eslintrc.js (401, 2023-04-06)
.prettierrc (154, 2023-04-06)
.solhint.json (778, 2023-04-06)
LICENSE (12051, 2023-04-06)
SPECIFICATIONS.md (35526, 2023-04-06)
audits (0, 2023-04-06)
audits\Security_Audit_Nitfyswap_Horizon_Games_1.pdf (108947, 2023-04-06)
audits\consensys-diligence-audit-2020-02.pdf (180850, 2023-04-06)
below_size_limit.js (1668, 2023-04-06)
foundry.toml (120, 2023-04-06)
hardhat.config.ts (818, 2023-04-06)
lib (0, 2023-04-06)
lib\forge-std (0, 2023-04-06)
package.json (3214, 2023-04-06)
remappings.txt (241, 2023-04-06)
src (0, 2023-04-06)
src\.npmignore (56, 2023-04-06)
src\contracts (0, 2023-04-06)
src\contracts\exchange (0, 2023-04-06)
src\contracts\exchange\NiftyswapExchange.sol (39535, 2023-04-06)
src\contracts\exchange\NiftyswapExchange20.sol (50057, 2023-04-06)
src\contracts\exchange\NiftyswapFactory.sol (1434, 2023-04-06)
src\contracts\exchange\NiftyswapFactory20.sol (3435, 2023-04-06)
src\contracts\interfaces (0, 2023-04-06)
src\contracts\interfaces\IDelegatedERC1155Metadata.sol (197, 2023-04-06)
src\contracts\interfaces\IERC1155Metadata.sol (461, 2023-04-06)
src\contracts\interfaces\IERC2981.sol (802, 2023-04-06)
src\contracts\interfaces\INiftyswapExchange.sol (7169, 2023-04-06)
src\contracts\interfaces\INiftyswapExchange20.sol (11270, 2023-04-06)
... ...

Niftyswap ========= Niftyswap is a decentralized token swap protocol for ERC-1155 tokens on Ethereum. In other words, Niftyswap is Uniswap for ERC-1155 tokens. [For detailed documentation on the Niftyswap Protocol and how to use it, please read the SPECIFICATION.](https://github.com/0xsequence/niftyswap/blob/master/./SPECIFICATIONS.md) *We are incredibly thankful for the work done by the Uniswap team, without which Niftyswap wouldn't exists.* ## Description Niftyswap is an implementation of [Uniswap](https://github.com/0xsequence/niftyswap/blob/master/), a protocol for automated token exchange on Ethereum. While Uniswap is for trading [ERC-20](https://github.com/0xsequence/niftyswap/blob/master/) tokens, Niftyswap is a protocol for [ERC-1155](https://github.com/0xsequence/niftyswap/blob/master/) tokens. Both are designed to favor ease of use and provide guaranteed access to liquidity on-chain. Most exchanges maintain an order book and facilitate matches between buyers and sellers. Niftyswap smart contracts hold liquidity reserves of various tokens, and trades are executed directly against these reserves. Prices are set automatically using the [constant product](https://github.com/0xsequence/niftyswap/blob/master/https://ethresear.ch/t/improving-front-running-resistance-of-x-y-k-market-makers/1281) $x*y = K$ market maker mechanism, which keeps overall reserves in relative equilibrium. Reserves are pooled between a network of liquidity providers who supply the system with tokens in exchange for a proportional share of transaction fees. An important feature of Niftyswap is the utilization of a factory/registry contract that deploys a separate exchange contract for each ERC-1155 token contract. These exchange contracts each hold independent reserves of a single fungible ERC-1155 currency and their associated ERC-1155 token id. This allows trades between the [Currency](https://github.com/0xsequence/niftyswap/blob/master/#currency) and the ERC-1155 tokens based on the relative supplies. For more details, see [Specification](https://github.com/0xsequence/niftyswap/blob/master/https://github.com/0xsequence/niftyswap/blob/master/SPECIFICATIONS.md) ## Getting started ### Install `yarn add @0xsequence/niftyswap` or `npm install @0xsequence/niftyswap` # Differences with Uniswap There are some differences compared to the original Uniswap that we would like to outline below: 1. For ERC-1155 tokens, not ERC-20s 2. Base currency is not ETH, but needs to be an ERC-1155 3. Liquidity fee is 0.5% instead of 0.3% 4. All fees are taken from base currency (Uniswap takes trading fees on both sides). This will lead to some small inneficiencies which will be corrected via arbitrage. 4. Users do not need to set approvals before their first trade 5. 100% native meta-tx friendly for ERC-1155 implementations with native meta-tx functionalities 6. Front-end implementations can add arbitrary fee (in addition to the 0.5%) for tokens with native meta-transactions. 7. Less functions than Uniswap There are pros and cons to these differences and we welcome you to discuss these by openning issues in this repository. ## Contracts * [NiftyswapExchange.sol](https://github.com/0xsequence/niftyswap/blob/master/https://github.com/0xsequence/niftyswap/blob/master/src/contracts/exchange/NiftyswapExchange.sol): The exchange contract that handles the logic for exchanging assets for a given base token. * [NiftyswapFactory.sol](https://github.com/0xsequence/niftyswap/blob/master/https://github.com/0xsequence/niftyswap/blob/master/src/contracts/exchange/NiftyswapFactory.sol): The exchange factory that allows the creation of nifyswap exchanges for the tokens of a given ERC-1155 token conract and an ERC-1155 base currency. ## Security Review Niftyswap has been audited by two independant parties and all issues discovered were addressed. - [Agustin Aguilar**](https://github.com/0xsequence/niftyswap/blob/master/https://github.com/0xsequence/niftyswap/blob/master/audits/Security_Audit_Nitfyswap_Horizon_Games_1.pdf) - [Consensys Diligence](https://github.com/0xsequence/niftyswap/blob/master/https://github.com/0xsequence/niftyswap/blob/master/audits/consensys-diligence-audit-2020-02.pdf) ** Agustin was hired as a full-time employee at Horizon after the audit was completed. Agustin did not take part in the writing of Niftyswap contracts. ## Dev env & release This repository is configured as a yarn workspace, and has multiple pacakge.json files. Specifically, we have the root ./package.json for the development environment, contract compilation and testing. Contract source code and distribution files are packaged in "src/package.json". To release a new version, make sure to bump the version, tag it, and run `yarn release`. The `release` command will publish the `@0xsequence/niftyswap` package in the "src/" folder, separate from the root package. The advantage here is that application developers who consume `@0xsequence/niftyswap` aren't required to install any of the devDependencies in their toolchains as our build and contract packages are separated. ## LICENSE Copyright (c) 2017-present [Horizon Blockchain Games Inc](https://github.com/0xsequence/niftyswap/blob/master/https://horizon.io). Licensed under [Apache-2.0](https://github.com/0xsequence/niftyswap/blob/master/./LICENSE)

近期下载者

相关文件


收藏者