Vault Smart Contract
This smart contract facilitates the issuance and management of yield-bearing tokens tied to a Bond Vault. It includes functionalities for initializing the contract, managing tokens, and handling administrative roles and actions. The smart contract manages the bond contract, minting and burning bonds.
Core Contract Functions
initialize
Description: Initializes the contract with necessary parameters and sets up the token and admin details.
Inputs:
token_wasm_hash: BytesN<32>
- The hash of the token contract. (use the official token from soroban-examples https://github.com/stellar/soroban-examples/tree/main/token)token: Address
- Address of the token.admin: Address
- Address of the administrator.start_time: u64
- Start time of the bond.end_time: u64
- End time of the bond.quote_period: u64
- Duration for which quotes are valid.treasury: Address
- Address of the treasury.min_deposit: u128
- Minimum deposit required.bond_symbol: String
- Symbol for the bond token.
Output:
Result<(), VaultError>
- Success or specific error code.
deposit
Description: Allows depositing tokens into the vault, issuing corresponding shares based on current quote.
Inputs:
from: Address
- Address from which tokens are deposited.amount: i128
- Amount of tokens to deposit.
Output:
Result<i128, VaultError>
- Amount of shares issued or an error code.
withdraw
Description: Withdraws tokens by burning the corresponding amount of shares and transferring the tokens to the specified address.
Inputs:
to: Address
- Address to which tokens are to be sent.amount: i128
- Amount of shares to redeem.
Output:
Result<i128, VaultError>
- Amount of tokens withdrawn or an error code.
set_quote
Description: Sets the current quote for the token shares.
Inputs:
amount: i128
- The new quote to be set.
Output:
Result<(), VaultError>
- Success or an error code indicating failure.
set_total_redemption
Description: Sets the total amount available for redemption at maturity.
Inputs:
amount: i128
- Total redemption amount to set.
Output:
Result<(), VaultError>
- Success or an error code.
set_treasury
Description: Updates the address of the treasury.
Inputs:
treasury: Address
- New treasury address.
Output:
Result<(), VaultError>
- Success or an error code.
set_admin
Description: Updates the administrator of the contract.
Inputs:
new_admin: Address
- New administrator address.
Output:
Result<(), VaultError>
- Success or an error code.
Administrative Functions
admin
Description: Retrieves the current administrator address.
Output:
Result<Address, VaultError>
- Current admin address or an error code.
maturity
Description: Retrieves the end time of the bond.
Output:
Result<u64, VaultError>
- End time or an error code.
total_bonds
Description: Retrieves the total number of shares issued.
Output:
Result<i128, VaultError>
- Total shares or an error code.
treasury_account
Description: Retrieves the address of the treasury.
Output:
Result<Address, VaultError>
- Treasury address or an error code.
Utility Functions
quote
Description: Retrieves the current quote for the token shares.
Output:
Result<i128, VaultError>
- Current quote or an error code.
total_deposit
Description: Retrieves the total amount of tokens deposited in the vault.
Output:
Result<i128, VaultError>
- Total deposited tokens or an error code.
available_redemption
Description: Retrieves the total available redemption amount.
Output:
Result<i128, VaultError>
- Available redemption amount or an error code.
Last updated