vitelabs / bounties

The Bounty program is to help the community take part in the development of the Vite ecosystem.
MIT License
9 stars 6 forks source link

Automated Market Maker #16

Open joelyangxyz opened 2 years ago

joelyangxyz commented 2 years ago

Overview:

This task is to build a basic AMM contract and frontend that facilitates token swapping based on a constant product formula. The contract should be built using Solidity++, while the frontend should use Vite.js.

Basic contract requirements/features:

  1. Each trading pair maintains separate accounting of deposited tokens / liquidity.
  2. Trading pairs must be unique (no duplicate pairs).
  1. Either a single token or both tokens can be added.
  2. Swap fees are applied to liquidity deposit if added token liquidity is not balanced based on the current swap rate.
  3. Adding liquidity is a multi-transaction process due to the limitation that only a single token type can be sent in a Vite transaction. (see Note No. 1 below)
  4. Amount of liquidity provided by each user is stored in a mapping. (see Note No. 2 below)
  1. Swaps must have slippage limit (a minimum token received) and a deadline (swap not executed after a given snapshot height).
  2. Swaps have fixed percent fee paid to liquidity pool.

Basic frontend interface features:

Notes:

  1. In Vite, each transaction can only send a single native token. Providing liquidity to an AMM requires providing two different tokens, thus requiring two transactions. One way to get around this limitation is to allow deposits and withdrawals (of each token type) into a "holding pool", and then once those tokens are deposited, invoke a function to confirm providing liquidity with an additional function call.
  2. Tokens on Vite are native to the Vite protocol, and do not have many features/options that ERC-20 tokens have. As such, the amount of liquidity provided to the contract by an address should only be accounted internally by the contract state using a mapping (rather than with an additional contract-based token like in Uniswap).
  3. There is no gas in Vite. Instead, contracts require Vite to be locked to provide quota for the contract. This allows the contract to have a certain throughput based on the amount of Vite staked. As such, keeping a contract consolidated rather than spread out among multiple contracts is often a better approach, so an operator does not need to split Vite reserves to provide quota among several contracts.
  4. Do not worry about routing, multi-step swaps, price-feeds, or other advanced features.

Resources:

It is recommended to look at Uniswap v1 or Uniswap v2 for basic features expected for adding/removing liquidity and swapping tokens (for dealing with minimum liquidity, time-to-expiration, slippage).

Even if you know solidity, before starting with solidity++ you'll likely need to read through the docs at https://docs.vite.org/ https://docs.vite.org/vite.js/

For inspiration / formulas you can check: https://github.com/Uniswap/v1-contracts https://github.com/Uniswap/v2-core

For good examples of some quality projects on Vite that make use of both Vite.js and Solidity++, check out: https://github.com/vitelabs/vitex.net https://github.com/ImmutableNotes https://github.com/niklr/vite-quota-bank https://github.com/niklr/vite-staking

Prize

Submission Requirements

Judging Criteria

Winner Announcement

Vite Resources

Follow Vite on social media

gitcoinbot commented 2 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 7500.0 USD (7497.0 USD @ $1.0/USD) attached to it.

gitcoinbot commented 2 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 2 weeks, 1 day from now. Please review their action plans below:

1) sabadevs20 has started work.

Creatring an automated market maker

Learn more on the Gitcoin Issue Details page.

gitcoinbot commented 2 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 7500.0 USD (7488.75 USD @ $1.0/USD) has been submitted by:


gitcoinbot commented 2 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


The funding of 7500.0 USD (7494.75 USD @ $1.0/USD) attached to this issue has been approved & issued to @peyton.