4. Withdraw

The withdrawal process is summarized in the diagram below. Note that withdrawing involves:

  1. Collecting your original asset (principal)

  2. Claiming your IC

  3. Claiming your yield (interest)

  4. Swapping your IC into SACRED through our AMM

Reason for multiple steps:

Paying out yield earned from Aave during withdrawal might give hints as to how long assets stayed in a Sacred pool. Based on yield size and date of withdrawal, an attacker could figure out the date of deposit. This is because deposits are not arbitrary amounts but are specific. Having the date of deposit would shrink the anonymity set of the withdrawing user to a single day or even hour.

Therefore, breaking the link between the principal and the yield earned is essential.To do this, the user withdraws their interest separately from their principal. Since these are separate transactions, also separated by time, it becomes impossible to find the user’s deposit date.

Note: The commitment is not sent to the contract during a withdrawal. This makes it not possible to link a commitment (deposit) to its nullifier (withdrawal). Only the Note holder possesses the ability to view both, even after the withdrawal (Or anyone with the note, for example if the User had to turn in the note to authorities to comply, they would then be able to view the deposit and withdrawal linked.). This is why you don’t want to post your Notes up publicly even after it has been withdrawn.

Verify the withdrawal note

The first step in the withdrawal is verifying the note:

Code Summary -

Verifying the note - (ZK Proof)

  1. Send parameters to contract

    1. Proof

    2. Root

    3. Nullifier Hash

    4. Recipient (address)

    5. Relayer (address)

    6. Fee

    7. Refund

  2. Using the parameters, the contract verifies that the proof matches the supplied parameter inputs.

  3. The contract marks the Nullifier Hash as void

  4. The contract sends funds to User (amount - fee)

  5. The contract sends fee to Relayer (fee)

  6. The contract sends refund tokens to Relayer (only for tokens, non native currency)

Note the detailed flow in red of the claim process.

Note the detailed flow in red of the withdraw after the claim.

Last updated