Skip to main contentProtocol Flow
Overview
The OdinTrade protocol follows a carefully orchestrated sequence of steps to ensure secure and atomic cross-chain swaps. Here’s a detailed breakdown of the process.
1. Swap Initialization
Important Note on Execution Flow
It’s important to clarify a key aspect of the atomic swap execution flow.
The first on-chain interaction involves the creation of the Liquidity Node’s HTLC, which locks the amountOut that the user expects to receive.
At this stage, the user is shown a current estimation of the required amountIn for the swap. However, this value may change, as it depends on dynamic factors such as exchange rates and network fees.
The actual amountIn that the user must deposit into their own HTLC is only finalized at the moment their HTLC is created.
Price Quote Request
- User requests swap quote from Liquidity Node
- Specifies desired token pair and amount
- Receives current exchange rate
Secret Generation
- Liquidity Node generates
SECRET_X
- Computes
HASH(SECRET_X) using SHA-256
- Securely stores both values
Pre-Signed Transaction
- Liquidity Node creates
UserClaimToSign
- User receives and verifies claim transaction
- User signs claim for future execution
2. Contract Deployment
Liquidity Node HTLC
- Deploys HTLC on
ChainOut
- Includes:
HASH(SECRET_X)
AmountOut
LOCKTIME_1
- Monitors for confirmation
User HTLC
- Creates HTLC on
ChainIn
- Matches
HASH(SECRET_X)
- Sets
LOCKTIME_2 (where L2 < L1)
- Sends to Liquidity Node for broadcasting
3. Claim Process
Liquidity Node Claims
- Monitors
ChainIn for HTLC confirmation
- Reveals
SECRET_X to claim TOKEN_IN
- Transaction executes if hash matches
User Claims
SECRET_X becomes public on ChainIn
- Liquidity Node broadcasts pre-signed user claim
- User can manually claim if needed
4. Settlement & Completion
Successful Completion
- Liquidity Node receives
TOKEN_IN
- User receives
TOKEN_OUT
- Both HTLCs are marked as executed
Fallback Scenarios
-
Timeout on
ChainIn:
- User reclaims funds after
L2
- No action needed from Liquidity Node
-
Timeout on
ChainOut:
- Liquidity Node reclaims after
L1
- Only possible if
ChainIn claim failed
Transaction Flow Summary
Monitoring and Verification
Status Tracking
- Monitor transaction confirmations
- Track HTLC states
- Verify hash commitments
Error Handling
- Network congestion management
- Transaction retry mechanisms
- Fallback procedures
Completion Verification
- Confirm both HTLCs executed
- Verify token transfers
- Update swap status