atomiq.exchange enables trustless swaps between smart chains (chains supporting complex smart contracts - Solana, EVM, Starknet, etc.) and Bitcoin (both on-chain - L1 and lightning network - L2). On-chain swaps are based on an escrow system (similar to atomic swaps) and utilize permissionless bitcoin light clients deployed on smart chains to secure swaps. Lightning network swaps use HTLC atomic swaps. Please refer to our docs for detailed system overview.
Manages initialization, claiming & refunds of swap escrows, LP vaults & reputation tracking:
- Escrow - structure holding funds, can be claimed by claimer (the intended recipient of the escrow funds) upon satisfying the conditions as set in the claim handler (external contract) used for the escrow & can be refunded by the offerer (who funded the escrow), upon satisfying the conditions as set in the refund handler (external contract) used in the escrow. Escrow can also be cooperatively closed with the claimer's signature, immediately returning funds to offerer and skipping refund handler verification.
- LP vault - funds deposited into the smart contract by the LPs (intermediary nodes), that can be used for swaps
- Reputation tracking - the contract tracks count & volume of swaps with a specific outcome (success, failed, cooperative_close), enabling users to identify LPs that fail to process swaps often.
Set the conditions that need to be satisfied by the claimer before they are able to claim the swap funds. The escrow contains the address of a specific claim handler to be used, along with a commitment to the conditions that need to be satisified. In order to claim the claimer provides a witness that satisfies the conditions set forth by the claim handler.
Set the conditions that need to be satisfied by the offerer before they are able to refund the swap funds. The escrow contains the address of a specific refund handler to be used, along with a commitment to the conditions that need to be satisified. In order to refund the offerer provides a witness that satisfies the conditions set forth by the refund handler.
/packages/common
- common (claim & refund handler interfaces)/packages/btc_utils
- bitcoin utilities (bitcoin SPV merkle tree verification & transaction parsing)/packages/erc20_utils
- erc20 utilities (transfer from, transfer & balance)
/packages/btc_relay
- bitcoin relay (bitcoin SPV light client)/packages/escrow_manager
- escrow manager (handling swap escrows, lp vaults & reputation)- Refund handlers:
/packages/timelock_refund_handler
- allows refund after a specifed timestamp, used by all current swaps.
- Claim handlers:
/packages/hashlock_claim_handler
- claim based on the knowledge of a secret preimage of a sha256 hash, BTC (lightning) -> SC & SC -> BTC (lightning) swaps./packages/btc_txid_claim_handler
- claim based on the confirmation of a specific transaction id on the bitcoin chain, as verified through the btc_relay contract, currently not used, future uses include ordinals/runes/rgb/taro swaps./packages/btc_output_claim_handler
- claim based on the confirmation of a transaction containing a pre-specified output script & amount on the bitcoin chain, as verified through the btc_relay contract, used for BTC (on-chain) -> SC swaps./packages/btc_nonced_output_claim_handler
- claim based on the confirmation of a transaction containing a pre-specified output script & amount + pre-specified nonce (a combination of transaction's timelock & input's nSequence) on the bitcoin chain, as verified through the btc_relay contract, used for SC -> BTC (on-chain) swaps.
In order to test the contracts simply run scarb test
, this will first run the scripts to generate the test data and then use snforge to test all the contracts and libraries.