Skip to content

feat(cosmwasm): introduce escrow vault for fungibility layer #4937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hussein-aitlahcen
Copy link
Contributor

A CosmWasm contract that acts as a solver in the zkgm protocol, enabling fungible token transfers across IBC channels by managing escrowed assets.

Key Features

  • Dual Token Support: Handles both native Cosmos tokens (via BankMsg) and CW20 tokens
  • Fungible Lane Configuration: Maps (channel_id, base_token) pairs to counterparty beneficiaries for cross-chain settlement
  • Intent Whitelisting: Controls which packet hashes can be filled before finality
  • Solver Interface: Implements DoSolve to release escrowed tokens and return beneficiary addresses for acknowledgments

How It Works

  1. Admin configures fungible lanes linking channels/tokens to counterparty beneficiaries
  2. When zkgm calls DoSolve, the contract validates the order and releases escrowed tokens
  3. Relayers receive fees (base_amount - quote_amount)
  4. Returns the counterparty beneficiary address for source chain repayment (symmetric vault)

Security

  • Access controlled: Only zkgm can call DoSolve, only admin can configure lanes
  • Validates base_amount ≥ quote_amount to prevent underflows
  • Intent packets must be whitelisted to prevent unauthorized pre-finality fills

Copy link

vercel bot commented Aug 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
site ⬜️ Ignored (Inspect) Visit Preview Aug 4, 2025 0:00am

@hussein-aitlahcen hussein-aitlahcen force-pushed the cosmwasm-fungible-layer branch from 3e80ab3 to 9237d5f Compare August 4, 2025 11:32
@hussein-aitlahcen hussein-aitlahcen force-pushed the cosmwasm-fungible-layer branch from 9237d5f to b0723cc Compare August 4, 2025 12:00
@unionlabs unionlabs deleted a comment from Soch-08 Aug 7, 2025
Copy link
Contributor

@benluelo benluelo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just a few questions. also I hate to say it but some documentation on how this works would be great (either in code or a small readme)

let fee = order
.base_amount
.checked_sub(order.quote_amount)
.expect("impossible");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps I'm missing some context but why is this impossible?

Copy link
Contributor Author

@hussein-aitlahcen hussein-aitlahcen Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we check that base covers quote in term of amount just before

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok i missed that line. maybe good to do the comparison as the checked_sub call then? then we can match on the result, instead of doing the check twice?

value.as_bytes().into()
}

fn decode_value(raw: &Bytes) -> StdResult<Addr> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Todo for me: add a default addr value codec impl somehow in depolama

type Encoding = Bincode;
}

pub type BaseToken = Bytes;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either newtype wrapped or don't use an alias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants