Skip to content

Commit 27f4de5

Browse files
committed
Fix non-ASCII chars in contracts, fix broadcast serialization
1 parent ca8d2ae commit 27f4de5

4 files changed

Lines changed: 16 additions & 13 deletions

File tree

contracts/flashstack-pool-oracle.clar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
;; - Pool balance only increases (fees flow in, verified by reserve invariant)
1010
;; - Flash loans cannot inflate the pool: the reserve invariant check inside
1111
;; flashstack-stx-pool ensures balance grows by >= fee after every loan
12-
;; - No external price feeds required purely on-chain, single-asset
12+
;; - No external price feeds required - purely on-chain, single-asset
1313
;;
1414
;; Integration pattern for lending protocols:
1515
;; 1. Call get-share-price to get current STX value per share (in microstacks)

contracts/flashstack-sbtc-pool.clar

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
;;
33
;; LP pool for canonical sBTC flash loans.
44
;; Depositors earn sBTC yield from every flash loan fee.
5-
;; Share value is denominated in sats appreciates with BTC.
5+
;; Share value is denominated in sats - appreciates with BTC.
66
;;
77
;; Share model (identical to flashstack-stx-pool but in sats):
88
;; shares_minted = deposit * total_shares / pool_balance
@@ -12,14 +12,14 @@
1212
;;
1313
;; Collateral oracle:
1414
;; get-share-price returns sats per share (scaled by SHARE-PRECISION)
15-
;; Lending protocols can call this directly no external oracle needed
15+
;; Lending protocols can call this directly - no external oracle needed
1616
;; Flash loan manipulation-resistant: reserve invariant guarantees
1717
;; pool balance only ever grows by >= fee per loan
1818
;;
1919
;; Security model:
2020
;; - Receiver whitelist prevents arbitrary contracts from borrowing
2121
;; - Repayment verified by reserve balance before/after
22-
;; - Admin cannot drain pool only set parameters
22+
;; - Admin cannot drain pool - only set parameters
2323

2424
(use-trait sbtc-flash-receiver-trait 'SP20XD46NGAX05ZQZDKFYCCX49A3852BQABNP0VG5.sbtc-flash-receiver-trait.sbtc-flash-receiver-trait)
2525

@@ -52,7 +52,7 @@
5252
(define-data-var total-volume uint u0)
5353
(define-data-var total-fees uint u0)
5454

55-
(define-constant SHARE-PRECISION u100000000) ;; 1e8 matches sBTC sat precision
55+
(define-constant SHARE-PRECISION u100000000) ;; 1e8 - matches sBTC sat precision
5656

5757
(define-map approved-receivers principal bool)
5858
(define-map lp-shares principal uint)
@@ -138,7 +138,7 @@
138138
;; Invoke receiver callback
139139
(try! (contract-call? receiver execute-sbtc-flash amount (as-contract tx-sender)))
140140

141-
;; Verify repayment reserve must have grown by >= fee
141+
;; Verify repayment - reserve must have grown by >= fee
142142
(let ((reserve-after (unwrap!
143143
(contract-call? 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token
144144
get-balance (as-contract tx-sender))
@@ -202,7 +202,7 @@
202202
)
203203

204204
;; =============================================
205-
;; Read-only including collateral oracle
205+
;; Read-only - including collateral oracle
206206
;; =============================================
207207

208208
;; Current value of one pool share in sats, scaled by SHARE-PRECISION (1e8).

contracts/velar-sbtc-arb-receiver.clar

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
;; FlashStack Velar sBTC Arbitrage Receiver
1+
;; FlashStack - Velar sBTC Arbitrage Receiver
22
;;
33
;; Borrows canonical sBTC from flashstack-sbtc-core, swaps it for wSTX
44
;; on the Velar wSTX<>sBTC pool (pool ID 70), then swaps back to sBTC and repays.
@@ -17,10 +17,10 @@
1717
;; 2. Leg 1: swap sBTC -> wSTX (sBTC is token1 in pool 70, wSTX is token0)
1818
;; 3. Leg 2: swap wSTX -> sBTC
1919
;; 4. Repay core: amount + 0.05% fee (min 1 sat)
20-
;; 5. Any surplus sBTC stays here sweep via sweep-sbtc
20+
;; 5. Any surplus sBTC stays here - sweep via sweep-sbtc
2121
;;
2222
;; Note: must be whitelisted in flashstack-sbtc-core before borrowing.
23-
;; min-out is u1 on both legs repayment invariant is the real safety gate.
23+
;; min-out is u1 on both legs - repayment invariant is the real safety gate.
2424

2525
(impl-trait 'SP20XD46NGAX05ZQZDKFYCCX49A3852BQABNP0VG5.sbtc-flash-receiver-trait.sbtc-flash-receiver-trait)
2626

@@ -54,7 +54,7 @@
5454
(owed (+ amount fee))
5555
)
5656
;; Leg 1: sBTC -> wSTX
57-
;; Pool 70: token0=wSTX, token1=sBTC swapping token1 for token0
57+
;; Pool 70: token0=wSTX, token1=sBTC - swapping token1 for token0
5858
(unwrap!
5959
(as-contract (contract-call? 'SP1Y5YSTAHZ88XYK1VPDH24GY0HPX5J4JECTMY4A1.univ2-router
6060
swap-exact-tokens-for-tokens

scripts/deploy-lp-oracle-and-sbtc-pool.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,11 @@ async function waitForConfirm(txid, label) {
7474
}
7575

7676
async function broadcast(tx) {
77-
// tx.serialize() returns raw Uint8Array — always safe to POST as octet-stream
78-
const bytes = tx.serialize();
77+
// serialize() may return hex string or Uint8Array depending on SDK version
78+
const raw = tx.serialize();
79+
const bytes = typeof raw === "string"
80+
? Buffer.from(raw.replace(/^0x/, ""), "hex")
81+
: raw;
7982
const res = await fetch(`${API}/v2/transactions`, {
8083
method: "POST",
8184
headers: { "Content-Type": "application/octet-stream" },

0 commit comments

Comments
 (0)