-
Notifications
You must be signed in to change notification settings - Fork 3
AMPL Bridge Primer
Bridges transfer data from one blockchain to another. This can be used to transfer tokens or other useful information programmatically between block-chains. A cross-chain transaction (xc-txn) happens in 2 phases. User initiates the transaction on the source chain, bridge executes off-chain data transfer to the target chain, and the transaction is finalized on the target chain. The ordering of cross-chain transactions may or may not be guaranteed based on the implementation of the bridge (safe to assume that they are not guaranteed).
Cross-chain token transfers are a type of cross-chain transaction. They work by locking up assets on the 'base' chain and minting equivalent number of assets on a 'satellite' chain. eg) The bitcoin blockchain is BTC's base chain. BTC is locked up in the REN's BTC wallet on the base chain, then renBTC ERC-20 tokens are minted on ethereum the satellite chain. When they are transferred back, the ERC-20 tokens are burnt on the satellite chain and BTC is released to the user wallet on the base chain.

Token transfers can also happen between 'satellite' chains, with a n-way bridge. eg) BTC is locked up on the base chain and renBTC ERC-20 tokens are minted on the satellite chain (ethereum). Provided a 3 way bridge exists (between bitcoin, ethereum and tron), tokens can directly be transferred to another satellite chain without going back to the base chain. ie) Tokens are burnt in ethereum and minted in tron, and the ones locked on the base chain remain unaffected.
The AMPL is a rebasing crypto currency that conforms to the ERC-20 interface deployed on the base chain (ethereum v1.0). AMPL adjusts its total supply proportionally based on supply and demand, through a daily rebase operation. User's AMPL balances can change up or down at any given day. AMPLs are non-dilutive, any user's AMPL share or the ratio of the user's AMPL balance to the total supply of AMPL will be constant regardless of rebasing.
- User should be able to lock up X AMPLs on the base chain and receive X minted xc-amples (coss-chain amples) on the satellite chain
- User should be able to burn X xc-amples on the satellite chain and receive X AMPLs on the base chain
- User should be able to burn X xc-amples on the satellite chain and receive minted X xc-amples on a different satellite chain
- When rebase on the base chain changes supply and wallet balances, it reflects in changing supply and wallet balances on all other satellite chains chain
On the base chain the AMPL ERC-20 uses a internal scalar variable (coefficient of expansion) to proportionally change all users balances. When the rebase operation occurs, the scalar variable is updated based on the new total supply calculated by the monetary policy.
gonsPerAMPL = TOTAL_GONS.div(globalAMPLSupply);
On every new rebase, the updated total supply is reported to the other satellite chains through the bridge. The satellite chains update their local copy of the scalar, and thus updating all user's balances proportionally (they mimic the expansion/contraction of AMPL token).
recordedGlobalAMPLSupply = newGlobalAMPLSupply #from base chain
gonsPerAMPL = TOTAL_GONS.div(recordedGlobalAMPLSupply);
Rebases through a bridge are only propagated 1-way, ie) from the base chain (source chain) to a satellite chain (target chain).
XC-Rebase execution flow:
- Rebase executes on the base chain
- XC rebase report transaction is executed on the base chain (source chain)
- XC rebase report transaction is executed on the satellite chain (target chain)
- Rebase executes on the target chain
The source and target chains can either be base or satellite chains. The following transfers are possible:
- Source chain as base chain to target chain as satellite chain
- Initiation: Tokens are locked in base chain
- Finalization: XC-Tokens are mint in the satellite chain
- Source chain as satellite chain to target chain as base chain
- Initiation: XC-Tokens are burn in the satellite chain
- Finalization: Tokens are unlocked in base chain
- Source chain as satellite chain to target chain as satellite chain
- Initiation: XC-Tokens are burn in the satellite chain
- Finalization: XC-Tokens are mint in the satellite chain
When a user sends AMPL from a source chain to target chain, they need to be rebase safe as the ordering of finalization on the target chain is not guaranteed. For rebase safe transfers between chains, we denominate transfers using 2 numbers:
- The amount of AMPL being transferred
- The globalAMPLSupply on the source chain at the time of transfer initiation
Thus on the target chain, the contract can calculate the correct amount of AMPL to {unlock/mint}. The user can never lose or gain tokens when initiating a xc-txn based on the transaction ordering.
mintAmt = transferInitAmount/globalAMPLSupplyAtSource * recordedGlobalAMPLSupply
For example:
- 100 AMPL (at 50M supply) transfer from ethereum to tron is initiated on ethereum
- Rebase executes on ethereum increasing supply by 100% (100M)
- Rebase executes on tron increasing supply by 100%
- when transfer is finalized at tron 200 XC-Ample is mint to the user
mintAmt = 100/50000000 * 100000000 = 200 XCAmple
Cross-Chain Ample is an almost identical version of the AMPL token and deployed on satellite chains chains. XC-Ample is owned by a XC-Controller contract, which maintains a authorized whitelist of bridges. Only these bridges have the ability to mint
,burn
and rebase
the xc-ample tokens.
-
Base Chain: Ethereum; chain where the core asset likes and AMPL tokens are locked/unlocked
-
Satellite Chain: (tron, acala, near ..); chain where xc-ample tokens are mint/burnt
-
Source chain: Chain where a xc-txn is initiated. (any chain base or satellite)
-
Target chain: Chain where a xc-txn is finalized. (any chain base or satellite)