@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/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { PawtomClient } from "./client.js";
2
+ export { UNICHAIN_SEPOLIA, HOOKS, TOKENS, SAFE_PRIORITY_FEE, unichainSepolia } from "./deployments.js";
3
+ export * from "./math.js";
4
+ export { MIN_TICK, MAX_TICK, alignTick, sqrtAtTick, liquidityForAmounts, amountsForLiquidity, permit2Approvals, mintTx, increaseTx, decreaseTx, burnTx, decodePositionInfo, } from "./liquidity.js";
5
+ export * as abis from "./abis.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEvG,cAAc,WAAW,CAAC;AAC1B,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,MAAM,EACN,UAAU,EACV,UAAU,EACV,MAAM,EACN,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { type Address } from "viem";
2
+ import type { Deployment, PoolKey } from "./deployments.js";
3
+ import type { UnsignedTx } from "./client.js";
4
+ export declare const MIN_TICK = -887272;
5
+ export declare const MAX_TICK = 887272;
6
+ /** √P (raw, not X96) at a tick. */
7
+ export declare const sqrtAtTick: (tick: number) => number;
8
+ /** A tick aligned to the pool's spacing, inside the usable range. */
9
+ export declare function alignTick(tick: number, spacing: number, mode?: "down" | "up"): number;
10
+ /** Liquidity for token amounts in a range at √P (LiquidityAmounts.getLiquidityForAmounts, in floating point). */
11
+ export declare function liquidityForAmounts(sqrtP: number, lower: number, upper: number, amount0: number, amount1: number): number;
12
+ /** Token amounts a liquidity amount holds in a range at √P (raw units, floating point). */
13
+ export declare function amountsForLiquidity(sqrtP: number, lower: number, upper: number, L: number): {
14
+ amount0: number;
15
+ amount1: number;
16
+ };
17
+ export declare const deadlineIn: (seconds?: number) => bigint;
18
+ /** The two approvals the PositionManager needs to pull a token: ERC-20 approve to Permit2, then a Permit2 allowance. */
19
+ export declare function permit2Approvals(d: Deployment, token: Address, amount: bigint, symbol?: string): UnsignedTx[];
20
+ /** New position: MINT_POSITION, SETTLE_PAIR, then SWEEP both currencies back (the unused slack). */
21
+ export declare function mintTx(d: Deployment, o: {
22
+ key: PoolKey;
23
+ tickLower: number;
24
+ tickUpper: number;
25
+ liquidity: bigint;
26
+ amount0Max: bigint;
27
+ amount1Max: bigint;
28
+ owner: Address;
29
+ deadline?: bigint;
30
+ }): UnsignedTx;
31
+ /** Add to an existing position: INCREASE_LIQUIDITY, SETTLE_PAIR, SWEEP both. */
32
+ export declare function increaseTx(d: Deployment, o: {
33
+ key: PoolKey;
34
+ tokenId: bigint;
35
+ liquidity: bigint;
36
+ amount0Max: bigint;
37
+ amount1Max: bigint;
38
+ owner: Address;
39
+ deadline?: bigint;
40
+ }): UnsignedTx;
41
+ /** Remove liquidity and collect fees (and Pawtom's donated charges): DECREASE_LIQUIDITY, TAKE_PAIR. liquidity 0
42
+ * collects only. */
43
+ export declare function decreaseTx(d: Deployment, o: {
44
+ key: PoolKey;
45
+ tokenId: bigint;
46
+ liquidity: bigint;
47
+ amount0Min: bigint;
48
+ amount1Min: bigint;
49
+ owner: Address;
50
+ deadline?: bigint;
51
+ }): UnsignedTx;
52
+ /** Close a position: BURN_POSITION (all liquidity and fees), TAKE_PAIR. */
53
+ export declare function burnTx(d: Deployment, o: {
54
+ key: PoolKey;
55
+ tokenId: bigint;
56
+ amount0Min: bigint;
57
+ amount1Min: bigint;
58
+ owner: Address;
59
+ deadline?: bigint;
60
+ }): UnsignedTx;
61
+ /** PositionInfo packs, from the top: poolId (200 bits) | tickUpper (24) | tickLower (24) | hasSubscriber (8). */
62
+ export declare function decodePositionInfo(info: bigint): {
63
+ tickLower: number;
64
+ tickUpper: number;
65
+ };
@@ -0,0 +1,135 @@
1
+ import { encodeAbiParameters, encodeFunctionData, encodePacked } from "viem";
2
+ import { erc20Abi, permit2Abi, positionManagerAbi } from "./abis.js";
3
+ // Liquidity through the Uniswap v4 PositionManager: ERC-20 approve to Permit2, Permit2 allowance to the
4
+ // PositionManager, then modifyLiquidities(actions, params). Every builder returns unsigned transactions.
5
+ const A = {
6
+ INCREASE_LIQUIDITY: 0x00,
7
+ DECREASE_LIQUIDITY: 0x01,
8
+ MINT_POSITION: 0x02,
9
+ BURN_POSITION: 0x03,
10
+ SETTLE_PAIR: 0x0d,
11
+ TAKE_PAIR: 0x11,
12
+ SWEEP: 0x14,
13
+ };
14
+ const KEY = {
15
+ type: "tuple",
16
+ components: [
17
+ { name: "currency0", type: "address" },
18
+ { name: "currency1", type: "address" },
19
+ { name: "fee", type: "uint24" },
20
+ { name: "tickSpacing", type: "int24" },
21
+ { name: "hooks", type: "address" },
22
+ ],
23
+ };
24
+ export const MIN_TICK = -887272;
25
+ export const MAX_TICK = 887272;
26
+ /** √P (raw, not X96) at a tick. */
27
+ export const sqrtAtTick = (tick) => Math.pow(1.0001, tick / 2);
28
+ /** A tick aligned to the pool's spacing, inside the usable range. */
29
+ export function alignTick(tick, spacing, mode = "down") {
30
+ const t = mode === "down" ? Math.floor(tick / spacing) * spacing : Math.ceil(tick / spacing) * spacing;
31
+ return Math.min(Math.floor(MAX_TICK / spacing) * spacing, Math.max(Math.ceil(MIN_TICK / spacing) * spacing, t));
32
+ }
33
+ /** Liquidity for token amounts in a range at √P (LiquidityAmounts.getLiquidityForAmounts, in floating point). */
34
+ export function liquidityForAmounts(sqrtP, lower, upper, amount0, amount1) {
35
+ const sa = sqrtAtTick(lower);
36
+ const sb = sqrtAtTick(upper);
37
+ if (sqrtP <= sa)
38
+ return (amount0 * sa * sb) / (sb - sa);
39
+ if (sqrtP >= sb)
40
+ return amount1 / (sb - sa);
41
+ return Math.min((amount0 * sqrtP * sb) / (sb - sqrtP), amount1 / (sqrtP - sa));
42
+ }
43
+ /** Token amounts a liquidity amount holds in a range at √P (raw units, floating point). */
44
+ export function amountsForLiquidity(sqrtP, lower, upper, L) {
45
+ const sa = sqrtAtTick(lower);
46
+ const sb = sqrtAtTick(upper);
47
+ if (sqrtP <= sa)
48
+ return { amount0: (L * (sb - sa)) / (sa * sb), amount1: 0 };
49
+ if (sqrtP >= sb)
50
+ return { amount0: 0, amount1: L * (sb - sa) };
51
+ return { amount0: (L * (sb - sqrtP)) / (sqrtP * sb), amount1: L * (sqrtP - sa) };
52
+ }
53
+ const enc = {
54
+ mint: (key, lower, upper, liquidity, a0Max, a1Max, owner) => encodeAbiParameters([KEY, { type: "int24" }, { type: "int24" }, { type: "uint256" }, { type: "uint128" }, { type: "uint128" }, { type: "address" }, { type: "bytes" }], [key, lower, upper, liquidity, a0Max, a1Max, owner, "0x"]),
55
+ modify: (tokenId, liquidity, a0, a1) => encodeAbiParameters([{ type: "uint256" }, { type: "uint256" }, { type: "uint128" }, { type: "uint128" }, { type: "bytes" }], [tokenId, liquidity, a0, a1, "0x"]),
56
+ pair: (key) => encodeAbiParameters([{ type: "address" }, { type: "address" }], [key.currency0, key.currency1]),
57
+ take: (key, to) => encodeAbiParameters([{ type: "address" }, { type: "address" }, { type: "address" }], [key.currency0, key.currency1, to]),
58
+ sweep: (currency, to) => encodeAbiParameters([{ type: "address" }, { type: "address" }], [currency, to]),
59
+ burn: (tokenId, a0Min, a1Min) => encodeAbiParameters([{ type: "uint256" }, { type: "uint128" }, { type: "uint128" }, { type: "bytes" }], [tokenId, a0Min, a1Min, "0x"]),
60
+ };
61
+ const unlock = (actions, p) => encodeAbiParameters([{ type: "bytes" }, { type: "bytes[]" }], [encodePacked(actions.map(() => "uint8"), actions), p]);
62
+ const modify = (unlockData, deadline) => encodeFunctionData({ abi: positionManagerAbi, functionName: "modifyLiquidities", args: [unlockData, deadline] });
63
+ export const deadlineIn = (seconds = 600) => BigInt(Math.floor(Date.now() / 1000) + seconds);
64
+ /** The two approvals the PositionManager needs to pull a token: ERC-20 approve to Permit2, then a Permit2 allowance. */
65
+ export function permit2Approvals(d, token, amount, symbol = "token") {
66
+ const expiration = Math.floor(Date.now() / 1000) + 30 * 86400;
67
+ return [
68
+ {
69
+ to: token,
70
+ data: encodeFunctionData({ abi: erc20Abi, functionName: "approve", args: [d.permit2, amount] }),
71
+ value: 0n,
72
+ chainId: d.chain.id,
73
+ description: `Approve Permit2 to move ${symbol}`,
74
+ },
75
+ {
76
+ to: d.permit2,
77
+ data: encodeFunctionData({ abi: permit2Abi, functionName: "approve", args: [token, d.positionManager, amount, expiration] }),
78
+ value: 0n,
79
+ chainId: d.chain.id,
80
+ description: `Let the PositionManager use ${symbol} through Permit2 for 30 days`,
81
+ },
82
+ ];
83
+ }
84
+ /** New position: MINT_POSITION, SETTLE_PAIR, then SWEEP both currencies back (the unused slack). */
85
+ export function mintTx(d, o) {
86
+ const { key } = o;
87
+ return {
88
+ to: d.positionManager,
89
+ data: modify(unlock([A.MINT_POSITION, A.SETTLE_PAIR, A.SWEEP, A.SWEEP], [enc.mint(key, o.tickLower, o.tickUpper, o.liquidity, o.amount0Max, o.amount1Max, o.owner), enc.pair(key), enc.sweep(key.currency0, o.owner), enc.sweep(key.currency1, o.owner)]), o.deadline ?? deadlineIn()),
90
+ value: 0n,
91
+ chainId: d.chain.id,
92
+ description: `Mint a position on ticks ${o.tickLower} to ${o.tickUpper} with liquidity ${o.liquidity}`,
93
+ };
94
+ }
95
+ /** Add to an existing position: INCREASE_LIQUIDITY, SETTLE_PAIR, SWEEP both. */
96
+ export function increaseTx(d, o) {
97
+ const { key } = o;
98
+ return {
99
+ to: d.positionManager,
100
+ data: modify(unlock([A.INCREASE_LIQUIDITY, A.SETTLE_PAIR, A.SWEEP, A.SWEEP], [enc.modify(o.tokenId, o.liquidity, o.amount0Max, o.amount1Max), enc.pair(key), enc.sweep(key.currency0, o.owner), enc.sweep(key.currency1, o.owner)]), o.deadline ?? deadlineIn()),
101
+ value: 0n,
102
+ chainId: d.chain.id,
103
+ description: `Add liquidity ${o.liquidity} to position ${o.tokenId}`,
104
+ };
105
+ }
106
+ /** Remove liquidity and collect fees (and Pawtom's donated charges): DECREASE_LIQUIDITY, TAKE_PAIR. liquidity 0
107
+ * collects only. */
108
+ export function decreaseTx(d, o) {
109
+ return {
110
+ to: d.positionManager,
111
+ data: modify(unlock([A.DECREASE_LIQUIDITY, A.TAKE_PAIR], [enc.modify(o.tokenId, o.liquidity, o.amount0Min, o.amount1Min), enc.take(o.key, o.owner)]), o.deadline ?? deadlineIn()),
112
+ value: 0n,
113
+ chainId: d.chain.id,
114
+ description: o.liquidity === 0n ? `Collect fees of position ${o.tokenId}` : `Remove liquidity ${o.liquidity} from position ${o.tokenId}`,
115
+ };
116
+ }
117
+ /** Close a position: BURN_POSITION (all liquidity and fees), TAKE_PAIR. */
118
+ export function burnTx(d, o) {
119
+ return {
120
+ to: d.positionManager,
121
+ data: modify(unlock([A.BURN_POSITION, A.TAKE_PAIR], [enc.burn(o.tokenId, o.amount0Min, o.amount1Min), enc.take(o.key, o.owner)]), o.deadline ?? deadlineIn()),
122
+ value: 0n,
123
+ chainId: d.chain.id,
124
+ description: `Close position ${o.tokenId} and withdraw everything`,
125
+ };
126
+ }
127
+ /** PositionInfo packs, from the top: poolId (200 bits) | tickUpper (24) | tickLower (24) | hasSubscriber (8). */
128
+ export function decodePositionInfo(info) {
129
+ const s24 = (v) => {
130
+ const n = Number(v & 0xffffffn);
131
+ return n >= 0x800000 ? n - 0x1000000 : n;
132
+ };
133
+ return { tickLower: s24(info >> 8n), tickUpper: s24(info >> 32n) };
134
+ }
135
+ //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AC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC;IACF,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;AACrE,CAAC"}
package/dist/math.d.ts ADDED
@@ -0,0 +1,41 @@
1
+ import { type Hex } from "viem";
2
+ import type { PawtomPool, PoolKey } from "./deployments.js";
3
+ export declare const WAD: bigint;
4
+ export declare const PIPS = 1000000n;
5
+ export declare const BPS = 0.0001;
6
+ /** PoolId = keccak256(abi.encode(key)). */
7
+ export declare function poolId(key: PoolKey): Hex;
8
+ /** The pool's slot0 and liquidity slots in the PoolManager (pools mapping at slot 6). */
9
+ export declare function poolStateSlots(id: Hex): {
10
+ slot0: Hex;
11
+ liquidity: Hex;
12
+ };
13
+ /** K(x) = 1 - exp(-x^2 / 2w^2) for x > 0, else 0: the share of the cap a measured move beyond the dead zone earns.
14
+ * Floating point, for previews and "what if" questions; the hook's momentumRates() view is the exact rate. */
15
+ export declare function kernel(x: number, w: number): number;
16
+ /** The momentum charge rate (fraction of the unspecified amount) for a swap continuing a measured move `delta`
17
+ * (log-price), with kernel width w, dead zone z and cap (fractions). */
18
+ export declare function momentumRate(delta: number, w: number, z: number, cap: number): number;
19
+ /** v8's priority rate (1e18 = 100%), exactly as PawtomHook._priorityRate computes it:
20
+ * min(priorityCapPips, priorityRate * (bid - floor)), 0 at or below the floor, cap taken before multiplying. */
21
+ export declare function priorityRateWad(bid: bigint, p: {
22
+ priorityFloor: bigint;
23
+ priorityRate: bigint;
24
+ priorityCapPips: bigint;
25
+ }): bigint;
26
+ /** ceil(amount * rate / 1e18): how the hook rounds each charge (in LPs' favour). */
27
+ export declare function chargeOf(amount: bigint, rateWad: bigint): bigint;
28
+ /** The priority fee a transaction bids: tx.gasprice - block.basefee, 0 at or below the base fee. */
29
+ export declare function priorityBid(gasPrice: bigint, baseFee: bigint): bigint;
30
+ /** u = ln(raw token1 per raw token0) from sqrtPriceX96. */
31
+ export declare function logPriceFromSqrt(sqrtPriceX96: bigint): number;
32
+ /** Price as people read it: quote per base, whole tokens (USDC per WETH), from u. */
33
+ export declare function displayPrice(u: number, pool: PawtomPool): number;
34
+ /** A raw log-price move in bps of the displayed price (USDC per WETH rises when raw WETH-per-USDC falls). */
35
+ export declare function displayMoveBps(delta: number, pool: PawtomPool): number;
36
+ /** "1.5" with 6 decimals -> 1500000n. Returns null for anything that is not a plain non-negative decimal. */
37
+ export declare function parseAmount(text: string, decimals: number): bigint | null;
38
+ /** 1500000n with 6 decimals -> "1.5". Exact, no rounding beyond `maxFrac` truncation. */
39
+ export declare function formatAmount(raw: bigint, decimals: number, maxFrac?: number): string;
40
+ /** A 1e18 rate in basis points, as a number (5e14 -> 5). */
41
+ export declare const rateBps: (rateWad: bigint) => number;
package/dist/math.js ADDED
@@ -0,0 +1,88 @@
1
+ import { encodeAbiParameters, keccak256 } from "viem";
2
+ export const WAD = 10n ** 18n;
3
+ export const PIPS = 1000000n;
4
+ export const BPS = 1e-4;
5
+ /** PoolId = keccak256(abi.encode(key)). */
6
+ export function poolId(key) {
7
+ return keccak256(encodeAbiParameters([{ type: "address" }, { type: "address" }, { type: "uint24" }, { type: "int24" }, { type: "address" }], [key.currency0, key.currency1, key.fee, key.tickSpacing, key.hooks]));
8
+ }
9
+ /** The pool's slot0 and liquidity slots in the PoolManager (pools mapping at slot 6). */
10
+ export function poolStateSlots(id) {
11
+ const base = BigInt(keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "uint256" }], [id, 6n])));
12
+ const hex = (n) => `0x${n.toString(16).padStart(64, "0")}`;
13
+ return { slot0: hex(base), liquidity: hex(base + 3n) };
14
+ }
15
+ // ------------------------------------------------------------------------------------------------- momentum
16
+ /** K(x) = 1 - exp(-x^2 / 2w^2) for x > 0, else 0: the share of the cap a measured move beyond the dead zone earns.
17
+ * Floating point, for previews and "what if" questions; the hook's momentumRates() view is the exact rate. */
18
+ export function kernel(x, w) {
19
+ if (x <= 0)
20
+ return 0;
21
+ if (w <= 0)
22
+ return 1;
23
+ return 1 - Math.exp(-(x * x) / (2 * w * w));
24
+ }
25
+ /** The momentum charge rate (fraction of the unspecified amount) for a swap continuing a measured move `delta`
26
+ * (log-price), with kernel width w, dead zone z and cap (fractions). */
27
+ export function momentumRate(delta, w, z, cap) {
28
+ return cap * kernel(Math.abs(delta) - z, w);
29
+ }
30
+ // ------------------------------------------------------------------------------------------------- priority
31
+ /** v8's priority rate (1e18 = 100%), exactly as PawtomHook._priorityRate computes it:
32
+ * min(priorityCapPips, priorityRate * (bid - floor)), 0 at or below the floor, cap taken before multiplying. */
33
+ export function priorityRateWad(bid, p) {
34
+ if (p.priorityRate === 0n || bid <= p.priorityFloor)
35
+ return 0n;
36
+ const over = bid - p.priorityFloor;
37
+ const cap = p.priorityCapPips * (WAD / PIPS);
38
+ return over >= cap / p.priorityRate ? cap : over * p.priorityRate;
39
+ }
40
+ /** ceil(amount * rate / 1e18): how the hook rounds each charge (in LPs' favour). */
41
+ export function chargeOf(amount, rateWad) {
42
+ if (rateWad === 0n || amount === 0n)
43
+ return 0n;
44
+ return (amount * rateWad + WAD - 1n) / WAD;
45
+ }
46
+ /** The priority fee a transaction bids: tx.gasprice - block.basefee, 0 at or below the base fee. */
47
+ export function priorityBid(gasPrice, baseFee) {
48
+ return gasPrice > baseFee ? gasPrice - baseFee : 0n;
49
+ }
50
+ // ------------------------------------------------------------------------------------------------- prices
51
+ const Q96 = 2 ** 96;
52
+ /** u = ln(raw token1 per raw token0) from sqrtPriceX96. */
53
+ export function logPriceFromSqrt(sqrtPriceX96) {
54
+ return 2 * Math.log(Number(sqrtPriceX96) / Q96);
55
+ }
56
+ /** Price as people read it: quote per base, whole tokens (USDC per WETH), from u. */
57
+ export function displayPrice(u, pool) {
58
+ const t1PerT0 = Math.exp(u) * 10 ** (pool.token0.decimals - pool.token1.decimals);
59
+ return pool.base.address.toLowerCase() === pool.token1.address.toLowerCase() ? 1 / t1PerT0 : t1PerT0;
60
+ }
61
+ /** A raw log-price move in bps of the displayed price (USDC per WETH rises when raw WETH-per-USDC falls). */
62
+ export function displayMoveBps(delta, pool) {
63
+ const sign = pool.base.address.toLowerCase() === pool.token1.address.toLowerCase() ? -1 : 1;
64
+ return (sign * delta) / BPS;
65
+ }
66
+ // ------------------------------------------------------------------------------------------------- amounts
67
+ /** "1.5" with 6 decimals -> 1500000n. Returns null for anything that is not a plain non-negative decimal. */
68
+ export function parseAmount(text, decimals) {
69
+ const t = text.trim().replace(/,/g, "");
70
+ if (!/^\d*\.?\d*$/.test(t) || t === "" || t === ".")
71
+ return null;
72
+ const [i = "", f = ""] = t.split(".");
73
+ if (f.length > decimals)
74
+ return null;
75
+ return BigInt(i || "0") * 10n ** BigInt(decimals) + BigInt((f + "0".repeat(decimals)).slice(0, decimals) || "0");
76
+ }
77
+ /** 1500000n with 6 decimals -> "1.5". Exact, no rounding beyond `maxFrac` truncation. */
78
+ export function formatAmount(raw, decimals, maxFrac = decimals) {
79
+ const neg = raw < 0n;
80
+ const v = neg ? -raw : raw;
81
+ const base = 10n ** BigInt(decimals);
82
+ const i = v / base;
83
+ const f = (v % base).toString().padStart(decimals, "0").slice(0, maxFrac).replace(/0+$/, "");
84
+ return `${neg ? "-" : ""}${i.toString()}${f ? "." + f : ""}`;
85
+ }
86
+ /** A 1e18 rate in basis points, as a number (5e14 -> 5). */
87
+ export const rateBps = (rateWad) => Number(rateWad) / 1e14;
88
+ //# sourceMappingURL=math.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"math.js","sourceRoot":"","sources":["../src/math.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAY,MAAM,MAAM,CAAC;AAGhE,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,IAAI,GAAG,CAAC;AAC9B,MAAM,CAAC,MAAM,IAAI,GAAG,QAAU,CAAC;AAC/B,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AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "@pawtom/sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK for Pawtom, the Uniswap v4 hook that charges trades that chase the market: pool state, exact quotes with a charge breakdown, transaction explanations and unsigned transaction builders.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/Prakhar-30/Pawtom-Swap.git",
9
+ "directory": "packages/sdk"
10
+ },
11
+ "homepage": "https://github.com/Prakhar-30/Pawtom-Swap/tree/main/packages/sdk#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/Prakhar-30/Pawtom-Swap/issues"
14
+ },
15
+ "keywords": [
16
+ "uniswap",
17
+ "uniswap-v4",
18
+ "hook",
19
+ "unichain",
20
+ "viem",
21
+ "defi",
22
+ "lvr"
23
+ ],
24
+ "type": "module",
25
+ "main": "./dist/index.js",
26
+ "types": "./dist/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.js"
31
+ }
32
+ },
33
+ "files": [
34
+ "dist",
35
+ "README.md"
36
+ ],
37
+ "sideEffects": false,
38
+ "engines": {
39
+ "node": ">=20"
40
+ },
41
+ "scripts": {
42
+ "build": "tsc -p tsconfig.build.json",
43
+ "typecheck": "tsc --noEmit",
44
+ "test": "vitest run",
45
+ "test:live": "PAWTOM_LIVE=1 vitest run",
46
+ "bundle:edge": "node scripts/bundle-edge.mjs",
47
+ "prepublishOnly": "npm run build"
48
+ },
49
+ "peerDependencies": {
50
+ "viem": "^2.30.0"
51
+ },
52
+ "devDependencies": {
53
+ "@types/node": "^22.20.7",
54
+ "esbuild": "^0.25.12",
55
+ "typescript": "~5.9.3",
56
+ "viem": "^2.58.4",
57
+ "vitest": "^3.2.4"
58
+ }
59
+ }