Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Commit

Permalink
Update repositories urls
Browse files Browse the repository at this point in the history
  • Loading branch information
pedro committed Nov 30, 2020
1 parent 77d025c commit 5df8fe9
Show file tree
Hide file tree
Showing 28 changed files with 135 additions and 138 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "uniswap-org",
"name": "rskswap-com",
"private": true,
"description": "RSK Swap homepage and knowledgebase",
"version": "0.1.0",
Expand Down
26 changes: 13 additions & 13 deletions src/pages/blog/04-uniswap-v2/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: 'RSK Swap V2 Overview'
date: '2020-06-10'
author: 'Pedro Prete'
featuredImage: ./featured.jpg
previewText: 'All about Uniswap V2 on RSK. Price oracles, optimistic swaps and much much more. Launching July 2020.'
previewText: 'All about Rsk Swap. Price oracles, optimistic swaps and much much more. Launching July 2020.'
---

**RSK Swap** is a fork of the famous [Uniswap Protocol](https://rskswap.com) adapted to work on the RSK Network. It includes many new features and improvements. This article will serve as a high-level overview of these changes including:
Expand All @@ -18,8 +18,8 @@ previewText: 'All about Uniswap V2 on RSK. Price oracles, optimistic swaps and m

For full details check out the:

- [Core smart contracts](https://github.com/Think-and-Dev/uniswap-v2-core/)
- [Periphery smart contracts](https://github.com/Think-and-Dev/uniswap-v2-periphery)
- [Core smart contracts](https://github.com/Think-and-Dev/rskswap-core/)
- [Periphery smart contracts](https://github.com/Think-and-Dev/rskswap-periphery)
- <a href='/whitepaper.pdf' target='_blank' rel='noopener noreferrer'>Uniswap V2 Technical Whitepaper</a>
- <Link to='/docs/v2/'>RSK Swap V2 Documentation</Link> (in progress!)

Expand Down Expand Up @@ -71,7 +71,7 @@ A few notes:

There are some nuances that are good to be aware of when using Uniswap V2 as an oracle, especially where manipulation resistance is concerned. The <a href='/whitepaper.pdf' target='_blank' rel='noopener noreferrer'>whitepaper</a> elaborates on some of them. Additional oracle-focused developer guides and documentation will be released soon.

In the meantime, check out our [example implementation](https://github.com/Think-and-Dev/uniswap-v2-periphery/blob/master/contracts/examples/ExampleOracleSimple.sol) of a 24 hr TWAP Oracle built on Uniswap V2!
In the meantime, check out our [example implementation](https://github.com/Think-and-Dev/rskswapperiphery/blob/master/contracts/examples/ExampleOracleSimple.sol) of a 24 hr TWAP Oracle built on Uniswap V2!

## Flash Swaps

Expand Down Expand Up @@ -111,20 +111,20 @@ If the Uniswap pool does not receive enough DAI to cover the RBTC withdrawn, the

## Core/Helper Architecture

[Uniswap V2 Core](https://github.com/Think-and-Dev/uniswap-v2-core) are the essential Uniswap V2 smart contracts, consisting of:
[Uniswap V2 Core](https://github.com/Think-and-Dev/rskswap-core) are the essential Uniswap V2 smart contracts, consisting of:

- [UniswapV2Pair.sol](https://github.com/Think-and-Dev/uniswap-v2-core/blob/master/contracts/UniswapV2Pair.sol), which implements core swapping and liquidity provision functionality
- [UniswapV2Factory.sol](https://github.com/Think-and-Dev/uniswap-v2-core/blob/master/contracts/UniswapV2Factory.sol), which deploys [UniswapV2Pair.sol](https://github.com/Think-and-Dev/uniswap-v2-core/blob/master/contracts/UniswapV2Pair.sol) contracts for any ERC20 token/ERC20 token pair
- [UniswapV2Pair.sol](https://github.com/Think-and-Dev/rskswap-core/blob/master/contracts/UniswapV2Pair.sol), which implements core swapping and liquidity provision functionality
- [UniswapV2Factory.sol](https://github.com/Think-and-Dev/rskswap-core/blob/master/contracts/UniswapV2Factory.sol), which deploys [UniswapV2Pair.sol](https://github.com/Think-and-Dev/rskswap-core/blob/master/contracts/UniswapV2Pair.sol) contracts for any ERC20 token/ERC20 token pair

**Core is minimalist in design, removing all logic that is not strictly necessary to secure liquidity stored in its pools.** Logic related to trader security or ease-of-use must be implemented in external helper contracts. Since external helpers can be improved and replaced without needing to migrate liquidity, **this improves on the flexibility and modularity of Uniswap.**

[Uniswap V2 Periphery](https://github.com/Think-and-Dev/uniswap-v2-periphery) (periphery) is an initial set of helpers, including:
[Uniswap V2 Periphery](https://github.com/Think-and-Dev/rskswap-periphery) (periphery) is an initial set of helpers, including:

- [A router contract](https://github.com/Think-and-Dev/uniswap-v2-periphery/blob/master/contracts/UniswapV2Router02.sol) that performs the safety checks needed for safely swapping, adding, and removing liquidity.
- [A migrator contract](https://github.com/Think-and-Dev/uniswap-v2-periphery/blob/master/contracts/UniswapV2Migrator.sol) that can remove liquidity from Uniswap V1 and deposit it into Uniswap V2 in a single transaction.
- [A library contract](https://github.com/Think-and-Dev/uniswap-v2-periphery/blob/master/contracts/libraries/UniswapV2Library.sol) that can be used in the creation of other helper contracts.
- [An example oracle contract](https://github.com/Think-and-Dev/uniswap-v2-periphery/blob/master/contracts/examples/ExampleOracleSimple.sol) that creates a simple TWAP from Uniswap V2 cumulative prices.
- [An example flash swap contract](https://github.com/Think-and-Dev/uniswap-v2-periphery/blob/master/contracts/examples/ExampleFlashSwap.sol) that withdraws ERC20 tokens, executes arbitrary code, and then pays for them.
- [A router contract](https://github.com/Think-and-Dev/rskswap-periphery/blob/master/contracts/UniswapV2Router02.sol) that performs the safety checks needed for safely swapping, adding, and removing liquidity.
- [A migrator contract](https://github.com/Think-and-Dev/rskswap-periphery/blob/master/contracts/UniswapV2Migrator.sol) that can remove liquidity from Uniswap V1 and deposit it into Uniswap V2 in a single transaction.
- [A library contract](https://github.com/Think-and-Dev/rskswap-periphery/blob/master/contracts/libraries/UniswapV2Library.sol) that can be used in the creation of other helper contracts.
- [An example oracle contract](https://github.com/Think-and-Dev/rskswap-periphery/blob/master/contracts/examples/ExampleOracleSimple.sol) that creates a simple TWAP from Uniswap V2 cumulative prices.
- [An example flash swap contract](https://github.com/Think-and-Dev/rskswap-periphery/blob/master/contracts/examples/ExampleFlashSwap.sol) that withdraws ERC20 tokens, executes arbitrary code, and then pays for them.

_Periphery contracts described as "Example" are for illustrative purposes only and should not be used in actual transactions._

Expand Down
27 changes: 12 additions & 15 deletions src/pages/blog/06-ipfs-uniswap-interface/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ previewText: 'The Uniswap Interface is now served exclusively from IPFS'
# TL;DR

- In an effort to continue decentralizing, we have created a mechanism for the community to host the Uniswap Interface
- The open-source [Uniswap Interface](https://github.com/Uniswap/uniswap-interface) built by our team and
community is [automatically deployed](https://github.com/Uniswap/uniswap-interface/releases) daily to IPFS
- The open-source [RSK Swap Interface](https://github.com/Think-and-Dev/rskswap-frontend) built by our team and
community is [automatically deployed](https://github.com/Think-and-Dev/rskswap-frontend/releases) daily to IPFS
- Community members can pin the IPFS hashes to ensure availability
- We use IPNS + DNSLink to point `/ipns/app.uniswap.org` to the latest [IPFS release](https://github.com/Uniswap/uniswap-interface/releases)
- [app.uniswap.org](https://app.uniswap.org) is now served exclusively from the latest
[IPFS release](https://github.com/Uniswap/uniswap-interface/releases), however any IPFS gateway can be used directly
- The URL [uniswap.exchange](https://uniswap.exchange) now forwards to [app.uniswap.org](https://app.uniswap.org)
- The ENS contenthash for `uniswap.eth` now points to the latest IPFS release allowing the URL [uniswap.eth.link](https://uniswap.eth.link/) to be used
- We use IPNS + DNSLink to point `/ipns/app.rskswap.com` to the latest [IPFS release](https://github.com/Think-and-Dev/rskswap-frontend/releases)
- [app.rskswap.com](https://app.rskswap.com) is now served exclusively from the latest
[IPFS release](https://github.com/Think-and-Dev/rskswap-frontend/releases), however any IPFS gateway can be used directly

## Interfaces and decentralization

Expand Down Expand Up @@ -47,9 +45,8 @@ is now deployed at least once per day to IPFS. Each release is automatically [pi
using [pinata.cloud](https://pinata.cloud), a free IPFS pinning service.
The IPFS releases can be found [on GitHub](https://github.com/Uniswap/uniswap-interface/releases).

This means the Uniswap Interface can now be accessed via IPFS directly, through a gateway such as [cloudflare-ipfs.com](https://cloudflare-ipfs.com/ipns/app.uniswap.org/), or by an _alias_ to the Cloudflare gateway at [app.uniswap.org](https://app.uniswap.org).
This means the Uniswap Interface can now be accessed via IPFS directly, through a gateway such as [cloudflare-ipfs.com](https://cloudflare-ipfs.com/ipns/app.uniswap.org/), or by an _alias_ to the Cloudflare gateway at [app.rskswap.com](https://app.rskswap.com).

The domain uniswap.exchange is now redirected to app.uniswap.org, which is an alias to the Cloudflare IPFS gateway that serves the Uniswap Interface from IPFS.

## How we did it

Expand All @@ -64,13 +61,13 @@ Cloudflare’s IPFS gateway then fetches the content using the IPFS protocol and

## Some changes

Because IPFS gateways will not default to serving `/index.html` as is expected by many single page applications, the Uniswap Interface uses a "hash" based router.
Because IPFS gateways will not default to serving `/index.html` as is expected by many single page applications, the Rsk Swap Interface uses a "hash" based router.

This means that links that contain paths, such as [app.uniswap.org/swap](https://app.uniswap.org) will no longer work, but [app.uniswap.org/#/pool](https://app.uniswap.org/#/swap) will work.
This means that links that contain paths, such as [app.rskswap.com/swap](https://app.rskswap.com) will no longer work, but [app.rskswap.com/#/pool](https://app.uniswap.org/#/swap) will work.

## Security Unicorn

Some settings on the Uniswap Interface use localstorage, which is shared across users in some IPFS gateways.
Some settings on the Rsk Swap Interface use localstorage, which is shared across users in some IPFS gateways.

When using an IPFS gateway and referencing an IPFS hash or IPNS name by the _path_
(e.g. [cloudflare-ipfs.com/ipfs/QmdJApBwfsGua9v.../](https://cloudflare-ipfs.com/ipfs/QmdJApBwfsGua9vKnMbswGFGA4y5Kj2VNNPhvcsc8NC7iA/))
Expand All @@ -79,7 +76,7 @@ rather than the _subdomain_
other sites accessed from the same IPFS gateway can view and change your settings in the Uniswap Interface.

To avoid this possibility, you can use the subdomain format of IPFS gateway URLs, which are contained in
[every release](https://github.com/Uniswap/uniswap-interface/releases) along with the path format.
[every release](https://github.com/Think-and-dev/rskswap-frontend/releases) along with the path format.

## Verifying a build

Expand All @@ -91,6 +88,6 @@ Cloudflare's gateway uses the IPFS hash of the deployment in the `etag` header,

## How you can help

To keep the Uniswap Interface available, you can pin the hash of the [latest release](https://github.com/Uniswap/uniswap-interface/releases/latest).
To keep the Rsk Swap Interface available, you can pin the hash of the [latest release](https://github.com/Think-and-dev/rskswap-frontend/releases/latest).

If this sort of work sounds cool to you, we're hiring! [Shoot us a message!](mailto:contact@uniswap.org)
If this sort of work sounds cool to you, we're hiring! [Shoot us a message!](mailto:hello@thinkanddev.com)
4 changes: 2 additions & 2 deletions src/pages/docs/v1/02-SDK/01-getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ Additionally, it exports a number of custom types:
To start using the SDK, simply install it into your project...

```bash
yarn add @thinkanddev/uniswap-rsk-sdk
yarn add @thinkanddev/rskswap-sdk
```

...import some functions...

```javascript
import { ... } from '@thinkanddev/uniswap-rsk-sdk'
import { ... } from '@thinkanddev/rskswap-sdk'
```

...and dive into the rest of the documentation to learn more!
20 changes: 10 additions & 10 deletions src/pages/docs/v2/02-core-concepts/03-flash-swaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@ title: Flash Swaps
tags: flash-swaps, documentation
---

Uniswap flash swaps allow you to withdraw up to the full reserves of any ERC20 token on Uniswap and execute arbitrary logic at no upfront cost, provided that by the end of the transaction you either:
Rsk Swap flash swaps allow you to withdraw up to the full reserves of any ERC20 token on Rsk Swap and execute arbitrary logic at no upfront cost, provided that by the end of the transaction you either:

- pay for the withdrawn ERC20 tokens with the corresponding pair tokens
- return the withdrawn ERC20 tokens along with a small fee

Flash swaps are incredibly useful because they obviate upfront capital requirements and unnecessary order-of-operations constraints for multi-step transactions involving Uniswap.
Flash swaps are incredibly useful because they obviate upfront capital requirements and unnecessary order-of-operations constraints for multi-step transactions involving Rak Swap.

# Examples

## Capital Free Arbitrage

One particularly interesting use case for flash swaps is capital-free arbitrage. It's well-known that an integral part of Uniswap's design is to create incentives for arbitrageurs to trade the Uniswap price to a "fair" market price. While game-theoretically sound, this strategy is accessible only to those with sufficient capital to take advantage of arbitrage opportunities. Flash swaps remove this barrier entirely, effectively democratizing arbitrage.
One particularly interesting use case for flash swaps is capital-free arbitrage. It's well-known that an integral part of Rsk Swap's design is to create incentives for arbitrageurs to trade the Rsk Swap price to a "fair" market price. While game-theoretically sound, this strategy is accessible only to those with sufficient capital to take advantage of arbitrage opportunities. Flash swaps remove this barrier entirely, effectively democratizing arbitrage.

Imagine a scenario where the cost of buying 1 RBTC on Uniswap is 200 DOC (which is calculated by calling `getAmountIn` with 1 RBTC specified as an exact output), and on Money on Chain 1 RBTC buys 220 DOC. To anyone with 200 DOC available, this situation represents a risk-free profit of 20 DOC. Unfortunately, you may not have 200 DOC lying around. With flash swaps, however, this risk-free profit is available for anyone to take as long as they're able to pay gas fees.
Imagine a scenario where the cost of buying 1 RBTC on Rsk Swap is 200 DOC (which is calculated by calling `getAmountIn` with 1 RBTC specified as an exact output), and on Money on Chain 1 RBTC buys 220 DOC. To anyone with 200 DOC available, this situation represents a risk-free profit of 20 DOC. Unfortunately, you may not have 200 DOC lying around. With flash swaps, however, this risk-free profit is available for anyone to take as long as they're able to pay gas fees.

### Withdrawing RBTC from Uniswap
### Withdrawing RBTC from Rsk Swap

The first step is to _optimistically_ withdraw 1 RBTC from Uniswap via a flash swap. This will serve as the capital that we use to execute our arbitrage. Note that in this scenario, we're assuming that:
The first step is to _optimistically_ withdraw 1 RBTC from Rsk Swap via a flash swap. This will serve as the capital that we use to execute our arbitrage. Note that in this scenario, we're assuming that:

- 1 RBTC is the pre-calculated profit-maximizing trade
- The price has not changed on Uniswap or Money on Chain since our calculation
- The price has not changed on Rsk Swap or Money on Chain since our calculation

It may be the case that we'd like to calculate the profit-maximizing trade on-chain at the moment of execution, which is robust to price movements. This can be somewhat complex, depending on the strategy being executed. However, one common strategy is trading as profitably as possible _against a fixed external price_. If the Uniswap market price is far enough above or below this external price, the following example contains code that calculates the amount to trade over Uniswap for maximum profit: [`ExampleSwapToPrice.sol`](https://github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/examples/ExampleSwapToPrice.sol).
It may be the case that we'd like to calculate the profit-maximizing trade on-chain at the moment of execution, which is robust to price movements. This can be somewhat complex, depending on the strategy being executed. However, one common strategy is trading as profitably as possible _against a fixed external price_. If the Rsk Swap market price is far enough above or below this external price, the following example contains code that calculates the amount to trade over Rsk Swap for maximum profit: [`ExampleSwapToPrice.sol`](https://github.com/Think-and-Dev/rskswap-periphery/blob/master/contracts/examples/ExampleSwapToPrice.sol).

<Github href="https://github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/examples/ExampleSwapToPrice.sol">ExampleSwapToPrice.sol</Github>
<Github href="https://github.com/Think-and-Dev/rskswap-periphery/blob/master/contracts/examples/ExampleSwapToPrice.sol">ExampleSwapToPrice.sol</Github>

### Trade at External Venue

Once we've obtained our temporary capital of 1 RBTC from Uniswap, we now can trade this for 220 DOC on Money on Chain. Once we've received the DOC, we need to pay Uniswap back. We've mentioned that the amount required to cover 1 RBTC is 200 DOC, calculated via `getAmountIn`. So, after sending 200 of the DOC back to the Uniswap pair, you're left with 20 DOC of profit!
Once we've obtained our temporary capital of 1 RBTC from Rsk Swap, we now can trade this for 220 DOC on Money on Chain. Once we've received the DOC, we need to pay Uniswap back. We've mentioned that the amount required to cover 1 RBTC is 200 DOC, calculated via `getAmountIn`. So, after sending 200 of the DOC back to the Rsk Swap pair, you're left with 20 DOC of profit!

## Instant Leverage

Expand Down
Loading

0 comments on commit 5df8fe9

Please sign in to comment.