InstaWrap Module
InstaWrap enables instant cross-chain asset wrapping, allowing users to receive wrapped tokens immediately without waiting for confirmations.
Overview
Traditional bridge: Wait 6 BTC confirmations (~60 minutes) InstaWrap: Receive wBTC instantly, LP takes confirmation risk
┌─────────────────────────────────────────────────────────────┐
│ InstaWrap Flow │
│ │
│ Bitcoin Network RP1 Network │
│ ┌────────────┐ ┌────────────┐ │
│ │ Send BTC │────0 conf────────▶│ Instant │ │
│ │ to bridge │ │ wBTC credit│ │
│ └────────────┘ └────────────┘ │
│ │ │ │
│ │ │ │
│ ▼ ▼ │
│ Confirmations LP backs the credit until │
│ accumulate confirmations complete │
│ │ │ │
│ │ │ │
│ ▼ ▼ │
│ 6 confirmations Credit finalized, LP released │
│ │
└─────────────────────────────────────────────────────────────┘
Supported Chains
| Chain | Asset | Confirmations | Instant Credit |
|---|---|---|---|
| Bitcoin | BTC → wBTC | 6 | ✅ Yes |
| Ethereum | ETH → wETH | 12 | ✅ Yes |
| Solana | SOL → wSOL | 32 | ✅ Yes |
| Ethereum | ERC20s | 12 | ✅ Yes |
Instant Credit
How It Works
- User sends BTC to bridge address
- Relayer detects 0-conf transaction
- LP pool provides instant wBTC credit
- User can use wBTC immediately
- As confirmations increase, credit finalizes
- LP released after full confirmation
Fee Structure
| Confirmations | Fee | Description |
|---|---|---|
| 0 | 0.1% | Instant credit (highest risk) |
| 1-2 | 0.05% | Partial confirmation |
| 3-5 | 0.02% | Near-final |
| 6+ | 0% | Fully confirmed |
Using InstaWrap
Deposit (Wrap)
# Get your unique deposit address
rp1d query instawrap deposit-address \
--chain bitcoin \
--recipient $(rp1d keys show my-wallet -a)
# Output: bc1q... (send BTC here)
Check Deposit Status
rp1d query instawrap deposit \
--tx-hash <bitcoin_tx_hash>
Withdraw (Unwrap)
rp1d tx instawrap withdraw \
--chain bitcoin \
--amount 0.1wbtc \
--destination bc1q... \
--from my-wallet
TypeScript SDK
import { InstaWrap } from '@rp1/sdk';
const bridge = new InstaWrap(client);
// Get deposit address
const depositAddr = await bridge.getDepositAddress({
chain: 'bitcoin',
recipient: wallet.address,
});
// Check deposit status
const status = await bridge.getDepositStatus(btcTxHash);
console.log(`Status: ${status.status}`);
console.log(`Confirmations: ${status.confirmations}`);
console.log(`Instant: ${status.instant}`);
// Withdraw
const tx = await bridge.withdraw({
chain: 'bitcoin',
amount: '10000000', // 0.1 BTC in satoshis
destination: 'bc1q...',
});
Liquidity Providers
Provide Liquidity
LPs earn fees from instant credit:
rp1d tx instawrap provide-liquidity \
--amount 100000000wbtc \
--from my-wallet
Withdraw Liquidity
rp1d tx instawrap withdraw-liquidity \
--amount 50000000wbtc \
--from my-wallet
LP APY
| Asset | Current APY | Volume (24h) |
|---|---|---|
| wBTC | 5-15% | Varies |
| wETH | 3-10% | Varies |
| wSOL | 4-12% | Varies |
Message Types
MsgDeposit
message MsgDeposit {
string sender = 1;
string chain = 2;
bytes tx_hash = 3;
bytes proof = 4;
}
MsgWithdraw
message MsgWithdraw {
string sender = 1;
string chain = 2;
cosmos.base.v1beta1.Coin amount = 3;
string destination = 4;
}
Parameters
| Parameter | Default | Description |
|---|---|---|
instant_credit_enabled | true | Enable 0-conf credits |
instant_threshold | 100000000 | Max instant amount (satoshis) |
max_instant_credit | 1000000000 | Maximum instant credit |
base_fee | 0.001 | 0.1% base fee |
Events
EventTypeDeposit = "instawrap_deposit"
EventTypeInstantCredit = "instawrap_instant_credit"
EventTypeWithdraw = "instawrap_withdraw"
EventTypeLiquidityProvided = "instawrap_lp_provided"
Security
Double-Spend Protection
If the source chain transaction is double-spent:
- Credit is revoked
- User's wBTC burned
- If already spent, becomes "bad debt"
- LP compensated from insurance fund
Oracle Verification
// Multiple relayers must confirm deposit
type DepositProof struct {
TxHash []byte
BlockHash []byte
MerkleProof []byte
Signatures []ValidatorSignature // 2/3+ required
}