Skip to content
Open
Show file tree
Hide file tree
Changes from 7 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
19 changes: 15 additions & 4 deletions sdk/packages/sdk/src/protocols/intents/BidManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {
TokenInfo,
ERC7821Call,
} from "@/types"
import { SolverBidSignerType } from "@/types"
import type { IntentGatewayContext } from "./types"
import { BundlerMethod } from "./types"
import { CryptoUtils } from "./CryptoUtils"
Expand Down Expand Up @@ -59,7 +60,7 @@ export class BidManager {
const {
order,
solverAccount,
solverPrivateKey,
solverSigner,
nonce,
entryPointAddress,
callGasLimit,
Expand Down Expand Up @@ -93,9 +94,19 @@ export class BidManager {
const sessionKey = order.session

const messageHash = keccak256(concat([userOpHash, order.id as HexString, sessionKey as import("viem").Hex]))

const solverAccount_ = privateKeyToAccount(solverPrivateKey as import("viem").Hex)
const solverSignature = await solverAccount_.signMessage({ message: { raw: messageHash } })
let solverSignature: HexString
switch (solverSigner.type) {
case SolverBidSignerType.External:
solverSignature = await solverSigner.signMessage(messageHash)
break
case SolverBidSignerType.PrivateKey: {
const solverAccount_ = privateKeyToAccount(solverSigner.privateKey as import("viem").Hex)
solverSignature = await solverAccount_.signMessage({ message: { raw: messageHash } })
break
}
default:
throw new Error("Unsupported solver signer type")
}

const signature = concat([order.id as HexString, solverSignature as import("viem").Hex]) as HexString

Expand Down
23 changes: 22 additions & 1 deletion sdk/packages/sdk/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1164,11 +1164,32 @@ export interface PackedUserOperation {
signature: HexString
}

export enum SolverBidSignerType {
PrivateKey = "privateKey",
External = "external",
}

export type SolverBidSigner =
| {
/** Local EOA private key signer. */
type: SolverBidSignerType.PrivateKey
privateKey: HexString
}
| {
/** External signer backend (MPC/KMS/HSM/etc). */
type: SolverBidSignerType.External
signMessage: (messageHash: HexString) => Promise<HexString>
}

export interface SubmitBidOptions {
order: Order
fillOptions: FillOptions
solverAccount: HexString
solverPrivateKey: HexString
/**
* Tagged polymorphic signer for bid message signing.
* Must return a 65-byte ECDSA signature over the raw `messageHash`.
*/
solverSigner: SolverBidSigner
nonce: bigint
entryPointAddress: HexString
// Estimated gas for executing fillOrder calldata
Expand Down
205 changes: 3 additions & 202 deletions sdk/packages/simplex/README.md
Original file line number Diff line number Diff line change
@@ -1,204 +1,5 @@
# Hyperbridge Intent FillerV2
# Hyperbridge Simplex

A high-performance intent filler for the Hyperbridge IntentGatewayV2 protocol. This package provides both a library interface and a CLI binary for running an intent filler that monitors and fills cross-chain orders.
Canonical documentation for Simplex lives in the Hyperbridge docs:

## Installation

### Binary

```bash
npm install -g @hyperbridge/filler
# or
pnpm add -g @hyperbridge/filler
```

### Library

```bash
npm install @hyperbridge/filler
# or
pnpm add @hyperbridge/filler
```

## Quick Start

### 1. Create Configuration

Copy the example configuration file and customize it:

```bash
cp filler-config-example.toml filler-config.toml
```

### 2. Edit Configuration

Update `filler-config.toml` with:

- Your EVM private key
- RPC URLs for each chain you want to support
- Confirmation policies for each chain
- (Optional) Solver selection mode settings for Hyperbridge integration

### 3. Run the FillerV2

```bash
filler run -c filler-config.toml
```

## Docker Usage

We provide a simple script for Docker operations:

```bash
# Build Docker image
./scripts/docker.sh build

# Run as container
./scripts/docker.sh run

# Use Docker Compose
./scripts/docker.sh up
./scripts/docker.sh down
./scripts/docker.sh logs
```

## Configuration

The filler uses a TOML configuration file. See `filler-config-example.toml` for a complete example.

### Basic Configuration

```toml
[filler]
privateKey = "0xYourPrivateKey"
maxConcurrentOrders = 5

# Logging configuration
[filler.logging]
level = "debug" # Options: trace, debug, info, warn, error

# Pending queue configuration
[filler.pendingQueue]
maxRechecks = 10
recheckDelayMs = 30000

# Strategy configuration
[[strategies]]
type = "basic"

# Chain configurations (only chainId and rpcUrl required - other data from SDK)
[[chains]]
chainId = 1 # Ethereum Mainnet
rpcUrl = "https://your-eth-rpc-url"

[[chains]]
chainId = 56 # BSC Mainnet
rpcUrl = "https://your-bsc-rpc-url"

[[chains]]
chainId = 42161 # Arbitrum Mainnet
rpcUrl = "https://your-arbitrum-rpc-url"

# Confirmation policies per chain
[confirmationPolicies."1"] # Ethereum Mainnet
minAmount = "5" # 5 USD
maxAmount = "5000" # 5000 USD
minConfirmations = 3
maxConfirmations = 12

[confirmationPolicies."56"] # BSC Mainnet
minAmount = "1" # 1 USD
maxAmount = "5000" # 5000 USD
minConfirmations = 3
maxConfirmations = 15
```

### Watch-Only Mode

Monitor orders without executing fills. Useful for testing or observing market activity.

```toml
# Option 1: Global watch-only (all chains)
[filler]
watchOnly = true

# Option 2: Per-chain watch-only
[filler.watchOnly]
"1" = true # Ethereum Mainnet - watch only
"56" = false # BSC Mainnet - normal execution
```

### Solver Selection Mode

For participating in Hyperbridge's solver selection mechanism:

```toml
[filler]
privateKey = "0xYourEVMPrivateKey"

# Substrate private key for signing Hyperbridge extrinsics
# Can be a hex seed (without 0x prefix) or mnemonic phrase
# Note: Requires BRIDGE tokens for transaction fees
substratePrivateKey = "your-substrate-seed-or-mnemonic"

# Hyperbridge WebSocket URL
hyperbridgeWsUrl = "wss://hyperbridge-rpc-url"

# ERC-4337 EntryPoint contract address
entryPointAddress = "0x..."

# SolverAccount.sol contract address for EIP-7702 delegation
solverAccountContractAddress = "0x..."

# Directory for persistent bid storage (enables fund recovery)
dataDir = "/path/to/data"
```

## CLI Commands

```bash
# Run the filler with configuration
filler run -c <config-file>
```

## Strategies

### Basic Filler

- Direct token transfers between chains
- No swapping capability
- Lower gas costs
- Recommended for standard cross-chain fills

## Development

```bash
# Install dependencies
pnpm install

# Build
pnpm build

# Run tests
pnpm test

# Run CLI in development
pnpm cli run -c filler-config.toml
```

## Data Storage

The filler stores bid transaction hashes for fund recovery purposes. By default, data is stored in `.filler-data` in the current working directory. You can customize this with the `dataDir` configuration option.

## Security

⚠️ **Never commit private keys to version control!**

- Use environment variables or secure key management in production
- Run fillers in isolated environments
- Monitor for unusual activity
- Keep your Substrate account funded with BRIDGE tokens for solver selection mode

## License

Part of the Hyperbridge SDK.
- [Simplex Docs](https://docs.hyperbridge.network/developers/intent-gateway/simplex/)
19 changes: 17 additions & 2 deletions sdk/packages/simplex/filler-config-example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,22 @@

# Filler configuration
[simplex]
privateKey = "" # Replace with your actual EVM private key (not required if all chains are watchOnly)
# Choose ONE signer mode via [simplex.signer]:
# 1) Private key signer:
# [simplex.signer]
# type = "privateKey"
# privateKey = "0x..." # Not required if all chains are watchOnly
#
# 2) MPCVault signer:
# [simplex.signer]
# type = "mpcVault"
# [simplex.signer.mpcVault]
# apiToken = ""
# vaultUuid = ""
# accountAddress = "0x0000000000000000000000000000000000000000"
# callbackClientSignerPublicKey = "ssh-ed25519 AAAA..."
# baseUrl = "https://api.mpcvault.com" # optional

maxConcurrentOrders = 5

# ===== Solver Selection Mode Configuration =====
Expand Down Expand Up @@ -75,7 +90,7 @@ triggerPercentage = 0.5

# Strategy configuration
# You can configure multiple strategies
# All strategies use the simplex.privateKey from above
# All strategies use the configured simplex signer (privateKey or mpcVault)
[[strategies]]
type = "basic"
# Filler BPS (basis points) curve based on order value
Expand Down
1 change: 0 additions & 1 deletion sdk/packages/simplex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"build": "tsup",
"prepublishOnly": "npm run build",
"test": "vitest --watch=false --maxConcurrency=1",
"test:services": "vitest --watch=false --maxConcurrency=1 --testTimeout=1000000 src/tests/services.test.ts",
"test:filler": "vitest --watch=false --maxConcurrency=1 --testTimeout=1000000 src/tests/strategies/basic.testnet.test.ts",
"test:basic": "vitest --watch=false --maxConcurrency=1 --testTimeout=1000000 src/tests/strategies/basic.testnet.test.ts",
"test:fx": "vitest --watch=false --maxConcurrency=1 --testTimeout=1000000 src/tests/strategies/fx.mainnet.test.ts",
Expand Down
Loading
Loading