Rehypothecation of locked Dai on Ethereum side


#1

<igorbarinov will place the feature description here>

This is a summary of details how it can be implemented:

ETH-to-xDai

  1. The token bridge instances get the Transfer event when someone sends tokens to the brdige contract on the ETH Mainnet.
  2. The token bridge instances send the relay confirmation to the bridge contract on the xDai chain.
  3. The bridge contracts sends a request to mint new coins on the xDai chain.
  4. The bridge contracts also checks if it is the 10th relay (the number could be configured or any another check could be implemented).
  5. If the check is valid the event to increase supply on the Compound raised. The supply amount is provided by the bridge contract.
  6. As soon as the token bridge instances receives the event they send the confirmation to increase supply to the xDai chain.
  7. When enough confirmations are received the event to relay the request to increase supply is raised.
  8. One of the bridge instances relays the request to the bridge contract on the ETH Mainnet.
  9. The bridge contract calls the supply method of the moneyMarket contract on the ETH Mainnet.

xDai-to-ETH

  1. The token bridge instances receives the event from the bridge contract on the xDai chain to relay transfer to the ETH Mainnet.
  2. They send the confirmations to the bridge contract on the xDai chain.
  3. When enough confirmations are received the event to relay the transfer request is raised.
  4. One of the bridge instances relays the request to the bridge contract on the ETH Mainnet.
  5. If the amount of DAI tokens owned by the bridge is not enough the bridge contract calls the withdraw method of the moneyMarket contract on the ETH Mainnet with the corresponding amount of tokens.

Receive the interest

  1. By using the multisig wallet the validators construct the transaction to call requestInterest in the bridge contract on the ETH Mainnet.
  2. If the amount of tokens requested in the transaction is less or equal the difference between the amount supplied to the Compound service and the amount returned by getSupplyBalance of moneyMarket, the bridge contract sends withdraw method of the moneyMarket contract with the amount of tokens corresponding requested value.
  3. The bridge contract sends withdrawn funds to the account specified in the initial transaction with the requestInterest call.