Skip to content

Commit cb8c3d8

Browse files
dharjeezyWizdave97
andauthored
[runtime, indexer, simplex]: add phantom order support for passive price and liquidity indexing (#983)
Co-authored-by: David Salami <wizdave97@gmail.com>
1 parent 9816eba commit cb8c3d8

42 files changed

Lines changed: 3161 additions & 104 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test-sdk.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,81 @@ jobs:
148148
echo "Indexer logs:"
149149
cat packages/indexer/indexer_output.log
150150
fi
151+
152+
# Full phantom-order flow: a locally-built simnode emits the order, real simplex IntentFillers
153+
# watch + submit USDC->cNGN bids, and the SDK aggregation reduces them to a snapshot — simulated
154+
# against an anvil fork of Base mainnet (needs eth_simulateV1 + the real gateway/tokens).
155+
phantom-filler-e2e:
156+
name: Phantom filler E2E (simnode + anvil)
157+
runs-on: arc-runner-set
158+
steps:
159+
- name: Checkout repository
160+
uses: actions/checkout@v4
161+
with:
162+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
163+
submodules: recursive
164+
165+
- name: Install system dependencies
166+
run: |
167+
sudo apt-get update
168+
sudo apt-get install -y clang netcat wget curl libssl-dev llvm libclang-dev libudev-dev make libprotobuf-dev protobuf-compiler pkg-config
169+
echo "LIBCLANG_PATH=/usr/lib/llvm-14/lib" >> $GITHUB_ENV
170+
171+
- name: Install Rust toolchain
172+
uses: dtolnay/rust-toolchain@nightly
173+
with:
174+
toolchain: stable
175+
176+
- name: Add wasm toolchain
177+
run: rustup target add wasm32-unknown-unknown --toolchain nightly
178+
179+
- uses: webfactory/ssh-agent@v0.7.0
180+
with:
181+
ssh-private-key: ${{ secrets.SSH_KEY }}
182+
183+
- uses: Swatinem/rust-cache@v2
184+
185+
- name: Install Foundry (anvil)
186+
uses: foundry-rs/foundry-toolchain@v1
187+
188+
- name: Set up Node
189+
uses: actions/setup-node@v4
190+
with:
191+
node-version: "22"
192+
193+
- name: Set up pnpm
194+
uses: pnpm/action-setup@v4
195+
with:
196+
version: 11
197+
198+
# Required by the sp1-recursion-gnark-ffi build script, which compiles a Go library.
199+
- name: Install Go
200+
uses: actions/setup-go@v5
201+
with:
202+
go-version: "1.24"
203+
204+
- name: Build hyperbridge simnode
205+
run: cargo build -p hyperbridge
206+
207+
- name: Install + build SDK
208+
working-directory: sdk
209+
run: |
210+
pnpm install
211+
pnpm --filter "@hyperbridge/sdk" build:node
212+
213+
- name: Run phantom-filler E2E (anvil fork of Base + simnode)
214+
env:
215+
SIMNODE_URL: ws://127.0.0.1:9991
216+
ANVIL_URL: http://127.0.0.1:8545
217+
run: |
218+
anvil --fork-url "${{ secrets.BASE_MAINNET }}" --port 8545 --silent &
219+
./target/debug/hyperbridge simnode --chain gargantua-1000 --rpc-port 9991 --port 40341 --tmp --rpc-methods=unsafe --rpc-cors=all --pool-type=single-state &
220+
./scripts/wait_for_tcp_port_opening.sh localhost 8545
221+
./scripts/wait_for_tcp_port_opening.sh localhost 9991
222+
cd sdk && pnpm --filter "@hyperbridge/simplex" test:phantom-filler-e2e
223+
224+
- name: Cleanup
225+
if: always()
226+
run: |
227+
pkill -f "hyperbridge simnode" || true
228+
pkill -f "anvil --fork-url" || true

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,7 @@ parachain/simtests/hyperbridge-main-binary
6969
**/config.mainnet.toml
7070
evm/script/UpdateConsensusClient.s.sol
7171
evm/script/update-consensus-client.sh
72+
73+
# Generated by indexer codegen (generate-chain-yamls.ts) — not committed
74+
sdk/packages/indexer/src/token-slot-overrides.ts
75+
sdk/packages/indexer/src/yield-vault-addresses.ts

modules/pallets/intents-coprocessor/src/benchmarking.rs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use frame_support::{
2525
BoundedVec,
2626
};
2727
use frame_system::RawOrigin;
28-
use ismp::host::StateMachine;
28+
use ismp::{consensus::StateMachineId, host::StateMachine};
2929
use primitive_types::{H160, H256, U256};
3030
use sp_runtime::traits::ConstU32;
3131

@@ -186,5 +186,46 @@ mod benchmarks {
186186
Ok(())
187187
}
188188

189+
#[benchmark]
190+
fn set_phantom_order_config() -> Result<(), BenchmarkError> {
191+
let origin =
192+
T::GovernanceOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
193+
let config = types::PhantomOrderConfiguration {
194+
chain: StateMachineId {
195+
state_id: StateMachine::Evm(8453),
196+
consensus_state_id: *b"ETH0",
197+
},
198+
token_pairs: vec![types::PhantomTokenPair {
199+
token_a: H160::repeat_byte(0x01),
200+
token_b: H160::repeat_byte(0x02),
201+
standard_amount: 1_000_000_000_000_000_000u128,
202+
}]
203+
.try_into()
204+
.expect("one pair fits in BoundedVec<_, 10>"),
205+
interval_blocks: 10,
206+
};
207+
208+
#[extrinsic_call]
209+
_(origin as T::RuntimeOrigin, config);
210+
211+
assert!(PhantomOrderConfig::<T>::get().is_some());
212+
Ok(())
213+
}
214+
215+
#[benchmark]
216+
fn set_phantom_bid_window() -> Result<(), BenchmarkError> {
217+
let origin =
218+
T::GovernanceOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
219+
let window: u32 = 100;
220+
221+
#[extrinsic_call]
222+
_(origin as T::RuntimeOrigin, window);
223+
224+
// Verify the window was stored
225+
assert_eq!(PhantomBidWindow::<T>::get(), window);
226+
227+
Ok(())
228+
}
229+
189230
impl_benchmark_test_suite!(Pallet, crate::tests::new_test_ext(), crate::tests::Test);
190231
}

0 commit comments

Comments
 (0)