Feature : XRC-20 And AMM protocol
Opened this issue · 2 comments
Idea:
To enhance the liquidity and ecological development of XDAG, it is crucial for XDAG to make continuous progress. The community has experienced various losses in the past due to issues with centralized exchanges. While we are aware of the ERC-20 Token protocol on the Ethereum Virtual Machine (EVM), the cryptocurrency field is saturated with numerous EVMs. Unfortunately, the development of EVM has become increasingly complex, with frequent occurrences of hacker attacks and security concerns related to Solidity programs. Therefore, XDAG must pursue an innovative approach that is technically straightforward, secure, practical, and suitable for the community.
To achieve greater decentralization and grant users absolute control over XDAG and their transaction rights, we propose implementing native transaction technology on the XDAG network. We have discovered a promising protocol called BRC-20, currently in development on the Bitcoin (BTC) network. This protocol is rapidly growing, both in terms of security and ecosystem, and we believe it is better suited for XDAG.
(For more information on BRC-20, please refer to: https://domo-2.gitbook.io/brc-20-experiment/)
The following functionalities are compatible with the BRC-20 protocol:
- xrc-20 mint
- xrc-20 deploy
- xrc-20 transfer
However, we aim for innovation rather than mere compatibility or plagiarism. After extensive discussions among developers, we identified the core capability in the decentralized finance (DeFi) field as swap. We observed that the core automated market maker (AMM) capability of Uniswap is highly effective. Therefore, building upon the BRC-20 protocol, we have introduced an innovative, protocol-level AMM on the XDAG public chain. The following ideas outline our approach:
- xrc-20 add_liquidity
- xrc-20 remove_liquidity
- xrc-20 swap
This implementation may position XDAG as the first public chain to support the AMM native chain protocol. Compared to AMMs implemented using Solidity, XDAG's protocol-level AMM implementation will be groundbreaking and innovative.
Specific implementation method:
Regarding the implementation of the XRC-20 and AMM protocols in XDAGJ:
- Add the aforementioned XRC-20 agreement in the remark field.
- Provide XRC-20 indexing at the XDAGJ node level.
- Implement XRC-20 RPC-related interfaces on XDAGJ nodes.
- Implement add_liquidity,remove_liquidity,swap operation in XDAG-Pro
Protocol Design:
index | name | bytes | Type | Description |
---|---|---|---|---|
1 | Protocol | 1 | unsigned number | Protocol: XRC-20:1 , AMM: 2 |
XRC-20 Protocol
- Deploy xrc-20
index | name | bytes | value | Description |
---|---|---|---|---|
1 | Protocol | 1 | 1 | xrc-20 |
2 | Token Name | 5 | BTC | Token name |
3 | Operation | 1 | 1 | deploy |
4 | Max | 8 | 21000000 | Max supply: set max supply of the XRC-20 |
5 | Lim | 8 | 10000 | Mint limit: If letting users mint to themsleves |
6 | Dec | 1 | 8 | Decimals: set decimal precision, max is 8 |
7 | permissions | 1 | 0 | Permissions: 0: allow everyone mint, 1: only allow Deploy address mint |
- Mint xrc-20
index | name | bytes | value | Description |
---|---|---|---|---|
1 | Protocol | 1 | 1 | xrc-20 |
2 | Token Name | 5 | BTC | Token name |
3 | Operation | 1 | 2 | mint |
4 | Amount | 16 | 100000000 | Amount to mint: States the amount of the xrc-20 to mint. Has to be less than "lim" above if stated. |
- Transfer xrc-20
index | name | bytes | value | Description |
---|---|---|---|---|
1 | Protocol | 1 | 1 | xrc-20 |
2 | Token Name | 5 | BTC | Token name |
3 | Operation | 1 | 3 | transfer |
4 | Amount | 16 | 100000000 | Amount to transfer: States the amount of the xrc-20 to transfer. |
AMM(Automated Market Maker) Protocol
- add_liquidity xrc-20/xdag
index | name | bytes | value | Description |
---|---|---|---|---|
1 | Protocol | 1 | 2 | AMM |
2 | Operation | 1 | 1 | add_liquidity |
3 | Token Name | 5 | BTC | Token name |
4 | AmountDesire | 8 | 1 | The amount of token you wish to deposit. |
5 | AmountMin | 1 | 5 | Percentage of Minimal Deposited Token. |
6 | deadline | 1 | 168801901704 | request expiration time. (unix timestamp) |
- add_liquidity xrc-20/xrc-20
index | name | bytes | value | Description |
---|---|---|---|---|
1 | Protocol | 1 | 2 | AMM |
2 | Operation | 1 | 2 | add_liquidity |
3 | TokenA | 5 | BTC | Token name A |
4 | TokenB | 5 | USDT | Token name B |
5 | AmountADesire | 8 | 1 | The amount of token A you wish to deposit. |
6 | AmountBDesire | 8 | 30000 | The amount of token B you wish to deposit. |
7 | AmountAMin | 1 | 5 | Percentage of Minimal Deposited Token A. |
8 | AmountBMin | 1 | 5 | Percentage of Minimal Deposited Token B. |
9 | deadline | 1 | 168801901704 | request expiration time. (unix timestamp) |
- remove_liquidity xrc-20/xdag
index | name | bytes | value | Description |
---|---|---|---|---|
1 | Protocol | 1 | 2 | AMM |
2 | Operation | 1 | 3 | add_liquidity |
3 | Token Name | 5 | BTC | Token name |
4 | Liquidity | 8 | 1 | Amount to transfer: States the amount of the xrc-20 to add_liquidity. |
5 | AmountAMin | 1 | 5 | Percentage of Minimal Deposited Token A. |
6 | AmountBMin | 1 | 5 | Percentage of Minimal Deposited Token B. |
7 | deadline | 1 | 168801901704 | request expiration time. (unix timestamp) |
- remove_liquidity xrc-20/xrc-20
index | name | bytes | value | Description |
---|---|---|---|---|
1 | Protocol | 1 | 2 | AMM |
2 | Operation | 1 | 4 | remove_liquidity |
3 | TokenA | 5 | BTC | Token name of A |
4 | TokenB | 5 | USDT | Token name of B |
5 | Liquidity | 8 | 1 | Amount to transfer: States the amount of the xrc-20 to add_liquidity. |
6 | AmountAMin | 1 | 5 | Percentage of Minimal Deposited Token A. |
7 | AmountBMin | 1 | 5 | Percentage of Minimal Deposited Token B. |
8 | deadline | 1 | 168801901704 | request expiration time. (unix timestamp) |
- swap xrc-20/xdag
index | name | bytes | value | Description |
---|---|---|---|---|
1 | Protocol | 1 | 2 | AMM |
2 | Operation | 1 | 5 | swap |
3 | amountIn | 8 | 100 | Swap Token Input Amount. |
4 | amountOutMin | 8 | 1000000 | Swap Token Min Output Amount. |
5 | path | 15 | BTC USDT | Token name array(split by 5 bytes). |
6 | deadline | 1 | 168801901704 | request expiration time. (unix timestamp) |
- swap xrc-20/xrc-20
index | name | bytes | value | Description |
---|---|---|---|---|
1 | Protocol | 1 | 2 | AMM |
2 | Operation | 1 | 6 | swap |
3 | amountOut | 8 | 100 | Swap Token Output Amount. |
4 | amountInMax | 8 | 1000000 | Swap Token Max Output Amount. |
5 | path | 15 | BTC USDT | Token name array(split by 5 bytes). |
6 | deadline | 1 | 168801901704 | request expiration time. (unix timestamp) |