AmpliDex Technical Architecture
1. Purpose and Scope
AmpliDex is a non-custodial leveraged-markets and liquidity protocol designed for Stellar Soroban. Liquidity providers supply assets to isolated lending pools. Traders post collateral and borrow from those pools to create long or short exposure through approved Stellar execution venues. Interest accrues through pool-level borrow indexes, while positions remain subject to deterministic solvency rules at every relevant protocol transition and may be independently monitored for permissionless liquidation eligibility. AmpliDex is designed around five production principles:- keep financial authority and settlement on Stellar/Soroban;
- isolate markets and external dependencies so failures remain bounded;
- constrain, delay, and expose privileged actions;
- preserve permissionless repayment, exits, and liquidation wherever safe; and
- allow EVM users to access Stellar-native positions without introducing backend custody.
- isolated lending pools;
- LP share accounting;
- indexed borrowing and interest accrual;
- leveraged long and short positions;
- bounded DEX execution;
- resilient pricing;
- deterministic solvency checks;
- permissionless liquidation;
- bad-debt accounting;
- indexing and query infrastructure;
- governance and upgrade controls; and
- production monitoring and operations.
2. Scope and Maturity
2.1 Capability Register
The architecture describes the intended production system. A capability appearing in this document does not imply that it has been deployed, audited, or classified as production-ready.
“MVP validated” reflects implementation or validation claims associated with the current project scope. Before external production claims are made, each relevant capability must be linked to verifiable evidence such as a repository release, deployed contract ID, automated test report, transaction record, review artifact, or reproducible build.
For canonical release status and supporting artifacts, see Production Readiness & Evidence.
2.2 Release Non-Goals
The production release does not target:- replicated leveraged-position state across multiple chains;
- arbitrary user-supplied DEX contracts;
- arbitrary user-supplied execution routes;
- arbitrary user-supplied price feeds;
- backend custody;
- server-held user signing keys;
- uncapped permissionless market listing;
- guaranteed LP withdrawal liquidity during high utilization;
- complete transaction anonymity;
- unreviewed automatic contract upgrades; or
- hidden socialization of bad debt across unrelated markets.
3. System Context
The authoritative financial state remains on Stellar. Off-chain systems improve discovery, monitoring, transaction preparation, and automation but cannot redefine balances, debt, position health, or liquidation eligibility.3.1 Trust Boundaries
4. Architecture Principles
Single settlement domain
Liquidity, debt, positions, fees, and liquidations settle on Stellar/Soroban.On-chain authority; off-chain acceleration
Backends, indexers, APIs, keepers, and interfaces improve usability and liveness but cannot rewrite financial truth.Fail closed for added risk
Unsafe oracle, route, liquidity, market-cap, or execution conditions reject new risk.Preserve risk reduction
Repayment, margin addition, position reduction, close, and liquidation remain available whenever they can be performed safely.Least privilege
Governance, guardian, deployer, keeper, CI, infrastructure, and operational identities are separate and narrowly scoped.Deterministic execution
Protocol-managed assets interact only with registered adapters and bounded execution routes.Market isolation
Risk caps, pools, pricing rules, routes, liquidation behavior, and emergency controls are defined per market.Atomicity and idempotency
On-chain financial transitions are atomic. Off-chain event processing is replay-safe and idempotent.Explicit failure domains
A failure in a DEX, oracle, keeper, indexer, RPC provider, bridge, or staged extension must not implicitly corrupt unrelated market accounting.Measurable operations
Safety-relevant signals have explicit metrics, owners, alert thresholds, and runbooks.5. On-Chain Architecture
5.1 Contract Topology
5.2 Canonical Records
- versioned;
- bounded;
- idempotent;
- migration-order aware; and
- tested against serialized production-shaped state.
- source commit;
- release tag;
- compiler and toolchain versions;
- reproducible WASM hash;
- Stellar network;
- contract ID;
- migration version;
- deployment configuration; and
- governance authorization transaction.
5.3 Market Configuration
Each market defines:- enabled operations;
- emergency state;
- base and quote assets;
- asset decimal scales;
- pool supply cap;
- borrow cap;
- utilization limits;
- maximum position size;
- market open-interest cap;
- maximum borrow multiplier;
- warning margin;
- maintenance margin;
- opening fee;
- closing fee;
- reserve factor;
- liquidation fee or incentive;
- approved execution routes;
- maximum route hops;
- route liquidity floors;
- user and protocol slippage limits;
- approved reference-price sources;
- maximum oracle age;
- price-deviation threshold;
- degraded-mode policy;
- minimum position size; and
- minimum residual-position size.
6. Economic Model
6.1 Pool and LP Accounting
For an established pool, deposits mint LP shares using the pre-deposit exchange rate:- empty-pool initialization;
- minimum initial liquidity;
- donation behavior;
- share-price manipulation protections;
- deposit rounding direction;
- withdrawal rounding direction;
- dust handling;
- token decimal normalization;
- fee-on-transfer token rejection;
- reserve treatment;
- loss realization; and
- behavior when losses reduce the LP exchange rate.
6.2 Debt and Interest
Debt is represented through a pool-level borrow index. Conceptually:- elapsed-time limits;
- fixed-point arithmetic limits;
- maximum configured interest rate;
- overflow-safe multiplication/division; and
- defined maximum accrual intervals.
- time basis;
- compounding convention;
- fixed-point scale;
- interest-accrual granularity;
- maximum rate;
- reserve accounting;
- rounding direction; and
- reference test vectors.
6.3 Leverage Semantics
AmpliDex uses borrow multiplier, not gross-exposure multiplier.in the initial traded notional. For a fully deployed position: position_exposure = borrowed_notional Example:
6.4 Position State Machine
A long position borrows USDC and acquires the market asset. A short position borrows the market asset and sells it into USDC or the configured quote asset. Every open or increase operation validates, within the authoritative transaction:- market status;
- user authorization;
- collateral;
- pool capacity;
- borrow cap;
- position cap;
- open-interest cap;
- price environment;
- execution-route bounds;
- route liquidity;
- realized balance changes;
- resulting holdings;
- fees; and
- resulting margin.
- collateral;
- holdings;
- debt;
- realized PnL;
- protocol fees; and
- residual state
- dust-sized;
- structurally invalid;
- outside current caps;
- under minimum collateral requirements; or
- immediately liquidatable.
Closed.
6.5 Position Risk Calculation
Risk evaluation considers both independent reference pricing and realizable execution value. Collateral remains committed as loss-absorbing margin and is accounted for separately from the assets or proceeds representing the leveraged position. For a long position:- initial position exposure;
- current position exposure;
- positive and negative equity;
- treatment of collateral;
- treatment of short-sale proceeds;
- valuation units;
- margin denominator;
- warning and maintenance-margin thresholds;
- liquidation equality conditions;
- accrued-interest treatment;
- fee ordering;
- liquidation incentive priority;
- decimal normalization;
- rounding direction;
- residual collateral;
- negative-value handling; and
- behavior when no executable quote exists.
7. Execution and Pricing
7.1 Execution Router
The AmpliDex Core invokes only execution routes registered through governed configuration. A route binds:- market;
- direction;
- adapter;
- venue;
- input asset;
- output asset;
- path;
- maximum hops;
- quote expiration;
- liquidity floor;
- protocol slippage ceiling;
- optional route priority; and
- enabled status.
- is enabled;
- matches the expected market and asset direction;
- uses an approved adapter;
- stays inside the user-signed maximum input or minimum output;
- stays inside protocol-level slippage limits;
- stays inside configured price-deviation limits;
- satisfies freshness requirements;
- meets configured liquidity requirements; and
- produces an actual balance delta consistent with the executed operation.
7.2 Oracle Router
AmpliDex distinguishes between two pricing concepts.Reference price
An independent, freshness-checked observation used for:- solvency;
- margin evaluation;
- circuit breakers;
- price-deviation checks; and
- risk controls.
Executable price
A conservative approved-route quote used to estimate:- realizable sale value;
- asset repurchase cost;
- liquidation proceeds;
- closing cost; and
- execution viability.
- ledger or timestamp freshness;
- decimal normalization;
- source validity;
- cross-source deviation;
- route/reference deviation; and
- configured market policy.
Degraded Pricing Behavior
Exact behavior is defined per market before activation.
An oracle incident never silently substitute an unbounded spot price.
8. Liquidation and Bad Debt
8.1 Liquidation Eligibility
Liquidation eligibility is recalculated atomically in the settlement transaction. A keeper or liquidation buyer may identify and submit a candidate position, but cannot force a healthy position to liquidate. No off-chain service has authority to override on-chain eligibility.8.2 Liquidation Quote
A liquidation quote binds, where applicable:- position ID;
- position version;
- market;
- required buyer payment;
- debt principal;
- accrued interest;
- protocol fees;
- liquidation incentive;
- collateral delivered;
- reference price;
- executable price;
- quote ledger;
- expiry; and
- relevant route constraints.
- authorization;
- current position version;
- current position health;
- quote validity;
- debt;
- fees;
- route bounds;
- payment;
- collateral delivery; and
- market state.
- collects settlement value;
- repays the affected lending pool;
- distributes only configured and permitted fees;
- returns any eligible residual surplus to the position owner; and
- marks the position as
Liquidated.
8.3 Keeper Model
Keepers provide automation and liveness but are not protocol authorities. Multiple independent keepers may:- discover risky positions;
- simulate liquidation;
- submit liquidation transactions;
- rebroadcast after RPC failure; and
- monitor execution.
- do not control governance;
- do not control user accounts;
- do not decide liquidation eligibility;
- hold only bounded operating balances; and
- can be replaced without changing protocol solvency rules.
8.4 Bad Debt
Bad debt is recognized only after position-held assets and collateral have been exhausted. The intended loss waterfall is:- balances;
- contribution rules;
- per-market limits;
- global limits;
- epoch payout limits; and
- governance controls.
9. Off-Chain Platform
9.1 Event Indexer
Soroban contract events feed a replayable indexer with a durable ledger checkpoint. Event rows use deterministic identities such as:- account positions;
- pool activity;
- market history;
- utilization;
- liquidations;
- fees;
- execution activity;
- protocol metrics; and
- staged cross-chain status.
- resumes from the last durable checkpoint;
- tolerates duplicate event delivery;
- handles supported Stellar history semantics;
- detects gaps;
- replays deterministically;
- reconciles materialized state against contract reads; and
- exposes lag and reconciliation metrics.
9.2 Query API
The query API is:- versioned;
- read-oriented;
- paginated;
- rate-limited;
- cache-aware; and
- non-authoritative.
- markets;
- pools;
- positions;
- account history;
- liquidations;
- protocol metrics;
- route status;
- analytics; and
- cross-chain status where applicable.
9.3 Frontend and SDK
The non-custodial client is responsible for:- wallet connection;
- market discovery;
- authoritative state refresh;
- transaction construction;
- simulation;
- signing;
- submission;
- lifecycle feedback; and
- failure recovery guidance.
- contract state for balances, debt, configuration, position status, and eligibility;
- current simulation for transaction-specific effects and resource costs; and
- indexed data for discovery, history, and analytics.
10. Cross-Chain Access
10.1 EVM-Controlled Soroban Smart Accounts
An EVM-controlled Soroban smart account may hold Stellar assets and authorize scoped Soroban invocations after validating an EVM signature. An authorization binds at minimum:- EVM signer;
- Stellar network passphrase;
- smart-account address;
- target contract;
- invocation tree or invocation hash;
- nonce;
- validity window; and
- account implementation version.
10.2 Circle CCTP
Circle CCTP transports native USDC to and from the user-controlled Stellar account. CCTP does not transport:- AmpliDex position state;
- debt;
- LP shares;
- liquidation state; or
- protocol governance state.
- retry the AmpliDex operation;
- hold the USDC in their Soroban account;
- transfer the USDC to another Stellar account;
- use the USDC with another Stellar application; or
- separately authorize a CCTP transfer to bridge the USDC to a supported destination chain.
- source domain;
- destination domain;
- supported chains;
- finality assumptions;
- message uniqueness and replay protection;
- duplicate-message behavior;
- attestation behavior;
- retry and idempotency handling;
- partial-completion and recovery procedures; and
- operational monitoring.
11. Governance and Upgrade Safety
Production control consists of:- governance multisig or governor;
- timelock;
- narrowly scoped emergency guardian; and
- minimized deployment authority.
11.1 Role Boundaries
11.2 Emergency States
Granular emergency modes include:- emit on-chain events;
- identify the initiating role;
- carry bounded authority;
- have documented entry criteria;
- have documented exit criteria; and
- map to operational runbooks.
11.3 Upgrade Process
Production upgrades follow:12. Security Model
12.1 Critical Invariants
Critical invariants include:- LP shares cannot create value through deposit or withdrawal rounding.
- Withdrawals cannot exceed the user’s economic ownership.
- Withdrawals cannot exceed available pool cash.
- Accrued debt cannot decrease except through repayment, settlement, or explicit recognized loss.
- Borrowing cannot exceed pool, asset, market, or position limits.
- A newly opened or increased position cannot be immediately liquidatable.
- Partial close cannot leave invalid or unaccounted state.
- Only registered adapters and bounded routes may move protocol-managed trade assets.
- Stale or conflicting pricing conditions cannot create new leveraged exposure.
- Liquidation eligibility is recalculated in the settlement transaction.
- Fees cannot consume unrelated LP principal.
- Fees cannot exceed configured or economically valid limits.
- Bad debt is explicit and isolated to its configured loss domain.
- Indexed or API state cannot authorize financial transitions.
- User bounds cannot be loosened by route fallback.
- An EVM authorization cannot replay across nonce, account, contract, version, or Stellar network.
- A failed AmpliDex operation after successful CCTP mint leaves the minted funds under user control.
- Privileged actors cannot arbitrarily transfer user or LP balances.
- Emergency modes may reduce risk but may not silently rewrite economic ownership.
12.2 Threats and Controls
All financial arithmetic uses:
- checked integers;
- fixed-point representations;
- normalized decimals;
- overflow-safe
mul_divpatterns; - explicit rounding rules; and
- no floating-point arithmetic.
13. Verification and Assurance
13.1 Test Strategy
Unit tests
Cover:- interest;
- borrow indexes;
- LP shares;
- fees;
- decimal normalization;
- margin;
- liquidation thresholds;
- slippage;
- configuration validation;
- authorization; and
- error conditions.
Property tests
Verify properties such as:- asset conservation;
- debt monotonicity absent repayment;
- no rounding extraction;
- bounds never loosen;
- invalid routes cannot execute;
- healthy positions cannot liquidate; and
- user authorization cannot replay.
Stateful fuzz tests
Exercise long operation sequences including:- deposit;
- withdrawal;
- borrow;
- repay;
- open;
- increase;
- add margin;
- repeated partial close;
- liquidation;
- loss events;
- extreme time jumps;
- dust;
- mixed decimals; and
- cap transitions.
Integration tests
Cover:- Aquarius adapter;
- Soroswap adapter;
- oracle adapters;
- route fallback;
- pricing disagreement;
- RPC failure;
- indexer replay;
- reconciliation;
- contract migration; and
- staged cross-chain components where enabled.
Adversarial tests
Cover:- manipulated DEX prices;
- stale reference sources;
- divergent oracle sources;
- front-running;
- keeper races;
- liquidation-buyer races;
- replay attempts;
- malicious token behavior;
- resource exhaustion; and
- invalid cross-domain authorization.
End-to-end tests
Validate the full lifecycle on testnet:13.2 CI Requirements
CI blocks merge on applicable failures in:- formatting;
- linting;
- contract build;
- unit tests;
- property tests;
- integration tests;
- known-vulnerability policy;
- generated-binding drift;
- reproducible artifact generation; and
- dependency-lock consistency.
13.3 Independent Review
Independent security review is scoped by subsystem. Required review domains include:- core economics;
- contract accounting;
- position-state transitions;
- liquidation;
- DEX integrations;
- oracle integrations;
- governance;
- upgrade and emergency authorization;
- EVM smart-account authentication before activation; and
- CCTP recovery and integration behavior before cross-chain launch.
- reviewed commit;
- review scope;
- findings;
- remediation commits;
- retest status; and
- accepted residual risk where applicable.
14. Reliability, Observability, and Operations
14.1 Service Objectives
Targets are validated under production-shaped load and failure testing.
These values are operational targets and may evolve based on production measurements.
14.2 Metrics
Operational metrics include:Pools
- cash;
- borrows;
- utilization;
- reserves;
- share price;
- deposit flow;
- withdrawal flow.
Positions
- open interest;
- side distribution;
- margin distribution;
- warning positions;
- liquidatable positions;
- close volume;
- bad debt.
Execution
- route usage;
- quote failures;
- execution failures;
- slippage;
- route fallback;
- liquidity-floor violations.
Pricing
- reference-source age;
- source availability;
- cross-source deviation;
- reference/executable deviation;
- degraded-mode transitions.
Liquidation
- candidate count;
- submission latency;
- success rate;
- buyer participation;
- keeper activity;
- race frequency;
- unpaid debt.
Infrastructure
- RPC latency and failure;
- indexer lag;
- indexer reconciliation;
- database health;
- API latency;
- keeper heartbeat;
- keeper operating balance.
Cross-chain
Where staged CCTP access is enabled:- burn state;
- attestation duration;
- mint duration;
- retry count;
- unresolved transfers; and
- recovery events.
14.3 Alerts and Runbooks
Alerts define:- severity;
- threshold;
- owner;
- escalation;
- suppression policy; and
- linked runbook.
- oracle divergence;
- stale pricing;
- DEX or adapter failure;
- abnormal utilization;
- liquidation backlog;
- bad debt;
- RPC outage;
- indexer replay;
- indexer rebuild;
- reconciliation failure;
- database recovery;
- compromised keys;
- governance incident;
- contract-upgrade failure;
- CCTP delay;
- smart-account incident; and
- frontend compromise.
14.4 Operational Security
Secrets are stored in managed secret systems. Governance and upgrade keys use hardware-backed multisig or threshold custody where applicable. Deployer authority is removed or minimized after handoff. Keeper credentials, CI credentials, RPC secrets, and database credentials are:- scoped;
- rotated;
- monitored; and
- independently revocable.
15. Deployment and Release
The production release process follows:- few markets;
- conservative borrow multipliers;
- low supply caps;
- low borrow caps;
- low open-interest caps;
- conservative utilization;
- strict oracle-deviation limits;
- limited execution routes; and
- at least two independently operated keeper paths where keeper automation is required.
- utilization;
- route execution;
- oracle behavior;
- liquidation latency;
- bad debt;
- infrastructure reliability; and
- incident history.
- source tag;
- immutable source commit;
- dependency lockfiles;
- SBOM where applicable;
- compiler version;
- Stellar toolchain version;
- WASM hash;
- deployed contract IDs;
- configuration manifest;
- migration manifest;
- automated test summary;
- audit references;
- signer approval; and
- rollback or forward-fix plan.