Contract b0fe36b2b294d0af86846ccc4036279418907b60f6f74dae752847ae9d3bca0e

← Back to Index 📥 Download WASM

Meta

rssdkver 22.0.6#0c47dcfa187069d241f11fb082730f667b55e802
rsver 1.85.0

Instances

  • CDKFHFJIET3A73A2YN4KV7NSV32S6YGQMUFH3DNJXLBWL4SKEGVRNFKI
  • CDOIC7245ONYVOTEDLGKUM263EQ7SEEQ74ZQCN4SSH4TSYXOCMU6254O

Interface

Initializes the factory contract with the given parameters.

Arguments

  • e - The environment in which the contract is running.
  • admin - The address of the contract administrator who can manage settings.
  • defindex_receiver - The default address designated to receive the DeFindex portion of fees.
  • defindex_fee - The initial fee rate in basis points (1 basis point = 0.01%).
  • vault_wasm_hash - The hash of the DeFindex Vault's WASM file used for deploying new vaults.

Behavior

  1. Sets the initial admin address
  2. Sets the initial DeFindex fee receiver address
  3. Sets the initial vault WASM hash
  4. Sets the initial DeFindex fee rate
  5. Extends the contract instance's time-to-live
fn __constructor(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    defindex_receiver: soroban_sdk::Address,
    defindex_fee: u32,
    vault_wasm_hash: soroban_sdk::BytesN<32>,
) -> Result<(), FactoryError>

Creates a new DeFindex Vault with the specified parameters.

Arguments

  • e - The environment in which the contract is running.
  • roles - A Map containing role identifiers (u32) and their corresponding Address assignments. Example roles include the manager and fee receiver.
  • vault_fee - The fee rate in basis points (1 basis point = 0.01%) allocated to the fee receiver.
  • assets - A vector of AssetStrategySet structs defining the strategies and assets managed by the vault.
  • soroswap_router - The Address of the Soroswap router, which facilitates swaps within the vault.
  • name_symbol - A Map containing the vault's name and symbol metadata (e.g., "name" -> "MyVault", "symbol" -> "MVLT").
  • upgradable - A boolean flag indicating whether the deployed vault contract should support upgrades.

Returns

  • Result<Address, FactoryError> - Returns the address of the newly created vault if successful, or an error if creation fails.
fn create_defindex_vault(
    env: soroban_sdk::Env,
    roles: soroban_sdk::Map,
    vault_fee: u32,
    assets: soroban_sdk::Vec,
    soroswap_router: soroban_sdk::Address,
    name_symbol: soroban_sdk::Map,
    upgradable: bool,
) -> Result

Creates a new DeFindex Vault with specified parameters and performs an initial deposit to set asset ratios.

Arguments

  • e - The environment in which the contract is running.
  • caller - The address of the caller, who must authenticate and provide the initial deposit.
  • roles - A Map containing role identifiers (u32) and their corresponding Address assignments. Example roles include the manager and fee receiver.
  • vault_fee - The fee rate in basis points (1 basis point = 0.01%) allocated to the fee receiver.
  • assets - A vector of AssetStrategySet structs defining the strategies and assets managed by the vault.
  • soroswap_router - The Address of the Soroswap router, which facilitates swaps within the vault.
  • name_symbol - A Map containing the vault's name and symbol metadata (e.g., "name" -> "MyVault", "symbol" -> "MVLT").
  • upgradable - A boolean flag indicating whether the deployed vault contract should support upgrades.
  • amounts - A vector of i128 values representing the
fn create_defindex_vault_deposit(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    roles: soroban_sdk::Map,
    vault_fee: u32,
    assets: soroban_sdk::Vec,
    soroswap_router: soroban_sdk::Address,
    name_symbol: soroban_sdk::Map,
    upgradable: bool,
    amounts: soroban_sdk::Vec,
) -> Result

Sets a new admin address.

Arguments

  • e - The environment in which the contract is running.
  • new_admin - The new administrator's address.

Returns

  • Result<(), FactoryError> - Returns Ok(()) if successful, or an error if not authorized.
fn set_new_admin(
    env: soroban_sdk::Env,
    new_admin: soroban_sdk::Address,
) -> Result<(), FactoryError>

Updates the default receiver address for the DeFindex portion of fees.

Arguments

  • e - The environment in which the contract is running.
  • new_fee_receiver - The address of the new fee receiver.

Returns

  • Result<(), FactoryError> - Returns Ok(()) if successful, or an error if not authorized.
fn set_defindex_receiver(
    env: soroban_sdk::Env,
    new_fee_receiver: soroban_sdk::Address,
) -> Result<(), FactoryError>

Updates the default fee rate for new vaults.

Arguments

  • e - The environment in which the contract is running.
  • defindex_fee - The new annual fee rate in basis points.

Returns

  • Result<(), FactoryError> - Returns Ok(()) if successful, or an error if not authorized.
fn set_defindex_fee(
    env: soroban_sdk::Env,
    defindex_fee: u32,
) -> Result<(), FactoryError>
fn set_vault_wasm_hash(
    env: soroban_sdk::Env,
    new_vault_wasm_hash: soroban_sdk::BytesN<32>,
) -> Result<(), FactoryError>

Retrieves the current admin's address.

Arguments

  • e - The environment in which the contract is running.

Returns

  • Result<Address, FactoryError> - Returns the admin's address or an error if not found.
fn admin(env: soroban_sdk::Env) -> Result

Retrieves the current DeFindex receiver's address.

Arguments

  • e - The environment in which the contract is running.

Returns

  • Result<Address, FactoryError> - Returns the DeFindex receiver's address or an error if not found.
fn defindex_receiver(
    env: soroban_sdk::Env,
) -> Result

Retrieves the total number of deployed DeFindex vaults.

Arguments

  • e - The environment in which the contract is running.

Returns

  • Result<u32, FactoryError> - Returns the total number of deployed vaults or an error if retrieval fails.
fn total_vaults(env: soroban_sdk::Env) -> Result

Retrieves a specific vault address by its index.

Arguments

  • e - The environment in which the contract is running.
  • index - The index of the vault to retrieve (0-based).

Returns

  • Result<Address, FactoryError> - Returns the vault address at the specified index or an error if not found.
fn get_vault_by_index(
    env: soroban_sdk::Env,
    index: u32,
) -> Result

Retrieves the current fee rate.

Arguments

  • e - The environment in which the contract is running.

Returns

  • Result<u32, FactoryError> - Returns the fee rate in basis points or an error if not found.
fn defindex_fee(env: soroban_sdk::Env) -> Result

Retrieves the WASM hash of the vault contract.

Arguments

  • e - The environment in which the contract is running.

Returns

  • Result<BytesN<32>, FactoryError> - Returns the 32-byte WASM hash of the vault contract or an error if the contract is not properly initialized.

Behavior

  1. Assumes that the contract is initialized by the constructor.
  2. Extends the instance's time-to-live (TTL) by invoking extend_instance_ttl(&e).
  3. Retrieves and returns the vault WASM hash by calling get_vault_wasm_hash(&e).
fn vault_wasm_hash(
    env: soroban_sdk::Env,
) -> Result, FactoryError>

Imports

WebAssembly Text (WAT) ▶