Function balancedWithdrawalMacro

  • Corrects a user inputs and returns relevant withdrawal values

    Parameters

    • vaults: VaultInformation[]

      The vaults which are in the pool

    • userVaultTokens: bigint[]

      User's vault tokens. This is used to balance the withdrawal between the vaults.

    • userInput: {
          tokenIndex: number;
          value: bigint;
          vaultIndex: number;
      }

      The reference value which is used for the compute the rest of the balanced withdrawal.

      • tokenIndex: number
      • value: bigint
      • vaultIndex: number

    Returns {
        newUserInputs: bigint[][];
        vaultTokensToWithdraw: bigint[];
    }

    • newUserInputs: bigint[][]
    • vaultTokensToWithdraw: bigint[]

    Dev

    We do not check if the user has enough vault tokens. The user of this function should check that vaultTokensToWithdraw <= userVaultTokens