Skip to content
This repository was archived by the owner on Jun 16, 2025. It is now read-only.

Commit 09f482c

Browse files
authored
solver: update readme along with some minor tweaks (#165)
1 parent f57444f commit 09f482c

File tree

10 files changed

+166
-61
lines changed

10 files changed

+166
-61
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
.vscode
55
node_modules
66
*.tgz
7-
dist
7+
dist
8+
.env

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,32 @@ Install [Foundry tools](https://book.getfoundry.sh/getting-started/installation)
2121
Each directory represents Wormhole integrations for specific blockchain networks. Please navigate to a network subdirectory to see more details (see the relevant README.md) on building, testing and deploying the smart contracts.
2222

2323
[Wormhole Circle Integration]: https://github.com/wormhole-foundation/wormhole-circle-integration/blob/main/DESIGN.md
24+
25+
26+
### Typescript SDK
27+
28+
To use the Typescript SDK, at the root of this repository, run:
29+
30+
```sh
31+
npm ci && npm run build && npm run pack
32+
```
33+
34+
Which will produce a `.tgz` file that can be installed using npm or any other package manager like:
35+
36+
```sh
37+
npm install /path/to/example-liquidity-layer/wormhole-foundation-example-liquidity-layer-solana-0.0.1.tgz
38+
```
39+
40+
Once installed, it can be used like any other package:
41+
42+
```ts
43+
// ...
44+
import * as tokenRouterSdk from "@wormhole-foundation/example-liquidity-layer-solana/tokenRouter";
45+
import {
46+
LiquidityLayerDeposit,
47+
LiquidityLayerMessage,
48+
} from "@wormhole-foundation/example-liquidity-layer-solana/common";
49+
import { PreparedOrder } from "@wormhole-foundation/example-liquidity-layer-solana/tokenRouter/state";
50+
// ...
51+
```
52+

solana/Makefile

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ BUILD_mainnet=artifacts-mainnet
22
BUILD_testnet=artifacts-testnet
33
BUILD_localnet=artifacts-localnet
44

5-
SPY_NETWORK_mainnet=/wormhole/mainnet/2
6-
SPY_BOOTSTRAP_mainnet="/dns4/wormhole-v2-mainnet-bootstrap.xlabs.xyz/udp/8999/quic/p2p/12D3KooWNQ9tVrcb64tw6bNs2CaNrUGPM7yRrKvBBheQ5yCyPHKC,/dns4/wormhole.mcf.rocks/udp/8999/quic/p2p/12D3KooWDZVv7BhZ8yFLkarNdaSWaB43D6UbQwExJ8nnGAEmfHcU,/dns4/wormhole-v2-mainnet-bootstrap.staking.fund/udp/8999/quic/p2p/12D3KooWG8obDX9DNi1KUwZNu9xkGwfKqTp2GFwuuHpWZ3nQruS1"
7-
8-
SPY_NETWORK_testnet=/wormhole/testnet/2/1
9-
SPY_BOOTSTRAP_testnet="/dns4/t-guardian-01.nodes.stable.io/udp/8999/quic/p2p/12D3KooWCW3LGUtkCVkHZmVSZHzL3C4WRKWfqAiJPz1NR7dT9Bxh,/dns4/t-guardian-02.nodes.stable.io/udp/8999/quic/p2p/12D3KooWJXA6goBCiWM8ucjzc4jVUBSqL9Rri6UpjHbkMPErz5zK"
10-
115
CLONED_MAINNET_PROGRAMS=\
126
ts/tests/artifacts/mainnet_core_bridge.so \
137
ts/tests/artifacts/mainnet_cctp_token_messenger_minter.so \
@@ -86,22 +80,6 @@ lint:
8680
NETWORK=localnet $(MAKE) clippy
8781
NETWORK=testnet $(MAKE) clippy
8882

89-
.PHONY: wormhole-spy-up
90-
wormhole-spy-up:
91-
ifdef SPY_NETWORK_$(NETWORK)
92-
WORMHOLE_NETWORK_ID=$(SPY_NETWORK_$(NETWORK)) \
93-
WORMHOLE_BOOTSTRAP=$(SPY_BOOTSTRAP_$(NETWORK)) \
94-
NATS_STREAM="${NETWORK}-vaas" \
95-
docker-compose -f docker-compose.yml up -d
96-
endif
97-
98-
.PHONY: wormhole-spy-down
99-
wormhole-spy-down:
100-
docker-compose -f docker-compose.yml down
101-
102-
.PHONY: wormhole-spy-restart
103-
wormhole-spy-restart: wormhole-spy-down wormhole-spy-up
104-
10583
ts/tests/artifacts:
10684
mkdir ts/tests/artifacts
10785

solver/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/cfg/**/*.json
2+
!/cfg/**/sample.*.json

solver/Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
SPY_NETWORK_mainnet=/wormhole/mainnet/2
2+
SPY_BOOTSTRAP_mainnet="/dns4/wormhole-v2-mainnet-bootstrap.xlabs.xyz/udp/8999/quic/p2p/12D3KooWNQ9tVrcb64tw6bNs2CaNrUGPM7yRrKvBBheQ5yCyPHKC,/dns4/wormhole.mcf.rocks/udp/8999/quic/p2p/12D3KooWDZVv7BhZ8yFLkarNdaSWaB43D6UbQwExJ8nnGAEmfHcU,/dns4/wormhole-v2-mainnet-bootstrap.staking.fund/udp/8999/quic/p2p/12D3KooWG8obDX9DNi1KUwZNu9xkGwfKqTp2GFwuuHpWZ3nQruS1"
3+
4+
SPY_NETWORK_testnet=/wormhole/testnet/2/1
5+
SPY_BOOTSTRAP_testnet="/dns4/t-guardian-01.nodes.stable.io/udp/8999/quic/p2p/12D3KooWCW3LGUtkCVkHZmVSZHzL3C4WRKWfqAiJPz1NR7dT9Bxh,/dns4/t-guardian-02.nodes.stable.io/udp/8999/quic/p2p/12D3KooWJXA6goBCiWM8ucjzc4jVUBSqL9Rri6UpjHbkMPErz5zK"
6+
7+
.PHONY: wormhole-spy-up
8+
wormhole-spy-up:
9+
ifdef SPY_NETWORK_$(NETWORK)
10+
WORMHOLE_NETWORK_ID=$(SPY_NETWORK_$(NETWORK)) \
11+
WORMHOLE_BOOTSTRAP=$(SPY_BOOTSTRAP_$(NETWORK)) \
12+
NATS_STREAM="${NETWORK}-vaas" \
13+
docker-compose -f docker-compose.yml up -d
14+
endif
15+
16+
.PHONY: wormhole-spy-down
17+
wormhole-spy-down:
18+
docker-compose -f docker-compose.yml down
19+
20+
.PHONY: wormhole-spy-restart
21+
wormhole-spy-restart: wormhole-spy-down wormhole-spy-up

solver/README.md

Lines changed: 83 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,97 @@
1-
Solvers
2-
-------
1+
## Testnet Example Solver
32

4-
To use the Typescript SDK, at the root of this repository, run:
3+
The example solver is split up into three processes: `vaaAuctionRelayer`, `improveOffer` and
4+
`executeOrder`. All three rely on the same configuration file, which can created by copying the
5+
sample file `cfg/testnet/sample.config.json`.
6+
7+
To get started, create a durable nonce account (see these
8+
[instructions](https://solana.com/developers/guides/advanced/introduction-to-durable-nonces)) with
9+
your Solana keypair. Copy the public key and move it to the `nonceAccount` field in your config.
10+
11+
**NOTE: We encourage using a durable nonce to avoid an expired blockhash error in case there is
12+
network congestion. We demonstrate how to use this nonce account in the `vaaAuctionRelayer`
13+
process.**
14+
15+
Next, you'll need an RPC for each network that you wish to relay `FastMarketOrders` from. Add each
16+
RPC to the config for the corresponding chain name.
17+
18+
Finally, you will need a funded USDC Associated Token Account (ATA), whose owner is your keypair.
19+
Ensure that your private key is securely stored in the `.env` file under the `SOLANA_PRIVATE_KEY`
20+
variable. This key is essential for signing transactions and interacting with the blockchain.
21+
Format the private key as a base64 string before adding it to the `.env` file.
22+
23+
### Vaa Auction Relayer
24+
25+
The `vaaAuctionRelayer` listens for `FastMarketOrder` VAAs emitted by the Liquidity Layer's network
26+
of contracts. It determines if the `maxFee` encoded in the `FastMarketOrder` VAA is high enough to
27+
participate in an auction, if it is, it executes a `place_initial_offer` instruction on the Solana
28+
`MatchingEngine`.
29+
30+
If any known token accounts are the highest bidder at the end of an auction, this process will settle
31+
the auction by executing the `settle_auction_complete` instruction and posting the finalized VAA
32+
associated with the auction's `FastMarketOrder` VAA. For the `vaaAuctionRelayer` to recognize executed
33+
fast transfers and execute the `settle_auction_complete` instruction, add the owner's public key to the
34+
`knownAtaOwners` array field in the configuration file.
35+
36+
The `vaaAuctionRelayer` relies on the [Beacon](https://github.com/pyth-network/beacon) as the `VaaSpy` to listen for `FastMarketOrder` VAAs. To set up the
37+
Beacon, increase the UDP buffer size for the OS:
538

639
```sh
7-
npm ci && npm run build && npm run pack
40+
# for linux
41+
sudo sysctl -w net.core.rmem_max=2097152
42+
sudo sysctl -w net.core.rmem_default=2097152
43+
# for macos
44+
sudo sysctl -w net.inet.udp.recvspace=2097152
845
```
946

10-
Which will produce a `.tgz` file that can be installed using npm or any other package manager like:
47+
Then, make sure Docker is running and execute the following command to run Beacon in a detached mode:
1148

1249
```sh
13-
npm install /path/to/example-liquidity-layer/wormhole-foundation-example-liquidity-layer-solana-0.0.1.tgz
50+
make wormhole-spy-up NETWORK=testnet
1451
```
1552

16-
Once installed, it can be used like any other package:
53+
To stop or restart the beacon
1754

18-
```ts
55+
```sh
56+
make wormhole-spy-down
57+
make wormhole-spy-restart NETWORK=testnet
58+
```
1959

20-
// ...
21-
import * as tokenRouterSdk from "@wormhole-foundation/example-liquidity-layer-solana/tokenRouter";
22-
import { LiquidityLayerDeposit, LiquidityLayerMessage } from "@wormhole-foundation/example-liquidity-layer-solana/common";
23-
import { PreparedOrder } from "@wormhole-foundation/example-liquidity-layer-solana/tokenRouter/state";
24-
// ...
60+
`vaaAuctionRelayer` depends on the `@wormhole-foundation/example-liquidity-layer-solana` Typescript SDK. To make sure we can use this SDK, in the root directory of the repository:
2561

62+
```sh
63+
npm ci && npm run build
2664
```
2765

66+
To run the `vaaAuctionRelayer` execute the following command:
67+
68+
```sh
69+
npm run relayer -- path/to/config/your.config.json
70+
```
71+
72+
### Improve Offers
73+
74+
The `improveOffer` process listens for `AuctionUpdated` events on the `MatchingEngine` via
75+
websocket. Once an auction has been initiated, this process will determine if it is willing to
76+
improve the offer based on the `pricing` parameters in your config.
77+
78+
To run the `improveOffer` script, execute the following command:
79+
80+
```sh
81+
npm run improve -- path/to/config/your.config.json
82+
```
83+
84+
### Execute Fast Orders
85+
86+
The `executeOrder` process listens for `AuctionUpdated` events on the `MatchingEngine` via
87+
websocket. At the end of an auction's duration (see `endSlot` of the `AuctionUpdated` event), this
88+
process will execute the order reflecting this auction within the auction's grace period.
89+
90+
**NOTE: You will need an address lookup table for the execute order instructions because these
91+
instructions require so many accounts. This LUT address can be added to your config.**
92+
93+
To run the `executeOrder` script, execute the following command:
94+
95+
```sh
96+
npm run execute -- path/to/config/your.config.json
97+
```

solana/cfg/testnet/sample.config.json renamed to solver/cfg/testnet/sample.config.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"environment": "testnet",
2+
"environment": "Testnet",
33
"logging": {
44
"app": "warn",
55
"logic": "debug"
@@ -25,70 +25,70 @@
2525
"knownAtaOwners": [],
2626
"endpointConfig": [
2727
{
28-
"chain": "sepolia",
28+
"chain": "Sepolia",
2929
"rpc": "",
3030
"endpoint": "0xE57D917bf955FedE2888AAbD056202a6497F1882",
3131
"chainType": 0
3232
},
3333
{
34-
"chain": "avalanche",
34+
"chain": "Avalanche",
3535
"rpc": "",
3636
"endpoint": "0x8Cd7D7C980cd72eBD16737dC3fa04469dcFcf07A",
3737
"chainType": 0
3838
},
3939
{
40-
"chain": "optimism_sepolia",
40+
"chain": "OptimismSepolia",
4141
"rpc": "",
4242
"endpoint": "0x6BAa7397c18abe6221b4f6C3Ac91C88a9faE00D8",
4343
"chainType": 0
4444
},
4545
{
46-
"chain": "arbitrum_sepolia",
46+
"chain": "ArbitrumSepolia",
4747
"rpc": "",
4848
"endpoint": "0xe0418C44F06B0b0D7D1706E01706316DBB0B210E",
4949
"chainType": 0
5050
},
5151
{
52-
"chain": "base_sepolia",
52+
"chain": "BaseSepolia",
5353
"rpc": "https://sepolia.base.org",
5454
"endpoint": "0x824Ea687CD1CC2f2446235D33Ae764CbCd08e18C",
5555
"chainType": 0
5656
},
5757
{
58-
"chain": "polygon",
58+
"chain": "Polygon",
5959
"rpc": "",
6060
"endpoint": "0xa098368AaaDc0FdF3e309cda710D7A5f8BDEeCD9",
6161
"chainType": 0
6262
}
6363
],
6464
"pricing": [
6565
{
66-
"chain": "sepolia",
66+
"chain": "Sepolia",
6767
"probability": 0.0005,
6868
"edgePctOfFv": 0
6969
},
7070
{
71-
"chain": "avalanche",
71+
"chain": "Avalanche",
7272
"probability": 0.0005,
7373
"edgePctOfFv": 0
7474
},
7575
{
76-
"chain": "optimism_sepolia",
76+
"chain": "OptimismSepolia",
7777
"probability": 0.0005,
7878
"edgePctOfFv": 0
7979
},
8080
{
81-
"chain": "arbitrum_sepolia",
81+
"chain": "ArbitrumSepolia",
8282
"probability": 0.0005,
8383
"edgePctOfFv": 0
8484
},
8585
{
86-
"chain": "base_sepolia",
86+
"chain": "BaseSepolia",
8787
"probability": 0.0005,
8888
"edgePctOfFv": 0
8989
},
9090
{
91-
"chain": "polygon",
91+
"chain": "Polygon",
9292
"probability": 0.1,
9393
"edgePctOfFv": 0
9494
}
File renamed without changes.

solver/package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
"author": "Wormhole Contributors",
55
"license": "Apache-2.0",
66
"main": "./dist/cjs/index.js",
7-
"types":"./dist/cjs/index.d.ts",
7+
"types": "./dist/cjs/index.d.ts",
88
"module": "./dist/esm/index.js",
99
"scripts": {
10-
"execute":"tsx src/executeOrder/app.ts",
11-
"improve":"tsx src/improveOffer/app.ts",
12-
"relayer":"tsx src/vaaAuctionRelayer/app/ts",
13-
"clean":"rm -rf node_modules"
10+
"execute": "tsx src/executeOrder/app.ts",
11+
"improve": "tsx src/improveOffer/app.ts",
12+
"relayer": "tsx src/vaaAuctionRelayer/app.ts",
13+
"clean": "rm -rf node_modules"
1414
},
1515
"dependencies": {
16-
"@wormhole-foundation/sdk-base":"^0.7.0-beta.4",
17-
"@wormhole-foundation/sdk-definitions":"^0.7.0-beta.4",
18-
"@wormhole-foundation/sdk-solana":"^0.7.0-beta.4",
19-
"@wormhole-foundation/example-liquidity-layer-solana":"0.0.1",
20-
"@wormhole-foundation/example-liquidity-layer-evm":"0.0.1",
21-
"@solana/spl-token": "^0.4.6"
16+
"@solana/spl-token": "^0.4.6",
17+
"@wormhole-foundation/example-liquidity-layer-evm": "0.0.1",
18+
"@wormhole-foundation/example-liquidity-layer-solana": "0.0.1",
19+
"@wormhole-foundation/sdk-base": "^0.7.0-beta.4",
20+
"@wormhole-foundation/sdk-definitions": "^0.7.0-beta.4",
21+
"@wormhole-foundation/sdk-solana": "^0.7.0-beta.4"
2222
}
23-
}
23+
}

solver/src/utils/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// required for `toNative` to register the addresses
2+
import "@wormhole-foundation/sdk-evm/address";
3+
import "@wormhole-foundation/sdk-solana/address";
4+
15
import * as splToken from "@solana/spl-token";
26
import { Commitment, Connection, FetchFn, PublicKey, PublicKeyInitData } from "@solana/web3.js";
37
import { ethers } from "ethers";

0 commit comments

Comments
 (0)