---
# System prepended metadata

title: Project documentation template

---

---
title: 'Project documentation template'
disqus: hackmd
---

Project Title:Cross Chain Swaps
===

## Table of Contents

Control flow of cross chain swap

1.User open site
2.connect his web3 wallet with react-app(give permission to metamask) 
3.if he is on matic network he can start to swap assets
4.if not on matic open a prompt asking to switch to matic network,display until on matic network
5.swap token balance of user for other token
6.there is add liquidity also if user wants to add liquidity to pool on matic chain



## Swap functionality

1.First ERC20 .apporve called to allow kyber and uniswap to spend tokens on behalf of user
2. use 1inch like aggregator to split the order across kyber and matic
3. use kyber swap function and uniswap swap funtion with divided token amount to swap one token for other
4. contract sent new swapped token to user so show him token swap succesful

add liquidity
---

1.use matic.js and matic bridge to swap tokens from mainet to matic network

2.then once tokens are on matic network use ERC20.approve to approve contracts to spend token
check if previous tokens are approved if not then only ask for approval

3.use add liuidity functions of uniswap and kyber to add liuidity

Goals
---

1. kyber and uniswap integration strategy
->So basically get exchange rates from both exchanges 
If difference between uniswap and kyber is calculated with 
Uniswap exchange rate - kyber exchange rate 
If positive then swap on uniswap if not then on kyber?
2. Multiple wallet integration using 
->https://web3connect.com/(is it possible on matic?)
yes possible found this 
https://github.com/maticnetwork/walletconnect-provider

3. frontend?
4. biconomy integration?

Frontend-> if we are using kyber widget
---
1.

TO-DO
---

Defining scopes

1.should we integrate uniswap and kyber individually with biconomy by having additional method for swap through metatransaction or replace msg.sender of uniswap and kyber with generalized meta transaction support?

2.what to do of 1inch ,how 1 inch split code will work?

3.which frontend we should use?
kyber widget
uniswap
write a new frontend with code samples taken from uniswap and kyber

4.explore other wallets option





