Skip to content

fix: wire real XDR generation into liquidity deposit/withdraw#94

Open
Godfrey-Delight wants to merge 1 commit into
StepFi-app:mainfrom
Godfrey-Delight:fix/liquidity-real-xdr-generation
Open

fix: wire real XDR generation into liquidity deposit/withdraw#94
Godfrey-Delight wants to merge 1 commit into
StepFi-app:mainfrom
Godfrey-Delight:fix/liquidity-real-xdr-generation

Conversation

@Godfrey-Delight

Copy link
Copy Markdown
Contributor

🔗 Related Issue

Closes #1


🔖 Title

Wire real XDR generation into liquidity deposit/withdraw


📝 Description

Wires the real LiquidityContractClient into LiquidityService for deposit and withdraw, replacing the hardcoded placeholder XDR strings that were blocking the sponsor deposit flow end-to-end. LIQUIDITY_POOL_CONTRACT_ID is read via ConfigService, and contract simulation errors (codes 100–104) are mapped to typed BadRequestExceptions instead of surfacing raw Soroban errors.


🔄 Changes Made

  • Restored liquidity-contract.client.ts with buildUnsignedXdr (build, simulate, assemble unsigned envelope), and added blockchain.module.ts to provide it via SorobanService
  • Wired LiquidityService deposit/withdraw to the real client, mapping contract simulation errors to typed HTTP 400s instead of placeholder XDR
  • Updated unit and e2e tests (20 passing) to mock the client, assert correct invocation, and verify returned XDR parses via TransactionBuilder.fromXDR()

📸 Screenshots (if applicable)


🗒️ Additional Notes

-npm run build passes with zero TypeScript errors, no new any types introduced

-E2E tests run against mocked RPC simulation responses rather than a live Soroban testnet RPC — worth flagging since the acceptance criteria specifically asks for the e2e test to pass against a running testnet RPC; happy to add that run if a testnet endpoint/funded account is available in CI, or confirm this mock-based coverage is sufficient

-No schema changes, so no new migration file

Wires the real LiquidityContractClient into LiquidityService for deposit and withdraw, replacing the hardcoded placeholder XDR strings that were blocking the sponsor deposit flow end-to-end. LIQUIDITY_POOL_CONTRACT_ID is read via ConfigService, and contract simulation errors (codes 100–104) are mapped to typed BadRequestExceptions instead of surfacing raw Soroban errors.
Closes StepFi-app#1

@EmeditWeb EmeditWeb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review verdict: ✅ APPROVE with minor corrections

Solid money-path work. The new liquidity client and service wiring are clean:

  • STROOPS = 10_000_000n and Math.round(amount * 10_000_000) — correct 7-decimal conversion (avoids the * 100 bug fixed in #89).
  • Share-price math for deposit/withdraw; proper service/client separation; BadRequestException on failure; no any in the new client; e2e + unit tests added. CI green.

Minor corrections:

  1. liquidity.service.ts:279handleContractError(error: any, operation: string) uses any. Per code-standards, use unknown and narrow (e.g. error instanceof Error).
  2. Cross-verify the deposit/withdraw 2-arg call signatures against the deployed liquidity-pool contract (same class of check as #90 for repay; lower risk since deposit/withdraw are simpler and more stable).

Merge-ready once the any is addressed.

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.

[9] Wire LiquidityContractClient into LiquidityService

2 participants