SACRED Technical Private Doc
  • What is Sacred?
    • Introduction to Sacred
    • Repos and Video Walkthrough
    • How to Use Sacred
    • Sacred Pools (Boxes)
    • Anonymity Set
    • User journey - from Deposit to Withdrawal
      • 1. Receive Note
      • 2. Deposit Tokens
      • 3. Earn While Waiting
        • Shares-of-Staked Seconds
        • Interest earning interest
        • Share Tracking Quirks
      • 4. Withdraw
      • 5. Redeem Claim - Receive Principal
        • Sacred Automated Market Maker
      • 6. Redeem Yield
      • 7. Redeem Incognito Credits
      • Using a Relayer to withdraw the principal, IC and yield
    • Sacred Rules to keep your deposit private
    • Circuits Summary
    • Links to individual Contracts
Powered by GitBook
On this page
  1. What is Sacred?
  2. User journey - from Deposit to Withdrawal

5. Redeem Claim - Receive Principal

When the user puts the unredeemed claim into Sacred, they will be able to withdraw their tokens to their wallet of choice. They can use a relayer service or redeem directly to their wallet. After this, the claim is nullified and marked as redeemed (Sacred generates a nullified hash). This will allow the user to cash in their Incognito Credits (IC) for Sacred.

After the user withdraws their principal, the user’s portion of yield continues to gain interest which is shared amongst the users who have not withdrawn their principal. This further de-links the principal that is earned from the yield and benefits the people in the Sacred pool as they continue to earn more (and more than other individuals in Aave pools).

The user will be able to withdraw the principal and yield in separate transactions. They can even redeem their yield earned all at the same time at a later date after making multiple deposits and withdrawals in a Sacred pool. While users can redeem the YIELD accumulated all at once from principals, it is recommended to stagger principal redemption and NEVER do this at the same time as it will compromise privacy!

Code Summary - Withdraw principal

User Inputs:

  1. Note

  2. Recipient Address

  3. Relayer settings (relayer URL, fee amount) or current wallet

Process:

  1. Browser (front-end only) decodes the Note (more info on Note structure in proof generation section).

  2. Check if Note is valid, check if deposit still exists (check Merkle Tree)

  3. Arguments set to the contract:

    1. proof (zksnark output)

    2. root (merkle tree)

    3. Nullifier

    4. recipient address

    5. relayer (address)

    6. fee

    7. refund (non native currency only)

  4. Contract verifies proof, marks that nullifier used and sends funds to:

    1. User (denomination - fee)

    2. Relayer (fee) - if used

  5. Front-end catches transaction receipt and displays all relevant info

Outputs:

  1. Transaction receipt

The claim process is highlighted below in red

Previous4. WithdrawNextSacred Automated Market Maker

Last updated 2 years ago

Logosacred-cli-tools/cli.js at 9e297751a63087e140b6e0577cba6af702806341 · Sacred-Finance/sacred-cli-toolsGitHub