@ubi.fun/sdk 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.
Files changed (191) hide show
  1. package/LICENSE +10 -0
  2. package/README.md +279 -0
  3. package/dist/abi/AddressFeeSplitManager.d.cts +938 -0
  4. package/dist/abi/AddressFeeSplitManager.d.ts +939 -0
  5. package/dist/abi/AddressFeeSplitManager.d.ts.map +1 -0
  6. package/dist/abi/BidWall.d.cts +739 -0
  7. package/dist/abi/BidWall.d.ts +740 -0
  8. package/dist/abi/BidWall.d.ts.map +1 -0
  9. package/dist/abi/FairLaunch.d.cts +535 -0
  10. package/dist/abi/FairLaunch.d.ts +536 -0
  11. package/dist/abi/FairLaunch.d.ts.map +1 -0
  12. package/dist/abi/FeeEscrow.d.cts +281 -0
  13. package/dist/abi/FeeEscrow.d.ts +282 -0
  14. package/dist/abi/FeeEscrow.d.ts.map +1 -0
  15. package/dist/abi/Flaunch.d.cts +775 -0
  16. package/dist/abi/Flaunch.d.ts +776 -0
  17. package/dist/abi/Flaunch.d.ts.map +1 -0
  18. package/dist/abi/FlaunchPositionManager.d.cts +2170 -0
  19. package/dist/abi/FlaunchPositionManager.d.ts +2171 -0
  20. package/dist/abi/FlaunchPositionManager.d.ts.map +1 -0
  21. package/dist/abi/FlaunchZap.d.cts +300 -0
  22. package/dist/abi/FlaunchZap.d.ts +301 -0
  23. package/dist/abi/FlaunchZap.d.ts.map +1 -0
  24. package/dist/abi/InitialPrice.d.cts +252 -0
  25. package/dist/abi/InitialPrice.d.ts +253 -0
  26. package/dist/abi/InitialPrice.d.ts.map +1 -0
  27. package/dist/abi/Memecoin.d.cts +680 -0
  28. package/dist/abi/Memecoin.d.ts +681 -0
  29. package/dist/abi/Memecoin.d.ts.map +1 -0
  30. package/dist/abi/Multicall.d.cts +332 -0
  31. package/dist/abi/Multicall.d.ts +333 -0
  32. package/dist/abi/Multicall.d.ts.map +1 -0
  33. package/dist/abi/PoolManager.d.cts +1056 -0
  34. package/dist/abi/PoolManager.d.ts +1057 -0
  35. package/dist/abi/PoolManager.d.ts.map +1 -0
  36. package/dist/abi/PoolSwap.d.cts +89 -0
  37. package/dist/abi/PoolSwap.d.ts +90 -0
  38. package/dist/abi/PoolSwap.d.ts.map +1 -0
  39. package/dist/abi/Quoter.d.cts +485 -0
  40. package/dist/abi/Quoter.d.ts +486 -0
  41. package/dist/abi/Quoter.d.ts.map +1 -0
  42. package/dist/abi/ReferralEscrow.d.cts +459 -0
  43. package/dist/abi/ReferralEscrow.d.ts +460 -0
  44. package/dist/abi/ReferralEscrow.d.ts.map +1 -0
  45. package/dist/abi/TreasuryManager.d.cts +325 -0
  46. package/dist/abi/TreasuryManager.d.ts +326 -0
  47. package/dist/abi/TreasuryManager.d.ts.map +1 -0
  48. package/dist/abi/TreasuryManagerFactory.d.cts +433 -0
  49. package/dist/abi/TreasuryManagerFactory.d.ts +434 -0
  50. package/dist/abi/TreasuryManagerFactory.d.ts.map +1 -0
  51. package/dist/abi/UniversalRewardsDistributor.d.cts +191 -0
  52. package/dist/abi/UniversalRewardsDistributor.d.ts +192 -0
  53. package/dist/abi/UniversalRewardsDistributor.d.ts.map +1 -0
  54. package/dist/abi/XHandleClaims.d.cts +383 -0
  55. package/dist/abi/XHandleClaims.d.ts +384 -0
  56. package/dist/abi/XHandleClaims.d.ts.map +1 -0
  57. package/dist/abi/index.cjs +13541 -0
  58. package/dist/abi/index.cjs.map +1 -0
  59. package/dist/abi/index.d.cts +18 -0
  60. package/dist/abi/index.d.ts +19 -0
  61. package/dist/abi/index.d.ts.map +1 -0
  62. package/dist/abi/index.js +13522 -0
  63. package/dist/abi/index.js.map +1 -0
  64. package/dist/addresses/index.cjs +90 -0
  65. package/dist/addresses/index.cjs.map +1 -0
  66. package/dist/addresses/index.js +70 -0
  67. package/dist/addresses/index.js.map +1 -0
  68. package/dist/addresses.d.cts +48 -0
  69. package/dist/addresses.d.ts +49 -0
  70. package/dist/addresses.d.ts.map +1 -0
  71. package/dist/clients/BidWallClient.d.cts +44 -0
  72. package/dist/clients/BidWallClient.d.ts +45 -0
  73. package/dist/clients/BidWallClient.d.ts.map +1 -0
  74. package/dist/clients/FairLaunchClient.d.cts +47 -0
  75. package/dist/clients/FairLaunchClient.d.ts +48 -0
  76. package/dist/clients/FairLaunchClient.d.ts.map +1 -0
  77. package/dist/clients/FeeEscrowClient.d.cts +40 -0
  78. package/dist/clients/FeeEscrowClient.d.ts +41 -0
  79. package/dist/clients/FeeEscrowClient.d.ts.map +1 -0
  80. package/dist/clients/FlaunchClient.d.cts +35 -0
  81. package/dist/clients/FlaunchClient.d.ts +36 -0
  82. package/dist/clients/FlaunchClient.d.ts.map +1 -0
  83. package/dist/clients/FlaunchPositionManagerClient.d.cts +117 -0
  84. package/dist/clients/FlaunchPositionManagerClient.d.ts +118 -0
  85. package/dist/clients/FlaunchPositionManagerClient.d.ts.map +1 -0
  86. package/dist/clients/FlaunchZapClient.d.cts +127 -0
  87. package/dist/clients/FlaunchZapClient.d.ts +128 -0
  88. package/dist/clients/FlaunchZapClient.d.ts.map +1 -0
  89. package/dist/clients/InitialPriceClient.d.cts +32 -0
  90. package/dist/clients/InitialPriceClient.d.ts +33 -0
  91. package/dist/clients/InitialPriceClient.d.ts.map +1 -0
  92. package/dist/clients/MemecoinClient.d.cts +66 -0
  93. package/dist/clients/MemecoinClient.d.ts +67 -0
  94. package/dist/clients/MemecoinClient.d.ts.map +1 -0
  95. package/dist/clients/MulticallClient.d.cts +15 -0
  96. package/dist/clients/MulticallClient.d.ts +16 -0
  97. package/dist/clients/MulticallClient.d.ts.map +1 -0
  98. package/dist/clients/PoolManagerClient.d.cts +50 -0
  99. package/dist/clients/PoolManagerClient.d.ts +51 -0
  100. package/dist/clients/PoolManagerClient.d.ts.map +1 -0
  101. package/dist/clients/PoolSwapClient.d.cts +37 -0
  102. package/dist/clients/PoolSwapClient.d.ts +38 -0
  103. package/dist/clients/PoolSwapClient.d.ts.map +1 -0
  104. package/dist/clients/QuoterClient.d.cts +58 -0
  105. package/dist/clients/QuoterClient.d.ts +59 -0
  106. package/dist/clients/QuoterClient.d.ts.map +1 -0
  107. package/dist/clients/ReferralEscrowClient.d.cts +39 -0
  108. package/dist/clients/ReferralEscrowClient.d.ts +40 -0
  109. package/dist/clients/ReferralEscrowClient.d.ts.map +1 -0
  110. package/dist/clients/TreasuryManagerClient.d.cts +71 -0
  111. package/dist/clients/TreasuryManagerClient.d.ts +72 -0
  112. package/dist/clients/TreasuryManagerClient.d.ts.map +1 -0
  113. package/dist/clients/TreasuryManagerFactoryClient.d.cts +15 -0
  114. package/dist/clients/TreasuryManagerFactoryClient.d.ts +16 -0
  115. package/dist/clients/TreasuryManagerFactoryClient.d.ts.map +1 -0
  116. package/dist/clients/UniversalRewardsDistributorClient.d.cts +45 -0
  117. package/dist/clients/UniversalRewardsDistributorClient.d.ts +46 -0
  118. package/dist/clients/UniversalRewardsDistributorClient.d.ts.map +1 -0
  119. package/dist/clients/XHandleClaimsClient.d.cts +64 -0
  120. package/dist/clients/XHandleClaimsClient.d.ts +65 -0
  121. package/dist/clients/XHandleClaimsClient.d.ts.map +1 -0
  122. package/dist/helpers/chainIdToChain.d.cts +113 -0
  123. package/dist/helpers/chainIdToChain.d.ts +114 -0
  124. package/dist/helpers/chainIdToChain.d.ts.map +1 -0
  125. package/dist/helpers/hex.d.cts +3 -0
  126. package/dist/helpers/hex.d.ts +4 -0
  127. package/dist/helpers/hex.d.ts.map +1 -0
  128. package/dist/helpers/index.cjs +196 -0
  129. package/dist/helpers/index.cjs.map +1 -0
  130. package/dist/helpers/index.d.cts +3 -0
  131. package/dist/helpers/index.d.ts +4 -0
  132. package/dist/helpers/index.d.ts.map +1 -0
  133. package/dist/helpers/index.js +184 -0
  134. package/dist/helpers/index.js.map +1 -0
  135. package/dist/helpers/ipfs.d.cts +56 -0
  136. package/dist/helpers/ipfs.d.ts +57 -0
  137. package/dist/helpers/ipfs.d.ts.map +1 -0
  138. package/dist/hooks/FlaunchPositionManagerHooks.d.cts +28 -0
  139. package/dist/hooks/FlaunchPositionManagerHooks.d.ts +29 -0
  140. package/dist/hooks/FlaunchPositionManagerHooks.d.ts.map +1 -0
  141. package/dist/hooks/index.cjs +73 -0
  142. package/dist/hooks/index.cjs.map +1 -0
  143. package/dist/hooks/index.d.cts +1 -0
  144. package/dist/hooks/index.d.ts +2 -0
  145. package/dist/hooks/index.d.ts.map +1 -0
  146. package/dist/hooks/index.js +70 -0
  147. package/dist/hooks/index.js.map +1 -0
  148. package/dist/index.cjs +16808 -0
  149. package/dist/index.cjs.map +1 -0
  150. package/dist/index.d.cts +31 -0
  151. package/dist/index.d.ts +32 -0
  152. package/dist/index.d.ts.map +1 -0
  153. package/dist/index.js +16718 -0
  154. package/dist/index.js.map +1 -0
  155. package/dist/index.umd.cjs +2 -0
  156. package/dist/index.umd.cjs.map +1 -0
  157. package/dist/sdk/FlaunchSDK.d.cts +520 -0
  158. package/dist/sdk/FlaunchSDK.d.ts +521 -0
  159. package/dist/sdk/FlaunchSDK.d.ts.map +1 -0
  160. package/dist/sdk/calldata.d.cts +65 -0
  161. package/dist/sdk/calldata.d.ts +66 -0
  162. package/dist/sdk/calldata.d.ts.map +1 -0
  163. package/dist/sdk/drift.d.cts +20 -0
  164. package/dist/sdk/drift.d.ts +21 -0
  165. package/dist/sdk/drift.d.ts.map +1 -0
  166. package/dist/sdk/factory.d.cts +20 -0
  167. package/dist/sdk/factory.d.ts +21 -0
  168. package/dist/sdk/factory.d.ts.map +1 -0
  169. package/dist/types.d.cts +56 -0
  170. package/dist/types.d.ts +57 -0
  171. package/dist/types.d.ts.map +1 -0
  172. package/dist/utils/index.cjs +455 -0
  173. package/dist/utils/index.cjs.map +1 -0
  174. package/dist/utils/index.d.cts +4 -0
  175. package/dist/utils/index.d.ts +5 -0
  176. package/dist/utils/index.d.ts.map +1 -0
  177. package/dist/utils/index.js +431 -0
  178. package/dist/utils/index.js.map +1 -0
  179. package/dist/utils/parseSwap.d.cts +45 -0
  180. package/dist/utils/parseSwap.d.ts +46 -0
  181. package/dist/utils/parseSwap.d.ts.map +1 -0
  182. package/dist/utils/slippage.d.cts +11 -0
  183. package/dist/utils/slippage.d.ts +12 -0
  184. package/dist/utils/slippage.d.ts.map +1 -0
  185. package/dist/utils/swap.d.cts +49 -0
  186. package/dist/utils/swap.d.ts +50 -0
  187. package/dist/utils/swap.d.ts.map +1 -0
  188. package/dist/utils/univ4.d.cts +78 -0
  189. package/dist/utils/univ4.d.ts +79 -0
  190. package/dist/utils/univ4.d.ts.map +1 -0
  191. package/package.json +161 -0
