Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 44 additions & 117 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -705,151 +705,78 @@ Output example:
⛽ Gas Used: 21000
```

### 11. Transaction Simulation
### 11. Flyover Swap - Check Liquidity

The `simulate` command allows you to simulate RBTC or ERC20 token transfers before executing them. This feature helps you estimate gas costs, validate balances, and ensure your transaction will succeed without actually executing it on the blockchain.
The `swap` command allows you to check available liquidity providers for BTC ↔ RBTC conversions using the Flyover Protocol. View real-time information about providers, their minimum/maximum amounts, fees, and confirmations required.

#### Benefits of Transaction Simulation
**What this command does:**
- 🔍 Displays all available liquidity providers
- 💰 Shows minimum and maximum swap amounts
- 📊 Lists fees and confirmation requirements
- 🌐 Works for both mainnet and testnet
- ✅ **No wallet required** - read-only information

- Estimate accurate gas costs before sending transactions
- Validate that you have sufficient balance for both transfer and gas fees
- Verify transaction parameters without risking real funds
- Preview the impact on your wallet balance
- Identify potential transaction failures before execution

#### Simulate RBTC Transfer
#### Check Available Liquidity

##### Mainnet

```bash
# Basic RBTC transfer simulation
rsk-cli simulate --address 0xRecipientAddress --value 0.001

# With custom gas parameters
rsk-cli simulate --address 0xRecipientAddress --value 0.001 --gas-limit 21000 --gas-price 0.00000006

# With custom transaction data
rsk-cli simulate --address 0xRecipientAddress --value 0.001 --data 0x1234abcd
rsk-cli swap --liquidity
```

##### Testnet

```bash
# Basic RBTC transfer simulation on testnet
rsk-cli simulate --testnet --address 0x08C4E4BdAb2473E454B8B2a4400358792786d341 --value 0.001

# Using specific wallet
rsk-cli simulate --testnet --wallet myWallet --address 0x08C4E4BdAb2473E454B8B2a4400358792786d341 --value 0.001
rsk-cli swap --testnet --liquidity
```

Output example for RBTC simulation:
#### Example Output

```
🔮 Simulating Transaction
🔑 From Address: 0xb4eb1352Ac339766727Df550A24D21f90935E78c
🎯 To Address: 0x08C4E4BdAb2473E454B8B2a4400358792786d341
💵 Amount: 0.001 RBTC
✅ Liquidity Information Retrieved!

📊 SIMULATION RESULTS
💧 Available Liquidity Providers:
──────────────────────────────────────────────────

Network: Rootstock Testnet
Transaction Type: RBTC Transfer
Transfer Amount: 0.001 RBTC
Current Balance: 0.501586 RBTC
Estimated Gas: 21000
Gas Price: 0.06 Gwei
Total Gas Cost: 0.000001 RBTC
Balance After: 0.500585 RBTC
Total Transaction Cost: 0.001001 RBTC

✅ VALIDATION RESULTS

Sufficient Balance: ✅ Enough RBTC for transfer + gas
Transaction Validity: ✅ Transaction simulation successful

✅ Transaction simulation successful! Transaction is ready to execute.
```

#### Simulate ERC20 Token Transfer

Add the `--token` flag with the token contract address to simulate ERC20 token transfers:

##### Mainnet

```bash
# Basic token transfer simulation
rsk-cli simulate --token 0xTokenAddress --address 0xRecipientAddress --value 10

# With custom gas parameters
rsk-cli simulate --token 0xTokenAddress --address 0xRecipientAddress --value 10 --gas-limit 65000
```
📍 Provider: RSK Provider
Address: 0x7C4890A0f1D4bBf2C669Ac2d1efFa185c505359b
API: https://lps.testnet.flyover.rif.technology
🔹 Peg-In (BTC → RBTC):
Min: 0.005 BTC
Max: 15 BTC
Confirmations: 7
🔸 Peg-Out (RBTC → BTC):
Min: 0.001 RBTC
Max: 15 RBTC
Confirmations: 120

##### Testnet

```bash
# Basic token transfer simulation on testnet
rsk-cli simulate --testnet --token 0x32Cd6c5831531F96f57d1faf4DDdf0222c4Af8AB --address 0x8A0d290b2EE35eFde47810CA8fF057e109e4190B --value 10

