# Initialization

### Installation

```sh
npm install @yelay-lite/sdk
```

#### Required Dependencies

The Yelay Lite SDK requires a drift web3 adapter and the drift core library. Install both the core drift library and choose one adapter based on your web3 library:

**Core dependency (required for all setups):**

```sh
npm install @gud/drift
```

**For Viem:**

```sh
npm install @gud/drift-viem
```

**For Ethers v6:**

```sh
npm install @gud/drift-ethers
```

**For Ethers v5:**

```sh
npm install @gud/drift-ethers-v5
```

### Caching Configuration

The Yelay Lite SDK automatically disables drift's internal caching to ensure fresh data on every request.

When you call `sdk.init(drift)`, the SDK automatically replaces drift's default LRU cache with a no-op implementation, ensuring all contract calls fetch fresh data from the blockchain. The SDK will throw an error if you try to use custom caching.

### Initialization

The SDK uses a **drift adapter pattern** that works with any web3 library. The `init()` method is **mandatory** and must be called before using any SDK features.

#### With Viem

```ts
import { YelayLiteSdk } from '@yelay-lite/sdk';
import { viemAdapter } from '@gud/drift-viem';
import { createDrift } from '@gud/drift';
import { createPublicClient, createWalletClient, http } from 'viem';
import { base } from 'viem/chains';

// Set up your viem clients
const publicClient = createPublicClient({
	chain: base,
	transport: http(),
});

const walletClient = createWalletClient({
	chain: base,
	transport: http(),
});

// Create the adapter and drift instance
const adapter = viemAdapter({ publicClient, walletClient });
const drift = createDrift({ adapter });

// Initialize the SDK
const sdk = new YelayLiteSdk();
await sdk.init(drift);
```

#### With Ethers v6

```ts
import { YelayLiteSdk } from '@yelay-lite/sdk';
import { ethersAdapter } from '@gud/drift-ethers';
import { createDrift } from '@gud/drift';
import { ethers } from 'ethers';

// Set up your ethers provider and signer
const provider = new ethers.JsonRpcProvider('https://mainnet.base.org');
const signer = new ethers.Wallet('YOUR_PRIVATE_KEY', provider);

// Create the adapter and drift instance
const adapter = ethersAdapter({ provider, signer });
const drift = createDrift({ adapter });

// Initialize the SDK
const sdk = new YelayLiteSdk();
await sdk.init(drift);
```

#### With Ethers v5

```ts
import { YelayLiteSdk } from '@yelay-lite/sdk';
import { ethersV5Adapter } from '@gud/drift-ethers-v5';
import { createDrift } from '@gud/drift';
import { ethers } from 'ethers';

// Set up your ethers v5 provider and signer
const provider = new ethers.providers.JsonRpcProvider('https://mainnet.base.org');
const signer = new ethers.Wallet('YOUR_PRIVATE_KEY', provider);

// Create the adapter and drift instance
const adapter = ethersV5Adapter({ provider, signer });
const drift = createDrift({ adapter });

// Initialize the SDK
const sdk = new YelayLiteSdk();
await sdk.init(drift);
```


---

# 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.yelay.io/yelay-sdk/initialization.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.
