@baseline-markets/sdk 0.0.3 → 1.0.1

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 (2) hide show
  1. package/README.md +18 -12
  2. package/package.json +2 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A typed TypeScript SDK for interacting with [Baseline Protocol](https://baseline.markets) contracts via [viem](https://viem.sh).
4
4
 
5
- Baseline is an onchain AMM for leveraged tokens — `@baseline-markets/sdk` exposes a single `BaselineSDK` class covering token launches, swaps, borrowing, leverage, staking, and rewards.
5
+ Baseline is an onchain AMM for tokens with built-in liquidity — `@baseline-markets/sdk` exposes a single `BaselineSDK` class covering token launches, swaps, borrowing, leverage, staking, and rewards.
6
6
 
7
7
  ## Install
8
8
 
@@ -49,9 +49,9 @@ const quote = await sdk.quoteBuyExactOut(bToken, 100n);
49
49
  ### Swaps
50
50
 
51
51
  ```ts
52
- // Buy exactly 100 bTokens, capped at `quote.reservesIn` reserve in
53
- const hash = await sdk.buyTokensExactOut(bToken, 100n, quote.reservesIn, {
54
- wait: true,
52
+ // Buy exactly 100 bTokens, capped at `quote.amountIn` reserve in
53
+ const hash = await sdk.buyTokensExactOut(bToken, 100n, quote.amountIn, {
54
+ confirmations: 1,
55
55
  });
56
56
 
57
57
  // Sell 100 bTokens, accept at least `minOut` reserve out
@@ -62,9 +62,17 @@ const hash2 = await sdk.sellTokensExactIn(bToken, 100n, minOut);
62
62
 
63
63
  ```ts
64
64
  await sdk.deposit(bToken, collateral);
65
- await sdk.borrow(bToken, debtAmount);
66
- await sdk.leverage(bToken, collateral, targetLTV);
67
- await sdk.repay(bToken, debtAmount);
65
+ await sdk.borrow(bToken, debtAmount, recipient);
66
+
67
+ const leverageQuote = await sdk.quoteLeverage(bToken, collateralIn, leverageFactor);
68
+ await sdk.leverage(
69
+ bToken,
70
+ leverageQuote.targetCollateral,
71
+ collateralIn,
72
+ leverageQuote.maxSwapReservesIn,
73
+ );
74
+
75
+ await sdk.repay(bToken, reservesIn, recipient);
68
76
  await sdk.claim(bToken);
69
77
  ```
70
78
 
@@ -165,7 +173,7 @@ function BuyButton({ bToken, amount, maxIn }: {
165
173
 
166
174
  const buy = useMutation({
167
175
  mutationFn: () =>
168
- sdk!.buyTokensExactOut(bToken, amount, maxIn, { wait: true }),
176
+ sdk!.buyTokensExactOut(bToken, amount, maxIn, { confirmations: 1 }),
169
177
  onError: (err) => {
170
178
  if (err instanceof SDKError && err.kind === 'user_rejected') return;
171
179
  // surface other kinds: insufficient_funds, reverted, network, ...
@@ -183,7 +191,7 @@ function BuyButton({ bToken, amount, maxIn }: {
183
191
  }
184
192
  ```
185
193
 
186
- The `wait: true` option resolves the promise only after the receipt is mined, so `buy.isPending` covers both the wallet-prompt and the on-chain confirmation.
194
+ The `confirmations` option resolves the promise only after the receipt reaches the requested confirmation count, so `buy.isPending` covers both the wallet prompt and the on-chain confirmation.
187
195
 
188
196
  ## Configuration
189
197
 
@@ -191,7 +199,7 @@ The `wait: true` option resolves the promise only after the receipt is mined, so
191
199
 
192
200
  ```ts
193
201
  new BaselineSDK(publicClient, walletClient, {
194
- defaultUseNative: true, // wrap/unwrap ETH automatically for native-reserve pools
202
+ defaultUseNative: true, // use native ETH paths by default where supported
195
203
  });
196
204
  ```
197
205
 
@@ -222,8 +230,6 @@ if (!supportedChainIds.includes(chainId)) {
222
230
 
223
231
  ## Development
224
232
 
225
- This package is part of the [baseline-mono](https://github.com/baseline-markets/baseline-mono) workspace.
226
-
227
233
  ```bash
228
234
  bun install
229
235
  bun run build # bundle ESM + CJS + .d.ts via tsup
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@baseline-markets/sdk",
3
- "version": "0.0.3",
3
+ "version": "1.0.1",
4
4
  "description": "TypeScript SDK for Baseline — the end-to-end asset issuance protocol where tokens own their liquidity.",
5
+ "license": "MIT",
5
6
  "type": "module",
6
7
  "main": "./dist/index.cjs",
7
8
  "module": "./dist/index.js",