# Using specific wallet
rsk-cli simulate --testnet --wallet myWallet --token 0x32Cd6c5831531F96f57d1faf4DDdf0222c4Af8AB --address 0x8A0d290b2EE35eFde47810CA8fF057e109e4190B --value 10
```

Output example for ERC20 simulation:

```
🔮 Simulating Transaction
🔑 From Address: 0x6ad6b3926Fd18b0A8c9a20d659A25c9F6a69c8e0
🎯 To Address: 0x8A0d290b2EE35eFde47810CA8fF057e109e4190B
💵 Amount: 10 tokens

📊 SIMULATION RESULTS

Network: Rootstock Testnet
Transaction Type: ERC20 Token Transfer
Transfer Amount: 10 MTK
Current Balance: 100.000000 MTK
Estimated Gas: 35460
Gas Price: 0.06 Gwei
Total Gas Cost: 0.000002 RBTC
Balance After: 0.501584 RBTC
RBTC Balance After Gas: 0.501584 RBTC
Token Balance After Transfer: 90.000000 MTK

✅ VALIDATION RESULTS
──────────────────────────────────────────────────
🌐 Network: Rootstock Testnet

Sufficient Token Balance: ✅ Enough tokens for transfer
Sufficient Gas Balance: ✅ Enough RBTC for gas
Transaction Validity: ✅ Transaction simulation successful
💡 To execute swaps (BTC ↔ RBTC):
→ https://powpeg.rootstock.io

✅ Transaction simulation successful! Transaction is ready to execute.
The web interface provides the same secure Flyover protocol
with full functionality for peg-in and peg-out operations.
```

#### Available Options

The simulate command supports the following options:
#### To Execute Actual Swaps

- `-t, --testnet`: Simulate on Rootstock testnet network
- `-a, --address <address>`: Recipient address (required)
- `--value <value>`: Amount to transfer (required)
- `--token <address>`: ERC20 token contract address (for token transfers)
- `--wallet <wallet>`: Name of the wallet to use
- `--gas-limit <limit>`: Custom gas limit for the transaction
- `--gas-price <price>`: Custom gas price in RBTC
- `--data <data>`: Custom transaction data in hexadecimal format
After checking liquidity, use the **Flyover web interface** to execute swaps:

#### Understanding Simulation Results
**🌐 https://powpeg.rootstock.io**

The simulation provides comprehensive information:
The web interface provides:
- ✅ Full peg-in (BTC → RBTC) functionality
- ✅ Full peg-out (RBTC → BTC) functionality
- ✅ Automatic captcha handling
- ✅ Real-time quotes and fee calculations
- ✅ Secure wallet integration
- ✅ Transaction tracking

1. **Transaction Details**: From/to addresses, amount, and network
2. **Gas Estimation**: Estimated gas units, gas price, and total gas cost
3. **Balance Preview**: Current balance and projected balance after transaction
4. **Validation Checks**:
- Sufficient balance for transfer amount
- Sufficient RBTC for gas fees
- Transaction validity (whether it would succeed)
#### Why Use Web Interface for Swaps?

> **Note**: Simulation uses real blockchain state but does not execute transactions. It provides accurate estimates based on current network conditions. Gas prices may vary, so actual costs might differ slightly from simulation results.
Liquidity providers require browser-based captcha verification for security. The CLI is perfect for checking liquidity and getting information, but actual swap execution is best done through the web interface which handles all security requirements automatically.

### 12. RNS Resolve

Expand Down
22 changes: 22 additions & 0 deletions bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { verifyCommand } from "../src/commands/verify.js";
import { ReadContract } from "../src/commands/contract.js";
import { Address } from "viem";
import { bridgeCommand } from "../src/commands/bridge.js";
import { swapCommand } from "../src/commands/swap.js";
import { batchTransferCommand } from "../src/commands/batchTransfer.js";
import { historyCommand } from "../src/commands/history.js";
import { selectAddress } from "../src/commands/selectAddress.js";
Expand Down Expand Up @@ -282,6 +283,27 @@ program
});
});

program
.command("swap")
.description("Check Flyover liquidity providers for BTC ↔ RBTC swaps")
.option("-t, --testnet", "Use testnet")
.option("--liquidity", "Check available liquidity providers (default behavior)")
.action(async (options: CommandOptions & {
liquidity?: boolean;
}) => {
try {
await swapCommand({
testnet: !!options.testnet,
liquidity: true, // Always check liquidity
});
} catch (error: any) {
console.error(
chalk.red("Error checking liquidity:"),
error.message || error
);
}
});

program
.command("history")
.description("Fetch history for current wallet")
Expand Down
Loading
Loading