Skip to content

fix(dex): escrow trading competition rewards before they can be claimed - #1077

Merged
nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
jonathanayubausara-a11y:fix/dex-competition-reward-escrow
Aug 29, 2026
Merged

fix(dex): escrow trading competition rewards before they can be claimed#1077
nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
jonathanayubausara-a11y:fix/dex-competition-reward-escrow

Conversation

@jonathanayubausara-a11y

Copy link
Copy Markdown
Contributor

Summary

Resolves #1022. claim_competition_reward previously minted governance tokens from nothing: governance_balances and total_supply were credited by the competition's reward_amount with no value ever escrowed (the DEX had no payable messages and no transferred_value reads).

This PR makes the reward pool custody-backed:

  • create_trading_competition is now payable. The caller must attach native value at least equal to reward_amount; an unfunded competition is rejected.
  • The attached value is recorded in a new competition_reward_escrow mapping, and the governance total_supply is minted once, by exactly the escrowed amount.
  • claim_competition_reward pays winners pro rata from the escrow (min(reward_amount * score / total_score, remaining escrow)), deducts the payout, and no longer touches total_supply. An unfunded/fully-drawn competition yields RewardUnavailable.
  • New get_competition_reward_escrow message exposes the remaining escrow.

Verification

  • cargo test -p propchain-dex — 30 passed, including a full lifecycle test asserting supply increases only by the escrowed amount and the escrow shrinks by exactly the claim
  • cargo clippy -p propchain-dex --all-targets -- -D warnings — clean
  • cargo check --workspace — clean

Closes #1022

create_trading_competition is now payable and requires the reward to be
funded up front: the attached value is escrowed in
competition_reward_escrow and the governance supply is minted once, by
exactly the escrowed amount. claim_competition_reward pays winners pro
rata from the escrow and no longer inflates total_supply, so an unfunded
competition yields RewardUnavailable and supply grows only by value
actually held for the competition.

Closes MettaChain#1022
@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@jonathanayubausara-a11y Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@nanaf6203-bit
nanaf6203-bit merged commit 37ddf10 into MettaChain:main Aug 29, 2026
1 check passed
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.

DEX competition rewards mint governance tokens with no escrow: claim_competition_reward inflates total_supply for free

2 participants