# Transparent & Shielded DEX with Maya Protocol

**URL:** <https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857>\
**Category:** Applications\
**Created:** [February 7, 2024, 3:05am UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857 "2024-02-07T03:05:08Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![mayaprotocol](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/mayaprotocol/32/30064_2.png) [@mayaprotocol](https://forum.zcashcommunity.com/u/mayaprotocol)\
**Post date:** [February 16, 2024, 3:12pm UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857/41 "2024-02-16T15:12:10Z")

</div>

All open source, repo has already been shared I see

---

<div class="post-metadata">

**Author:** ![mayaprotocol](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/mayaprotocol/32/30064_2.png) [@mayaprotocol](https://forum.zcashcommunity.com/u/mayaprotocol)\
**Post date:** [February 16, 2024, 3:12pm UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857/42 "2024-02-16T15:12:22Z")

</div>

Should take a couple of months

---

<div class="post-metadata">

**Author:** ![wobbzz](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/wobbzz/32/27021_2.png) [@wobbzz](https://forum.zcashcommunity.com/u/wobbzz)\
**Post date:** [February 16, 2024, 10:13pm UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857/43 "2024-02-16T22:13:03Z")

</div>

Hi @hanh

ZCG discussed this grant in our brainstorm session today. There are two things that we would like to see updated in your current proposal.

1. We would like to see more substantive information for each of your milestone deliverables.

- For example, your milestone 1 deliverable states “design and planning”. Can you please provide more detail on what this entails and what you are planning to submit to the Zcash Foundation as a deliverable?
- Milestone deliverables need to be clear and substantive for the Zcash Foundation to properly evaluate them without needing to reach out to the committee causing delays to your milestone payouts. Please update each milestone deliverable with more detail.

1. Our current understanding is that Maya will only support receiving transparent ZEC, and that it’s highly recommended to only send funds to Maya from a transparent address because Maya needs to know a return address.

- Can you please document Maya’s vault/liquidity pool incompatibility with shielded addresses and how you plan to overcome this in the wallet as an execution risk in your grant? We would like this to be captured in your grant.

Thanks,  
Brian

---

<div class="post-metadata">

**Author:** ![hanh](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/hanh/32/27853_2.png) [@hanh](https://forum.zcashcommunity.com/u/hanh)\
**Post date:** [February 18, 2024, 12:12am UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857/44 "2024-02-18T00:12:29Z")

</div>

> [@wobbzz](#):
>
> Milestone deliverables need to be clear and substantive for the Zcash Foundation to properly evaluate them without needing to reach out to the committee causing delays to your milestone payouts. Please update each milestone deliverable with more detail.

The form accepts a single line of text per milestone. Where would you like to have the extended description?

 ![image](https://global.discourse-cdn.com/zcash/original/3X/1/0/10ed94f09718e18fb60c464ec7dcd80bf480a52c.png)

Edit: I added this section then.

## Extended Milestone Description

M1: Resolve issues surrounding the usage of transparent & shielded addresses for sending and receiving ZEC

### Sending ZEC: A shielded sender does not include a return address. In case of rejection from MP, how do they refund the user?

Proposal: Add a custom refund address in the memo. Signed off my MP but pending implementation and merge from upstream (Thorchain). That shouldn’t be a problem since it is already planned, but we need to follow up.

Alternatives:

- Restrict to transparent

- Issue warning when sending from shielded

### Receiving ZEC: MP Validators need to check that the payment from the Vault is completed successfully in a decentralized way. As such, they must be able to decrypt shielded tx from MP.

- Solution: Establish a rotating OVK used by Asgard that allows validators to recover the encryption key. The output notes are not malleable per the protocol design. Open Issues: What’s the process for managing the OVK? How do validators get the OVK?

### How do we integrate librustzcash into MP?

- MP is written in Go. They are OK if external components are integrated via C FFI.

### What API will the Zcash integration have?

TBD

Deliverable:

- API documents

- Sequence Diagrams for the swap from/to ZEC

- Signoff for any dependency on MP

## M2: BiFrost

Implementation of the BiFrost component for Zcash.

- Zcash Blockchain scanner

- Detect and verify incoming ZEC into Asguard

- Detect and verify outgoing ZEC (use transparent address or decrypt using OVK)

- Parse memo

- Calculate Fees per ZIP 317

- Build unsigned transaction v5

- Calculate Sighash per ZIP 244

- Sign TSS

Deliverable:

- PR Into BiFrost

- Zcash external library

## M3: Mayanode

- Add logic to parse an address

- Return gas asset for the chain

- add logic in regards to how to update

- define a new asset

- add logic to get address from a pubic key

Deliverable:

- PR into MayaNode

### M4: Finishing touches and testing

- Deployment script: Node Launcher

- Stagenet/Testnet

- Add support to JS client library xchainjs

Deliverable:

- **Test end to end swap from NodeJS**

## M5: Integration in YWallet

Delivarable:

- Ability to swap without leaving YWallet.

Note that YW only has support for Zcash. Therefore for the another currency, a different app must be used.

For bitcoin, YW will generate a payment URI.

This work is primarily for adding Zcash to the backend of MP. As such YW has no dependency on it and works like any other MP client. In other words, users should be able to swap using other apps or online as long as their wallet supports custom memos.

---

<div class="post-metadata">

**Author:** ![kayabaNerve](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/kayabanerve/32/27977_2.png) [@kayabaNerve](https://forum.zcashcommunity.com/u/kayabaNerve)\
**Post date:** [February 18, 2024, 10:16am UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857/45 "2024-02-18T10:16:19Z")

</div>

> [@tokidoki](#):
>
> Revealing a one-use t-addr also doesn’t pose a problem, as long as the ZEC enters the shielded pool eventually.

This reveals non-negligible metadata and fails to achieve a z ecosystem. It’s also irrelevant to this discussion now that hanh has committed to support swaps to shielded addresses.

> [@mayaprotocol](#):
>
> Should take a couple of months

I don’t want to disagree with the representative from Maya yet I will say this sounds optimistic to me. hanh quoted ~5-6 months.

---

<div class="post-metadata">

**Author:** ![ZcashFoundation](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/zcashfoundation/32/21548_2.png) [@ZcashFoundation](https://forum.zcashcommunity.com/u/ZcashFoundation)\
**Post date:** [February 20, 2024, 7:13pm UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857/46 "2024-02-20T19:13:48Z")

</div>

@hanh at the most recent meeting, the [@ZcashGrants](https://forum.zcashcommunity.com/groups/zcashgrants) Committee voted to approve this proposal and has requested that you provide monthly updates via the forum in this thread.

---

<div class="post-metadata">

**Author:** ![hanh](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/hanh/32/27853_2.png) [@hanh](https://forum.zcashcommunity.com/u/hanh)\
**Post date:** [February 20, 2024, 10:21pm UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857/47 "2024-02-20T22:21:24Z")

</div>

Thank you for your ongoing trust. I’m looking forward to swapping BTC for ZEC 😉

---

<div class="post-metadata">

**Author:** ![silentZcollector](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/silentzcollector/32/30093_2.png) [@silentZcollector](https://forum.zcashcommunity.com/u/silentZcollector)\
**Post date:** [February 20, 2024, 10:39pm UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857/48 "2024-02-20T22:39:17Z")

</div>

if THORChain ever decides to integrate ZEC, would this grant also help to get that done fast?  
or would that need a lot of additional work?

---

<div class="post-metadata">

**Author:** ![hanh](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/hanh/32/27853_2.png) [@hanh](https://forum.zcashcommunity.com/u/hanh)\
**Post date:** [February 20, 2024, 10:51pm UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857/49 "2024-02-20T22:51:50Z")

</div>

That’s probably best to ask @mayaprotocol

---

<div class="post-metadata">

**Author:** ![mayaprotocol](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/mayaprotocol/32/30064_2.png) [@mayaprotocol](https://forum.zcashcommunity.com/u/mayaprotocol)\
**Post date:** [February 21, 2024, 12:26pm UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857/50 "2024-02-21T12:26:30Z")

</div>

Yes it would be very easy. Would require a few minor changes only.  
But it wouldn’t make sense for THORChain to do it. MP and TC work with liquidity pools. We rely on users to provide liquidity. More liquidity also means less slippage. If liquidity gets fragmented, it’s ultimately bad for the user. Hence being on either TC or Maya should be sufficient.  
Also, we’ll (Maya) have aggregation with THORChain soon, making it possible to swap from Maya supported assets (DASH, KUJI, ARB, (and soon: ADA, KAS, ZEC, etc.)) to THORChain supported assets (LTC, BCH, DOGE, AVAX, ATOM, BSC) and vice versa in one transaction.

---

<div class="post-metadata">

**Author:** ![hanh](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/hanh/32/27853_2.png) [@hanh](https://forum.zcashcommunity.com/u/hanh)\
**Post date:** [March 13, 2024, 12:50am UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857/51 "2024-03-13T00:50:28Z")

</div>

Quick update: Still working on the tech design & prototype with the Maya team. It’s getting there. No issues so far.

---

<div class="post-metadata">

**Author:** ![hanh](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/hanh/32/27853_2.png) [@hanh](https://forum.zcashcommunity.com/u/hanh)\
**Post date:** [March 18, 2024, 2:02pm UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857/52 "2024-03-18T14:02:56Z")

</div>

Here’s the design doc [Maya Protocol / Zcash :: Docs](https://hhanh00.github.io/docs/maya_protocol/)

---

<div class="post-metadata">

**Author:** ![Cryptoblaz](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/cryptoblaz/32/30846_2.png) [@Cryptoblaz](https://forum.zcashcommunity.com/u/Cryptoblaz)\
**Post date:** [March 18, 2024, 4:15pm UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857/53 "2024-03-18T16:15:16Z")

</div>

Very very cool. Seems like zcashd is being used. What will happen when zcashd is deprecated?

---

<div class="post-metadata">

**Author:** ![hanh](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/hanh/32/27853_2.png) [@hanh](https://forum.zcashcommunity.com/u/hanh)\
**Post date:** [March 18, 2024, 10:29pm UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857/54 "2024-03-18T22:29:12Z")

</div>

Currently zebrad does not have the features required to be used with bifrost. Eventually it should become possible to replace zcashd with it.

---

<div class="post-metadata">

**Author:** ![Blazin8888](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/blazin8888/32/9263_2.png) [@Blazin8888](https://forum.zcashcommunity.com/u/Blazin8888)\
**Post date:** [March 19, 2024, 4:58am UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857/55 "2024-03-19T04:58:15Z")

</div>

wow, very thankful for your constant updates here @hanh. I cannot stress enough how important this work is for freedom… If we can actually pull this off it would be monumental, for the first time in history people will have permissionless access to private p2p electronic cash.

---

<div class="post-metadata">

**Author:** ![mayaprotocol](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/mayaprotocol/32/30064_2.png) [@mayaprotocol](https://forum.zcashcommunity.com/u/mayaprotocol)\
**Post date:** [March 27, 2024, 1:29am UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857/56 "2024-03-27T01:29:04Z")

</div>

Looks great, @hanh!

---

<div class="post-metadata">

**Author:** ![mayaprotocol](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/mayaprotocol/32/30064_2.png) [@mayaprotocol](https://forum.zcashcommunity.com/u/mayaprotocol)\
**Post date:** [April 17, 2024, 3:00pm UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857/57 "2024-04-17T15:00:28Z")

</div>

Join us next week for a new Monday’s with Maya! We’ll have @joshs and @hanh joining to talk about Zcash, the upcoming $ZEC integration into Maya Protocol and more!

> <https://twitter.com/maya_protocol/status/1780601039676486092?s=46&t=F6Puc7MLYZ-EjRsa8-hEyA>

---

<div class="post-metadata">

**Author:** ![decentralistdan](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/decentralistdan/32/28747_2.png) [@decentralistdan](https://forum.zcashcommunity.com/u/decentralistdan)\
**Post date:** [April 23, 2024, 12:03am UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857/58 "2024-04-23T00:03:58Z")

</div>

Twitter space with @hanh, @mayaprotocol, & @joshs is starting now:

[Join Here ▶](https://twitter.com/i/spaces/1YqGoDgMlRXJv)

---

<div class="post-metadata">

**Author:** ![zkcroc](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/zkcroc/32/26962_2.png) [@zkcroc](https://forum.zcashcommunity.com/u/zkcroc)\
**Post date:** [April 23, 2024, 2:16am UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857/59 "2024-04-23T02:16:46Z")

</div>

1st half was pretty introductory high level stuff, I missed the second half, did it get into the weeds a bit more? Any new info or annoucnements?

---

<div class="post-metadata">

**Author:** ![hanh](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/hanh/32/27853_2.png) [@hanh](https://forum.zcashcommunity.com/u/hanh)\
**Post date:** [April 25, 2024, 4:34am UTC](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857/60 "2024-04-25T04:34:38Z")

</div>

Here’s a run of the smoke tests from a dev build

```auto
I[2024-04-25 04:22:58,532] 0 MASTER => USER-1 [SEED] 5.00000000 ZEC.ZEC
I[2024-04-25 04:23:09,043] 1 MASTER => PROVIDER-1 [SEED] 5.00000000 ZEC.ZEC
I[2024-04-25 04:23:19,562] 2 PROVIDER-1 => VAULT [ADD:ZEC.ZEC:PROVIDER-1] 2.50000000 ZEC.ZEC
I[2024-04-25 04:23:32,626] 3 PROVIDER-1 => VAULT [ADD:ZEC.ZEC:PROVIDER-1] 100,000.00000000 MAYA.CACAO
I[2024-04-25 04:23:37,761] 4 USER-1 => VAULT [SWAP:MAYA.CACAO:USER-1] 1.00000000 ZEC.ZEC
I[2024-04-25 04:23:48,632] [+] 20,388.16326530 MAYA.CACAO | Fee 20.00000000 MAYA.CACAO | Gas 20.00000000 MAYA.CACAO
I[2024-04-25 04:23:48,632] 5 USER-1 => VAULT [SWAP:ZEC.ZEC:USER-1] 50,000.00000000 MAYA.CACAO
I[2024-04-25 04:24:07,579] [+] 0.84745086 ZEC.ZEC | Fee 0.00030000 ZEC.ZEC | Gas 0.00015000 ZEC.ZEC

```

- Steps 0 & 1: Send some ZEC funds to the USER-1 and PROVIDER-1
- Steps 2 & 3: Provide some liquidity to the ZEC pool (ZEC & CACAO)
- Step 4: Swap from ZEC to CACAO: 1 ZEC → 20,388.16326530 CACAO
- Step 5: Swap from CACAO to ZEC: 50,000 CACAO → 0.84745086 ZEC

I’ll set up a live cast if enough people are interested.

[Previous page](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857.md?page=2)

[Next page](https://forum.zcashcommunity.com/t/transparent-shielded-dex-with-maya-protocol/46857.md?page=4)
