Skip to content

fix(tholos): account for fee-on-transfer shortfall in reclaim_stalled… - #220

Closed
gloskull wants to merge 1 commit into
drydocs:mainfrom
gloskull:reclaim_stalled_dispute-12741328123233312752
Closed

gloskull wants to merge 1 commit into
drydocs:mainfrom
gloskull:reclaim_stalled_dispute-12741328123233312752

Conversation

@gloskull

Copy link
Copy Markdown

Motivation
Ensure payouts never overpay or trap funds when tokens have transfer fees by recording the actual escrowed amounts rather than assuming full transfer success.
Expose the new AssertionEscrow storage type in the generated TypeScript SDK so the SDK drift check and consumers match the compiled contract spec.
Make small formatting tweaks to pass CI formatting checks.
Description
Add a AssertionEscrow contracttype and a new DataKey::AssertionEscrow(u64) storage key and implement get_assertion_escrow / set_assertion_escrow.
Record actual per-side escrow deltas by sampling token_client.balance(...) before/after transfers and store asserter_escrow / disputer_escrow, then use those escrowed amounts for refunds, rewards, and payouts (reclaim_stalled_dispute, finalize, resolve).
Regenerate the TypeScript SDK bindings: embed the updated contract spec entries and add AssertionEscrow to the SDK DataKey union and exported interfaces in packages/tholos-sdk/src/index.ts.
Apply formatting adjustments to token transfer call sites (compact single-line calls) to satisfy cargo fmt.
Testing
Ran cargo fmt --check (passed).
Ran cargo clippy --workspace --all-targets --locked -- -D warnings (passed).
Ran cargo test --workspace --locked (all unit tests passed).
Built the contract cargo build -p tholos --target wasm32v1-none --release --locked and verified the generated tholos.wasm was used to regenerate the SDK spec entries.
Ran pnpm --dir packages/tholos-sdk build and verified the SDK's embedded contract spec matches the compiled WASM (sdk drift check passed).

Closes #207

…_dispute

Cap refunds in reclaim_stalled_dispute against tracked AssertionEscrow balance deltas, preventing contract traps or overpaying from pooled balances.

Co-authored-by: gloskull <189399494+gloskull@users.noreply.github.com>
@collinsezedike

Copy link
Copy Markdown
Collaborator

@gloskull This duplicates #211 (same fix, different branch). Also, #220 has no CI runs at all, which usually means Actions aren't enabled on this fork; the code here still has the unformatted multi-line transfer calls despite the PR description saying cargo fmt passed. Please consolidate into #211, close this one, and rebase.

@collinsezedike

Copy link
Copy Markdown
Collaborator

@gloskull Closing this. #211 has the review history and progress on this fix, continue there.

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.

[Bug] reclaim_stalled_dispute doesn't account for fee-on-transfer shortfall

2 participants