|
1 | | -# uni-dev-kit |
| 1 | +# uniswap-dev-kit |
2 | 2 |
|
3 | 3 | [](https://github.com/BootNodeDev/uni-dev-kit/actions/workflows/ci.yml) |
4 | 4 | [](https://github.com/BootNodeDev/uni-dev-kit/actions/workflows/release.yml) |
5 | | -[](https://github.com/BootNodeDev/uni-dev-kit/tree/main/docs) |
| 5 | +[](https://bootnodedev.github.io/uni-dev-kit) |
6 | 6 |
|
7 | | -A modern TypeScript library for integrating Uniswap into your dapp. |
| 7 | +A modern TypeScript library for integrating Uniswap V4 into your dapp. |
8 | 8 |
|
9 | 9 | ## Installation |
10 | 10 |
|
11 | 11 | ```bash |
12 | | -pnpm install uni-dev-kit |
| 12 | +pnpm install uniswap-dev-kit |
13 | 13 | ``` |
14 | 14 |
|
15 | | -## Usage |
| 15 | +## Quick Start |
| 16 | + |
| 17 | +### 1. Configure and create an SDK instance |
| 18 | + |
| 19 | +```ts |
| 20 | +import { createInstance } from 'uniswap-dev-kit'; |
| 21 | + |
| 22 | +const config = { |
| 23 | + chainId: 1, |
| 24 | + rpcUrl: 'https://eth.llamarpc.com', |
| 25 | + contracts: { |
| 26 | + poolManager: '0x...', |
| 27 | + positionDescriptor: '0x...', |
| 28 | + positionManager: '0x...', |
| 29 | + quoter: '0x...', |
| 30 | + stateView: '0x...', |
| 31 | + universalRouter: '0x...', |
| 32 | + permit2: '0x...' |
| 33 | + } |
| 34 | +}; |
| 35 | + |
| 36 | +createInstance(config); |
| 37 | +``` |
| 38 | + |
| 39 | +### 2. Use the getQuote function (vanilla JS/TS) |
16 | 40 |
|
17 | 41 | ```ts |
18 | | -import { useUniswap, someFunction } from 'uni-dev-kit'; |
| 42 | +import { getQuote } from 'uniswap-dev-kit'; |
| 43 | +import { parseEther } from 'viem'; |
| 44 | + |
| 45 | +const quote = await getQuote({ |
| 46 | + tokens: [ |
| 47 | + "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC |
| 48 | + "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" // WETH |
| 49 | + ], |
| 50 | + feeTier: 3000, |
| 51 | + tickSpacing: 60, |
| 52 | + amountIn: parseEther("1"), // 1 ETH in wei |
| 53 | + zeroForOne: true |
| 54 | +}); |
| 55 | +console.log(quote.amountOut); |
| 56 | +``` |
| 57 | + |
| 58 | +**Parameters of getQuote:** |
| 59 | +- `tokens`: `[tokenA, tokenB]` (addresses) |
| 60 | +- `feeTier`: pool fee (e.g. 3000) |
| 61 | +- `tickSpacing`: pool tick spacing (e.g. 60) |
| 62 | +- `amountIn`: amount to swap (bigint, e.g. `parseEther("1")`) |
| 63 | +- `zeroForOne`: swap direction (true: tokenA→tokenB) |
| 64 | +- `hooks` and `hookData`: optional |
| 65 | + |
| 66 | +### 3. Use the useGetQuote hook (React) |
| 67 | + |
| 68 | +```tsx |
| 69 | +import { useGetQuote } from 'uniswap-dev-kit'; |
| 70 | +import { parseEther } from 'viem'; |
19 | 71 |
|
20 | | -// Example React hook usage |
21 | | -const result = useUniswap(/* params */); |
| 72 | +function QuoteComponent() { |
| 73 | + const { data, isLoading, error } = useGetQuote({ |
| 74 | + params: { |
| 75 | + tokens: [ |
| 76 | + "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", |
| 77 | + "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" |
| 78 | + ], |
| 79 | + feeTier: 3000, |
| 80 | + tickSpacing: 60, |
| 81 | + amountIn: parseEther("1"), |
| 82 | + zeroForOne: true |
| 83 | + } |
| 84 | + }); |
22 | 85 |
|
23 | | -// Example function usage |
24 | | -const data = someFunction(/* params */); |
| 86 | + if (isLoading) return <span>Loading...</span>; |
| 87 | + if (error) return <span>Error: {error.message}</span>; |
| 88 | + return <span>Quote: {data?.amountOut?.toString()}</span>; |
| 89 | +} |
25 | 90 | ``` |
26 | 91 |
|
27 | 92 | ## Documentation |
|
0 commit comments