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

Commit 4900191

Browse files
committed
replace more execute fns
1 parent 4cf3221 commit 4900191

File tree

4 files changed

+100
-181
lines changed

4 files changed

+100
-181
lines changed

solana/ts/src/matchingEngine/index.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,9 +1860,7 @@ export class MatchingEngineProgram {
18601860
initialOfferToken?: PublicKey;
18611861
initialParticipant?: PublicKey;
18621862
},
1863-
opts: {
1864-
targetChain?: ChainId;
1865-
} = {},
1863+
opts: { targetChain?: ChainId } = {},
18661864
) {
18671865
const connection = this.program.provider.connection;
18681866

@@ -1882,10 +1880,8 @@ export class MatchingEngineProgram {
18821880
if (targetChain === undefined) {
18831881
fastVaaAccount ??= await VaaAccount.fetch(connection, fastVaa);
18841882

1885-
const { fastMarketOrder } = LiquidityLayerMessage.decode(fastVaaAccount.payload());
1886-
if (fastMarketOrder === undefined) {
1887-
throw new Error("Message not FastMarketOrder");
1888-
}
1883+
const { payload: fastMarketOrder } = fastVaaAccount.vaa("FastTransfer:FastMarketOrder");
1884+
18891885
targetChain ??= toChainId(fastMarketOrder.targetChain);
18901886
}
18911887

solana/ts/src/protocol/matchingEngine.ts

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,18 +196,48 @@ export class SolanaMatchingEngine<N extends Network, C extends SolanaChains>
196196
yield this.createUnsignedTx({ transaction }, "MatchingEngine.improveOffer");
197197
}
198198

199-
async *executeFastOrder(sender: AnySolanaAddress, vaa: FastTransfer.VAA) {
199+
async *executeFastOrder(
200+
sender: AnySolanaAddress,
201+
vaa: FastTransfer.VAA,
202+
participant?: AnySolanaAddress,
203+
) {
204+
if (vaa.payloadLiteral !== "FastTransfer:FastMarketOrder") throw new Error("Invalid VAA");
205+
200206
const payer = new SolanaAddress(sender).unwrap();
201207

208+
const initialParticipant = participant
209+
? new SolanaAddress(participant).unwrap()
210+
: undefined;
211+
202212
const fastVaa = coreUtils.derivePostedVaaKey(
203213
this.coreBridgeProgramId(),
204214
Buffer.from(vaa.hash),
205215
);
206216

207-
const ix = await this.executeFastOrderCctpIx({
208-
payer,
209-
fastVaa,
210-
});
217+
const digest = keccak256(vaa.hash);
218+
const auction = this.auctionAddress(digest);
219+
const reservedSequence = this.reservedFastFillSequenceAddress(digest);
220+
221+
const { targetChain } = vaa.payload;
222+
223+
const ix =
224+
targetChain === "Solana"
225+
? await this.executeFastOrderLocalIx({
226+
payer,
227+
fastVaa,
228+
auction,
229+
reservedSequence,
230+
initialParticipant,
231+
})
232+
: await this.executeFastOrderCctpIx(
233+
{
234+
payer,
235+
fastVaa,
236+
auction,
237+
initialParticipant,
238+
},
239+
{ targetChain: toChainId(targetChain) },
240+
);
211241

212242
const computeIx = ComputeBudgetProgram.setComputeUnitLimit({
213243
units: 300_000,

solana/ts/src/testing/utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import {
1111
TransactionMessage,
1212
VersionedTransaction,
1313
} from "@solana/web3.js";
14+
import { Network } from "@wormhole-foundation/sdk-base";
15+
import { SignAndSendSigner as SdkSigner, signAndSendWait } from "@wormhole-foundation/sdk-connect";
16+
import { UniversalAddress, VAA } from "@wormhole-foundation/sdk-definitions";
17+
import { SolanaSendSigner, SolanaUnsignedTransaction } from "@wormhole-foundation/sdk-solana";
18+
import { SolanaWormholeCore, utils as coreUtils } from "@wormhole-foundation/sdk-solana-core";
1419
import { expect } from "chai";
1520
import { execSync } from "child_process";
1621
import { Err, Ok } from "ts-results";
1722
import { CORE_BRIDGE_PID, USDC_MINT_ADDRESS } from "./consts";
18-
import { SolanaSendSigner, SolanaUnsignedTransaction } from "@wormhole-foundation/sdk-solana";
19-
import { SolanaWormholeCore, utils as coreUtils } from "@wormhole-foundation/sdk-solana-core";
20-
import { SignAndSendSigner as SdkSigner, signAndSendWait } from "@wormhole-foundation/sdk-connect";
21-
import { UniversalAddress, VAA, deserialize } from "@wormhole-foundation/sdk-definitions";
22-
import { Chain, Network } from "@wormhole-foundation/sdk-base";
2323

2424
export function toUniversalAddress(address: number[] | Buffer | Array<number>): UniversalAddress {
2525
return new UniversalAddress(new Uint8Array(address));

0 commit comments

Comments
 (0)