Dapp Integration Example
Last updated
Last updated
Anon (zk) swap is a tool for users to exchange a token from the scuba swap contract with a public swap pool while keeping their address hidden. We offer two types of swap: fixed one-step and flexible two-step.
For fixed one-step swaps, users initiate the swap by sending the swap transaction (zk proof) to the scuba swap contract on the Host chain. The Scuba swap contract then forwards the corresponding operation to the Scuba System. The Scuba bundler collects this swap operation and executes it on the scuba swap contract. Once the compiled swap operation is received by the Scuba swap contract, it interacts with the public swap contracts like Uniswap and Curve to exchange the user’s tokens without disclosing their wallet address. Upon completion of the swap, the user’s tokens are exchanged within the Scuba system, and the Scuba swap contract confirms the transaction to the Scuba System.
The other type of swap is the flexible two-step. In this mode, users first send the flex swap transaction containing the source token and amounts (zk proofs) to the Scuba contract. The scuba contract then passes the corresponding operation to the Scuba system. Once the callback result is returned to the Scuba swap contract, users can send the destination token and amounts to the Scuba swap contract. The scuba swap contract immediately interacts with the public contract to perform the swap. After completing the swap, the swapped assets are recorded as anonymous assets under the user’s name. The difference between flex and fixed swaps is that flex swaps can offer lower slippage since the Scuba swap contract interacts with the public swap contract right away.