> ## Documentation Index
> Fetch the complete documentation index at: https://docs.glider.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# Portfolio Deposit with Simulation

> Generate a deposit transaction with full gas estimation and simulation

Generate a deposit transaction with full gas estimation and simulation.

<ParamField path="portfolioId" type="string" required>
  The unique identifier of the portfolio
</ParamField>

<ParamField body="tokenContractAddress" type="string" required>
  The contract address of the token to deposit, or "native" for ETH
</ParamField>

<ParamField body="tokenChainId" type="number" required>
  The chain ID where the token exists (e.g., 8453 for Base)
</ParamField>

<ParamField body="tokenAmount" type="string" required>
  The amount to deposit in base units (e.g., wei for ETH, without decimals)
</ParamField>

<ParamField body="userWalletAddress" type="string">
  Optional custom sender address (defaults to the portfolio owner address)
</ParamField>

<ParamField body="simulate" type="boolean" default="true">
  Set to true to perform full transaction simulation and gas estimation
</ParamField>

<ParamField header="X-API-KEY" type="string" required>
  Your API key for authentication
</ParamField>

<ParamField header="Content-Type" type="string" default="application/json">
  The format of the request body
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.glider.fi/v1/portfolio/port_abc123/deposit' \
    --header 'Content-Type: application/json' \
    --header 'X-API-KEY: your_api_key_here' \
    --data '{
      "tokenContractAddress": "native",
      "tokenChainId": 8453,
      "tokenAmount": "100000000000000000",
      "userWalletAddress": "0xCustomSenderAddress",
      "simulate": true
    }'
  ```

  ```javascript JavaScript theme={null}
  const depositWithSimulationResponse = await fetch(
    `https://api.glider.fi/v1/portfolio/${portfolioId}/deposit`,
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "X-API-KEY": "your_api_key_here",
      },
      body: JSON.stringify({
        tokenContractAddress: "native",
        tokenChainId: 8453,
        tokenAmount: "100000000000000000",
        userWalletAddress: "0xCustomSenderAddress",
        simulate: true, // Enable full transaction simulation and gas estimation
      }),
    }
  );

  const simulatedDepositData = await depositWithSimulationResponse.json();

  // When simulate=true, the response includes fully prepared transaction data
  console.log("Gas limit:", simulatedDepositData.data.tx.gas);
  console.log("Gas price:", simulatedDepositData.data.tx.gasPrice);
  console.log("Chain ID:", simulatedDepositData.data.chainId);

  // Execute the validated transaction with your wallet
  const depositTxHash = await wallet.sendTransaction({
    to: simulatedDepositData.data.tx.to,
    data: simulatedDepositData.data.tx.data,
    value: simulatedDepositData.data.tx.value,
    gas: simulatedDepositData.data.tx.gas,
    gasPrice: simulatedDepositData.data.tx.gasPrice,
    chainId: simulatedDepositData.data.chainId,
  });
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "success": true,
    "data": {
      "portfolioId": "port_abc123",
      "depositRequest": {
        "vaultAddress": "0xPortfolioVaultAddress",
        "token": "native",
        "amount": "100000000000000000"
      },
      "tx": {
        "to": "0xPortfolioVaultAddress",
        "data": "0x",
        "value": "100000000000000000",
        "gas": "21000",
        "gasPrice": "1000000000"
      },
      "simulation": {
        "success": true,
        "gasUsed": "21000"
      },
      "chainId": "8453",
      "message": "Deposit transaction data generated and simulated successfully"
    },
    "correlationId": "corr_abc123",
    "requestId": "req_xyz789",
    "timestamp": "2023-05-21T13:45:12.345Z"
  }
  ```
</ResponseExample>
