Skip to content

feat(sdk-core): seamless recovery for in-flight defi deposits - #10229

Draft
mullapudipruthvik wants to merge 1 commit into
pruthvikpruthvik/DEFI-1359-defi-earn-bitgojsfrom
pruthvikpruthvik/DEFI-1360-defi-earn-bitgojs
Draft

mullapudipruthvik wants to merge 1 commit into
pruthvikpruthvik/DEFI-1359-defi-earn-bitgojsfrom
pruthvikpruthvik/DEFI-1360-defi-earn-bitgojs

Conversation

@mullapudipruthvik

Copy link
Copy Markdown
Contributor

Summary

depositToVault pre-flights against the vault-scoped operations route (state pending, type DEPOSIT, filtered by wallet — a pending withdraw never blocks a deposit) and rejects with an enriched ActiveOperationExistsError carrying operationId, vaultId, and assetAmount, so catching it and calling resumeDeposit needs zero extra API calls. resumeDeposit is now idempotent: calling it on a fully-created operation returns the existing leg ids instead of throwing a dead end, so the catch-and-resume loop always converges to the standard deposit result shape. Guards: cancelled operations and operations belonging to a different wallet/vault are refused before anything is issued. Only an operation with no approve leg at all still throws — unrecoverable client-side.

Operation-record field semantics (verified live): associatedTxRequestId = the approve leg, txRequestId = the deposit leg. Known limitation, documented on resumeDeposit: the fully-created path returns leg ids only; callers discover pending approvals via the wallet's approval listing.

Verification

Unit suite green (111 in the defi suite: enriched-error fields, type filter, idempotent resume, cancelled/wallet/vault guards). Live (DEFI-1362): the crash-recover loop passed end-to-end on test env — approve-only crash → duplicate rejected with matching enriched fields → resume issued the missing leg → both approved → completed; fully-created duplicate → resume returned the existing legs, no second deposit.

Stack

Stacked on #10228.

Ticket: DEFI-1360

@linear-code

linear-code Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

DEFI-1360

depositToVault pre-flights against the vault-scoped operations route
(state pending, type DEPOSIT, filtered by wallet — a pending withdraw
never blocks a deposit) and rejects with an enriched
ActiveOperationExistsError carrying operationId, vaultId, and
assetAmount, so catching it and calling resumeDeposit needs zero extra
API calls. resumeDeposit is now idempotent: calling it on a
fully-created operation returns the existing leg ids instead of
throwing a dead end, so the catch-and-resume loop always converges to
the standard deposit result shape. Only an operation with no approve
leg at all still throws — that state is unrecoverable client-side.
Known limitation, documented on resumeDeposit: the fully-created path
returns leg ids only; callers discover pending approvals via the
wallet's approval listing. ActiveOperationExistsError's constructor
now takes the operation record fields (additive on instances).

Ticket: DEFI-1360
@mullapudipruthvik
mullapudipruthvik force-pushed the pruthvikpruthvik/DEFI-1359-defi-earn-bitgojs branch from 1d258a7 to 3e00ac7 Compare November 25, 2026 17:02
@mullapudipruthvik
mullapudipruthvik force-pushed the pruthvikpruthvik/DEFI-1360-defi-earn-bitgojs branch from 855a95f to 521516a Compare November 25, 2026 17:02

This branch has not been deployed

No deployments
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.

1 participant