Function prepareWithdrawWithLiquiditySwap

  • Parameters

    • userVaultTokens: bigint[]

      The vault tokens held by the user.

    • userWithdrawals: bigint[][]

      The amounts the user wants to withdraw.

    • chains: {
          chainId: number;
          channelId: string;
      }[]

      The chains that the user is withdrawing from. Is a list of objects with channelId. Is specific to AMBs. ChainId is the id in gasMap.

    • vaults: VaultInformation[]

      The vaults that the user is withdrawing from. Between volatile and amplified there is a lot of unused variables. So while all arguments aren't used by both, they are used by either.

    • vaultAddresses: string[]

      The addresses of the vaults that the user is withdrawing from.

    • assetsAddresses: string[][]

      The addresses of the assets within the vaults. Needs to be complete.

    • userAddresses: string[]

      The addresses of the users on the other chains.

    • messageVerifyGasCosts: bigint[]

      The cost to verify a message by the underlying messaging protocol on the various chains. Can be found by calling the CCI on estimateAdditionalCost.

    • priceOfDeliveryGas: bigint[][]

      What is the incentive for gas on the destination chain? Is indexed by from, to (in source chain wei).

    • priceOfAckGas: bigint[]

      What is the ack incentive for gas on the source chain? Is indexed by from chain. (in source chain wei).

    • refundGasTo: string

      Where should unspent gas go? (which is released on acks).

    • unwrapGas: boolean[] = []

      If to unwrap gas on the destination chain. Gas is sent to userAddresses.

    Returns {
        gasUsage: {
            estimatedGasUsedOnLocalAck: bigint;
            estimatedGasUsedOnRemote: bigint;
            estimatedRoutingPayment: bigint;
        };
        routerArgs: RouterArguments | undefined;
        transferDetails: {
            amount: bigint;
            token: string;
        };
    }[]

    An array of objects, the sequence follows with the chain order specified in the input. Each object contains:

    • routerArgs: The router arguments for a specific chain.
    • gasUsage: The estimated gas consumption.
    • transferDetails: The details of the transfers to be made, including the token address and amount.

    Notice

    Prepares the router arguments for a withdrawal along with liquidity swaps to balance the withdrawal over the whole pool. After calling this method, you should call transferWithPermitForWithdrawWithLiquiditySwap on the returned router arguments object to add the transfer instructions to the router.

    Dev

    All lists should be equal length.