Skip to content

Implement transaction simulation before execution in VaultModule.deposit #8

Description

@Code-Paragon

Problem

The deposit method in src/modules/vault.ts constructs and submits the transaction immediately without simulating it first, as noted by an existing TODO, which could lead to failed transactions consuming network fees.

Expected behavior

The deposit method calls simulateTransaction on the built operation first. If the simulation fails, it throws a descriptive error before prompting the user for a signature.

Files to update

  • src/modules/vault.ts

Project relevance

This protects Liquidity Providers from paying network fees for transactions that will inevitably revert due to slippage or insufficient funds.

Acceptance criteria

  • Feature works as described
  • Tests are added or updated where needed
  • Documentation is updated where needed
  • Simulation response is validated using rpc.Api.isSimulationSuccess before buildAndSubmit is called
  • No TypeScript, lint, test, or build errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions