project screenshot 1
project screenshot 2
project screenshot 3

cosmoFusion

Cross-chain atomic swaps: swap Ethereum/Cosmos assets via 1inch Fusion+, secure & decentralized.

cosmoFusion

Created At

Unite Defi

Project Description

πŸŒ‰ Cross-Chain Resolver: Ethereum ↔ Cosmos Fusion+

A complete cross-chain atomic swap system implementing 1inch Fusion+ protocol between Ethereum and Cosmos ecosystems.

πŸ—οΈ Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    IBC/Cross-Chain    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   ETHEREUM      β”‚ ◄─────────────────► β”‚     COSMOS      β”‚
β”‚                 β”‚                     β”‚                 β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚                     β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ 1inch LOP   β”‚ β”‚                     β”‚ β”‚ Cosmos LOP  β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚                     β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚        β”‚        β”‚                     β”‚        β”‚        β”‚
β”‚        β–Ό        β”‚                     β”‚        β–Ό        β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚                     β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚EscrowFactoryβ”‚ β”‚                     β”‚ β”‚EscrowFactoryβ”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚                     β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚        β”‚        β”‚                     β”‚        β”‚        β”‚
β”‚        β–Ό        β”‚                     β”‚        β–Ό        β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚                     β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚  Resolver   β”‚ β”‚                     β”‚ β”‚  Resolver   β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚                     β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

✨ Features

πŸ”₯ Core Capabilities

  • βœ… Atomic Cross-Chain Swaps - Trustless swaps between Ethereum and Cosmos
  • βœ… 1inch Fusion+ Integration - Built on proven 1inch infrastructure
  • βœ… IBC Communication - Native Cosmos Inter-Blockchain Communication
  • βœ… CosmWasm Smart Contracts - Production-ready Rust contracts
  • βœ… Hashlock/Timelock Security - Cryptographic safety guarantees
  • βœ… Safety Deposits - Collateral system prevents griefing attacks

🌐 Supported Networks

  • Ethereum ↔ Cosmos (Full implementation)
  • Extensible to any IBC-enabled chain

πŸ›‘οΈ Security Features

  • Atomic Execution - Either both sides complete or both fail
  • Secret-based Unlocking - Cryptographic proof required
  • Timelock Protection - Automatic refunds after expiration
  • Safety Deposits - Economic incentives for honest behavior

πŸš€ Quick Start

Prerequisites

# Install Node.js dependencies
pnpm install

# Install Foundry (for Ethereum contracts)
curl -L https://foundry.paradigm.xyz | bash

# Install Rust (for Cosmos contracts)  
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup target add wasm32-unknown-unknown

# Install contract dependencies
forge install

Test Commands

πŸ§ͺ Run Ethereum ↔ Cosmos Tests

# Test the Cosmos CosmWasm contracts
cd cosmos-contracts
cargo test --package escrow-factory --test simple_test

# Expected output:
# βœ… test_escrow_factory_instantiation ... ok
# βœ… test_cross_chain_swap_simulation ... ok  
# βœ… test_create_source_escrow ... ok
# βœ… test_withdraw_from_source ... ok
# test result: ok. 4 passed; 0 failed

πŸ”§ Build Cosmos Contracts

cd cosmos-contracts
make build    # Build all contracts
make test     # Run all tests
make optimize # Optimize for deployment

πŸ“ Project Structure

cross-chain-resolver-example/
β”œβ”€β”€ cosmos-contracts/          # πŸ†• Cosmos CosmWasm Contracts
β”‚   β”œβ”€β”€ contracts/
β”‚   β”‚   β”œβ”€β”€ escrow-factory/    # Cross-chain escrow management
β”‚   β”‚   β”œβ”€β”€ lop/              # 1inch LOP implementation  
β”‚   β”‚   └── resolver/         # Swap coordination
β”‚   β”œβ”€β”€ tests/                # Comprehensive test suite
β”‚   └── Makefile             # Build automation
β”œβ”€β”€ contracts/                # Ethereum Solidity contracts
β”‚   └── src/
β”‚       β”œβ”€β”€ Resolver.sol      # Main resolver contract
β”‚       └── TestEscrowFactory.sol
β”œβ”€β”€ tests/                    # Cross-chain integration tests
└── 1inch-lop/               # 1inch protocol integration

