# Build a postHook

After the swap or bridge is executed, the resulting tokens will be left on the Squid Multicall contract. From there the `postHooks` calls will be executed.

{% tabs %}
{% tab title="SDK" %}
Create contract interfaces for the posthook

```typescript
// Creating Contract interfaces
// Approve the lending contract to spend the erc20
const erc20Interface = new ethers.utils.Interface(erc20Abi);
const approvalerc20 = erc20Interface.encodeFunctionData("approve", [
  radiantLendingPoolAddress,
  ethers.constants.MaxUint256,
]);

// Create contract interface and encode deposit function for Radiant lending pool
const radiantLendingPoolInterface = new ethers.utils.Interface(
  radiantLendingPoolAbi
);
const depositEncodedData = radiantLendingPoolInterface.encodeFunctionData(
  "deposit",
  [
    usdcArbitrumAddress,
    "0", // Placeholder for dynamic balance
    signer.address,
    0,
  ]
);
```

Create postHook

```typescript

// Set up parameters for swapping tokens and depositing into Radiant lending pool
const params = {
  fromAddress: signer.address,
  fromChain: fromChainId,
  fromToken: fromToken,
  fromAmount: amount,
  toChain: toChainId,
  toToken: usdcArbitrumAddress,
  toAddress: signer.address,
  slippage: 1,
  quoteOnly: false,
  enableBoost: true,
  slippage: 1, //OPTIONAL to set slippage, it will be set dynamically if not included
  postHook: {
    chainType: ChainType.EVM,
    calls: [
      {
        chainType: ChainType.EVM, 
        callType: 1,// SquidCallType.FULL_TOKEN_BALANCE
        target: usdcArbitrumAddress,
        value: "0", // this will be replaced by the full native balance of the multicall after the swap
        callData: approvalerc20,
        payload: {
          tokenAddress: usdcArbitrumAddress,
          inputPos: 1,
        },
        estimatedGas: "50000",
      },
      {
        chainType: ChainType.EVM,
        callType: 1, // SquidCallType.FULL_TOKEN_BALANCE
        target: radiantLendingPoolAddress,
        value: "0",
        callData: depositEncodedData,
        payload: {
          tokenAddress: usdcArbitrumAddress,
          inputPos: 1,
        },
        estimatedGas: "50000",
      },
    ],
    provider: "Integration Test", //This should be the name of your product or application that is triggering the hook
    description: "Wrap native ETH",
    logoURI: "https://pbs.twimg.com/profile_images/1548647667135291394/W2WOtKUq_400x400.jpg", //Add your logo here
  },
};

```

{% endtab %}

{% tab title="API" %}
Import the ABIs and create the contract interface

```typescript
// Import Radiant lending pool ABI
import radiantLendingPoolAbi from "../abi/radiantLendingPoolAbi";

// Import erc20 contract ABI
import erc20Abi from "../abi/erc20Abi";

// Set up JSON RPC provider and signer 
const provider = new ethers.providers.JsonRpcProvider(FROM_CHAIN_RPC);
const signer = new ethers.Wallet(privateKey, provider);



// Creating Contract interfaces

// Approve the lending contract to spend the erc20
const erc20Interface = new ethers.utils.Interface(erc20Abi);
const approvalerc20 = erc20Interface.encodeFunctionData("approve", [
  radiantLendingPoolAddress,
  ethers.constants.MaxUint256,
]);

// Create contract interface and encode deposit function for Radiant lending pool
const radiantLendingPoolInterface = new ethers.utils.Interface(
  radiantLendingPoolAbi
);
const depositEncodedData = radiantLendingPoolInterface.encodeFunctionData(
  "deposit",
  [
    usdcArbitrumAddress,
    "0", // Placeholder for dynamic balance
    signer.address,
    0,
  ]
);
```

Build the parameters to including the postHook

<pre class="language-typescript"><code class="lang-typescript">
<strong>params = {
</strong>    fromAddress: signer.address,
    fromChain: fromChainId,
    fromToken: fromToken,
    fromAmount: amount,
    toChain: toChainId,
    toToken: usdcArbitrumAddress,
    toAddress: signer.address,
    slippage: 1,
    slippageConfig: {
      autoMode: 1,
    },
    postHook: {
      chainType: "evm",
      //fundAmount: amount,  //only required for prehooks
      //fundToken: usdcArbitrumAddress, //only required for prehooks
      calls: [
        {
          callType: 1,
          target: usdcArbitrumAddress,
          value: "0", // this will be replaced by the full native balance of the multicall after the swap
          callData: approvalerc20,
          payload: {
            tokenAddress: usdcArbitrumAddress, // unused in callType 2, dummy value
            inputPos: "1", // unused
          },
          estimatedGas: "50000",
          chainType: "evm",
        },
        {
          callType: 1, // SquidCallType.FULL_TOKEN_BALANCE
          target: radiantLendingPoolAddress,
          value: "0",
          callData: depositEncodedData,
          payload: {
            tokenAddress: usdcArbitrumAddress,
            inputPos: "1",
          },
          estimatedGas: "50000",
          chainType: "evm",
        },
      ],
      description: "",
      
    },
  };

</code></pre>

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.squidrouter.com/api-and-sdk-integration/key-concepts/hooks/build-a-posthook.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
