Inspiration;
The crypto trading landscape forces Bitcoin holders into an uncomfortable choice: sell their BTC to access leveraged trading, or trust centralized exchanges with custody of their assets. Both options come with significant drawbacks - selling triggers tax events and means missing out on potential BTC appreciation, while CEXs introduce counterparty risk and require invasive KYC processes.
We wanted to solve this fundamental problem by enabling Bitcoin holders to trade perpetual futures while maintaining full custody of their assets. The vision was simple: use tokenized Bitcoin (tBTC) as collateral on Starknet, eliminating the need to sell or transfer custody while accessing sophisticated trading instruments.
What it does;
Bytros is a decentralized perpetuals trading platform on Starknet that accepts tBTC as collateral. Users can deposit tBTC, open leveraged positions (1-20x) across 50+ markets including BTC/USD, ETH/USD, and other major crypto pairs, and trade without gas fees through AVNU Paymaster integration.
The platform handles the complete trading lifecycle: collateral management, position opening/closing, real-time price feeds via Pragma Oracle, and liquidation monitoring. Users maintain complete control of their funds throughout, with all operations secured by Bitcoin ECDSA signature verification and replay attack protection.
How we built it;
The core is a Cairo smart contract deployed on Starknet Sepolia that manages collateral and positions. We integrated four major protocols: tBTC for tokenized Bitcoin collateral, AVNU Paymaster for gasless transactions using SNIP-9 v2 meta-transactions, Extended Protocol for access to 50+ perpetual markets, and Pragma Oracle for reliable price feeds.
The contract implements position lifecycle management with automatic collateral locking, leverage calculations, and liquidation health monitoring. We built comprehensive testing with Starknet Foundry, covering deposit/withdrawal flows, position management, access control, and edge cases. Development followed an iterative approach with frequent testing and refinement based on real-world integration challenges.
Challenges we ran into;
Cairo's paradigm shift from Solidity required significant adjustment, particularly around storage patterns and the lack of native floating-point arithmetic. We implemented custom fixed-point math with 8-decimal precision for all financial calculations.
AVNU Paymaster integration proved complex due to limited documentation on SNIP-9 v2. We had to reverse-engineer examples and discovered critical implementation details like the requirement to use injected wallet accounts rather than manually created Account instances.
Multi-wallet compatibility required extensive testing across ArgentX, Braavos v1.1.0, and Xverse, each with different account implementations. Gas optimization was another focus area - initial implementations had high costs that we reduced by approximately 30% through storage access optimization and data structure refinements.
Accomplishments that we're proud of;
We successfully implemented every component outlined in the original proposal for Native Bitcoin Collateral Perps Trading. The project fully integrates all four sponsor technologies as specified:
Complete Xverse Integration: Implemented native Xverse wallet connection with Starknet support, enabling Bitcoin holders to authenticate and trade directly from their Bitcoin wallet without additional setup.
Full Extended Protocol Integration: Connected to Extended's perpetuals infrastructure, providing access to all 50+ markets including crypto and TradFi assets. Built complete position lifecycle management with their unified margin system.
Production AVNU Paymaster Implementation: Achieved fully gasless trading with SNIP-9 v2 meta-transactions. Users can pay fees in USDC, ETH, or STRK instead of requiring ETH for gas, removing a major friction point for Bitcoin-native users.
Native tBTC Collateral System: Built comprehensive collateral management allowing Bitcoin holders to deposit tBTC and use it directly for leveraged trading without bridging or conversion, maintaining the Bitcoin-native experience proposed.
Complete Feature Set: Delivered all key differentiators from the proposal - no KYC required, native Bitcoin collateral, gasless execution, 50+ markets access, full self-custody, and fast execution on Starknet. The platform handles deposits, withdrawals, position opening/closing, liquidation monitoring, and real-time price feeds through Pragma Oracle integration.
Security and Testing: Implemented Bitcoin ECDSA signature verification, replay attack protection, and comprehensive test coverage with 12+ test cases validating all critical paths.
What we learned;
Cairo development requires a different mental model than EVM languages. Storage operations, event handling, and mathematical operations all follow distinct patterns that took time to internalize. We gained deep understanding of Starknet's account abstraction model, particularly how meta-transactions work with execute_from_outside.
Oracle integration taught us about price feed reliability, staleness checks, and the importance of fallback mechanisms. We learned practical aspects of fixed-point arithmetic in smart contracts and the tradeoffs between precision and gas costs.
The integration work provided hands-on experience with production DeFi protocols and the importance of thorough testing when composing multiple external dependencies.
What's next for Bytros;
The roadmap includes mainnet deployment after security audits, cross-margin trading to share collateral across positions, and advanced order types like limit orders and stop-loss/take-profit. Longer term, we're planning a liquidation engine, funding rate mechanisms, mobile applications, and social trading features including copy trading and leaderboards.
Built With
- avnu
- avnu/avnu-sdk
- cairo
- gasless
- network
- next.js
- oracle
- paymester
- pragma
- react
- sats-connect
- scarb
- sepolia
- starknet
- starknet-io/get-starknet
- starkscan
- tailwind
- testnet
- threshold
- typescript
- zustand
Log in or sign up for Devpost to join the conversation.