Skip to content

feat(sdk-core): add getVaultConfig and Concrete BTC deposit path to DefiVault#9206

Closed
bitgo-ai-agent-dev[bot] wants to merge 2 commits into
venkatesh/defi-279-deposittovault-getvaultconfig-pt1from
venkatesh/defi-279-deposittovault-getvaultconfig-pt2
Closed

feat(sdk-core): add getVaultConfig and Concrete BTC deposit path to DefiVault#9206
bitgo-ai-agent-dev[bot] wants to merge 2 commits into
venkatesh/defi-279-deposittovault-getvaultconfig-pt1from
venkatesh/defi-279-deposittovault-getvaultconfig-pt2

Conversation

@bitgo-ai-agent-dev

Copy link
Copy Markdown

What

  • Add getVaultConfig(params) to DefiVault, proxying GET /api/defi-service/v1/vaults/:id
  • Add protocol dispatch to depositToVault: calls getVaultConfig, routes concrete_btccxdepositToConcreteVault, morphodepositToMorphoVault (renamed from the existing body, unchanged)
  • depositToConcreteVault: single sendMany with type: 'defi-deposit' and defiParams: { vaultId, amount, actionType }; no recipients key passed (WP resolves escrow destination server-side)
  • extractConcreteDepositResult: extracts { pendingApprovalId, state } from the custodial sendMany response (pendingApproval.id); throws descriptively on unexpected shape
  • Unit tests covering: getVaultConfig happy path + error cases, Concrete dispatch (single sendMany, no recipients, pendingApproval extraction, passphrase forwarding), Morpho regression guard (existing two-sendMany path unchanged)

Why

  • The Concrete BTCcx vault uses a custodial BTC wallet — sendMany returns a pendingApproval rather than a signed txRequest. A single sendMany with type: 'defi-deposit' and defiParams is the correct path (no approve step needed)
  • Callers should use a single unified depositToVault API regardless of protocol — provider dispatch belongs in the SDK, not in the caller

Test plan

  • yarn unit-test -- --grep "DefiVault" in modules/sdk-core: 24 passing, 1 pending
  • Build passes: yarn build in modules/sdk-core
  • Morpho tests (existing tests) are all green

Stack

This PR is part 2 of 2 in a stack. Review and merge in order:

  1. feat(sdk-core): add VaultConfig types and defiParams to BuildParams/SendManyOptions #9205 — types + interfaces + dependency bump (base: master)
  2. #TBD — core logic + tests (base: pt1) ← you are here

Ticket: DEFI-279

…endManyOptions

Part 1 of 2 for DEFI-279 (CB-1.8). Types + interfaces + dependency bump:

- Add GetVaultConfigOptions, VaultProvider, VaultConfig, ConcreteVaultConfig,
  ConcreteDepositResult to iDefiVault.ts; update DepositResult to a
  discriminated union (concrete_btccx pendingApproval | morpho operationId);
  add getVaultConfig to IDefiVault interface
- Add defiParams: t.unknown to BuildParams whitelist so it passes through
  prebuildWhitelistedParams() without being stripped
- Add optional defiParams field to SendManyOptions for discoverability
- Bump @bitgo/public-types to ^6.39.0 (picks up defiParams on TxSendBody)

Ticket: DEFI-279
Session-Id: ba171a5f-3d3c-4505-9e87-8df8afe5d59f
Task-Id: bffe5f00-9f9c-4882-be0f-d620f6eba4c5
…efiVault

Part 2 of 2 for DEFI-279 (CB-1.8). Core logic + tests:

- Add getVaultConfig(params) to DefiVault, proxying
  GET /api/defi-service/v1/vaults/:id
- Rename current depositToVault body to private depositToMorphoVault (unchanged)
- Add protocol dispatch in depositToVault: calls getVaultConfig, routes
  concrete_btccx → depositToConcreteVault, morpho → depositToMorphoVault
- depositToConcreteVault: single sendMany with type 'defi-deposit' and
  defiParams {vaultId, amount, actionType}; no recipients key passed
- extractConcreteDepositResult: extracts pendingApprovalId+state from the
  custodial sendMany response (pendingApproval.id), throws on missing id
- Unit tests: getVaultConfig happy path + error cases, Concrete dispatch
  (single sendMany, no recipients, pendingApproval extraction, passphrase),
  Morpho regression guard (existing two-sendMany behavior unchanged)

Ticket: DEFI-279
Session-Id: ba171a5f-3d3c-4505-9e87-8df8afe5d59f
Task-Id: bffe5f00-9f9c-4882-be0f-d620f6eba4c5
@linear-code

linear-code Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

DEFI-279

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