feat: add deposit_for() for third-party vault funding - #94
Conversation
- Add deposit_for() method to CleverVault contract (Soroban) - Add DepositForEvent for third-party deposit tracking - Add buildDepositForXdr to server-side vault client - Add POST /api/vault/deposit-for-xdr API endpoint - Add buildDepositForXdr to frontend vault client - Add 6 tests covering success, validation, multi-funder, and downstream use
📝 WalkthroughWalkthroughChangesThird-party vault funding
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Funder
participant Dashboard
participant VaultAPI
participant AgentVault
Funder->>Dashboard: provide recipient and amount
Dashboard->>VaultAPI: request deposit-for XDR
VaultAPI->>AgentVault: build deposit_for transaction
AgentVault-->>VaultAPI: unsigned XDR
VaultAPI-->>Dashboard: return XDR
Dashboard-->>Funder: provide transaction for signing
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/orchestrator/src/agent-vault-client.ts`:
- Around line 173-183: Update buildDepositForXdr in
packages/orchestrator/src/agent-vault-client.ts (lines 173-183) to accept
assetAddress and encode it between recipientAddress and the i128 amount. In
packages/orchestrator/src/server.ts (lines 641-659), require asset_address and
pass it through to buildDepositForXdr. In
packages/dashboard/src/lib/vault-client.ts (lines 39-52), accept and include
asset_address in the request payload so the full deposit_for argument flow is
preserved.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: bf6a877d-3e38-4e64-b4df-529c3f1056d7
📒 Files selected for processing (5)
contracts/agent-vault/src/lib.rscontracts/agent-vault/src/tests.rspackages/dashboard/src/lib/vault-client.tspackages/orchestrator/src/agent-vault-client.tspackages/orchestrator/src/server.ts
| export async function buildDepositForXdr( | ||
| funderAddress: string, | ||
| recipientAddress: string, | ||
| amountUsdc: number, | ||
| ): Promise<string | null> { | ||
| if (!VAULT_ACTIVE) return null; | ||
| return buildUnsignedXdr(funderAddress, 'deposit_for', [ | ||
| new Address(funderAddress).toScVal(), | ||
| new Address(recipientAddress).toScVal(), | ||
| nativeToScVal(usdcToStroops(amountUsdc), { type: 'i128' }), | ||
| ]); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
Pass the required asset argument through the full flow.
deposit_for(from, user, asset, amount) requires four contract arguments, but this XDR encodes only from, user, and amount. The simulator will reject the call because the i128 amount occupies the required asset: Address position.
packages/orchestrator/src/agent-vault-client.ts#L173-L183: acceptassetAddressand encodenew Address(assetAddress).toScVal()before the i128 amount.packages/orchestrator/src/server.ts#L641-L659: requireasset_addressand pass it tobuildDepositForXdr.packages/dashboard/src/lib/vault-client.ts#L39-L52: accept and sendasset_address.
📍 Affects 3 files
packages/orchestrator/src/agent-vault-client.ts#L173-L183(this comment)packages/orchestrator/src/server.ts#L641-L659packages/dashboard/src/lib/vault-client.ts#L39-L52
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/orchestrator/src/agent-vault-client.ts` around lines 173 - 183,
Update buildDepositForXdr in packages/orchestrator/src/agent-vault-client.ts
(lines 173-183) to accept assetAddress and encode it between recipientAddress
and the i128 amount. In packages/orchestrator/src/server.ts (lines 641-659),
require asset_address and pass it through to buildDepositForXdr. In
packages/dashboard/src/lib/vault-client.ts (lines 39-52), accept and include
asset_address in the request payload so the full deposit_for argument flow is
preserved.
|
lgtm. Address the failing CI and coderabbit comment |
closed #84
Summary
What does this PR do, and why?
Related issue
Closes #
Changes
Testing
How did you verify this works? Include commands run and their output where
useful (e.g.
cargo test,npm test, manual testnet transaction links).Checklist
npm run lintpassesnpm run typecheckpassesnpm testpassesnpm run format:checkpassescargo fmt --check,cargo clippy,cargo testpass in
contracts/<contract>CONTRACT_VERSIONwas bumped in that contractSummary by CodeRabbit