feat(sdk-core): add withdrawFromVault() to DefiVault#9229
Open
sachinBitgo wants to merge 1 commit into
Open
Conversation
Contributor
Ticket: DEFI-237
Single sendMany call (defiWithdraw → defi-withdraw intent) returns
{ operationId, txRequestId }. Maps SDK-level amount to shareTokenAmount
per the DefiWithdrawIntent schema in public-types.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
db0f2a6 to
948347d
Compare
OttoAllmendinger
requested changes
Jul 10, 2026
| /** DeFi-service vault identifier */ | ||
| vaultId: string; | ||
| /** Amount in base units of the vault share token */ | ||
| amount: string; |
| vaultId?: string; | ||
| amount?: { value: string; symbol: string } | string; | ||
| /** Vault share token amount for defi-withdraw intent (base units) */ | ||
| shareTokenAmount?: string; |
Comment on lines
+4474
to
4477
| defiParams: params.defiParams as { | ||
| vaultId: string; | ||
| amount: string; | ||
| }, |
Contributor
There was a problem hiding this comment.
don't cast, validate (ideally using io-ts)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
withdrawFromVault()to theDefiVaultSDK class, completing the ERC-4626 vault lifecycle alongside the existingdepositToVault()/resumeDeposit()methods.What changed:
DefiVault.withdrawFromVault(params)— issues a singlesendManycall withtype: 'defiWithdraw'and returns{ operationId, txRequestId }. The withdrawal state machine is simpler than deposit (no approve step):CREATED → WITHDRAW_TX_REQUESTED → WITHDRAW_SIGNED → WITHDRAW_CONFIRMED → COMPLETED.IDefiVault— newwithdrawFromVaultmethod signature; newWithdrawFromVaultOptionsandWithdrawResulttypes exported fromiDefiVault.ts.mpcUtils.ts— addeddefi-withdrawintent case. Maps SDKamount→shareTokenAmountper theDefiWithdrawIntentschema inpublic-types(vault share tokens, not underlying asset units).recipientUtils.ts— addeddefiWithdrawtoNO_RECIPIENT_TX_TYPES(recipients/calldata are built server-side fromdefiParams).wallet.ts— addeddefiWithdrawcase insendManyintent dispatch.baseTypes.ts— addedshareTokenAmount?: stringtoDefiIntentFields; removedclientIdempotencyKey(cleanup).commitlint.config.js— addedDEFI-to recognized issue prefixes.examples/ts/defi-vault-deposit.tsandexamples/ts/defi-vault-withdraw.tsfor manual staging tests.Removed:
clientIdempotencyKeyfrom the deposit flow (not used server-side, cleaned up to reduce surface area).Issue
DEFI-237
Type of change
How Has This Been Tested?
modules/sdk-core/test/unit/bitgo/defi/defiVault.tscovering:sendManycalled with correctdefiWithdrawargs;operationId+txRequestIdreturnedapiVersion(unsignedTxs)operationIdextraction pathoperationIdin response throwswalletPassphraseforwarded correctlyvaultId/amountexamples/ts/defi-vault-withdraw.ts)Checklist
DEFI-237was included in the commit message as a reference