# SwissBorg Documentation

Welcome to the official SwissBorg Documentation. You can find here all the informations related to the technical details of the CHSB to BORG migration.


# How to migrate?

The CHSB to BORG Migrator is now closed. For any further questions, please contact [SwissBorg Support.](https://help.swissborg.com/)


# Business Logic

Initialization

For organization reasons, the SwissBorgToken was created before the Migrator. The deployer of the contracts held the tokens until the migrator was deployed.

## Migration

The exchange rate is:

`1 CHSB = 1 * (10 ** 10) BORG`

This is because the CHSB has **8** decimals, while the BORG has **18** decimals.

To migrate, users will need to first approve the spending of their CHSB by the migrator contract. This can be done through direct contract interaction but will also be implemented on our official frontend.

Then, they will be able to call the migrate function on the contract (again either via contract interaction or through our frontend) passing an amount of CHSB.

This function will take their CHSB and transfer an equivalent amount of BORG according to the exchange rate defined above (in wei).

**Example:**

User A wants to migrate&#x20;

100.000000 (`100000000`) **CHSB**

He will approve the contract and migrate, getting back

100.000000000000000000 (`100000000000000000000`) **BORG**.

<figure><img src="https://311270402-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F20eavHG09ovQxEkHaAac%2Fuploads%2FBJtSBVF0cOGxE20z9nO4%2Fimage.png?alt=media&amp;token=539b460a-ba30-4b96-902c-58746fe5ea36" alt=""><figcaption><p>The "migrate" process.</p></figcaption></figure>

## Pause

In case of problems, the `manager` might want to pause the migration.

After calling `pause`, any `migrate` transaction must revert.

When decided by the `manager`, the process can be unpaused through the unpause method. After this is called, any transaction calling `migrate` should be working again with the same exchange rate.

For more details about the manager and security in general, you can check the [**Security**](/borg-migration/security) page.

<figure><img src="https://311270402-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F20eavHG09ovQxEkHaAac%2Fuploads%2FahjsAnp4YZbVWjqbRImG%2Fimage.png?alt=media&amp;token=c73b147e-9136-4222-b0ac-400b04ef6da9" alt=""><figcaption><p>The "pause" process.</p></figcaption></figure>

<figure><img src="https://311270402-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F20eavHG09ovQxEkHaAac%2Fuploads%2F3KGSoBYlfSvFmDBskbSm%2Fimage.png?alt=media&amp;token=d69df212-b318-4fd0-b45d-03a1938268ee" alt=""><figcaption><p>The "unpause" process.</p></figcaption></figure>


# Technical Documentation


# SwissBorgToken.sol

https\://github.com/SwissBorg/borg-token/blob/master/contracts/SwissBorgToken.sol

## Description

This contract represents the new BORG token. It is a simple ERC20 implementing three extensions from [OpenZeppelin](https://github.com/OpenZeppelin/openzeppelin-contracts):

\- `ERC20Burnable`: which allows real "burn" of the tokens, updating the total supply.

\- `ERC20Permit`: which is a gas-less alternative to approvals

\- `ERC20Votes`: which tracks historical balances for voting in on-chain governance, with a way to delegate one's voting power to a trusted account.

While the CHSB initial supply was hardcoded to 1 billion, the BORG initial supply will take into account the tokens sent to [address(0)](https://etherscan.io/token/0xba9d4199fab4f26efe3551d490e3821486f135ba?a=0x0000000000000000000000000000000000000000) to not mint tokens that can't be migrated.

When created, the supply will be directly transferred to the migrator which is in charge of exchanging CHSB tokens for BORG tokens.

**No roles are available on this contract.**&#x20;

**No proxy is implemented in front of the contract.**

*The SwissBorgToken contract is released under the MIT license.*

## Functional Requirements

This is a simple ERC20 and any user should be able to interact with it as he or she would do with any token.

With `ERC20Burnable`, it should be possible to burn some tokens and see the totalSupply() decrease.

With `ERC20Permit`, it should be possible to sign permits instead of approving the token to be spent.


# ChsbToBorgMigrator.sol

https\://github.com/SwissBorg/borg-token/blob/master/contracts/ChsbToBorgMigrator.sol

## Description

This contract is the migrator. The logic is inspired by Aave's [LendToAaveMigrator](https://github.com/aave/aave-token-v2/blob/master/contracts/token/LendToAaveMigrator.sol).

As for the [SwissBorgToken](/borg-migration/technical-documentation/swissborgtoken.sol), it is also implementing code from [OpenZeppelin](https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/).

It is composed of one main function which is `migrate(uint256 _amount)`. This method transfers from `msg.sender` an `_amount` of **CHSB** and transfers to the sender the equivalent amount of **BORG**.

The exchange rate is:

`1 CHSB = 1 * (10 ** 10) BORG`

This is because the CHSB has 8 decimals, while the BORG has 18 decimals.

A UUPSUpgradeable proxy is implemented in front of this contract.&#x20;

The proxy upgradeability role as well as the manager role are defined in the [**Security**](/borg-migration/security) page.

There is an unused variable in the code called `totalChsbMigrated` which will be used for the website.

*The ChsbToBorgMigrator contract is released under the AGPL 3.0 license.*

## Functional Requirements

The migrator should be able to migrate any amount of CHSB owned by a user into the equivalent amount of BORG according to the exchange rate (in wei) defined above.

If the contract is paused, no migration should be possible.

If the contract is unpaused, migrations should be possible.

As the CHSB is an old contract, we added one mitigation. In case an attacker is able to exploit the CHSB and mint some tokens, any migration process should be reverted to protect the BORG.&#x20;


# Security

## [SwissBorgToken.sol](/borg-migration/technical-documentation/swissborgtoken.sol)

The token contract is immutable and has no roles defined.

## [ChsbToBorgMigrator.sol](/borg-migration/technical-documentation/chsbtoborgmigrator.sol)

The migrator can be upgraded and has two roles defined:

\- **`owner`**: **which can upgrade the contract and set a new manager.**

&#x20;The owner will be a 5-out-of-7 multisig. The signers are part of the SwissBorg ecosystem.

\- **`manager`**: **which can pause the migration.**

&#x20;The manager will be a 3-out-of-5 multisig. The signers are also part of the SwissBorg ecosystem.

The addresses of all contracts, including the multisigs are on this page:

{% content-ref url="/pages/Xoj9Jbzg3BUgGtoqn0xz" %}
[Contract Addresses](/borg-migration/contract-addresses)
{% endcontent-ref %}


# Audit

Both contracts were audited by Hacken with a perfect score of 10/10.

The audit report is available here:

{% file src="/files/30LcfC1w51fKqHEum6VC" %}
Audit report
{% endfile %}

You can also get it directly on Hacken's website: <https://hacken.io/audits/swissborg/>


# Contract Addresses

### Mainnet <a href="#sepolia" id="sepolia"></a>

* `CHSB`: [`0xba9d4199faB4f26eFE3551D490E3821486f135Ba`](https://etherscan.io/address/0xba9d4199fab4f26efe3551d490e3821486f135ba)
* `BORG`: [`0x64d0f55Cd8C7133a9D7102b13987235F486F2224`](https://etherscan.io/address/0x64d0f55cd8c7133a9d7102b13987235f486f2224)
* `ChsbToBorgMigrator` Proxy: [`0xaA854688caAB725fe17b7D21b46fDA5AF365985a`](https://etherscan.io/address/0xaa854688caab725fe17b7d21b46fda5af365985a)
  * `ChsbToBorgMigrator` Implementation (v1 - deprecated: [`0x62931eF690876142114eCf5AA52Cf0fBBe5E910B`](https://etherscan.io/address/0x62931ef690876142114ecf5aa52cf0fbbe5e910b)
  * `ChsbToBorgMigrator` Implementation (v2): [`0xFb976eA3AE9Bfe4bC36fb7078e0B32e579463e96`](https://etherscan.io/address/0xFb976eA3AE9Bfe4bC36fb7078e0B32e579463e96)
* Owner: [`0xAC15982Ca8A8e8BAc738FE492b84D8761B4384a3`](https://etherscan.io/address/0xAC15982Ca8A8e8BAc738FE492b84D8761B4384a3)
* Manager: [`0x259c444b50e3Ab173c4f850BB40d85A9EA0230F3`](https://etherscan.io/address/0x259c444b50e3Ab173c4f850BB40d85A9EA0230F3)
* Deployer: [`0x6D608425941a40Cc74D5c5ae4aD75A7b7B21f9aa`](https://etherscan.io/address/0x6d608425941a40cc74d5c5ae4ad75a7b7b21f9aa)

### Sepolia <a href="#sepolia" id="sepolia"></a>

* `CHSB`: [`0x70aE3b93a49cA26abF80D8B26d5cf58087dC1bd5`](https://sepolia.etherscan.io/address/0x70ae3b93a49ca26abf80d8b26d5cf58087dc1bd5)​
* `BORG`: [`0xC5a86570bb55c1109c92A9523F93fE6a89dE2C77`](https://sepolia.etherscan.io/address/0xc5a86570bb55c1109c92a9523f93fe6a89de2c77)​
* `ChsbToBorgMigrator` Proxy: [`0x679CFB1c44Ff46D8847ff339a1654BF38a551EFe`](https://sepolia.etherscan.io/address/0x679cfb1c44ff46d8847ff339a1654bf38a551efe)​
* `ChsbToBorgMigrator` Implementation: [`0x3C0801025bE09463476359FB4c85eb2f2577D4E7`](https://sepolia.etherscan.io/address/0x3c0801025be09463476359fb4c85eb2f2577d4e7)​
* Owner: [`0x7d4e1c945651017ecb1911d037d6186671fe0b43`](https://sepolia.etherscan.io/address/0x7d4e1c945651017ecb1911d037d6186671fe0b43)​
* Manager: [`0x7d4e1c945651017ecb1911d037d6186671fe0b43`](https://sepolia.etherscan.io/address/0x7d4e1c945651017ecb1911d037d6186671fe0b43)​


# How to bridge?

If you hold SwissBorg tokens inside the app, this is the relevant page:

{% content-ref url="/pages/wGYQVCas4AaHVbiesL7d" %}
[SwissBorg app](/bridge/how-to-bridge/swissborg-app)
{% endcontent-ref %}

If for any reason, your tokens are not in the SwissBorg app, you will have to migrate yourself your tokens. You can migrate through our official bridge.

{% content-ref url="/pages/UhpIggeNUH5DNxVFwzIX" %}
[Bridge Website](/bridge/how-to-bridge/bridge-website)
{% endcontent-ref %}


# SwissBorg app

You can natively deposit and withdraw BORG tokens from the SwissBorg app.

Just select the right network when performing the operation!

<figure><img src="https://311270402-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F20eavHG09ovQxEkHaAac%2Fuploads%2FBcUaLqTicaewPaEzJCR1%2FIMG_E7247CA59617-1.jpeg?alt=media&amp;token=5a2a4aa3-b4e3-4df8-87d6-1a5b65ef0f24" alt=""><figcaption><p>The BORG deposit screen</p></figcaption></figure>


# Bridge Website

You can access the bridge website at: [bridge.swissborg.com](https://bridge.swissborg.com)

{% hint style="warning" %}
It takes \~**20 minutes** to bridge from Ethereum to Solana, where you funds won't be on any of your wallets.

It takes \~**2 minutes** to bridge back from Solana to Ethereum.
{% endhint %}

### Example: Ethereum to Solana

1. You need to connect an EVM wallet

<figure><img src="https://311270402-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F20eavHG09ovQxEkHaAac%2Fuploads%2FzkuInWwjFSPhzhoUHE8p%2FCapture%20d%E2%80%99e%CC%81cran%202024-06-04%20a%CC%80%2014.21.35.png?alt=media&amp;token=4e0093cc-2eb3-4581-86ea-363adece567e" alt=""><figcaption></figcaption></figure>

2. You also need to connect a Solana wallet

<figure><img src="https://311270402-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F20eavHG09ovQxEkHaAac%2Fuploads%2FiHyM4OjipFLVeOTyXbEK%2FCapture%20d%E2%80%99e%CC%81cran%202024-06-04%20a%CC%80%2014.21.44.png?alt=media&amp;token=c5bf7dc6-ccaf-403e-ab04-0472ac2fbbe0" alt=""><figcaption></figcaption></figure>

3. Input the amount and then you need to give an allowance to the bridge to be able to proceed with the migration.

<figure><img src="https://311270402-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F20eavHG09ovQxEkHaAac%2Fuploads%2FcQRUSD5yK0CAmDvWSF9B%2FCapture%20d%E2%80%99e%CC%81cran%202024-06-04%20a%CC%80%2014.22.24.png?alt=media&amp;token=fdb0349f-f2db-4368-b5e9-160142bebb1f" alt=""><figcaption></figcaption></figure>

4. Once the approval is executed, you can bridge! This step will transfer your BORG from the source chain to the destination chain.

<figure><img src="https://311270402-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F20eavHG09ovQxEkHaAac%2Fuploads%2FSJEeo4ddwYIrqaGaspy2%2FCapture%20d%E2%80%99e%CC%81cran%202024-06-04%20a%CC%80%2014.22.56.png?alt=media&amp;token=5610f0af-59c0-46e5-8c32-069666178774" alt=""><figcaption></figcaption></figure>

5. You need to wait for the bridging to happen, it takes 20 minutes from Ethereum to Solana and 2 minutes from Solana to Ethereum.

<figure><img src="https://311270402-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F20eavHG09ovQxEkHaAac%2Fuploads%2F2hY2qVPtrn8wUyp34ITm%2FCapture%20d%E2%80%99e%CC%81cran%202024-06-04%20a%CC%80%2014.23.16.png?alt=media&amp;token=09fd1680-928b-4609-9dd6-4feeee8944b7" alt=""><figcaption></figcaption></figure>

6. On the website, you can also see your pending transactions with their estimated time of completion as well as your previous transactions.

<figure><img src="https://311270402-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F20eavHG09ovQxEkHaAac%2Fuploads%2F1SeLhkHksMrWqBNAl085%2FCapture%20d%E2%80%99e%CC%81cran%202024-06-04%20a%CC%80%2014.23.25.png?alt=media&amp;token=9fe5d401-5aed-421e-b5d5-3113b56b1fc6" alt=""><figcaption></figcaption></figure>


# Security

## Ethereum

### NttManager.sol

The manager can be upgraded and has two roles defined:

\- **`owner`**: **which can upgrade the contract and perform administrative actions (like setting rate limits and new chains).**

&#x20;The owner will be a 5-out-of-7 multisig. The signers are part of the SwissBorg ecosystem.

\- **`manager`**: **which can pause the bridging.**

&#x20;The manager will be a 3-out-of-5 multisig. The signers are also part of the SwissBorg ecosystem.

### WormholeTransceiver.sol

The transceiver can be upgraded and has three roles defined:

\- **`owner`**: **which can upgrade the contract and perform administrative actions (like setting relayers).**

&#x20;The owner will be a 5-out-of-7 multisig. The signers are part of the SwissBorg ecosystem.

\- **`manager`**: **which can pause the bridging.**

&#x20;The manager will be a 3-out-of-5 multisig. The signers are also part of the SwissBorg ecosystem.

\- **`relayer`**: **which can unlock some tokens.**

The relayer is the Wormhole bridge.

The addresses of all contracts, including the multisigs are on this page:

{% content-ref url="/pages/yPbPqMHXc3i37rcJmeV3" %}
[Contract Addresses](/bridge/contract-addresses)
{% endcontent-ref %}


# Rate Limiting

The bridge has some rate limiting enforced. The rate limits are over a certain duration.

{% hint style="info" %}
Example: If the limit is 10M per 24h, and a wallet bridges out 10M in one transaction, the limit will be reset over the course of the 24h.

3 hours after this transaction, assuming no other transactions are done in the meantime, the outbound limit will be:

10M / 24 \* 3 = 1.25M BORG
{% endhint %}

At the moment the limits are:

| Chain    | Inbound | Outbound | Duration |
| -------- | ------- | -------- | -------- |
| Ethereum | 1M      | 10M      | 24 hours |
| Solana   | 10M     | 10M      | 24 hours |


# Audits

BORG Bridging on Solana is powered by [Wormhole's Native Token Transfers](https://github.com/wormhole-foundation/example-native-token-transfers).&#x20;

{% hint style="info" %}
The contracts deployed by SwissBorg have **not** been modified and were deployed from the following Github tags:

* v1.0.0+evm
* v1.0.0+solana
  {% endhint %}

At the time of writing (May 2024), NTT has been audited 4 times:

* [**Mar 2024 - Cyfrin**](https://github.com/wormhole-foundation/wormhole-audits/blob/main/2024-04-11-cyfrin-wormhole-evm-ntt.pdf): *NTT EVM Contracts*
* [**Mar 2024 - Cantina**](https://github.com/wormhole-foundation/wormhole-audits/blob/main/2024-04-cantina-wormhole-evm-ntt.pdf): *NTT EVM Contracts*
* [**Mar 2024 - OtterSec**](https://github.com/wormhole-foundation/wormhole-audits/blob/main/2024-03-28-ottersec-solana-ntt.pdf): *NTT Solana Contracts*
* [**Mar 2024 - Neodyme**](https://github.com/wormhole-foundation/wormhole-audits/blob/main/2024-04-12-neodyme-solana-ntt.pdf): *NTT Solana Contracts*

The up-to-date list of audits can be found on [Wormhole Github](https://github.com/wormhole-foundation/wormhole/blob/main/SECURITY.md#3rd-party-security-audits).


# Contract Addresses

### Ethereum <a href="#sepolia" id="sepolia"></a>

* BORG: [`0x64d0f55Cd8C7133a9D7102b13987235F486F2224`](https://etherscan.io/address/0x64d0f55Cd8C7133a9D7102b13987235F486F2224)
* NTTManager (Proxy): [`0x66a28B080918184851774a89aB94850a41f6a1e5`](https://etherscan.io/address/0x66a28B080918184851774a89aB94850a41f6a1e5)
* NTTManager (Implementation): [`0xd048a8D52da402611A0C5eb6f7388ffC41cd1417`](https://etherscan.io/address/0xd048a8D52da402611A0C5eb6f7388ffC41cd1417)
* WormholeTransceiver (Proxy): [`0x45E581d6841F0a99Fc34F70871ef56b353813ddb`](https://etherscan.io/address/0x45E581d6841F0a99Fc34F70871ef56b353813ddb)
* WormholeTransceiver (Implementation): [`0xf0dE6a331AB2EE4199d81462E740BC38E6f879C0`](https://etherscan.io/address/0xf0dE6a331AB2EE4199d81462E740BC38E6f879C0)
* Owner: [`0xAC15982Ca8A8e8BAc738FE492b84D8761B4384a3`](https://etherscan.io/address/0xAC15982Ca8A8e8BAc738FE492b84D8761B4384a3)
* Manager: [`0x259c444b50e3Ab173c4f850BB40d85A9EA0230F3`](https://etherscan.io/address/0x259c444b50e3Ab173c4f850BB40d85A9EA0230F3)
* Deployer: [`0x6D608425941a40Cc74D5c5ae4aD75A7b7B21f9aa`](https://etherscan.io/address/0x6d608425941a40cc74d5c5ae4ad75a7b7b21f9aa)

### Solana <a href="#sepolia" id="sepolia"></a>

* BORG: [`3dQTr7ror2QPKQ3GbBCokJUmjErGg8kTJzdnYjNfvi3Z`](https://solana.fm/address/3dQTr7ror2QPKQ3GbBCokJUmjErGg8kTJzdnYjNfvi3Z)
* NTTManager: [`NttBm3HouTCFnUBz32fEs5joQFRjFoJPA8AyhtgjFrw`](https://solana.fm/address/NttBm3HouTCFnUBz32fEs5joQFRjFoJPA8AyhtgjFrw)
* NTTManager PDA: [`39eUvaqshuCbTo7CmQkHG7zBBLaDAPK3qg89cMSmqKWx`](https://solana.fm/address/NttBm3HouTCFnUBz32fEs5joQFRjFoJPA8AyhtgjFrw)
* NTTManager Mint Authority: [`BNi33DZbWNj8N86eQj7jFKtUZzMSUCCSEV8oeEkuAgzL`](https://solana.fm/address/BNi33DZbWNj8N86eQj7jFKtUZzMSUCCSEV8oeEkuAgzL)
* Owner: [`4AMmkUTKvecXab4J4f8PbXJ8ELwy5RYN6YSyvnsSYbYM`](https://solana.fm/address/4AMmkUTKvecXab4J4f8PbXJ8ELwy5RYN6YSyvnsSYbYM)
* Manager: [`2TH2eKgNMNt67YP7D82LzMCfkLK9rjw7poxm8WZhdrFd`](https://solana.fm/address/2TH2eKgNMNt67YP7D82LzMCfkLK9rjw7poxm8WZhdrFd)
* Deployer: [`9YtbC9Ydx1Tr3V2Lep2AhqXbMyJzXA8M2h4DFBVnaij1`](https://solana.fm/address/9YtbC9Ydx1Tr3V2Lep2AhqXbMyJzXA8M2h4DFBVnaij1)


# Whitepaper

{% file src="/files/vMQoVDlgDnUSraRRzbur" %}
The original SwissBorg whitepaper from 2017
{% endfile %}


