fn upgrade(
env: soroban_sdk::Env,
new_wasm_hash: soroban_sdk::BytesN<32>,
operator: soroban_sdk::Address,
)
Initializes the coordinator contract by setting the owner, deployer, the initial publisher, the initial executor, and the treasury.
owner: The address of the owner of the coordinator contract.deployer: The address of the deployer of the coordinator contract.publisher: The address of the initial publisher of the coordinator contract.publisher_public_key: The public key of the initial publisher of the coordinator contract.executor: The address of the initial executor of the coordinator contract.executor_public_key: The public key of the initial executor of the coordinator contract.treasury: The address of the treasury of the coordinator contract.fn initialize(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
deployer: soroban_sdk::Address,
publisher: soroban_sdk::Address,
publisher_public_key: soroban_sdk::BytesN<32>,
executor: soroban_sdk::Address,
executor_public_key: soroban_sdk::BytesN<32>,
treasury: soroban_sdk::Address,
)
Updates the signature hashes of the Coordinator contract requiring the authorization of the Coordinator Owner. This function should be called after an upgrade to ensure that the signature verification uses the correct hashes for the new contract code.
fn update_signature_hashes(env: soroban_sdk::Env)
Sets the beacon of the Coordinator contract requiring the authorization of the Coordinator Owner.
beacon: The address of the new beacon for the coordinator contract.fn set_beacon(env: soroban_sdk::Env, beacon: soroban_sdk::Address)
Returns the current deployer of the Coordinator contract.
fn get_deployer(env: soroban_sdk::Env) -> soroban_sdk::Address
Updates the collateral deployer of the Coordinator contract requiring the authorization of the Coordinator Owner.
new_deployer: The address of the new deployer of the coordinator contract.fn update_collateral_deployer(
env: soroban_sdk::Env,
new_deployer: soroban_sdk::Address,
)
Returns the current treasury of the Coordinator contract.
fn get_treasury(env: soroban_sdk::Env) -> soroban_sdk::Address
Updates the treasury of the Coordinator contract requiring the authorization of the Coordinator Owner.
new_treasury: The address of the new treasury of the coordinator contract.fn update_treasury(env: soroban_sdk::Env, new_treasury: soroban_sdk::Address)
Returns the list of publishers of the Coordinator contract.
fn get_publishers(env: soroban_sdk::Env) -> soroban_sdk::Vec
Adds a new publisher to the list of publishers in the Coordinator contract requiring the authorization of the Coordinator Owner.
publisher: The address of the new publisher to add to the coordinator contract.public_key: The public key of the new publisher to add to the coordinator contract.fn add_publisher(
env: soroban_sdk::Env,
publisher: soroban_sdk::Address,
public_key: soroban_sdk::BytesN<32>,
)
Removes a publisher from the list of publishers in the Coordinator contract requiring the authorization of the Coordinator Owner.
publisher: The address of the publisher to remove from the coordinator contract.fn remove_publisher(env: soroban_sdk::Env, publisher: soroban_sdk::Address)
Returns the list of executors of the Coordinator contract.
fn get_executors(env: soroban_sdk::Env) -> soroban_sdk::Vec
Adds a new executor to the list of executors in the Coordinator contract requiring the authorization of the Coordinator Owner.
executor: The address of the new executor to add to the coordinator contract.public_key: The public key of the new executor to add to the coordinator contract.fn add_executor(
env: soroban_sdk::Env,
executor: soroban_sdk::Address,
public_key: soroban_sdk::BytesN<32>,
)
Removes an executor from the list of executors in the Coordinator contract requiring the authorization of the Coordinator Owner.
executor: The address of the executor to remove from the coordinator contract.fn remove_executor(env: soroban_sdk::Env, executor: soroban_sdk::Address)
Returns the hash of the Collateral contract of the Coordinator contract.
fn get_collateral_hash(env: soroban_sdk::Env) -> soroban_sdk::BytesN<32>
Sets the collateral hash of the Coordinator contract requiring the authorization of the Collateral Deployer.
hash: A 32-length byte array representing the hash of the Collateral contract's WASM.fn set_collateral_hash(env: soroban_sdk::Env, hash: soroban_sdk::BytesN<32>)
Creates a new collateral contract using the uploaded WASM, requiring the authorization of the Collateral Deployer.
fn create_collateral(
env: soroban_sdk::Env,
salt: soroban_sdk::BytesN<32>,
admin: soroban_sdk::Address,
name: soroban_sdk::String,
) -> soroban_sdk::Address
Returns the nonce of a collateral contract managed by the Coordinator contract.
collateral: The address of the collateral contract to get the nonce of.fn get_nonce(env: soroban_sdk::Env, collateral: soroban_sdk::Address) -> i128
Increases the nonce of a collateral contract requiring the authorization of the Executor.
env: The environment of the invocation.executor: The address of the executor of the coordinator contract that is increasing the
nonce.collateral: The address of the collateral contract to increase the nonce of.fn increase_collateral_nonce(
env: soroban_sdk::Env,
executor: soroban_sdk::Address,
collateral: soroban_sdk::Address,
)
Withdraws assets from a collateral contract requiring the authorization of the Executor/Publisher and collateral admins using their signatures.
env: The environment of the invocation.caller: The address of the caller of the withdrawal.collateral: The address of the collateral contract to withdraw the assets from.asset: The address of the asset to withdraw.amount: The amount of the asset to withdraw.recipient: The address of the recipient of the assets.expires_at: The expiration time of the executor's signature.salt: The salt used to generate the message signed by the executor.signature: The signature generated by the executor.public_key: The public key of the executor that is authorizing the action.fn withdraw_assets(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
collateral: soroban_sdk::Address,
asset: soroban_sdk::Address,
amount: i128,
recipient: soroban_sdk::Address,
expires_at: u64,
salt: soroban_sdk::BytesN<32>,
signature: soroban_sdk::BytesN<64>,
public_key: soroban_sdk::BytesN<32>,
)
Checks if a given asset is supported by the Coordinator contract.
asset: The address of the asset to check if it is supported.true if the asset is supported, false otherwise.
fn is_supported_asset(env: soroban_sdk::Env, asset: soroban_sdk::Address) -> bool
Converts an amount in cents to the amount in asset native decimals.
env: The environment of the invocation.asset: The address of the asset to convert the amount of.amount_cents: The amount in cents to convert.A tuple containing the amount in native currency and the decimals of the asset.
fn get_asset_amount_native(
env: soroban_sdk::Env,
asset: soroban_sdk::Address,
amount_cents: i128,
) -> (i128, u32)
Converts an amount in native currency to the amount in cents.
env: The environment of the invocation.asset: The address of the asset to convert the amount of.amount_native: The amount in asset native decimals to convert.A tuple containing the amount in cents and the decimals of the asset.
fn get_asset_amount_cents(
env: soroban_sdk::Env,
asset: soroban_sdk::Address,
amount_native: i128,
) -> (i128, u32)
Adds a new supported asset to the Coordinator contract requiring the authorization of the Coordinator Owner.
env: The environment of the invocation.asset: The address of the asset to add to the Coordinator contract.oracle: The address of the oracle to use for the asset.oracle_key: The key of the oracle to use for the asset.stale_threshold: The stale threshold in seconds to determine if the price is stale.min_price: The minimum valid price of the asset in cents.max_price: The maximum valid price of the asset in cents.payment_fee_bps: The fee in basis points of the asset to charge for payments of debt,
being 10000 equals to a 100% fee.liquidation_fee_bps: The fee in basis points of the asset to charge for liquidation of
statements, being 10000 equals to a 100% fee.fn add_supported_asset(
env: soroban_sdk::Env,
asset: soroban_sdk::Address,
oracle: Option,
oracle_key: Option,
stale_threshold: Option,
min_price: Option,
max_price: Option,
payment_fee_bps: i128,
liquidation_fee_bps: i128,
)
Removes a supported asset from the Coordinator contract requiring the authorization of the Coordinator Owner.
env: The environment of the invocation.asset: The address of the asset to remove from the Coordinator contract.CoordinatorError::AssetNotSupported: If the asset is not supported by the Coordinator
contract.fn remove_supported_asset(env: soroban_sdk::Env, asset: soroban_sdk::Address)
Returns the statement with the given ID.
env: The environment of the invocation.statement_id: The ID of the statement to get.The statement with the given ID.
CoordinatorError::StatementNotFound: If the statement with the given ID is not found.fn get_statement(env: soroban_sdk::Env, statement_id: soroban_sdk::String) -> Statement
Publishes a group of Statements requiring the authorization of the Publisher.
env: The environment of the invocation.publisher: The address of the publisher of the statements.collaterals: The addresses of the collaterals of the statements.statement_ids: The IDs of the statements to publish.team_ids: The IDs of the teams of the statements.closing_account_balance_cents: The closing account balance of the statements in cents.liquidatable_afters: The timestamps in seconds of the statements after which they can be
liquidated.fn publish_statements(
env: soroban_sdk::Env,
publisher: soroban_sdk::Address,
collaterals: soroban_sdk::Vec,
statement_ids: soroban_sdk::Vec,
team_ids: soroban_sdk::Vec,
closing_account_balance_cents: soroban_sdk::Vec,
liquidatable_afters: soroban_sdk::Vec,
)
Updates the information of an existing statement requiring the authorization of a Publisher.
env: The environment of the invocation.publisher: The address of the publisher that is authorizing the update.statement_id: The ID of the statement to update.team_id: The ID of the team that will own the statement.closing_account_balance_cents: The new debt balance of the statement in cents.collateral: The address of the new collateral that will be use to liquidate the statement.liquidatable_after: The new timestamp in seconds of the statement after which it can be
liquidated.CoordinatorError::StatementNotFound]: If the statement does not exist.CoordinatorError::InvalidTeamId]: If the team id is empty.CoordinatorError::BalanceMustBeGreaterThanZero]: If the closing account balance cents
is less or equal to zero.CoordinatorError::BalanceAlreadyPaid]: If the new closing account balance cents is less
than the paid amount.fn update_statement(
env: soroban_sdk::Env,
publisher: soroban_sdk::Address,
statement_id: soroban_sdk::String,
team_id: soroban_sdk::String,
closing_account_balance_cents: i128,
collateral: soroban_sdk::Address,
liquidatable_after: u64,
)
Marks a statement as paid requiring the authorization of the Executor.
env: The environment of the invocation.executor: The address of the executor that is marking the statement as paid.statement_id: The ID of the statement to mark as paid.amount_cents: The amount of the statement to mark as paid in cents.fn mark_statement_paid(
env: soroban_sdk::Env,
executor: soroban_sdk::Address,
statement_id: soroban_sdk::String,
amount_cents: i128,
)
Payments Management
Liquidates multiple statements requiring the authorization of the Executor.
env: The environment of the invocation.executor: The address of the executor that is liquidating the statements.statement_ids: The IDs of the statements to liquidate.assets: The assets to liquidate for each statement.max_statements_cents: The maximum amount in cents to liquidate for each statement.fn liquidate_asset(
env: soroban_sdk::Env,
executor: soroban_sdk::Address,
statement_ids: soroban_sdk::Vec,
assets: soroban_sdk::Vec>,
max_statements_cents: Option>>,
)
Makes a payment transferring the funds from the user that is calling the transaction to the treasury of the Coordinator.
env: The environment of the invocation.user: The address of the user that is making the payment.asset: The address of the asset to pay.amount_native: The amount of the asset to pay in asset native decimals.min_cents: The minimum amount in cents to pay.team_id: The ID of the team that is making the payment.fn make_payment_from_user_account(
env: soroban_sdk::Env,
user: soroban_sdk::Address,
asset: soroban_sdk::Address,
amount_native: i128,
min_cents: Option,
team_id: soroban_sdk::String,
)
Makes a payment transferring the funds from the user that is calling the transaction to the treasury of the Coordinator for a specific statement.
env: The environment of the invocation.user: The address of the user that is making the payment.asset: The address of the asset to pay.amount_native: The amount of the asset to pay in asset native decimals.min_cents: The minimum amount in cents to pay.statement_id: The ID of the statement that is making the payment.fn make_payment_from_ua_for_stmt(
env: soroban_sdk::Env,
user: soroban_sdk::Address,
asset: soroban_sdk::Address,
amount_native: i128,
min_cents: Option,
statement_id: soroban_sdk::String,
)
Makes a payment transferring the funds from a Collateral contract to the treasury of the Coordinator requiring the authorization of an executor or publisher via a signature with the specific invocation data.
env: The environment of the invocation.collateral: The address of the collateral that is making the payment.asset: The address of the asset to pay.amount: The amount of the asset to pay.min_cents: The minimum amount in cents to pay.expires_at: The expiration time of the signature.salt: The salt used to generate the signed message.signature: The signature generated by the executor.public_key: The public key of the executor that is authorizing the action.team_id: The ID of the team that is making the payment.fn make_payment_from_collateral(
env: soroban_sdk::Env,
collateral: soroban_sdk::Address,
asset: soroban_sdk::Address,
amount: i128,
min_cents: Option,
expires_at: u64,
salt: soroban_sdk::BytesN<32>,
signature: soroban_sdk::BytesN<64>,
public_key: soroban_sdk::BytesN<32>,
team_id: soroban_sdk::String,
)
Makes a payment transferring the funds from a Collateral contract to the treasury of the Coordinator for a specific statement requiring the authorization of an executor or publisher via a signature with the specific invocation data.
env: The environment of the invocation.collateral: The address of the collateral that is making the payment.asset: The address of the asset to pay.amount: The amount of the asset to pay.min_cents: The minimum amount in cents to pay.expires_at: The expiration time of the signature.salt: The salt used to generate the signed message.signature: The signature generated by the executor.public_key: The public key of the executor that is authorizing the action.team_id: The ID of the team that is making the payment.fn make_payment_from_col_for_stmt(
env: soroban_sdk::Env,
collateral: soroban_sdk::Address,
asset: soroban_sdk::Address,
amount: i128,
min_cents: Option,
expires_at: u64,
salt: soroban_sdk::BytesN<32>,
signature: soroban_sdk::BytesN<64>,
public_key: soroban_sdk::BytesN<32>,
team_id: soroban_sdk::String,
statement_id: soroban_sdk::String,
)
Returns the domain type hashes used for signature verification in the Coordinator
fn get_domain_type_hash(env: soroban_sdk::Env) -> soroban_sdk::Bytes
Returns the domain name hashes used in the Coordinator contract.
fn get_domain_name_hash(env: soroban_sdk::Env) -> soroban_sdk::Bytes
Returns the domain version hashes used in the Coordinator contract.
fn get_domain_version_hash(env: soroban_sdk::Env) -> soroban_sdk::Bytes
Returns the withdraw type hashes used in the Coordinator contract.
fn get_withdraw_type_hash(env: soroban_sdk::Env) -> soroban_sdk::Bytes
Returns the payment type hashes used in the Coordinator contract.
fn get_payment_type_hash(env: soroban_sdk::Env) -> soroban_sdk::Bytes
fn get_owner(env: soroban_sdk::Env) -> Option
fn transfer_ownership(
env: soroban_sdk::Env,
new_owner: soroban_sdk::Address,
live_until_ledger: u32,
)
fn accept_ownership(env: soroban_sdk::Env)
fn renounce_ownership(env: soroban_sdk::Env)