Contract 5e0bff5a29e2473b5289fe96aeb59b48ac335e5e87c46632b53be1f662447d2c

← Back to Index 📥 Download WASM

Meta

rssdkver 22.0.7#211569aa49c8d896877dfca1f2eb4fe9071121c8
rsver 1.86.0

Instances

  • CAYP3UWLJM7ZPTUKL6R6BFGTRWLZ46LRKOXTERI2K6BIJAWGYY62TXTO

Interface

Initializes the contract and sets the soroswap_router address.

Arguments

  • e - The environment in which the contract is running.
  • admin - The address of the administrator.
  • adapter_vec - A vector containing the adapters to be initialized.

Errors

Returns an AggregatorError::AlreadyInitialized error if the contract is already initialized.

Returns

Returns Ok(()) if the initialization is successful.

fn initialize(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    adapter_vec: soroban_sdk::Vec,
) -> Result<(), AggregatorError>

Updates the adapters in the contract.

This function overwrites any existing protocol address pairs if they exist. If an adapter does not exist, it will add it.

Arguments

  • e - The environment in which the contract is running.
  • adapter_vec - A vector containing the adapters to be updated.

Errors

Returns an AggregatorError if the contract is not initialized or if the caller is not the admin.

Returns

Returns Ok(()) if the adapters are successfully updated.

fn update_adapters(
    env: soroban_sdk::Env,
    adapter_vec: soroban_sdk::Vec,
) -> Result<(), AggregatorError>

Removes an adapter from the contract.

This function removes the adapter associated with the specified protocol ID.

Arguments

  • e - The environment in which the contract is running.
  • protocol_id - The ID of the protocol whose adapter is to be removed.

Errors

Returns an AggregatorError if the contract is not initialized or if the caller is not the admin.

Returns

Returns Ok(()) if the adapter is successfully removed.

fn remove_adapter(
    env: soroban_sdk::Env,
    protocol_id: Protocol,
) -> Result<(), AggregatorError>

Sets the paused state of the protocol in the aggregator.

Argumentsnts

  • e - The runtime environment.t.
  • protocol_id - The ID of the protocol to set the paused state for.
  • paused - The boolean value indicating whether the protocol should be paused or not.

Returns

Returns Ok(()) if the operation is successful, otherwise returns an AggregatorError.

fn set_pause(
    env: soroban_sdk::Env,
    protocol_id: Protocol,
    paused: bool,
) -> Result<(), AggregatorError>

Sets a new administrator for the contract.

This function updates the administrator of the contract to the specified new_admin address.

Arguments

  • e - The runtime environment.
  • new_admin - The address of the new administrator.

Errors

Returns an AggregatorError if the contract is not initialized or if the caller is not the current admin.

Returns

Returns Ok(()) if the operation is successful.

fn set_admin(
    env: soroban_sdk::Env,
    new_admin: soroban_sdk::Address,
) -> Result<(), AggregatorError>

Upgrades the contract with new WebAssembly (WASM) code.

This function updates the contract with new WASM code provided by the new_wasm_hash.

Arguments

  • e - The runtime environment.
  • new_wasm_hash - The hash of the new WASM code to upgrade the contract to.

Errors

Returns an AggregatorError if the contract is not initialized or if the caller is not the admin.

Returns

Returns Ok(()) if the upgrade is successful.

fn upgrade(
    env: soroban_sdk::Env,
    new_wasm_hash: soroban_sdk::BytesN<32>,
) -> Result<(), AggregatorError>

Swaps an exact amount of input tokens for output tokens across multiple DEXes.

This function performs a swap operation where an exact amount of input tokens is exchanged for output tokens, distributed across multiple DEXes as specified by the distribution parameter.

Arguments

  • e - The runtime environment.
  • token_in - The address of the input token.
  • token_out - The address of the output token.
  • amount_in - The exact amount of input tokens to be swapped.
  • amount_out_min - The minimum amount of output tokens expected to receive.
  • distribution - A vector specifying how the swap should be distributed across different DEXes.
  • to - The address to receive the output tokens.
  • deadline - The time by which the swap must be completed.

Errors

Returns an AggregatorError if any of the following conditions are met:

  • The parameters are invalid.
  • The swap amounts calculation fails.
  • There is an arithmetic error.
  • The final output amount is less than the minimum expected amount.

Retu

fn swap_exact_tokens_for_tokens(
    env: soroban_sdk::Env,
    token_in: soroban_sdk::Address,
    token_out: soroban_sdk::Address,
    amount_in: i128,
    amount_out_min: i128,
    distribution: soroban_sdk::Vec,
    to: soroban_sdk::Address,
    deadline: u64,
) -> Result>, AggregatorError>

Swaps tokens for an exact amount of output tokens across multiple DEXes.

This function performs a swap operation where tokens are exchanged for an exact amount of output tokens, distributed across multiple DEXes as specified by the distribution parameter.

Arguments

  • e - The runtime environment.
  • token_in - The address of the input token.
  • token_out - The address of the output token.
  • amount_out - The exact amount of output tokens to be received.
  • amount_in_max - The maximum amount of input tokens to be spent.
  • distribution - A vector specifying how the swap should be distributed across different DEXes.
  • to - The address to receive the output tokens.
  • deadline - The time by which the swap must be completed.

Errors

Returns an AggregatorError if any of the following conditions are met:

  • The parameters are invalid.
  • The swap amounts calculation fails.
  • There is an arithmetic error.
  • The final input amount exceeds the maximum allowed.

Returns

Returns a vector of vectors

fn swap_tokens_for_exact_tokens(
    env: soroban_sdk::Env,
    token_in: soroban_sdk::Address,
    token_out: soroban_sdk::Address,
    amount_out: i128,
    amount_in_max: i128,
    distribution: soroban_sdk::Vec,
    to: soroban_sdk::Address,
    deadline: u64,
) -> Result>, AggregatorError>

Retrieves the administrator address of the contract.

This function returns the current administrator address of the contract.

Arguments

  • e - A reference to the runtime environment.

Errors

Returns an AggregatorError if the contract is not initialized.

Returns

Returns the address of the current administrator if the operation is successful.

fn get_admin(env: soroban_sdk::Env) -> Result
fn get_adapters(
    env: soroban_sdk::Env,
) -> Result, AggregatorError>

Retrieves the paused state of a specific protocol adapter.

This function returns whether the adapter associated with the specified protocol_id is currently paused.

Arguments

  • e - A reference to the runtime environment.
  • protocol_id - The ID of the protocol whose paused state is to be retrieved.

Errors

Returns an AggregatorError if there are issues retrieving the adapter or if the protocol ID is not found.

Returns

Returns true if the adapter is paused, otherwise false.

fn get_paused(
    env: soroban_sdk::Env,
    protocol_id: Protocol,
) -> Result

Retrieves the version number of the contract.

This function returns the version number of the contract. If the WebAssembly (WASM) code is updated, this number should be increased accordingly to reflect the new version.

Returns

Returns the current version number of the contract as a u32.

fn get_version(env: soroban_sdk::Env) -> u32

Imports

WebAssembly Text (WAT) ▶