@baseline-markets/sdk 1.0.0 → 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.
- package/README.md +18 -10
- package/package.json +1 -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
|
|
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.
|
|
53
|
-
const hash = await sdk.buyTokensExactOut(bToken, 100n, quote.
|
|
54
|
-
|
|
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
|
-
|
|
67
|
-
await sdk.
|
|
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, {
|
|
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 `
|
|
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, //
|
|
202
|
+
defaultUseNative: true, // use native ETH paths by default where supported
|
|
195
203
|
});
|
|
196
204
|
```
|
|
197
205
|
|
package/package.json
CHANGED