Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/docs/architecture/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Builds an unsigned Soroban deposit transaction.
}
```

The `xdr` field is a base64-encoded unsigned `TransactionEnvelope`. The `fee` is the simulated resource fee in stroops. The client must forward the XDR to the wallet for signing before submitting.
The `xdr` field is a base64-encoded unsigned `TransactionEnvelope`. The `fee` is the assembled transaction's total fee in stroops, including the inclusion fee. The client must forward the XDR to the wallet for signing before submitting.

### `POST /api/v1/tx/withdraw`

Expand Down
3 changes: 2 additions & 1 deletion docs/signing-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ Response `200`:

- `xdr` — base64 transaction envelope, **unsigned**, already prepared via
`assembleTransaction` (Soroban footprint + resource fee included).
- `fee` — the simulated `minResourceFee` in stroops, for display.
- `fee` is the assembled transaction's total fee in stroops, including the
inclusion fee, for display.

### `POST /api/v1/tx/withdraw`

Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface Position {
export interface Transaction {
/** Base64-encoded unsigned Soroban transaction XDR. */
xdr: string;
/** Minimum Soroban resource fee in stroops, returned by simulation. */
/** Total assembled transaction fee in stroops, including the inclusion fee. */
fee: string;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/stellar-sdk-helpers/src/keeper-tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export interface KeeperTxConfig {
// confirmed on-chain failure). Callers must persist `priorHash` across their
// own retry attempts (see accrual-keeper.ts and migration-keeper.ts), and
// persist it across invocations through `hooks` (see keeper-state.ts).
// `attempt` (1-indexed, matching withKeeperRetry's own callback, see
// `attempt` (0-indexed, matching withKeeperRetry's callback, see
// keeperFeeForAttempt above) sets the classic inclusion fee for a
// freshly-built transaction, escalating on each retry so a
// `txInsufficientFee` rejection has a real chance of clearing next time;
Expand Down
22 changes: 22 additions & 0 deletions packages/stellar-sdk-helpers/src/tx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Asset,
Contract,
Operation,
SorobanDataBuilder,
TransactionBuilder,
nativeToScVal,
xdr,
Expand Down Expand Up @@ -245,6 +246,27 @@ describe("simErrorMessage snapshots", () => {
describe("prepareSorobanTx contract errors", () => {
afterEach(() => vi.restoreAllMocks());

it("returns the assembled transaction fee, including its inclusion fee", async () => {
const caller = "GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5";
const op = new Contract(CONTRACT_ADDRESSES.testnet.vault).call("deposit");
const account = new Account(caller, "0");

vi.spyOn(rpc.Server.prototype, "getAccount").mockResolvedValue(account);
vi.spyOn(rpc.Server.prototype, "simulateTransaction").mockResolvedValue({
id: "1",
latestLedger: 1,
minResourceFee: "500",
events: [],
transactionData: new SorobanDataBuilder().setResourceFee("500"),
result: { auth: [], retval: xdr.ScVal.scvVoid() },
_parsed: true,
});

await expect(prepareSorobanTx(TESTNET, caller, op)).resolves.toMatchObject({
fee: "600",
});
});

it.each([
["HostError: Error(Contract, #18)", true],
["HostError: Error(Contract, #15)", true],
Expand Down
5 changes: 3 additions & 2 deletions packages/stellar-sdk-helpers/src/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ export async function simulateView(
/**
* Fetch the caller's account, simulate the operation to obtain the resource
* footprint and fee, assemble the transaction, and return the unsigned XDR
* and minimum resource fee. Throws if simulation fails.
* and total transaction fee, including the inclusion fee. Throws if
* simulation fails.
*/
export async function prepareSorobanTx(
network: StellarNetwork,
Expand Down Expand Up @@ -227,7 +228,7 @@ export async function prepareSorobanTx(
const prepared = rpc.assembleTransaction(tx, sim).build();
return {
xdr: prepared.toEnvelope().toXDR("base64"),
fee: sim.minResourceFee,
fee: prepared.fee,
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/stellar-sdk-helpers/src/vaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ async function fetchMeridianVault(
"Meridian adapter RPC"
),
]);
const tvl = Math.round(Number(toBigInt(totalAssetsRaw) ?? 0n) / 1e7);
const tvl = Math.round(Number(toBigInt(totalAssetsRaw)) / 1e7);
return {
...meta,
asset: meta.asset ?? "USDC",
Expand Down
Loading