Function findOptimalDepositValues

  • Parameters

    • vaults: VaultInformation[]

      The vaults which are in the pool

    • userBalances: bigint[][]
    • userInputs: bigint[][]

      The user's current inputs.

    Returns {
        newUserInputs: bigint[][];
        restrictingBalanceIndex: [number, number];
    }

    newUserInputs The new user inputs

    • newUserInputs: bigint[][]
    • restrictingBalanceIndex: [number, number]

    Notice

    Returns a balanced deposit array constrainted by the user's balances and inputs.

    Dev

    Implemented by finding the ratios between all assets to be deposited. Then it divides userInputs and userBalances by the ratios to get values which can be compared with each other. Then the largest of userInputs is selected. Then it is compared against the user balances. If a conflict is found, the smallest is used. If a user balance is 0, it is ignored.