vUSD
On this page, you can find the contracts and their interactions involved when bridging to and from Ethereum (L1 - $DAI/$USDC/$USDT) and Cronos zkEVM (L2 - $vUSD ), it includes:
[L1 -> L2] Minting $vUSD with $DAI/$USDC/$USDT
[L2 -> L1] Withdrawing $DAI from $vUSD
The following instructions cover bridging and minting $vUSD with $DAI, $USDC, or $USDT deposits on L1.
Note that the contracts are based on $DAI. $USDC or $USDT deposits will be swapped to $DAI during the deposit process. Check Step 2) Minting And Bridging $ybUSD for details and parameters.
[L1 -> L2] Minting $vUSD with $DAI/$USDC/$USDT
From Ethereum mainnet (L1) to Cronos zkEVM mainnet (L2)
For bridging $DAI/$USDC/$USDT (Ethereum Mainnet) to $vUSD (Cronos zkEVM Mainnet), we would need to:
Mint and bridge $ybUSD from Ethereum to Cronos zkEVM Mainnet with $DAI/$USDC/$USDT;
Mint $vUSD with $ybUSD on Cronos zkEVM Mainnet.
To bridge $DAI/$USDC/$USDT from Ethereum mainnet -> Cronos zkEVM mainnet
, and obtain $vUSD we would need to interact with:
ybUSDBridge
$ybUSD token contract
Cronos zkEVM:
0xb1Ece5b548766215272BAFCfa36396B06Cd9e4C9
$vUSD token contract
Cronos zkEVM:
0x5b91e29Ae5A71d9052620Acb813d5aC25eC7a4A2
Step 1) Calculating the amount of $ybUSD to Bridge
On Ethereum, use ybUSD
token contract to call the convertToShares
function:
Keep this amount for later steps.
Step 2) Minting And Bridging $ybUSD
On Ethereum, call the mintAndBridge
function on the ybUSDBridge
contract:
This will mint $ybUSD on Ethereum and bridge it to the _l2Receiver
address on L2.
Step 3) Approving $ybUSD to be spend by $vUSD contract
On Cronos zkEVM, call approve
on the ybUSD contract to approve $vUSD contract to spend $ybUSD with appropriate amount.
Step 4) Minting of $vUSD
On Cronos zkEVM, call mint
on $vUSD contract , to mint $vUSD
This will mint $vUSD into the _receiver
address.
[L2 -> L1] Withdrawing $DAI from $vUSD
From Cronos zkEVM mainnet (L2) -> Ethereum mainnet (L1)
For withdrawing $vUSD (Cronos zkEVM Mainnet) and get $DAI (Ethereum Mainnet) , we would need to:
[On Cronos zkEVM] Use $vUSD to redeem $ybUSD;
[On Cronos zkEVM] Bridge $ybUSD to Ethereum;
[On Ethereum] Redeem $ybUSD for $DAI
To redeem $vUSD from Cronos zkEVM mainnet -> Ethereum mainnet
, and withdraw $DAI we would need to interact with the following contracts:
$vUSD token contract
Cronos zkEVM:
0x5b91e29Ae5A71d9052620Acb813d5aC25eC7a4A2
L2Bridge
Cronos zkEVM: 0x309429DE3621992Cb0ab8982A448c9Cc5c38405b
zk Chain Shared Bridge
$ybUSD token contract
Cronos zkEVM:
0xb1Ece5b548766215272BAFCfa36396B06Cd9e4C9
Step 1) Approving $vUSD to be spend by vUSD contract
On Cronos zkEVM, call approve
on the $vUSD contract to approve $vUSD spend with appropriate amount.
Step 2) Redeeming $vUSD for $ybUSD
On Cronos zkEVM, call redeem
on the vUSD contract, to burn $vUSD and redeem $ybUSD
Once done, corresponding $ybUSD will be transfer to the _reciever
address
Step 3) Approving $ybUSD to be spend by the L2Bridge
On Cronos zkEVM, call approve
on the ybUSD contract, to approve L2Bridge contract to spend $ybUSD.
Step 4) Withdrawing $ybUSD and store withdrawal hash
On Cronos zkEVM, call withdraw
on the L2Bridge contract
Keep the transaction hash for later use in Step 5. This withdraws $ybUSD from Cronos zkEVM to Ethereum. It takes 24 hours before the withdrawal can be finalized on Ethereum. Store the transaction hash from the withdrawal transaction; it will be needed to finalize the withdrawal.
Step 5) Gathering information for $ybUSD withdrawal on L1
Extra information for the L2 -> L1 transaction is required for the next step in claiming the $ybUSD. This information can be gathered by finalizeWithdrawalParams, using zksync-ethers
package
This takes the L2 withdrawal hash as parameters and returns the parameters required for finalizing a withdrawal in the next step.
Example outputs
Step 6) Claiming the $ybUSD on L1
Once the transaction in Step 4 has been finalized, we can claim the withdrawn $ybUSD from the L2Bridge contract by calling its finalizeWithdrawal
function. The inputs can be found in Step 5,
Once finalizeWithdrawal
is completed, the withdrawn amount of $ybUSD will go into the receiver's wallet on Ethereum.
We can use zksync-ethers
package isWithdrawalFinalized
call to whether the withdrawal transaction is finalized on the L1 network.
Step 7) Approving $ybUSD to be spend by ybUSD contract
On Ethereum, call approve
on the $ybUSD contract, to approve the contract to spend $ybUSD
Step 8) Redeem $ybUSD for $DAI
On Ethereum, call redeem
on the the $ybUSD contract
Once redeem
is completed, the withdrawn amount of $DAI will go into the receiver's wallet on Ethereum.
Last updated