Skip to content

feat(contracts): Emit WithdrawActionEvent for withdraw action [#130]#228

Open
agnesadoga-creator wants to merge 109 commits into
Vatix-Protocol:mainfrom
agnesadoga-creator:feat/withdraw-event-emission
Open

feat(contracts): Emit WithdrawActionEvent for withdraw action [#130]#228
agnesadoga-creator wants to merge 109 commits into
Vatix-Protocol:mainfrom
agnesadoga-creator:feat/withdraw-event-emission

Conversation

@agnesadoga-creator
Copy link
Copy Markdown

Summary

Defines and emits a dedicated WithdrawActionEvent in the withdraw module so indexers and off-chain listeners can subscribe to successful withdrawals without filtering on collateral accounting fields.

Changes

  • contracts/market/src/events.rs:
    • New WithdrawActionEvent { user (indexed topic), market_id (indexed topic), amount }
    • New emit_withdraw_action(env, user, market_id, amount) function
    • Test test_emit_withdraw_action asserts event emission with correct topics and data
  • contracts/market/src/withdraw.rs:
    • Calls emit_withdraw_action() on the success path after the token transfer and emit_collateral_withdrawn

Acceptance criteria

  • Event defined in events.rs
  • Test asserts emission

Closes #130

aji70 and others added 30 commits February 25, 2026 11:19
* feature/withdraw-unused-collateral

* feature/withdraw-unused-collateral

* feature/withdraw-unused-collateral
Co-authored-by: Yusuf Habib <109147010+manlikeHB@users.noreply.github.com>
* feature/resolve-market-oracle

* feature/resolve-market-oracle
onboarding fixes for expiration, deposit, withdraw docs, and positions errors
- Define ValidationFailedEvent in events.rs with context and error_code fields
- Add emit_validation_failed() helper function
- Add test asserting event emission and field values
Replace flat Symbol constants (MARKETS_KEY, POSITIONS_KEY, ADMIN_KEY,
COUNTER_KEY) with a contracttype StorageKey enum. No behavior change.
Add TODO(#issue) references near each emit_* call site explaining
potential future improvements to the event payloads.
- Assert all error discriminant values match their documented ranges
- Assert equality and inequality between variants
- Assert ordering across error categories
Explicitly reject withdrawals when total_deposited is zero before
computing locked collateral, preventing silent unwrap_or(0) fallthrough.
Adds test_withdraw_zero_deposited_rejected to cover the rejection.
…rams

HarnessError variants carry doc comments explaining the failure cause.
MarketParams::default_valid provides a reusable baseline for integration
tests, removing the need for repeated boilerplate setup.
Documents all arguments, return value, error variants, emitted event,
and includes an inline example showing typical usage.
…ejected

Defines PositionLimitExceededEvent in events.rs with market_id, user,
and side_yes (which share side would go negative). update_position now
emits the event before returning ShareBalanceBelowZero.
Adds test_update_position_limit_exceeded_emits_event to assert emission.
Adds a Next.js frontend under apps/web, plus scripts to generate/publish 375 onboarding issues across the three Vatix repos. Updates CI and docs to include the new frontend workflow.
 Add a no-layout-shift loading skeleton
…contract-improvements

Onboarding/contract improvements
khanavi272-spec and others added 30 commits May 29, 2026 00:32
Documents deploy-testnet.sh as an echo guard in README.md with a note
on what a real implementation should do, links it from the scripts README,
and adds a comment in ci.yml explaining the contract Makefile build step.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Document the purpose of the format check step in CI
- Explain that rustfmt.toml defines project-wide formatting rules
- Help future maintainers understand why consistent formatting matters
…ol#113, Vatix-Protocol#114

Vatix-Protocol#111 [tooling] Add echo guard comment to invoke-example.sh
- Added TODO comment explaining what the real contract invoke should do
- Updated scripts/README to reference the echo guard

Vatix-Protocol#112 [tooling] Add CI comment explaining CI workflow step
- Added explanatory comments for Tests and Build steps in ci.yml

Vatix-Protocol#113 [tooling] Document usage of README
- Added ## Scripts section to README.md with invoke-example.sh docs
- Includes example command and reference to scripts/README

Vatix-Protocol#114 [tooling] Add echo guard comment to contract Makefile
- Added TODO comments explaining what the real build/test should do
- Linked from scripts/README under Tooling config

Also:
- Added vrickish.md to .gitignore
…tion-guard

[contracts] Add validation guard in positions module
…clippy-lints

docs: add Clippy lints section to README (Vatix-Protocol#116)
…rd-and-ci-comment

tooling: add echo guard README section and CI build step comment
…mt-ci-comment

feat(Vatix-Protocol#115): Add CI comment explaining rustfmt config step
…comment-deploy-sh

tooling: add CI comment explaining deploy.sh step (Vatix-Protocol#109)
…o-guard-comment-clippy

tooling: add echo guard comment to clippy lint step (Vatix-Protocol#108)
…t-deploy-testnet-sh

tooling: document usage of deploy-testnet.sh in README (Vatix-Protocol#110)
…t-rustfmt-config

tooling: document usage of rustfmt config in README (Vatix-Protocol#107)
…todo-fee-calculation

contracts: add TODO with issue link near fee calculation
[contracts] Add unit test case for expiration check
…tix-Protocol#117 Vatix-Protocol#118 Vatix-Protocol#119 Vatix-Protocol#120)

- deploy.sh: add shebang and echo guard comment noting what real deployment should do
- ci.yml: add explanatory comment for deploy-testnet.sh CI step (issue Vatix-Protocol#118);
  add invoke-example.sh CI step with echo guard comment (issue Vatix-Protocol#120)
- scripts/README.md: expand deploy.sh and deploy-testnet.sh entries; add
  invoke-example.sh usage section with example command (issue Vatix-Protocol#119);
  link all echo guards back to the README (issues Vatix-Protocol#117, Vatix-Protocol#120)

Closes Vatix-Protocol#117, Vatix-Protocol#118, Vatix-Protocol#119, Vatix-Protocol#120

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…18-119-120-tooling-docs

feat(tooling): add echo guard comments and invoke-example.sh docs
…l#132)

- parseWithdrawAmount: display string → raw bigint with decimal precision;
  null for invalid/non-positive inputs
- formatWithdrawAmount: raw bigint → display string, trailing zeros trimmed
- validateWithdrawAmount: validates numeric, ≤ balance; returns { valid, error? }
  for direct use in form error display
- maxWithdrawDisplay: convenience wrapper for Max button population
- TokenBalance and WithdrawValidationResult types fully exported
- 12 unit tests covering all code paths in lib/__tests__/withdrawHelpers.test.ts

Closes Vatix-Protocol#132
…ix-Protocol#131)

Adds a step to CI that verifies README.md is present and non-empty, with a
block comment explaining:
  - why the step exists (prevent documentation rot on main branch)
  - what it checks (absence or zero-byte README)
  - how to skip it for WIP PRs (skip-readme-check label)
  - maintenance pointer (update CONTRIBUTING.md when logic changes)

Closes Vatix-Protocol#131
…Protocol#130)

- events.rs: define WithdrawActionEvent { user (topic), market_id (topic),
  amount }; emit_withdraw_action() publishes it via .publish(env)
- withdraw.rs: call emit_withdraw_action() on the success path after the
  token transfer and collateral accounting event, so indexers can subscribe
  to withdraw completions without filtering on collateral fields
- Test in events.rs asserts the event is emitted with correct topic symbols,
  indexed address/market_id topics, and amount data field

Closes Vatix-Protocol#130
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.