Vault Flow

Actors:

  • User: Can deposit, withdraw, and query share values.

  • Admin: Can initiate bridging operations.

  • Executor: Can add fees, add reserves, and request funds.

  • Gateway: Can add reserves.

Vault Smart Contract Actions:

  • Deposit: Increases total shares, user shares, and total deposited amount.

  • Withdraw: Decreases total shares, user shares, and total deposited amount.

  • Add Fees: Adds fees and increases value of each share in the vault.

  • Add Reserves: Doesn't change the total deposited amount but increases available funds. Used by executors and during bridging.

  • Request Funds: Allows the executor to withdraw funds without changing the total deposited amount.

  • Bridge: Decreases the total deposited amount as tokens are moved to another network.

  • Get Share Value: Reads the total shares and total deposited amount to calculate share value.

Flow:

  • Users interact with Deposit, Withdraw, and Get Share Value functions.

  • Admin can initiate bridging operations.

  • Executor and Gateway can add fees and reserves, with the Executor also able to request funds.

  • When fees are transferred from the executor, the total balance state variable of the contract is increased, leading to an increase in the price for every share.

Diagram Code
sequenceDiagram
    participant User
    participant Admin
    participant Executor
    participant Gateway
    participant Vault

    User->>+Vault: deposit(amount)
    Vault-->>-User: Deposit confirmed

    User->>+Vault: getShareValue(shares)
    Vault-->>-User: Share value

    User->>+Vault: withdraw(shares)
    Vault-->>-User: Tokens transferred

    Admin->>+Vault: bridge(networkIdentifier, amount)
    Vault->>Gateway: bridge(networkIdentifier, amount)
    Gateway-->>Vault: Bridge initiated
    Vault-->>-Admin: Bridge confirmed

    Executor->>+Vault: addFees(amount)
    Vault-->>-Executor: Fees added

    Executor->>+Vault: addReserves(amount)
    Vault-->>-Executor: Reserves added

    Executor->>+Vault: requestFunds(amount)
    Vault-->>-Executor: Funds transferred

    Gateway->>+Vault: addFees(amount)
    Vault-->>-Gateway: Fees added

    Gateway->>+Vault: addReserves(amount)
    Vault-->>-Gateway: Reserves added

    Note over Vault: Internal state updates:<br/>- Total Shares<br/>- User Shares<br/>- Total Deposited

Last updated