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
18 changes: 17 additions & 1 deletion client/src/pages/governance/TransactionBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ const RPC_URL =
const NETWORK_PASSPHRASE =
import.meta.env.VITE_NETWORK_PASSPHRASE ?? "Test SDF Network ; September 2015";

async function getRecommendedBaseFee(): Promise<string> {
try {
const response = await fetch("/api/fees");
if (!response.ok) return StellarSdk.BASE_FEE;
const payload = (await response.json()) as {
fees?: { average?: number };
};
const fee = payload.fees?.average;
if (!fee || !Number.isFinite(fee) || fee <= 0) return StellarSdk.BASE_FEE;
return String(Math.round(fee));
} catch {
return StellarSdk.BASE_FEE;
}
}

export default function TransactionBuilder({
threshold,
contractId,
Expand All @@ -38,6 +53,7 @@ export default function TransactionBuilder({
const server = new StellarSdk.rpc.Server(RPC_URL);
const contract = new StellarSdk.Contract(contractId);
const source = await server.getAccount(walletAddress);
const baseFee = await getRecommendedBaseFee();

// Build ScVal args: admin address + action-specific fields
const args: StellarSdk.xdr.ScVal[] = [
Expand All @@ -61,7 +77,7 @@ export default function TransactionBuilder({
}

const tx = new StellarSdk.TransactionBuilder(source, {
fee: StellarSdk.BASE_FEE,
fee: baseFee,
networkPassphrase: NETWORK_PASSPHRASE,
})
.addOperation(contract.call(action.method, ...args))
Expand Down
26 changes: 25 additions & 1 deletion client/src/services/soroban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ const ZAP_CONTRACT_ID = import.meta.env.VITE_ZAP_CONTRACT_ID ?? "";
const POLL_INTERVAL_MS = 2_000;
const POLL_TIMEOUT_MS = 30_000;

type FeePriority = "low" | "average" | "high";

interface FeeOraclePayload {
fees?: Partial<Record<FeePriority, number>>;
}

// ── Types ───────────────────────────────────────────────────────────────

export interface TxResult {
Expand All @@ -35,6 +41,23 @@ function getServer(): StellarSdk.rpc.Server {
return new StellarSdk.rpc.Server(RPC_URL);
}

async function getRecommendedBaseFee(priority: FeePriority = "average"): Promise<string> {
try {
const response = await fetch("/api/fees");
if (!response.ok) {
return StellarSdk.BASE_FEE;
}
const payload = (await response.json()) as FeeOraclePayload;
const fee = payload.fees?.[priority];
if (!fee || !Number.isFinite(fee) || fee <= 0) {
return StellarSdk.BASE_FEE;
}
return String(Math.round(fee));
} catch {
return StellarSdk.BASE_FEE;
}
}

function getContract(): StellarSdk.Contract {
if (!CONTRACT_ID) {
throw new Error("VITE_CONTRACT_ID is not configured");
Expand All @@ -61,9 +84,10 @@ async function buildContractCallOn(
): Promise<string> {
const server = getServer();
const source = await server.getAccount(sourcePublicKey);
const baseFee = await getRecommendedBaseFee("average");

const tx = new StellarSdk.TransactionBuilder(source, {
fee: StellarSdk.BASE_FEE,
fee: baseFee,
networkPassphrase: NETWORK_PASSPHRASE,
})
.addOperation(contract.call(method, ...args))
Expand Down
2 changes: 1 addition & 1 deletion contracts/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["yield_vault", "zap", "options", "aa_recovery", "aa_factory", "settlement", "intent_swap", "dutch_auction", "liquid_staking", "emission_controller", "strategies/delta_neutral", "stableswap", "stealth_addresses", "merkle_distributor"]
members = ["yield_vault", "zap", "options", "aa_recovery", "aa_factory", "settlement", "intent_swap", "dutch_auction", "liquid_staking", "emission_controller", "strategies/delta_neutral", "stableswap", "stealth_addresses", "merkle_distributor", "isolated_lending"]

[profile.release]
opt-level = "z"
Expand Down
13 changes: 13 additions & 0 deletions contracts/isolated_lending/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "isolated_lending"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
soroban-sdk = "22.0.0"

[dev-dependencies]
soroban-sdk = { version = "22.0.0", features = ["testutils"] }
Loading
Loading