# Putting It All Together

While this guide is a work-in-progress, we have a full-fledged react-based/wagmi web-app that showcases how to make use of the SDK. You can find it here: TBA

### **SDK instantiation**

```typescript
// Context
export interface SDKContextData {
  sdk: IonicSdk;
  address: string;
  disconnect: () => void;
  currentChain: Chain & {
    unsupported?: boolean | undefined;
  };
  chains: Chain[];
}

export const SDKContext = createContext<SDKContextData | undefined>(undefined);

// Hook
export function useSDK() {
  const context = useContext(SDKContext);

  if (context === undefined) {
    throw new Error(`useSDK must be used within a SDKProvider`);
  }
  return context;
}


...

const { sdk, address, currentChain } = useSDK();
```

Source code

### **Pool Creation**

```typescript
  const { sdk, address, currentChain } = useSDK();
  const deployResult = await sdk.deployPool(
    poolName,
    whitelistedAddresses.length !== 0,
    bigCloseFactor,
    bigLiquidationIncentive,
    oracle,
    { reporter },
    { from: address },
    whitelistedAddresses
);
```

Source code

### Fetching Assets

```typescript
  const { sdk, address, currentChain } = useSDK();
  
  const { data: allPools } = useQuery(
    ['allPools', address, currentChain.id],
    async () => {
      return await sdk.fetchPoolsManual({
        verification: false,
        options: {
          from: address,
        },
      });
    },
    { cacheTime: Infinity, staleTime: Infinity, enabled: !!address && !!currentChain.id }
  );
```

Source code


---

# 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.ionic.money/developers/ionic-sdk/putting-it-all-together.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.