@@ -0,0 +1,45 @@
1
+ export interface SwapLogArgs {
2
+ flAmount0: bigint;
3
+ flAmount1: bigint;
4
+ flFee0: bigint;
5
+ flFee1: bigint;
6
+ ispAmount0: bigint;
7
+ ispAmount1: bigint;
8
+ ispFee0: bigint;
9
+ ispFee1: bigint;
10
+ uniAmount0: bigint;
11
+ uniAmount1: bigint;
12
+ uniFee0: bigint;
13
+ uniFee1: bigint;
14
+ }
15
+ export interface SwapFees {
16
+ /** True when the fee was taken on the USDC side, false when in the coin. */
17
+ isInUSDC: boolean;
18
+ amount: bigint;
19
+ }
20
+ export interface BuySwapData {
21
+ type: "BUY";
22
+ delta: {
23
+ coinsBought: bigint;
24
+ usdcSold: bigint;
25
+ fees: SwapFees;
26
+ };
27
+ }
28
+ export interface SellSwapData {
29
+ type: "SELL";
30
+ delta: {
31
+ coinsSold: bigint;
32
+ usdcBought: bigint;
33
+ fees: SwapFees;
34
+ };
35
+ }
36
+ export type ParsedSwapData = BuySwapData | SellSwapData;
37
+ /**
38
+ * Parses raw PoolSwap log arguments into structured swap data. The three
39
+ * amount-pair legs (fl = fair launch fill, isp = internal swap pool, uni =
40
+ * Uniswap pool) show how a fill was sourced; this nets them into one delta.
41
+ * @param args - The swap log arguments
42
+ * @param usdcIsCurrencyZero - Whether USDC is currency0 in the pool
43
+ * @returns Parsed swap data with type and delta information
44
+ */
45
+ export declare function parseSwapData(args: SwapLogArgs, usdcIsCurrencyZero: boolean): ParsedSwapData;
@@ -0,0 +1,46 @@
1
+ export interface SwapLogArgs {
2
+ flAmount0: bigint;
3
+ flAmount1: bigint;
4
+ flFee0: bigint;
5
+ flFee1: bigint;
6
+ ispAmount0: bigint;
7
+ ispAmount1: bigint;
8
+ ispFee0: bigint;
9
+ ispFee1: bigint;
10
+ uniAmount0: bigint;
11
+ uniAmount1: bigint;
12
+ uniFee0: bigint;
13
+ uniFee1: bigint;
14
+ }
15
+ export interface SwapFees {
16
+ /** True when the fee was taken on the USDC side, false when in the coin. */
17
+ isInUSDC: boolean;
18
+ amount: bigint;
19
+ }
20
+ export interface BuySwapData {
21
+ type: "BUY";
22
+ delta: {
23
+ coinsBought: bigint;
24
+ usdcSold: bigint;
25
+ fees: SwapFees;
26
+ };
27
+ }
28
+ export interface SellSwapData {
29
+ type: "SELL";
30
+ delta: {
31
+ coinsSold: bigint;
32
+ usdcBought: bigint;
33
+ fees: SwapFees;
34
+ };
35
+ }
36
+ export type ParsedSwapData = BuySwapData | SellSwapData;
37
+ /**
38
+ * Parses raw PoolSwap log arguments into structured swap data. The three
39
+ * amount-pair legs (fl = fair launch fill, isp = internal swap pool, uni =
40
+ * Uniswap pool) show how a fill was sourced; this nets them into one delta.
41
+ * @param args - The swap log arguments
42
+ * @param usdcIsCurrencyZero - Whether USDC is currency0 in the pool
43
+ * @returns Parsed swap data with type and delta information
44
+ */
45
+ export declare function parseSwapData(args: SwapLogArgs, usdcIsCurrencyZero: boolean): ParsedSwapData;
46
+ //# sourceMappingURL=parseSwap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseSwap.d.ts","sourceRoot":"","sources":["../../src/utils/parseSwap.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,4EAA4E;IAC5E,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE;QACL,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,QAAQ,CAAC;KAChB,CAAC;CACH;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE;QACL,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,QAAQ,CAAC;KAChB,CAAC;CACH;AAED,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,YAAY,CAAC;AAExD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,WAAW,EACjB,kBAAkB,EAAE,OAAO,GAC1B,cAAc,CA6EhB"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Applies a slippage tolerance to an amount.
3
+ *
4
+ * @dev EXACT_OUT adds the slippage, EXACT_IN removes it. `slippage` is a
5
+ * fraction string, e.g. "0.05" for 5%.
6
+ */
7
+ export declare const getAmountWithSlippage: ({ amount, slippage, swapType, }: {
8
+ amount: bigint | undefined;
9
+ slippage: string;
10
+ swapType: "EXACT_IN" | "EXACT_OUT";
11
+ }) => bigint;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Applies a slippage tolerance to an amount.
3
+ *
4
+ * @dev EXACT_OUT adds the slippage, EXACT_IN removes it. `slippage` is a
5
+ * fraction string, e.g. "0.05" for 5%.
6
+ */
7
+ export declare const getAmountWithSlippage: ({ amount, slippage, swapType, }: {
8
+ amount: bigint | undefined;
9
+ slippage: string;
10
+ swapType: "EXACT_IN" | "EXACT_OUT";
11
+ }) => bigint;
12
+ //# sourceMappingURL=slippage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slippage.d.ts","sourceRoot":"","sources":["../../src/utils/slippage.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,iCAInC;IACD,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,UAAU,GAAG,WAAW,CAAC;CACpC,WAYA,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { type Address } from "viem";
2
+ import { PoolKey } from "../types.cjs";
3
+ /**
4
+ * Swap-building helpers shared by the quoter and PoolSwap clients. Pool keys,
5
+ * hook data and direction mirror the ubi.fun app and MCP server exactly; the
6
+ * SDK's price bound additionally anchors on the quoted end price so an
7
+ * exact-input trade's own impact does not eat the slippage budget.
8
+ */
9
+ /**
10
+ * Encodes the referrer for the hook: 5% of the swap fee accrues on-chain to
11
+ * this address (claimable from the ReferralEscrow). '0x' means no referrer and
12
+ * the share cascades down the fee split instead. The SAME hookData must be
13
+ * used for the quote and the swap for them to match.
14
+ */
15
+ export declare function referrerHookData(referrer: Address | undefined): `0x${string}`;
16
+ /** Builds the v4 pool key for a coin: USDC on the cash side, hook fixed by the protocol. */
17
+ export declare function coinPoolKey(coinAddress: Address, positionManagerAddress: Address): PoolKey;
18
+ /** True when USDC sorts as currency0 for this coin's pool. */
19
+ export declare function usdcIsCurrencyZero(coinAddress: Address): boolean;
20
+ /**
21
+ * v4 swap direction. Buys spend USDC for the coin: when USDC is currency0
22
+ * that's a zeroForOne swap, otherwise the reverse.
23
+ */
24
+ export declare function swapDirection(side: "buy" | "sell", coinAddress: Address): boolean;
25
+ /**
26
+ * Expected pool sqrt price after an exact-input fill, derived from the quoted
27
+ * amounts through the constant-liquidity identity amountOut/amountIn =
28
+ * sqrtP_start * sqrtP_end (inverted for oneForZero). Hook fees only skew the
29
+ * estimate toward the permissive side, so a slippage margin applied on top of
30
+ * it never lands tighter than the real fill. Falls back to the spot price when
31
+ * a quote leg is zero or the estimate lands on the wrong side of spot.
32
+ */
33
+ export declare function expectedEndSqrtPriceX96({ current, zeroForOne, amountIn, amountOut, }: {
34
+ current: bigint;
35
+ zeroForOne: boolean;
36
+ amountIn: bigint;
37
+ amountOut: bigint;
38
+ }): bigint;
39
+ /**
40
+ * Slippage bound as a sqrt price limit: the pool price may move at most
41
+ * `slippageBps` beyond `current` (pass the expected end price for exact-input
42
+ * swaps, so the trade's own quoted impact is not counted against the budget)
43
+ * before the swap stops filling.
44
+ */
45
+ export declare function sqrtPriceLimit({ current, zeroForOne, slippageBps, }: {
46
+ current: bigint;
47
+ zeroForOne: boolean;
48
+ slippageBps: number;
49
+ }): bigint;
@@ -0,0 +1,50 @@
1
+ import { type Address } from "viem";
2
+ import { PoolKey } from "../types.js";
3
+ /**
4
+ * Swap-building helpers shared by the quoter and PoolSwap clients. Pool keys,
5
+ * hook data and direction mirror the ubi.fun app and MCP server exactly; the
6
+ * SDK's price bound additionally anchors on the quoted end price so an
7
+ * exact-input trade's own impact does not eat the slippage budget.
8
+ */
9
+ /**
10
+ * Encodes the referrer for the hook: 5% of the swap fee accrues on-chain to
11
+ * this address (claimable from the ReferralEscrow). '0x' means no referrer and
12
+ * the share cascades down the fee split instead. The SAME hookData must be
13
+ * used for the quote and the swap for them to match.
14
+ */
15
+ export declare function referrerHookData(referrer: Address | undefined): `0x${string}`;
16
+ /** Builds the v4 pool key for a coin: USDC on the cash side, hook fixed by the protocol. */
17
+ export declare function coinPoolKey(coinAddress: Address, positionManagerAddress: Address): PoolKey;
18
+ /** True when USDC sorts as currency0 for this coin's pool. */
19
+ export declare function usdcIsCurrencyZero(coinAddress: Address): boolean;
20
+ /**
21
+ * v4 swap direction. Buys spend USDC for the coin: when USDC is currency0
22
+ * that's a zeroForOne swap, otherwise the reverse.
23
+ */
24
+ export declare function swapDirection(side: "buy" | "sell", coinAddress: Address): boolean;
25
+ /**
26
+ * Expected pool sqrt price after an exact-input fill, derived from the quoted
27
+ * amounts through the constant-liquidity identity amountOut/amountIn =
28
+ * sqrtP_start * sqrtP_end (inverted for oneForZero). Hook fees only skew the
29
+ * estimate toward the permissive side, so a slippage margin applied on top of
30
+ * it never lands tighter than the real fill. Falls back to the spot price when
31
+ * a quote leg is zero or the estimate lands on the wrong side of spot.
32
+ */
33
+ export declare function expectedEndSqrtPriceX96({ current, zeroForOne, amountIn, amountOut, }: {
34
+ current: bigint;
35
+ zeroForOne: boolean;
36
+ amountIn: bigint;
37
+ amountOut: bigint;
38
+ }): bigint;
39
+ /**
40
+ * Slippage bound as a sqrt price limit: the pool price may move at most
41
+ * `slippageBps` beyond `current` (pass the expected end price for exact-input
42
+ * swaps, so the trade's own quoted impact is not counted against the budget)
43
+ * before the swap stops filling.
44
+ */
45
+ export declare function sqrtPriceLimit({ current, zeroForOne, slippageBps, }: {
46
+ current: bigint;
47
+ zeroForOne: boolean;
48
+ slippageBps: number;
49
+ }): bigint;
50
+ //# sourceMappingURL=swap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swap.d.ts","sourceRoot":"","sources":["../../src/utils/swap.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+C,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AACjF,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAInC;;;;;GAKG;AAEH;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,OAAO,GAAG,SAAS,GAC5B,KAAK,MAAM,EAAE,CAIf;AAED,4FAA4F;AAC5F,wBAAgB,WAAW,CACzB,WAAW,EAAE,OAAO,EACpB,sBAAsB,EAAE,OAAO,GAC9B,OAAO,CAQT;AAED,8DAA8D;AAC9D,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO,CAEhE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,KAAK,GAAG,MAAM,EACpB,WAAW,EAAE,OAAO,GACnB,OAAO,CAIT;AAoBD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,OAAO,EACP,UAAU,EACV,QAAQ,EACR,SAAS,GACV,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,MAAM,CAWT;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAC7B,OAAO,EACP,UAAU,EACV,WAAW,GACZ,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,MAAM,CAsBT"}
@@ -0,0 +1,78 @@
1
+ import { PoolKey } from "../types.cjs";
2
+ export declare const TickFinder: {
3
+ MIN_TICK: number;
4
+ MAX_TICK: number;
5
+ };
6
+ export declare const Q96: bigint;
7
+ export declare const Q192: bigint;
8
+ export declare const TICK_SPACING = 60;
9
+ export declare const getPoolId: (poolKey: PoolKey) => `0x${string}`;
10
+ export declare const orderPoolKey: (poolKey: PoolKey) => {
11
+ currency0: `0x${string}`;
12
+ currency1: `0x${string}`;
13
+ fee: number;
14
+ tickSpacing: number;
15
+ hooks: import("abitype").Address;
16
+ };
17
+ export declare const getValidTick: ({ tick, tickSpacing, roundDown, }: {
18
+ tick: number;
19
+ tickSpacing: number;
20
+ roundDown?: boolean;
21
+ }) => number;
22
+ export declare const getNearestUsableTick: ({ tick, tickSpacing, }: {
23
+ tick: number;
24
+ tickSpacing: number;
25
+ }) => number;
26
+ export declare const getSqrtPriceX96FromTick: (tick: number) => bigint;
27
+ export declare const calculateUnderlyingTokenBalances: (liquidity: bigint, tickLower: number, tickUpper: number, tickCurrent: number) => {
28
+ amount0: bigint;
29
+ amount1: bigint;
30
+ };
31
+ export declare const priceRatioToTick: ({ priceInput, isDirection1Per0, decimals0, decimals1, spacing, shouldGetNearestUsableTick, }: {
32
+ priceInput: string;
33
+ isDirection1Per0: boolean;
34
+ decimals0: number;
35
+ decimals1: number;
36
+ spacing: number;
37
+ shouldGetNearestUsableTick?: boolean;
38
+ }) => number;
39
+ /**
40
+ * Accurate liquidity calculation using proper Uniswap v3/v4 math
41
+ */
42
+ export declare const getLiquidityFromAmounts: (params: {
43
+ currentTick: number;
44
+ tickLower: number;
45
+ tickUpper: number;
46
+ amount0: bigint;
47
+ amount1: bigint;
48
+ }) => bigint;
49
+ /**
50
+ * Returns a precise maximum amount of liquidity received for a given amount of token 0 by dividing by Q64 instead of Q96 in the intermediate step,
51
+ * and shifting the subtracted ratio left by 32 bits.
52
+ * @param sqrtRatioAX96 The price at the lower boundary
53
+ * @param sqrtRatioBX96 The price at the upper boundary
54
+ * @param amount0 The token0 amount
55
+ * @returns liquidity for amount0, precise
56
+ */
57
+ export declare function maxLiquidityForAmount0Precise(sqrtRatioAX96: bigint, sqrtRatioBX96: bigint, amount0: bigint): bigint;
58
+ /**
59
+ * Computes the maximum amount of liquidity received for a given amount of token1
60
+ * @param sqrtRatioAX96 The price at the lower tick boundary
61
+ * @param sqrtRatioBX96 The price at the upper tick boundary
62
+ * @param amount1 The token1 amount
63
+ * @returns liquidity for amount1
64
+ */
65
+ export declare function maxLiquidityForAmount1(sqrtRatioAX96: bigint, sqrtRatioBX96: bigint, amount1: bigint): bigint;
66
+ /**
67
+ * Calculate the actual amounts needed for a given liquidity
68
+ * This prevents MaximumAmountExceeded errors by ensuring we provide sufficient maximums
69
+ */
70
+ export declare const getAmountsForLiquidity: (params: {
71
+ currentTick: number;
72
+ tickLower: number;
73
+ tickUpper: number;
74
+ liquidity: bigint;
75
+ }) => {
76
+ amount0: bigint;
77
+ amount1: bigint;
78
+ };
@@ -0,0 +1,79 @@
1
+ import { PoolKey } from "../types.js";
2
+ export declare const TickFinder: {
3
+ MIN_TICK: number;
4
+ MAX_TICK: number;
5
+ };
6
+ export declare const Q96: bigint;
7
+ export declare const Q192: bigint;
8
+ export declare const TICK_SPACING = 60;
9
+ export declare const getPoolId: (poolKey: PoolKey) => `0x${string}`;
10
+ export declare const orderPoolKey: (poolKey: PoolKey) => {
11
+ currency0: `0x${string}`;
12
+ currency1: `0x${string}`;
13
+ fee: number;
14
+ tickSpacing: number;
15
+ hooks: import("abitype").Address;
16
+ };
17
+ export declare const getValidTick: ({ tick, tickSpacing, roundDown, }: {
18
+ tick: number;
19
+ tickSpacing: number;
20
+ roundDown?: boolean;
21
+ }) => number;
22
+ export declare const getNearestUsableTick: ({ tick, tickSpacing, }: {
23
+ tick: number;
24
+ tickSpacing: number;
25
+ }) => number;
26
+ export declare const getSqrtPriceX96FromTick: (tick: number) => bigint;
27
+ export declare const calculateUnderlyingTokenBalances: (liquidity: bigint, tickLower: number, tickUpper: number, tickCurrent: number) => {
28
+ amount0: bigint;
29
+ amount1: bigint;
30
+ };
31
+ export declare const priceRatioToTick: ({ priceInput, isDirection1Per0, decimals0, decimals1, spacing, shouldGetNearestUsableTick, }: {
32
+ priceInput: string;
33
+ isDirection1Per0: boolean;
34
+ decimals0: number;
35
+ decimals1: number;
36
+ spacing: number;
37
+ shouldGetNearestUsableTick?: boolean;
38
+ }) => number;
39
+ /**
40
+ * Accurate liquidity calculation using proper Uniswap v3/v4 math
41
+ */
42
+ export declare const getLiquidityFromAmounts: (params: {
43
+ currentTick: number;
44
+ tickLower: number;
45
+ tickUpper: number;
46
+ amount0: bigint;
47
+ amount1: bigint;
48
+ }) => bigint;
49
+ /**
50
+ * Returns a precise maximum amount of liquidity received for a given amount of token 0 by dividing by Q64 instead of Q96 in the intermediate step,
51
+ * and shifting the subtracted ratio left by 32 bits.
52
+ * @param sqrtRatioAX96 The price at the lower boundary
53
+ * @param sqrtRatioBX96 The price at the upper boundary
54
+ * @param amount0 The token0 amount
55
+ * @returns liquidity for amount0, precise
56
+ */
57
+ export declare function maxLiquidityForAmount0Precise(sqrtRatioAX96: bigint, sqrtRatioBX96: bigint, amount0: bigint): bigint;
58
+ /**
59
+ * Computes the maximum amount of liquidity received for a given amount of token1
60
+ * @param sqrtRatioAX96 The price at the lower tick boundary
61
+ * @param sqrtRatioBX96 The price at the upper tick boundary
62
+ * @param amount1 The token1 amount
63
+ * @returns liquidity for amount1
64
+ */
65
+ export declare function maxLiquidityForAmount1(sqrtRatioAX96: bigint, sqrtRatioBX96: bigint, amount1: bigint): bigint;
66
+ /**
67
+ * Calculate the actual amounts needed for a given liquidity
68
+ * This prevents MaximumAmountExceeded errors by ensuring we provide sufficient maximums
69
+ */
70
+ export declare const getAmountsForLiquidity: (params: {
71
+ currentTick: number;
72
+ tickLower: number;
73
+ tickUpper: number;
74
+ liquidity: bigint;
75
+ }) => {
76
+ amount0: bigint;
77
+ amount1: bigint;
78
+ };
79
+ //# sourceMappingURL=univ4.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"univ4.d.ts","sourceRoot":"","sources":["../../src/utils/univ4.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnC,eAAO,MAAM,UAAU;;;CAGtB,CAAC;AAEF,eAAO,MAAM,GAAG,QAAY,CAAC;AAC7B,eAAO,MAAM,IAAI,QAAa,CAAC;AAE/B,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B,eAAO,MAAM,SAAS,GAAI,SAAS,OAAO,kBAWzC,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,SAAS,OAAO;;;;;;CAY5C,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,mCAI1B;IACD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,WAoBA,CAAC;AAGF,eAAO,MAAM,oBAAoB,GAAI,wBAGlC;IACD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB,KAAG,MAGH,CAAC;AAyCF,eAAO,MAAM,uBAAuB,GAAI,MAAM,MAAM,KAAG,MA4DtD,CAAC;AAEF,eAAO,MAAM,gCAAgC,GAC3C,WAAW,MAAM,EACjB,WAAW,MAAM,EACjB,WAAW,MAAM,EACjB,aAAa,MAAM,KAClB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAqCpC,CAAC;AAGF,eAAO,MAAM,gBAAgB,GAAI,8FAO9B;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACtC,KAAG,MA6CH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAAI,QAAQ;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,WA8BA,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC3C,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,GACd,MAAM,CAeR;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,GACd,MAAM,CAYR;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GAAI,QAAQ;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,KAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CA8CrC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,161 @@
1
+ {
2
+ "name": "@ubi.fun/sdk",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK for the ubi.fun protocol on Arc: launch coins, trade USDC pools, and claim creator, referral, and daily holder rewards",
5
+ "license": "MIT",
6
+ "author": "ubi.fun",
7
+ "homepage": "https://github.com/ubidotfun/ubifun-sdk#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/ubidotfun/ubifun-sdk.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/ubidotfun/ubifun-sdk/issues"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "keywords": [
19
+ "ubi.fun",
20
+ "ubi",
21
+ "memecoin",
22
+ "launchpad",
23
+ "uniswap v4",
24
+ "arc",
25
+ "circle",
26
+ "usdc",
27
+ "sdk"
28
+ ],
29
+ "type": "module",
30
+ "main": "dist/index.cjs",
31
+ "module": "dist/index.js",
32
+ "unpkg": "dist/index.umd.cjs",
33
+ "types": "dist/index.d.ts",
34
+ "sideEffects": false,
35
+ "exports": {
36
+ ".": {
37
+ "import": {
38
+ "types": "./dist/index.d.ts",
39
+ "default": "./dist/index.js"
40
+ },
41
+ "require": {
42
+ "types": "./dist/index.d.cts",
43
+ "default": "./dist/index.cjs"
44
+ }
45
+ },
46
+ "./abi": {
47
+ "import": {
48
+ "types": "./dist/abi/index.d.ts",
49
+ "default": "./dist/abi/index.js"
50
+ },
51
+ "require": {
52
+ "types": "./dist/abi/index.d.cts",
53
+ "default": "./dist/abi/index.cjs"
54
+ }
55
+ },
56
+ "./addresses": {
57
+ "import": {
58
+ "types": "./dist/addresses.d.ts",
59
+ "default": "./dist/addresses/index.js"
60
+ },
61
+ "require": {
62
+ "types": "./dist/addresses.d.cts",
63
+ "default": "./dist/addresses/index.cjs"
64
+ }
65
+ },
66
+ "./helpers": {
67
+ "import": {
68
+ "types": "./dist/helpers/index.d.ts",
69
+ "default": "./dist/helpers/index.js"
70
+ },
71
+ "require": {
72
+ "types": "./dist/helpers/index.d.cts",
73
+ "default": "./dist/helpers/index.cjs"
74
+ }
75
+ },
76
+ "./hooks": {
77
+ "import": {
78
+ "types": "./dist/hooks/index.d.ts",
79
+ "default": "./dist/hooks/index.js"
80
+ },
81
+ "require": {
82
+ "types": "./dist/hooks/index.d.cts",
83
+ "default": "./dist/hooks/index.cjs"
84
+ }
85
+ },
86
+ "./utils": {
87
+ "import": {
88
+ "types": "./dist/utils/index.d.ts",
89
+ "default": "./dist/utils/index.js"
90
+ },
91
+ "require": {
92
+ "types": "./dist/utils/index.d.cts",
93
+ "default": "./dist/utils/index.cjs"
94
+ }
95
+ }
96
+ },
97
+ "typesVersions": {
98
+ "*": {
99
+ "abi": [
100
+ "./dist/abi/index.d.ts"
101
+ ],
102
+ "addresses": [
103
+ "./dist/addresses.d.ts"
104
+ ],
105
+ "helpers": [
106
+ "./dist/helpers/index.d.ts"
107
+ ],
108
+ "hooks": [
109
+ "./dist/hooks/index.d.ts"
110
+ ],
111
+ "utils": [
112
+ "./dist/utils/index.d.ts"
113
+ ]
114
+ }
115
+ },
116
+ "files": [
117
+ "dist"
118
+ ],
119
+ "engines": {
120
+ "node": ">=18"
121
+ },
122
+ "scripts": {
123
+ "build": "rimraf dist && tsc --emitDeclarationOnly && rollup -c && node scripts/emit-cts.mjs",
124
+ "dev": "rollup -c -w",
125
+ "clean": "rimraf dist",
126
+ "prepublishOnly": "npm run build",
127
+ "typecheck": "tsc --noEmit",
128
+ "docs:generate": "typedoc --plugin typedoc-plugin-markdown --out docs src/index.ts --excludeExternals --exclude '**/abi/**' --includeVersion",
129
+ "docs:llms": "node scripts/generate-llms-doc.js"
130
+ },
131
+ "packageManager": "pnpm@8.15.4",
132
+ "devDependencies": {
133
+ "@rollup/plugin-commonjs": "^28",
134
+ "@rollup/plugin-json": "^6",
135
+ "@rollup/plugin-node-resolve": "^16",
136
+ "@rollup/plugin-terser": "^0.4.4",
137
+ "@types/react": "^19.0.10",
138
+ "esbuild": "^0.28.1",
139
+ "rimraf": "^6.0.1",
140
+ "rollup": "^4",
141
+ "rollup-plugin-esbuild": "^6.2.1",
142
+ "tslib": "^2.4.0",
143
+ "typedoc": "^0.25.12",
144
+ "typedoc-plugin-markdown": "^3.17.1",
145
+ "typescript": "^5.3.3"
146
+ },
147
+ "dependencies": {
148
+ "@delvtech/drift": "^0.11.1",
149
+ "@delvtech/drift-viem": "^0.11.1",
150
+ "axios": "^1.19.0",
151
+ "viem": "^2.55.11"
152
+ },
153
+ "peerDependencies": {
154
+ "react": ">=18"
155
+ },
156
+ "peerDependenciesMeta": {
157
+ "react": {
158
+ "optional": true
159
+ }
160
+ }
161
+ }