Skip to content

Commit 28c7b43

Browse files
authored
chore: release v3.1.2 (#1059)
* properly ignore files for biome * add explicit checks * remove broken link and use next steps directive (#1055) * update redirects for clarinet and token metadata api (#1058)
1 parent 06e4b02 commit 28c7b43

File tree

2 files changed

+30
-37
lines changed

2 files changed

+30
-37
lines changed

content/docs/resources/guides/using-pyth-price-feeds.mdx

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ graph LR
2828
D -->|Submit VAA + TX| E[Stacks Chain]
2929
E -->|Verify & Update| F[Pyth Oracle Contract]
3030
F -->|Fresh Price| G[Your Contract]
31-
31+
3232
style A fill:#FF7733,stroke:#0d0c0c,stroke-width:2px,color:#0d0c0c
3333
style C fill:#B3D9FF,stroke:#0d0c0c,stroke-width:2px,color:#0d0c0c
3434
style D fill:#F5F5F5,stroke:#0d0c0c,stroke-width:2px,color:#0d0c0c
@@ -72,7 +72,7 @@ We'll create a "Benjamin Club" - an exclusive NFT that costs exactly $100 worth
7272
<Steps>
7373
<Step>
7474
### Write the smart contract
75-
75+
7676
First, implement the Clarity contract that reads Pyth price data:
7777

7878
```clarity contracts/benjamin-club.clar
@@ -105,32 +105,32 @@ We'll create a "Benjamin Club" - an exclusive NFT that costs exactly $100 worth
105105
pyth-decoder-contract: PYTH-DECODER,
106106
wormhole-core-contract: WORMHOLE-CORE
107107
})))
108-
108+
109109
;; Get the updated BTC price
110110
(price-data (try! (contract-call? PYTH-ORACLE
111111
get-price BTC-USD-FEED-ID PYTH-STORAGE)))
112-
112+
113113
;; Process the price data
114114
(btc-price (process-price-data price-data))
115-
115+
116116
;; Calculate required sBTC amount for $100
117117
(required-sbtc (calculate-sbtc-amount btc-price))
118-
118+
119119
;; Get user's sBTC balance
120-
(user-balance (unwrap!
120+
(user-balance (unwrap!
121121
(contract-call? .sbtc-token get-balance tx-sender)
122122
ERR-INSUFFICIENT-FUNDS))
123123
)
124124
;; Verify price is fresh (less than 5 minutes old)
125125
(try! (verify-price-freshness price-data))
126-
126+
127127
;; Verify user has enough sBTC
128128
(asserts! (>= user-balance required-sbtc) ERR-INSUFFICIENT-FUNDS)
129-
129+
130130
;; Transfer sBTC from user
131-
(try! (contract-call? .sbtc-token transfer
131+
(try! (contract-call? .sbtc-token transfer
132132
required-sbtc tx-sender (as-contract tx-sender) none))
133-
133+
134134
;; Mint the NFT
135135
(let ((token-id (+ (var-get last-token-id) u1)))
136136
(try! (nft-mint? benjamin-nft token-id tx-sender))
@@ -182,7 +182,7 @@ We'll create a "Benjamin Club" - an exclusive NFT that costs exactly $100 worth
182182

183183
<Step>
184184
### Build the frontend integration
185-
185+
186186
Create a service to fetch price data from Pyth:
187187

188188
```typescript frontend/pyth-service.ts
@@ -201,7 +201,7 @@ We'll create a "Benjamin Club" - an exclusive NFT that costs exactly $100 worth
201201

202202
const vaas = await pythClient.getLatestVaas([PRICE_FEEDS.BTC_USD]);
203203
const messageBuffer = Buffer.from(vaas[0], 'base64');
204-
204+
205205
return `0x${messageBuffer.toString('hex')}`;
206206
}
207207
```
@@ -222,7 +222,7 @@ We'll create a "Benjamin Club" - an exclusive NFT that costs exactly $100 worth
222222
try {
223223
// Fetch fresh price data
224224
const priceVAA = await fetchBTCPriceVAA();
225-
225+
226226
// Create post-conditions for safety
227227
const postConditions = [
228228
// Oracle fee (1 uSTX max)
@@ -249,8 +249,8 @@ We'll create a "Benjamin Club" - an exclusive NFT that costs exactly $100 worth
249249
};
250250

251251
return (
252-
<button
253-
onClick={handleMint}
252+
<button
253+
onClick={handleMint}
254254
disabled={loading}
255255
className="px-6 py-3 bg-blue-600 text-white rounded-lg"
256256
>
@@ -265,7 +265,7 @@ We'll create a "Benjamin Club" - an exclusive NFT that costs exactly $100 worth
265265

266266
<Step>
267267
### Test your implementation
268-
268+
269269
Write comprehensive tests using Clarinet:
270270

271271
```typescript tests/benjamin-club.test.ts
@@ -343,7 +343,7 @@ try {
343343
Batch multiple price updates when possible:
344344

345345
```clarity
346-
(define-public (update-multiple-prices
346+
(define-public (update-multiple-prices
347347
(btc-vaa (buff 8192))
348348
(eth-vaa (buff 8192))
349349
(stx-vaa (buff 8192)))
@@ -362,14 +362,14 @@ Batch multiple price updates when possible:
362362
Ensure you're fetching VAA data with `binary: true` option and converting from base64 to hex correctly. The VAA must be recent (typically within 5 minutes).
363363
</AccordionContent>
364364
</AccordionItem>
365-
365+
366366
<AccordionItem value="price-conversion">
367367
<AccordionTrigger>Price calculations are incorrect</AccordionTrigger>
368368
<AccordionContent>
369369
Check that you're handling the exponent correctly. Pyth uses fixed-point representation where the actual price = raw_price * 10^exponent. For negative exponents, divide by 10^(-exponent).
370370
</AccordionContent>
371371
</AccordionItem>
372-
372+
373373
<AccordionItem value="gas-issues">
374374
<AccordionTrigger>Transaction runs out of gas</AccordionTrigger>
375375
<AccordionContent>
@@ -408,22 +408,9 @@ Batch multiple price updates when possible:
408408

409409
- [Pyth Network documentation](https://docs.pyth.network)
410410
- [Trust Machines Pyth integration](https://github.com/Trust-Machines/stacks-pyth-bridge)
411-
- [Example repository](https://github.com/your-org/benjamin-club-example)
412411
- [Wormhole VAA specification](https://wormhole.com/docs/protocol/infrastructure/vaas/)
413412

414-
## Next steps
415-
416-
Now that you understand Pyth oracle integration:
417-
418-
<Cards>
419-
<NextCard
420-
href="/resources/clarity/external-data"
421-
title="Deep dive: Clarity"
422-
description="Advanced oracle patterns and optimizations"
423-
/>
424-
<NextCard
425-
href="/reference/stacks.js/pyth-oracle-integration"
426-
title="Deep dive: Frontend"
427-
description="Building production-ready oracle UIs"
428-
/>
429-
</Cards>
413+
:::next-steps
414+
- [Deep dive on Clarity](/resources/clarity/external-data): Advanced oracle patterns and optimizations
415+
- [Deep dive on frontend](/reference/stacks.js/pyth-oracle-integration): Building production-ready oracle UIs
416+
:::

vercel.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@
4444
"destination": "/apis/ordinals-api",
4545
"permanent": true
4646
},
47+
{ "source": "/clarinet", "destination": "/tools/clarinet", "permanent": true },
48+
{
49+
"source": "/token-metadata-api",
50+
"destination": "/apis/token-metadata-api",
51+
"permanent": true
52+
},
4753
{ "source": "/bitcoin/runes/:path*", "destination": "/apis/runes-api", "permanent": true },
4854
{ "source": "/stacks/:path*", "destination": "/", "permanent": true },
4955
{ "source": "/bitcoin/:path*", "destination": "/", "permanent": true },

0 commit comments

Comments
 (0)