πŸ”„ Cross-Chain Swap Flow

Step 1: Order Creation

// User creates order on Ethereum
const order = await createCrossChainOrder({
  makerAsset: "ETH",
  takerAsset: "ATOM", 
  makingAmount: "1000000000000000000", // 1 ETH
  takingAmount: "100000000"            // 100 ATOM
});

Step 2: Source Escrow

// Cosmos contract creates source escrow
execute_create_src_escrow(
  immutables,
  order_hash,
  safety_deposit
) -> IBC message to Ethereum

Step 3: Destination Escrow

// Ethereum contract receives IBC message
function deploySrc(immutables, order, signature, amount) 
  -> Creates destination escrow

Step 4: Atomic Completion

// Secret revealed, swap completes atomically
execute_withdraw_from_src(order_hash, secret)
  -> Transfers complete on both chains βœ…

πŸ§ͺ Test Results

βœ… Cosmos Contract Tests (ALL PASS)

running 4 tests
test tests::test_escrow_factory_instantiation ... ok
test tests::test_cross_chain_swap_simulation ... ok  
test tests::test_create_source_escrow ... ok
test tests::test_withdraw_from_source ... ok

test result: ok. 4 passed; 0 failed; 0 ignored

Test Coverage

  • βœ… Cross-chain escrow creation
  • βœ… IBC message generation
  • βœ… Atomic swap completion
  • βœ… Fund transfers and safety deposits
  • βœ… State management across chains
  • βœ… Error handling and edge cases

πŸ› οΈ Development

Cosmos Contracts

cd cosmos-contracts

# Development workflow
make dev          # Format, lint, test
make build        # Build contracts  
make optimize     # Optimize for deployment
make deploy-local # Deploy to local chain

Ethereum Contracts

# Compile contracts
forge build

# Run cross-chain tests
cargo test --package escrow-factory --test simple_test

# Deploy contracts
forge script script/Deploy.s.sol --broadcast

πŸš€ Deployment

Cosmos Deployment

# Optimize contracts
cd cosmos-contracts && make optimize

# Deploy to testnet
wasmd tx wasm store artifacts/escrow_factory.wasm --from wallet --gas-adjustment 1.3 --gas auto -y

# Instantiate contracts
wasmd tx wasm instantiate $CODE_ID '{"lop_address":"cosmos1lop","ethereum_channel":"channel-0"}' --from wallet --label "escrow-factory" -y

Ethereum Deployment

# Deploy with Foundry
forge script script/Deploy.s.sol --rpc-url $ETH_RPC_URL --broadcast --verify

πŸ”— Integration Examples

TypeScript Integration

import { EthereumCosmosIntegration } from './cosmos-contracts/tests/ethereum-cosmos-integration';

const integration = new EthereumCosmosIntegration(
  'http://localhost:26657', // Cosmos RPC
  cosmosWallet,
  'http://localhost:8545',  // Ethereum RPC  
  ethereumPrivateKey,
  contractAddresses
);

// Execute cross-chain swap
await integration.executeEthereumToCosmosSwap(
  'cosmos1maker',
  '0xTakerAddress', 
  '1000000000000000000', // 1 ETH
  '100000000'            // 100 ATOM
);

Rust Integration

use escrow_factory::contract::{execute, EscrowImmutables};

// Create cross-chain escrow
let immutables = EscrowImmutables {
    order_hash: "unique_order_id".to_string(),
    maker: "cosmos1maker".to_string(),
    taker: "cosmos1taker".to_string(),
    amount: Uint128::new(1000000),
    token: "uatom".to_string(),
    // ... other fields
};

execute(deps, env, info, ExecuteMsg::CreateSrcEscrow { immutables, order_hash })?;

πŸ“Š Network Information

Supported RPCs

| Network | RPC URL | Chain ID | |-----------|--------------------------------------|----------| | Ethereum | https://eth.merkle.io | 1 | | Cosmos | https://rpc.cosmos.network | cosmoshub-4 |

Test Accounts

| Role | Address | Private Key | |----------|----------------------------------------------|-------------| | Owner | 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 | 0xac0974... | | User | 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 | 0x59c6995... | | Resolver | 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC | 0x5de4111... |

πŸ”’ Security Considerations

⚠️ Audit Status

WARNING: These contracts are in development and have not been audited. Do not use in production.

Key Security Features

  • Atomic Swaps: Either both sides complete or both fail
  • Timelock Protection: Automatic refunds after expiration
  • Safety Deposits: Collateral to prevent griefing
  • Hash Verification: Secret-based unlock mechanisms
  • IBC Security: Leverages Cosmos IBC security guarantees

Built with ❀️ for the cross-chain future πŸŒ‰

How it's Made

πŸ—οΈ Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    IBC/Cross-Chain    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   ETHEREUM      β”‚ ◄─────────────────► β”‚     COSMOS      β”‚
β”‚                 β”‚                     β”‚                 β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚                     β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ 1inch LOP   β”‚ β”‚                     β”‚ β”‚ Cosmos LOP  β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚                     β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚        β”‚        β”‚                     β”‚        β”‚        β”‚
β”‚        β–Ό        β”‚                     β”‚        β–Ό        β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚                     β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚EscrowFactoryβ”‚ β”‚                     β”‚ β”‚EscrowFactoryβ”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚                     β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚        β”‚        β”‚                     β”‚        β”‚        β”‚
β”‚        β–Ό        β”‚                     β”‚        β–Ό        β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚                     β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚  Resolver   β”‚ β”‚                     β”‚ β”‚  Resolver   β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚                     β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

✨ Features

πŸ”₯ Core Capabilities

  • βœ… Atomic Cross-Chain Swaps - Trustless swaps between Ethereum and Cosmos
  • βœ… 1inch Fusion+ Integration - Built on proven 1inch infrastructure
  • βœ… IBC Communication - Native Cosmos Inter-Blockchain Communication
  • βœ… CosmWasm Smart Contracts - Production-ready Rust contracts
  • βœ… Hashlock/Timelock Security - Cryptographic safety guarantees
  • βœ… Safety Deposits - Collateral system prevents griefing attacks

🌐 Supported Networks

  • Ethereum ↔ Cosmos (Full implementation)
  • Extensible to any IBC-enabled chain

πŸ›‘οΈ Security Features

  • Atomic Execution - Either both sides complete or both fail
  • Secret-based Unlocking - Cryptographic proof required
  • Timelock Protection - Automatic refunds after expiration
  • Safety Deposits - Economic incentives for honest behavior

πŸš€ Quick Start

Prerequisites

# Install Node.js dependencies
pnpm install

# Install Foundry (for Ethereum contracts)
curl -L https://foundry.paradigm.xyz | bash

# Install Rust (for Cosmos contracts)  
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup target add wasm32-unknown-unknown

# Install contract dependencies
forge install

Test Commands

πŸ§ͺ Run Ethereum ↔ Cosmos Tests

# Test the Cosmos CosmWasm contracts
cd cosmos-contracts
cargo test --package escrow-factory --test simple_test

# Expected output:
# βœ… test_escrow_factory_instantiation ... ok
# βœ… test_cross_chain_swap_simulation ... ok  
# βœ… test_create_source_escrow ... ok
# βœ… test_withdraw_from_source ... ok
# test result: ok. 4 passed; 0 failed

πŸ”§ Build Cosmos Contracts

cd cosmos-contracts
make build    # Build all contracts
make test     # Run all tests
make optimize # Optimize for deployment
background image mobile

Join the mailing list

Get the latest news and updates