Skip to content

Swap across chains trustlessly using the power of timing games and black-scholes

License

Notifications You must be signed in to change notification settings

cdrn/cross-chain-atomics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cross-Chain Atomics

Test Lint

A platform for executing cross-chain atomic swaps between Bitcoin and Ethereum. This is an attempt to create feasible cross chain atomic swaps by pricing in volatility up to the duration of the commited timelock. Here's a quick overview of how it should work.

Taker (has ETH)                    Maker (has BTC)
|                                     |
|-- Request quote ------------------>.|
|                                     |
|<-- Quote (amount, premium, t) ------|
|                                     |
|-- Accept quote ------------------->.|
|                                     |
|                                     |-- Generate secret (s) ------->|
|                                     |-- Calculate hash (h=H(s)) --->|
|                                     |
|                                     |-- Lock BTC with (h,t1) ----->|
|                                     |
|<---- Notify BTC locked -------------|
|                                     |
|-- Lock ETH with (h,t2) ------------>|
|                                     |
|<---- Verify ETH locked -------------|
|                                     |
|<---- Maker claims ETH with s -------|
|                                     |
|-- Observe s on ETH chain ---------->|
|                                     |
|-- Claim BTC with revealed s ------->|

The Maker's price in the first pass should be determined by the scholes-equation over the period of the timelock. In this way, we're attempting to "price in" the volatility of the asset pair for the period of the time lock. This should economically incentivise the maker to follow through with the swap.

Takers are disincetivised from wasting Makers' time through the provisioning of an upfront fee to generate a quote and create an order.

Project Structure

  • backend/ - Server handling Bitcoin operations, pricing, and orderbook
  • frontend/ - Web interface for interacting with atomic swaps
  • contracts/ - Ethereum smart contracts for atomic swap functionality

Development Setup

  1. Install dependencies:
# Install backend dependencies
cd backend && npm install
cd ..

# Install frontend dependencies
cd frontend && npm install
cd ..
  1. Start development:
# Start backend
npm run dev

# In another terminal, start frontend
npm run dev:frontend

Building

npm run build

Testing

npm test

Requirements

  • Node.js >= 18.0.0
  • Ethereum development environment (e.g., Hardhat)
  • Bitcoin Core (for mainnet/testnet) or btcd (for development)

About

Swap across chains trustlessly using the power of timing games and black-scholes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published