xDai Bridge
The xDAI bridge can be used in https://bridge.gnosischain.com by selecting DAI/xDAI.
Please avoid using the legacy xDai bridge: https://bridge.legacy.gnosischain.com/.
xDAI bridge contract is undergoing a critical upgrade: DAI will be replaced with USDS as the default accepted token on Ethereum, while xDAI will continue to be minted on Gnosis Chain. Please refer to xDaiBridge-usds-migration page for more details.
The xDai bridge is a native DAI bridge from Ethereum that is used to mint and burn xDai, the native asset used for gas and transaction fees on Gnosis.
Once Dai is bridged into the xDai bridge, the xDai bridge contract on Gnosis notifies the block rewards contract. The consensus algorithm then mints xDai to the user's corresponding address on Gnosis in the next block.
Key Information
Overview
Detail | |
---|---|
Frontend URL | https://bridge.gnosischain.com |
Trust Model | 4-of-7 Validator Multisig |
Governance | 8-of-16 Multisig |
Governance Parameters | Validator Set, Daily Limits, Fees |
Bug Bounty | Up to $2m |
Bug Reporting | Immunefi |
Key Contracts
- Ethereum
- Gnosis
- Sepolia-Chiado
Ethereum
Contract | Ethereum Address |
---|---|
xDAI Bridge Contract | eth:0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016 |
Validator Management Contract | eth:0xe1579dEbdD2DF16Ebdb9db8694391fa74EeA201E |
Gnosis
Contract | Gnosis Address |
---|---|
xDAI Bridge Contract | gno:0x7301CFA0e1756B71869E93d4e4Dca5c7d0eb0AA6 |
Block Reward Contract | gno:0x481c034c6d9441db23Ea48De68BCAe812C5d39bA |
Validator Management Contract | gno:0xB289f0e6fBDFf8EEE340498a56e1787B303F1B6D |
ERC20ToNative Helper Contract | gno:0x2D51EAa266eafcb59bB36dD3c7E99C515e58113A |
Sepolia - Chiado
Contract | Address |
---|---|
xDAI Bridge Contract (Sepolia) | 0x180ff98e734415ecd35fac3d32940e1b45fad0a2 |
Validator Contract (Sepolia) | 0x3Ea1A9f92A99bC8e820541E7bed5d1F2419fFe59 |
xDAI Bridge Contract (Chiado) | 0xccA0Dc2A058884e62082312F09541cC7566406f0 |
Validator Contract (Chiado) | 0x138190e157d7604B8f89637AA10508Abd4c673B2 |
ERC20ToNative Helper Contract | 0x9866D9d242Ac9D7EC4AC56ce61D0d957A02FD8e2 |
The current deployment of xDAI bridge contract is from https://github.com/gnosischain/tokenbridge-contracts/tree/xdaibridge, with the commit hash fb6bae7589a102613b48c12addb425b72836574e
References:
** Some of the information from TokenBridge Docs are outdated, please verify the information before you bridge.
Fees & Daily Limits
Type | Ethereum -> Gnosis | Gnosis -> Ethereum |
---|---|---|
Bridge Fees | 0% | 0% |
Min Transfer | 0.005 Dai | 10 xDai |
Daily Limit | 10,000,000 Dai | 10,000,000 xDai |
Max Single Deposit | 9,999,999 Dai | 10,000,000 xDai |
Daily Limit is reset according to the following logic: the smart contract stores total amount of processed tokens per current day and reverts on a new transfer if it exceeds the daily limit. Id of the day is calculated using the formula timestamp / (number of seconds in 1 day)
, where timestamp
is the Unix timestamp.
Bridge Validators
- See Bridge Validator
Bridge Governance
How it Works
Ethereum -> Gnosis Chain.
The xDai token is minted when Dai** is transferred from Ethereum to Gnosis using the xDai Bridge. During the transfer process, a block reward contract is invoked to mint xDai to a user's account. Because contract calls are made from the consensus engine to create xDai tokens, balance updates are more difficult to trace than simple value transfers.
**xDAI bridge contract is undergoing a critical upgrade: DAI will be replaced with USDS as the default accepted token on Ethereum, while xDAI will continue to be minted on Gnosis Chain. Please refer to xDaiBridge-usds-migration page for more details.
Calling transfer
on Foreign xDAI bridge will no longer mint xDAI on Gnosis Chain, and users must use relayTokens
instead.
For more detail, please check here.
- Users initiate the relay transaction on Ethereum by approving the bridge contract and calling the bridge contract
relayTokens(address recipient, uint256 value)
. UserRequestForAffirmation(address recipient, uint256 value, bytes32 nonce)
event is emitted from the bridge contract.- Bridge validators observe the event and call
executeAffirmation(address recipient, uint256 value, bytes32 nonce)
function on Home xDAI bridge contract on Gnosis Chain. - When enough confirmations are collected (4/7 majority), the bridge contract on Gnosis Chain calls the block reward contract to record the receiver(s) and amount(s) of xDAI to mint. Hashi acts as an additional bridge valdiator who validates transactions but no actually calling
executeAffirmation
on Home xDAI Bridge. For more details about how Hashi works in this case, check out here - The block reward contract is called by the consensus engine to update user's xDAI balance.
AddedReceiver(uint256 amount, address indexed receiver, address indexed bridge)
event is emitted within the same transaction and receiver address will be credited for the equivalent xDAI amount.
User may check the balance change visually using Blockscout's coin balance history or programmatically using eth_getBalance API by querying the balance on block number where AddedReceiver
event is emitted.
You can also view a receiver's address and amount of xDai received in the block reward contract's logs. Whenever the executeAffirmation
method is called and enough signatures has been collected from bridge valdiators, it emits the AddedReceiver
event:
AddedReceiver(
uint256 amount,
address indexed receiver,
address indexed bridge
)
Gnosis Chain -> Ethereum.
- User transfer xDAI to or call
relayTokens(address receiver, uint256 value)
on Home xDAI bridge contract on Gnosis Chain. The equivalent amount of xDAI is burned. UserRequestForSignature(address recipient, uint256 value, bytes32 nonce)
event is emitted from Home xDAI bridge contract. Example- Bridge validators observe the event and call
submitSignature(bytes signature, bytes message)
function on Home xDAI bridge contract on Gnosis Chain. Hashi acts as an additional bridge valdiator who validates transactions but no actually callingsubmitSignature
on Home xDAI Bridge. For more details about how Hashi works in this case, check out here. - After enough signatures are collected,
CollectedSignatures
event is emitted/ - Anyone can execute the withdrawal on Ethereum by calling
executeSignatures(bytes message, bytes signatures)
on Foreign xDAI bridge on Ethereum. To fetch the calldata value, please check the guideline below. DAI** is unlocked to the receiver on Ethereum. RelayedMessage(address recipient, uint256 value, bytes32 transactionHash)
emitted on Foreign xDAI Bridge. Please be aware that after Hashi upgrade,transactionHash
has been replaced with the value ofnonce
. Please check here for more information on how it works.
Savings xDAI
Application: https://agave.finance/sdai/
Rationale
MakerDAO’s DSR current rate is 5%. Since the increase of the DSR to ~3.5%, ~7M DAI have fled out of the xDAI bridge, as can be seen on this dashboard. Bridging the DSR yield into Gnosis Chain will help regain these deposits. In order to provide the needed catalyst for Gnosis Chain Defi to boom, interest rates on Gnosis Chain have to pick up or reach parity with Ethereum or other chains with higher borrowing demand.
Introducing Savings DAI (sDAI), a DSR(Dai Savings Rate) module in xDAI Bridge between Ethereum and Gnosis Chain.
By depositing most of the DAI in xDAI bridge into sDAI vault from Spark Protocol on Ethereum, which is a ERC4626 vault depositing all DAI into the Maker DSR, interest is accrued from Maker DSR and relayed to Gnosis Chain. xDAI holders on Gnosis Chain can mint sDAI with their xDAI, and enjoy the interest accumulating from Ethereum.
Check out the proposal from Karpatkey to Deposit DAI of the xDAI bridge in sDAI vault from Spark
Interest rate
Assuming the amount of “Savings DAI on GC” minted is lower than the one held by the bridge, then the yield will be higher than the Dai savings Rate. The bridge currently holds roughly 25M DAI and the DSR yield is 5%, assuming 25M get wrapped into sDAI and only 10M xDAI get deposited into the vault on GC, the yield will be 12.5% .
The expectation is that the sDAI rate will always be higher on GC than Mainnet, as only if almost 100% of all DAI bridged is staked will we achieve rate parity.
Considering the current 25M DAI sitting in the bridge, that represents ~1.25M yearly to incentivise GC.
DSR yield is risk-free if you are already holding DAI. All the risks derived from the collateral are borne by all DAI holders, regardless of them depositing in the DSR. Karpatkey team have written a research piece here. The only newly introduced risk is smart contract risk in how the integration is made with the sDAI vault on Ethereum and the implementation of the sDAI vault on GC.
Architecture
Ethereum
A new implementation upgrade in xDAIForeignBridge contract: SavingsDAI Connector is added as a dependency in the contract. Compare to the old implementation of the Compound Connector, the payInterest function in SavingsDai Connector is used to transfer interest received from vault to receiver address on Gnosis Chain rather than to receiver address on Ethereum.
sDAI is deployed on Ethereum. Any future DAI deposited to the Bridge will be wrapped into sDAI, with caveat that it will always keep the buffer of the minimumCashThreshold when investing.
minimumCashThreshold: This value determines what is the recommended amount of DAI that should be held in the bridge at all times, in order to create a buffer for withdrawals without added operations and thus lower gas costs.
Gnosis Chain
There are two contracts being deployed on Gnosis.
The first one is the sDAI vault, also an ERC 4626 which is the most popular standard for vaults which makes it extremely useful for Defi integrations from Lending Protocols like Agave and Spark, to DEXes like Curve and Balancer with their boosted pools. The only modification to the standard vault (OZ implementation) is that it will allow for direct deposits and withdrawals in xDAI, rather than exclusively the ERC20 WXDAI.
The second contract is the Interest Receiver. This will be the address provided on Mainnet bridge as the interest receiver. What this contract does is quite simple, it distributes the balance it holds in xDAI and WXDAI into sDAI at a fixed block rate that gets updated every 1-2 days to adjust for interest rate changes coming from mainnet. The goal of this contract is to not make it possible to front run the bridging process of the interest, and to make sure there is a fairly frequent update of the sDAI shares value and exchange rate. This contract has the perk of being very easy to switch for a different one by simply setting a new receiver on the bridge, without impacting any of the operations. This means if we want to make modifications such as add a fee or normalize rates in the future, that will be very easy to plug-in.
Role and responsibilities
xDAI/wxDAI holder
- Deposit xDAI/wxDAI and get sDAI shares:
- xDAI/wxDAI holders can deposit xDAI/wxDAI in https://agave.finance/sdai/, in return for sDAI, and their corresponding shares in the vault are recorded.
- Bridge Interest Receiver receives interest from mainnet and distribute to sDAI vault.
- sDAI holders withdraw/redeem xDAI/wxDAI (interest+original amount) according to their shares, that has gone up because of the interest received in step 2
Keeper
- Call
investDAI()
refillBridge()
payInterest()
. On Ethereum, anyone is allowed toinvestDAI()
into the sDAI vault, anyone is allowed torefillBridge()
right back up to the threshold, and also anyone is allowed topayInterest()
. These processes are permissionless, and it’s also costly which is why we will have a bot to automate these 3 maintenance procedures in the most efficient way possible. - Keeper is maintained by Karpatkey team. Source Code
Contracts
- Ethereum
- Gnosis
- Goerli
- Chiado
Contract | Address |
---|---|
sDAI | 0x83F20F44975D03b1b09e64809B757c47f942BEeA |
DAI | 0x6B175474E89094C44Da98b954EedeAC495271d0F |
Keeper | 0xC5cD1e53839eeD4d0A38f80C610e77bD07120c90 |
Contract | Address |
---|---|
sDAI | 0xaf204776c7245bF4147c2612BF6e5972Ee483701 |
wxDAI | 0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d |
SavingsXDAI Adapter | 0xD499b51fcFc66bd31248ef4b28d656d67E591A94 |
Bridge Interest Receiver | 0x670daeaF0F1a5e336090504C68179670B5059088 |
Contract | Address |
---|---|
sDAI | 0xD8134205b0328F5676aaeFb3B2a0DC15f4029d8C |
DAI | 0x11fE4B6AE13d2a6055C8D9cF65c55bac32B5d844 |
Contract | Address |
---|---|
sDAI | 0x20e5eB701E8d711D419D444814308f8c2243461F |
wxDAI | 0x18c8a7ec7897177E4529065a7E7B0878358B3BfF |
SavingsXDAI Adapter | 0xc1529e13A5842D790da01F778Bf23a3677830986 |
Bridge Interest Receiver | 0x65e75819E4e8250a03958Ba303E8f95F8f578168 |
How to claim DAI on Ethereum
-
Fetch the value of
recipient
,value
andnonce
fromUserRequestForSignature(address recipient, uint256 value, bytes32 nonce)
from the transction which is emitted by Home xDAI Bridge Gnosis Chain. -
Go to the xDAI bridge helper contract on Gnosis Chain.
- Call
getMessageHash(address _recipient, uint256 _value, _origTxHash)
: withrecipient
andvalue
from theUserRequestForSignature
and_origTxHash
asnonce
fromUserRequestForSignature
(not the transaction hash!). Fetch the returned message hash. - Call
getMessage(bytes32 _msgHash)
&getSignatures(bytes32 _msgHash)
with the message hash from the previous step.
- Call
-
Use the value returned from the previous step to call
executeSignatures(bytes message, bytes signatures)
on xDAI Foreign Bridge on Ethereum.