POA Forum

Migration of the xDai TokenBridge completed!

We are happy to inform everyone that implementations upgrade of xDai bridge contracts has been completed. Just after upgrade all ~37K Sai tokens were swapped to the Dai tokens.

We also updated the TokenBridge oracles: 3 of 4 validators already finished the update of their nodes and one validator is still in progress but it does not impact the bridge operations.

As we stated earlier the following features are now available after the upgrade:

  • the bridge contract on the Ethereum Mainnet side accepts deposits in both Sai and Dai tokens

  • further, as soon as the balance of the xDai bridge in Sai exceeds >10 USD (> 10^19 tokens), it will be automatically swapped to Dai. It means that the major part of the xDai bridge balance on the Ethereum Mainner side is always in Dai

  • with the new feature Alternative Receiver integrated in the contracts of the bridge it is possible to transfer tokens through the bridge to any account by very simple actions. It means that Alice can send Dai or Sai to Bob’s account on the xDai chain in one transaction, and Bob can send xDai to Clare’s account on the Ethereum Mainnet in one transaction too. Technical details about this feature can be found below.

  • the xDai native tokens could be withdrawn only in Dai tokens that’s why the support of Sai relay trough the bridge we call a half duplex transfer.

  • the transfers of Sai tokens through the xDai bridge will be allowed until the Emergency Shutdown for Sai token contract is initiated.

Congrats the xDai chain community, supporters of POA Network and MakerDAO with the new age of xDai chain!

Alternative receiver feature technical details

Due to different nature of tokens on two sides of the xDai bridge the operations to transfer assets to an alternatvie receiver from one chain to another differ as well.

Sai/Dai to xDai

First of all the TokenBridge contract assumes that a user that would like to transfer tokens to the alternative receiver approves operations with tokens for the bridge contract 0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016 – the user must invoke approve() on the token contract before the next step.

Then to specify the receiver of the tokens they should call one of the following methods on the bridge contract:

  • relayTokens(address _receiver, uint256 _amount)– can be used to specify an alternative receiver to tranfer the Dai tokens
  • relayTokens(address _from, address _receiver, uint256 _amount) – intended to be invoked in scenarios when the Dai tokens deposit is performed by another contract on behalf of a user account (e.g. by a DEX)
  • relayTokens(address _receiver, uint256 _amount, address _token) – can be used to specify an alternative receiver to tranfer the Sai tokens
  • relayTokens(address _from, address _receiver, uint256 _amount, address _token) – intended to be invoked in scenarios when the Sai tokens deposit is performed by another contract on behalf of a user account (e.g. by a DEX)

After invocation of the method, the bridge contract will transfer the tokens to the bridge account, swap them to Dai (the method was used for Sai tokens) and publish a request to relay assets.

ABI for relayTokens calls:

[{"constant":false,"inputs":[{"name":"_receiver","type":"address"},
{"name":"_amount","type":"uint256"}],"name":"relayTokens","outputs":[],
"payable":false,"stateMutability":"nonpayable","type":"function"},
{"constant":false,"inputs":[{"name":"_from","type":"address"},
{"name":"_receiver","type":"address"},{"name":"_amount","type":"uint256"},
{"name":"_token","type":"address"}],"name":"relayTokens","outputs":[],
"payable":false,"stateMutability":"nonpayable","type":"function"},
{"constant":false,"inputs":[{"name":"_from","type":"address"},
{"name":"_receiver","type":"address"},{"name":"_amount","type":"uint256"}],
"name":"relayTokens","outputs":[],"payable":false,"stateMutability":"nonpayable",
"type":"function"},{"constant":false,"inputs":[{"name":"_receiver",
"type":"address"},{"name":"_amount","type":"uint256"},{"name":"_token",
"type":"address"}],"name":"relayTokens","outputs":[],"payable":false,
"stateMutability":"nonpayable","type":"function"}]

xDai to Dai

In order to specify the receiver for the Dai tokens, the user must made the withdrawal operation by relayTokens method. This method is payable so the value of xDai must be specified in the transaction which call the method. The method accepts one one parameter – the address of receiver account. No other methods are needed to be call before and after relayTokens

ABI for relayTokens call:

[{"type":"function","stateMutability":"payable","payable":true,
"outputs":[],"name":"relayTokens","inputs":[{"type":"address",
"name":"_receiver"}],"constant":false}]
2 Likes

There is more explanatory instructions describing to use the Alternative Receiver feature with the xDai bridge.

1 Like

Thanks for all of the hard work on the migration…I was able to move some DAI on main net to Xdai via the bridge without having to mess around with Sdai … https://etherscan.io/tx/0xbe7595008e10520327fc55c553a2272f19b38bf1ffe2e8e52e4973ecee9fc4cd

3 Likes

Great work on the half duplex transfer, we successfully rolled out Althea’s DAI update today with no disruption or problems with SAI deposits during the intervening holiday week.

2 Likes