/tfg-rsk-swap

A Decentralized Exchange (DEX) Vue dApp demo on the RSK blockchain with basic functionalities such as Add Liquidity and Swap ERC20 tokens.

Primary LanguageVue

Vue-RSK Swap Demo

version

This project is the practical part of a Computer Engineering final degree project related to the RSK Blockchain.

The goal of the project was to deploy two ERC20 tokens in the RSK Testnet Network and develop a dApp that replicates the basic functionalities of a DEX (Decentralized Exchange) such as Add Liquidity and Swap tokens.

ERC20 tokens

Liquidity Pools

To add liquidity of a token, the user will provide the balance of the token he wants to add along with the equivalent amount of RBTC, the RSK blockchain native token.

Depending on whether the user wants to add liquidity of the tokenA ($TKA) or the tokenB ($TKB), will use the TokensA Liquidity Pool or the TokenB Liquidity Pool.

The user will first indicate the amount of the token pool that he wants to contribute along with the amount of equivalent value of the RBTC token. This RBTC equivalent value is automatically calculated when the user inputs the token amount, based on the tokenX/RBTC price relation.

It will then be necessary to approve the expenditure of these tokens through the Metamask wallet so the Smart Contract can spend the user tokens and finally confirm the liquidity aggregation transaction.

LiquidityPools

Swap

The Swap page provides the interface to exchanged between both ERC20 tokens deployed in RSK network.

The user needs to select the input and output token, specify the amount of the input token he wants to exchange and the output token amount will be automatically calculated based on the price relation between both ERC20 tokens so the user don't have to manually calculate the output amount he will obtain.

Like in the Liquidity provision process, the user will need to first approve the action, a needed process to give spending permissions to the Smart Contract.

Swap

Router Contract

This Demo works with the Uniswap protocol UniswapV2Router02.sol, a Smart Contracts deployed both in the test and main RSK network.

This contract is deployed at 0xf55c496bb1058690DB1401c4b9C19F3f44374961 and provides functions to manage and maintain liquidity pools and exchange between tokens deployed in the RSK network.

Install Dependencies

npm install

Run Development Environment

npm run dev

App running at:

Stack

Vue.js Solidity JavaScript

Browser Support

Vercel Deployment

Licensing