Atomic swap between USDM0 and USDM1 (port of EVM swapTokens).
Always requires a USDM1 price attestation (USDM0 is pegged at 1e7). The signed swap permit binds the input token, output token, amount, nonce, and validity window. The broker pulls input by allowance, burns the broker-held input, and mints output in one transaction.
fn swap_tokens(
env: soroban_sdk::Env,
swapper: soroban_sdk::Address,
input_token_id: u32,
amount: i128,
usdm1_price: PriceAttestation,
swap_permit: SwapPermitAttestation,
)
fn pause(env: soroban_sdk::Env, admin: soroban_sdk::Address)
fn sweep(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
sac: soroban_sdk::Address,
recipient: soroban_sdk::Address,
amount: i128,
)
fn unpause(env: soroban_sdk::Env, admin: soroban_sdk::Address)
fn upgrade(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
new_wasm_hash: soroban_sdk::BytesN<32>,
)
fn get_usdm0(env: soroban_sdk::Env) -> Option
fn get_usdm1(env: soroban_sdk::Env) -> Option
fn is_paused(env: soroban_sdk::Env) -> bool
fn get_config(env: soroban_sdk::Env) -> Config
fn assign_usdm0(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
usdm0: soroban_sdk::Address,
)
fn assign_usdm1(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
usdm1: soroban_sdk::Address,
)
fn __constructor(env: soroban_sdk::Env, admin: soroban_sdk::Address)
fn migrate_to_v2(env: soroban_sdk::Env, admin: soroban_sdk::Address)
fn set_base_fees(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
deposit_fee_bps: u32,
redemption_fee_bps: u32,
)
fn add_collateral(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
collateral: soroban_sdk::Address,
requires_attestation: bool,
deposit_fee_bps: u32,
redemption_fee_bps: u32,
)
fn compute_feed_id(
env: soroban_sdk::Env,
token: soroban_sdk::Address,
) -> soroban_sdk::BytesN<32>
fn get_beneficiary(env: soroban_sdk::Env) -> Option
fn get_collaterals(
env: soroban_sdk::Env,
) -> Option>
fn verify_signature(
env: soroban_sdk::Env,
public_key: soroban_sdk::BytesN<32>,
message: soroban_sdk::BytesN<32>,
signature: soroban_sdk::BytesN<64>,
)
fn enable_collateral(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
collateral: soroban_sdk::Address,
)
fn get_administrator(env: soroban_sdk::Env) -> soroban_sdk::Address
fn is_trusted_signer(
env: soroban_sdk::Env,
public_key: soroban_sdk::BytesN<32>,
) -> bool
fn remove_collateral(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
collateral: soroban_sdk::Address,
)
fn add_trusted_signer(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
public_key: soroban_sdk::BytesN<32>,
)
fn assign_beneficiary(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
beneficiary: soroban_sdk::Address,
)
fn disable_collateral(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
collateral: soroban_sdk::Address,
)
fn get_trusted_signers(
env: soroban_sdk::Env,
) -> Option, bool>>
fn set_collateral_fees(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
collateral: soroban_sdk::Address,
deposit_fee_bps: u32,
redemption_fee_bps: u32,
)
fn accept_administrator(env: soroban_sdk::Env, new_admin: soroban_sdk::Address)
fn get_contract_version(env: soroban_sdk::Env) -> u32
fn get_redemption_limit(
env: soroban_sdk::Env,
redeemer: soroban_sdk::Address,
) -> Option
fn rotate_administrator(
env: soroban_sdk::Env,
current_admin: soroban_sdk::Address,
new_admin: soroban_sdk::Address,
)
fn set_redemption_limit(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
redeemer: soroban_sdk::Address,
max_per_call: i128,
max_per_day: i128,
)
fn get_collateral_config(
env: soroban_sdk::Env,
collateral: soroban_sdk::Address,
) -> Option
fn remove_trusted_signer(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
public_key: soroban_sdk::BytesN<32>,
)
fn clear_redemption_limit(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
redeemer: soroban_sdk::Address,
)
fn reset_usdm_token_admin(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
usdm: soroban_sdk::Address,
new_admin: soroban_sdk::Address,
)
fn accept_usdm_token_admin(
env: soroban_sdk::Env,
usdm: soroban_sdk::Address,
new_admin: soroban_sdk::Address,
)
fn assert_contract_version(env: soroban_sdk::Env, expected: u32)
fn redemption_pool_balance(
env: soroban_sdk::Env,
collateral: soroban_sdk::Address,
) -> RedemptionPoolBalance
fn set_collateral_disabled(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
collateral: soroban_sdk::Address,
disabled: bool,
)
fn build_swap_permit_digest(
env: soroban_sdk::Env,
source: soroban_sdk::Address,
input_token: soroban_sdk::Address,
output_token: soroban_sdk::Address,
amount: i128,
nonce: u64,
not_before: u64,
not_after: u64,
) -> soroban_sdk::BytesN<32>
fn get_base_deposit_fee_bps(env: soroban_sdk::Env) -> u32
fn build_redeem_permit_digest(
env: soroban_sdk::Env,
source: soroban_sdk::Address,
payout_recipient: soroban_sdk::Address,
token: soroban_sdk::Address,
collateral: soroban_sdk::Address,
amount: i128,
nonce: u64,
not_before: u64,
not_after: u64,
) -> soroban_sdk::BytesN<32>
fn effective_redemption_limit(
env: soroban_sdk::Env,
redeemer: soroban_sdk::Address,
) -> EffectiveRedemptionLimit
fn build_deposit_permit_digest(
env: soroban_sdk::Env,
source: soroban_sdk::Address,
recipient: soroban_sdk::Address,
collateral: soroban_sdk::Address,
usdm: soroban_sdk::Address,
amount: i128,
nonce: u64,
not_before: u64,
not_after: u64,
) -> soroban_sdk::BytesN<32>
fn get_base_redemption_fee_bps(env: soroban_sdk::Env) -> u32
fn build_queue_redemption_digest(
env: soroban_sdk::Env,
redemption_id: soroban_sdk::BytesN<16>,
source: soroban_sdk::Address,
payout_recipient: soroban_sdk::Address,
token: soroban_sdk::Address,
collateral: soroban_sdk::Address,
amount: i128,
nonce: u64,
not_before: u64,
not_after: u64,
) -> soroban_sdk::BytesN<32>
fn get_default_redemption_limits(
env: soroban_sdk::Env,
) -> Option
fn set_default_redemption_limits(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
max_per_call: i128,
max_per_day: i128,
)
fn build_price_attestation_digest(
env: soroban_sdk::Env,
feed_id: soroban_sdk::BytesN<32>,
consumer: soroban_sdk::Address,
quote_id: soroban_sdk::BytesN<16>,
direction: u32,
index: i128,
not_before: u64,
not_after: u64,
) -> soroban_sdk::BytesN<32>
fn build_queue_redeem_permit_digest(
env: soroban_sdk::Env,
redemption_id: soroban_sdk::BytesN<16>,
source: soroban_sdk::Address,
payout_recipient: soroban_sdk::Address,
token: soroban_sdk::Address,
collateral: soroban_sdk::Address,
amount: i128,
nonce: u64,
not_before: u64,
not_after: u64,
) -> soroban_sdk::BytesN<32>
fn remaining_daily_redemption_limit(
env: soroban_sdk::Env,
redeemer: soroban_sdk::Address,
) -> RemainingDailyRedemptionLimit
Redeem USDM for collateral via permit + price attestation.
Atomic redemption: consumes the permit, transfers collateral from the beneficiary to the recipient, and burns USDM in one transaction. Collateral movement is allowance-based because the beneficiary owns the redemption pool outside the broker contract.
fn redeem(
env: soroban_sdk::Env,
source: soroban_sdk::Address,
token_id: u32,
amount: i128,
collateral: soroban_sdk::Address,
recipient: soroban_sdk::Address,
collateral_price: PriceAttestation,
usdm_price: PriceAttestation,
permit: RedeemPermitAttestation,
)
fn get_redemption(
env: soroban_sdk::Env,
redemption_id: soroban_sdk::BytesN<16>,
) -> Option
Queue a redemption for manual processing.
The queued path uses the same redemption nonce lane as redeem,
escrows USDM in the contract, and records one pending redemption per
redeemer. Fee policy, whitelist policy, and redemption sizing are
enforced before the queue permit is signed.
fn queue_redemption(
env: soroban_sdk::Env,
source: soroban_sdk::Address,
token_id: u32,
amount: i128,
collateral: soroban_sdk::Address,
recipient: soroban_sdk::Address,
collateral_price: PriceAttestation,
usdm_price: PriceAttestation,
permit: QueueRedemptionPermitAttestation,
)
Cancel a pending queued redemption and return escrowed USDM.
The redeemer can cancel their own pending redemption; the administrator can also cancel it as an operational escape hatch.
fn cancel_redemption(
env: soroban_sdk::Env,
signer: soroban_sdk::Address,
redemption_id: soroban_sdk::BytesN<16>,
)
Process a pending queued redemption.
Processing burns the escrowed USDM and pays collateral from the beneficiary to the queued recipient. The pending records are deleted before token movement so the ledger state no longer advertises an executable pending redemption after this point in the invocation.
fn process_redemption(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
redemption_id: soroban_sdk::BytesN<16>,
)
fn get_pending_redemption_id(
env: soroban_sdk::Env,
redeemer: soroban_sdk::Address,
) -> Option>
Atomic deposit via permit + price attestation (port of EVM deposit).
The caller authorizes the Soroban invocation, while the signed permit binds the source, recipient, collateral, USDM token, amount, nonce, and validity window that m1api approved off chain.
source
to beneficiary through allowance, and mints USDM to recipient.Fees, whitelist eligibility, and redemption limits are enforced before signing; the contract enforces the signed quote and permit.
fn deposit(
env: soroban_sdk::Env,
source: soroban_sdk::Address,
recipient: soroban_sdk::Address,
collateral: soroban_sdk::Address,
amount: i128,
token_id: u32,
collateral_price: PriceAttestation,
usdm_price: PriceAttestation,
permit: DepositPermitAttestation,
)