Initializes the contract and sets the soroswap_router address.
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.Returns an AggregatorError::AlreadyInitialized error if the contract is already initialized.
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.
e - The environment in which the contract is running.adapter_vec - A vector containing the adapters to be updated.Returns an AggregatorError if the contract is not initialized or if the caller is not the admin.
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.
e - The environment in which the contract is running.protocol_id - The ID of the protocol whose adapter is to be removed.Returns an AggregatorError if the contract is not initialized or if the caller is not the admin.
Returns Ok(()) if the adapter is successfully removed.
fn remove_adapter(
env: soroban_sdk::Env,
protocol_id: soroban_sdk::String,
) -> Result<(), AggregatorError>
Sets the paused state of the protocol in the aggregator.
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 Ok(()) if the operation is successful, otherwise returns an AggregatorError.
fn set_pause(
env: soroban_sdk::Env,
protocol_id: soroban_sdk::String,
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.
e - The runtime environment.new_admin - The address of the new administrator.Returns an AggregatorError if the contract is not initialized or if the caller is not the current admin.
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.
e - The runtime environment.new_wasm_hash - The hash of the new WASM code to upgrade the contract to.Returns an AggregatorError if the contract is not initialized or if the caller is not the admin.
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.
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.Returns an AggregatorError if any of the following conditions are met:
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,
bytes: Option>>,
) -> 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.
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.Returns an AggregatorError if any of the following conditions are met:
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,
bytes: Option>>,
) -> Result>, AggregatorError>
Retrieves the administrator address of the contract.
This function returns the current administrator address of the contract.
e - A reference to the runtime environment.Returns an AggregatorError if the contract is not initialized.
Returns the address of the current administrator if the operation is successful.
fn get_admin(env: soroban_sdk::Env) -> Result
Retrieves the list of adapters registered in the contract.
This function returns a vector containing all the adapters registered in the contract.
e - A reference to the runtime environment.Returns an AggregatorError if the contract is not initialized or if there are issues retrieving adapters.
Returns a vector of Adapter objects if the operation is successful.
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.
e - A reference to the runtime environment.protocol_id - The ID of the protocol whose paused state is to be retrieved.Returns an AggregatorError if there are issues retrieving the adapter or if the protocol ID is not found.
Returns true if the adapter is paused, otherwise false.
fn get_paused(
env: soroban_sdk::Env,
protocol_id: soroban_sdk::String,
) -> 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 the current version number of the contract as a u32.
fn get_version(env: soroban_sdk::Env) -> u32