Skip to content

Commit c6a6dc8

Browse files
committed
fix: docs & getPool params
1 parent 6894f5b commit c6a6dc8

16 files changed

+590
-256
lines changed

README.md

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ npm install uniswap-dev-kit
1919

2020
## Quick Start
2121

22-
### 1. Configure and create an SDK instance
22+
### 1. Configure and create SDK instances
2323

2424
```ts
2525
import { createInstance } from "uniswap-dev-kit";
2626

27-
const config = {
27+
// Create instance for Ethereum mainnet
28+
createInstance({
2829
chainId: 1,
2930
rpcUrl: "https://eth.llamarpc.com",
3031
contracts: {
@@ -36,9 +37,29 @@ const config = {
3637
universalRouter: "0x...",
3738
permit2: "0x..."
3839
}
39-
};
40+
});
4041

41-
createInstance(config);
42+
// Create instance for another chain (e.g., Base)
43+
createInstance({
44+
chainId: 8453,
45+
rpcUrl: "https://mainnet.base.org",
46+
contracts: {
47+
// Base Uniswap V4 contract addresses...
48+
}
49+
});
50+
```
51+
52+
The SDK automatically manages multiple instances based on chainId. When using hooks or utilities, just specify the chainId to use the corresponding instance:
53+
54+
```ts
55+
// Will use Ethereum mainnet instance
56+
const ethPool = await getPool({ tokens: [...] }, 1);
57+
58+
// Will use Base instance
59+
const basePool = await getPool({ tokens: [...] }, 8453);
60+
61+
// If you only have one instance, chainId is optional
62+
const singleChainPool = await getPool({ tokens: [...] });
4263
```
4364

4465
### 2. Get a quote (vanilla JS/TS)
@@ -47,16 +68,25 @@ createInstance(config);
4768
import { getQuote } from "uniswap-dev-kit";
4869
import { parseEther } from "viem";
4970

50-
const quote = await getQuote({
51-
tokens: [
52-
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
53-
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" // WETH
54-
],
55-
feeTier: 3000,
56-
tickSpacing: 60,
57-
amountIn: parseEther("1"),
58-
zeroForOne: true
59-
});
71+
const quote = await getQuote(
72+
{
73+
tokens: [
74+
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
75+
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
76+
],
77+
feeTier: 3000,
78+
tickSpacing: 60,
79+
amountIn: parseEther("1"),
80+
},
81+
1,
82+
{
83+
enabled: true,
84+
staleTime: 30000,
85+
gcTime: 300000,
86+
retry: 3,
87+
onSuccess: (data) => console.log("Quote received:", data),
88+
},
89+
);
6090
console.log(quote.amountOut);
6191
```
6292

@@ -79,7 +109,8 @@ function QuoteComponent() {
79109
tickSpacing: 60,
80110
amountIn: parseEther("1"),
81111
zeroForOne: true
82-
}
112+
},
113+
chainId: 1
83114
});
84115

85116
if (isLoading) return <span>Loading...</span>;
@@ -101,8 +132,8 @@ function PoolComponent() {
101132
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
102133
],
103134
fee: 3000,
104-
chainId: 1
105-
}
135+
},
136+
chainId: 1
106137
});
107138

108139
if (isLoading) return <span>Loading...</span>;

0 commit comments

Comments
 (0)