@pawtom/sdk 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -2
- package/dist/abis.d.ts +649 -0
- package/dist/abis.js +47 -0
- package/dist/abis.js.map +1 -0
- package/dist/client.d.ts +228 -0
- package/dist/client.js +474 -0
- package/dist/client.js.map +1 -0
- package/dist/deployments.d.ts +53 -0
- package/dist/deployments.js +52 -0
- package/dist/deployments.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/liquidity.d.ts +65 -0
- package/dist/liquidity.js +135 -0
- package/dist/liquidity.js.map +1 -0
- package/dist/math.d.ts +41 -0
- package/dist/math.js +88 -0
- package/dist/math.js.map +1 -0
- package/package.json +57 -4
package/README.md
CHANGED
|
@@ -1,3 +1,91 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @pawtom/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TypeScript SDK for [Pawtom](https://github.com/Prakhar-30/Pawtom-Swap#readme), a Uniswap v4 hook that charges the trades that chase the market and pays the charge to LPs.
|
|
4
|
+
|
|
5
|
+
It reads pools, gives **exact quotes with a breakdown** (LP fee, momentum charge, priority charge), explains what any past swap paid and why, and builds **unsigned** transactions. It never holds a key, signs or sends anything.
|
|
6
|
+
|
|
7
|
+
Built on [viem](https://viem.sh). It targets the live v8 deployment on Unichain Sepolia by default.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @pawtom/sdk viem
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quote a swap
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { PawtomClient, TOKENS, formatAmount } from "@pawtom/sdk";
|
|
17
|
+
|
|
18
|
+
const pawtom = new PawtomClient(); // Unichain Sepolia, public RPC
|
|
19
|
+
|
|
20
|
+
const q = await pawtom.quote({ tokenIn: TOKENS.USDC.address, amount: 1_000_000_000n }); // 1,000 USDC in
|
|
21
|
+
console.log(formatAmount(q.amountOut, 18), "WETH");
|
|
22
|
+
console.log(q.explanation.join("\n"));
|
|
23
|
+
// LP fee: 4.5 bps, paid by every swap.
|
|
24
|
+
// No momentum charge: this swap goes against the last measured move, or the last block was quiet, ...
|
|
25
|
+
// No priority charge at a 0.001 gwei priority fee.
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Quote at the priority fee you will send.** The priority charge depends only on the transaction's priority fee per gas, so `quote` simulates the swap at `priorityFeePerGas` (default 0.001 gwei, below every floor) and the quote includes it exactly. A quote at gas price 0, which is what most quoting tools do, leaves the priority charge out.
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
const tipped = await pawtom.quote({ tokenIn: TOKENS.USDC.address, amount: 1_000_000_000n, priorityFeePerGas: 800_000_000n });
|
|
32
|
+
tipped.priority; // { bps: 7, rateWad: 700000000000000n, amount: ... } (10 bps per gwei above the 0.1 gwei floor)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Explain a past swap
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
const [s] = await pawtom.explainTx("0x7df4177a9573189f61f69abff7e80cec8caa2147dcba990460054b541ff46e13");
|
|
39
|
+
s.priority; // 396397629106812n (wei of WETH)
|
|
40
|
+
s.direction; // "against": it went against the measured move, so no momentum charge
|
|
41
|
+
s.explanation; // plain-language reasons
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Build transactions (unsigned)
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
const { quote, transactions } = await pawtom.buildSwap({
|
|
48
|
+
tokenIn: TOKENS.USDC.address,
|
|
49
|
+
amount: 50_000_000n,
|
|
50
|
+
recipient: me,
|
|
51
|
+
owner: me, // adds an ERC-20 approval first if the router's allowance is short
|
|
52
|
+
slippageBps: 50,
|
|
53
|
+
});
|
|
54
|
+
for (const tx of transactions) await wallet.sendTransaction(tx); // your wallet signs
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Liquidity:
|
|
58
|
+
- `buildAddLiquidity({ owner, amount0Max, amount1Max, rangePct })` returns Permit2 approvals and a mint.
|
|
59
|
+
- `buildRemoveLiquidity({ tokenId, owner, percent })` removes part or all of a position.
|
|
60
|
+
- `buildCollectFees({ tokenId, owner })` collects fees, including Pawtom's donated charges.
|
|
61
|
+
- `position(tokenId)` reads a position: its range, whether it is in range and what it holds.
|
|
62
|
+
|
|
63
|
+
## Read the pool
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
const st = await pawtom.getPool();
|
|
67
|
+
st.price; // USDC per WETH
|
|
68
|
+
st.measurement; // { moveBps, ageSeconds, fresh, ... } the move a swap now faces
|
|
69
|
+
st.momentumRateWad; // { up, down } exact rates for a swap now (1e18 = 100%)
|
|
70
|
+
st.params; // the hook's parameters for this pool, exact
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Other reads: `priorityRate(tip)` (exact, from the hook), `recentSwaps({ blocks })`.
|
|
74
|
+
|
|
75
|
+
## Maths, without a network
|
|
76
|
+
|
|
77
|
+
`priorityRateWad`, `chargeOf`, `kernel`, `momentumRate`, `poolId`, `displayPrice`, `parseAmount`, `formatAmount`, and tick and liquidity helpers. The priority rate and the charge rounding are exact mirrors of the hook. The tests check them against the Solidity test suite's values, and against the live deployment's four recorded swaps.
|
|
78
|
+
|
|
79
|
+
## Caveats it will tell you about
|
|
80
|
+
|
|
81
|
+
- **Later blocks:** a swap that lands in a later block than its quote faces that block's measurement. The momentum charge can then differ by up to its cap (2 bps), so always send with the quote's `limit` (slippage), never the bare quote.
|
|
82
|
+
- **Priority-ordered chains only:** the priority charge is a signal of informed flow only on chains that order transactions by priority fee, such as Unichain. `deployment.priorityOrdered` says which.
|
|
83
|
+
|
|
84
|
+
## Develop
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npm install
|
|
88
|
+
npm test # offline tests
|
|
89
|
+
npm run test:live # also against the live Unichain Sepolia deployment
|
|
90
|
+
npm run build
|
|
91
|
+
```
|