The token exchange architecture facilitates seamless token swaps between the Binance Smart Chain (BSC) and the Polygon network (MATIC). This document outlines the processes involved in both directions of the exchange and the control mechanisms to ensure token balance integrity.
-
Initiating Exchange:
- User calls the
swapStart
function of theBscVault
contract on the BSC network. - Before calling, the user must approve the BSW token for exchange.
- User calls the
-
Processing Exchange:
- Upon receiving the
SwapStart
event fromBscVault
, the server calls theswapEnd
function of theMaticMinter
contract on the Polygon network (MATIC). swapEnd
mints the specified amount to the recipient on the Polygon network.
- Upon receiving the
-
Completing Exchange:
- After receiving the
SwapEnd
event fromMaticMinter
, the server calls thesetSwapComplete
function ofBscVault
to finalize the exchange.
- After receiving the
-
Initiating Exchange:
- User calls the
swapStart
function of theMaticMinter
contract on the Polygon network (MATIC).
- User calls the
-
Processing Exchange:
- Upon receiving the
SwapStart
event fromMaticMinter
, the server calls theswapEnd
function of theBscVault
contract on the BSC network. swapEnd
unlocks the specified BSW Token amount in favor of the recipient on the BSC network.
- Upon receiving the
-
Completing Exchange:
- After receiving the
SwapEnd
event fromBscVault
, the server calls thesetSwapComplete
function ofMaticMinter
to finalize the exchange.
- After receiving the
- Upon completing all exchanges, the deposit count of
MaticMinter
should matchBscVault
. - The balance of
BscVault
must equal the total BSW token supply in the Polygon network (MATIC).
This architecture enables efficient and secure token swaps between BSC and Polygon networks, ensuring integrity through careful control mechanisms.