From db47f9398aeeaa9a4127223c1d9bd015814e2562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Claudio=20Nale?= Date: Fri, 26 Jul 2024 16:17:54 -0300 Subject: [PATCH] deploy: a few fixes for the initialize matching engine script --- deployment/helpers/solana.ts | 7 ++++--- .../scripts/evm/TokenRouter/upgrade-token-router.ts | 2 +- deployment/scripts/evm/TokenRouter/utils.ts | 2 +- deployment/scripts/solana/initializeMatchingEngine.ts | 9 +++++---- .../scripts/solana/registerRoutersInMatchingEngine.ts | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/deployment/helpers/solana.ts b/deployment/helpers/solana.ts index 3df4d892..31cc07ee 100644 --- a/deployment/helpers/solana.ts +++ b/deployment/helpers/solana.ts @@ -45,7 +45,8 @@ export async function runOnSolana(scriptName: string, cb: SolanaScriptCb) { const log = (...args: any[]) => console.log(`[${chain.chainId}]`, ...args); const signer = await getSigner(); // TODO: encode in base58 - log(`Starting script. Signer: ${(await signer.getAddress()).toString("hex")}`); + const signerPubkey = new PublicKey(await signer.getAddress()).toBase58(); + log(`Starting script. Signer: ${signerPubkey}`); try { await cb(chain, signer, log); @@ -95,7 +96,7 @@ async function addLedgerSignature(tx: Transaction, signer: SolanaLedgerSigner, s } export function getMatchingEngineProgram(connection: Connection) { - const matchingEngineId = getContractAddress("MatchingEngine", toChainId("Solana")) as MatchingEngineProgramId; + const matchingEngineId = getContractAddress("MatchingEngineProxy", toChainId("Solana")) as MatchingEngineProgramId; const network = env === "mainnet" ? "Mainnet" : "Testnet"; const usdcMint = new PublicKey(circle.usdcContract(network, "Solana")); @@ -103,7 +104,7 @@ export function getMatchingEngineProgram(connection: Connection) { }; export function getTokenRouterProgram(connection: Connection) { - const tokenRouterId = getContractAddress("TokenRouter", toChainId("Solana")) as TokenRouterProgramId; + const tokenRouterId = getContractAddress("TokenRouterProxy", toChainId("Solana")) as TokenRouterProgramId; const network = env === "mainnet" ? "Mainnet" : "Testnet"; const usdcMint = new PublicKey(circle.usdcContract(network, "Solana")); diff --git a/deployment/scripts/evm/TokenRouter/upgrade-token-router.ts b/deployment/scripts/evm/TokenRouter/upgrade-token-router.ts index 83513602..2b85a8f5 100644 --- a/deployment/scripts/evm/TokenRouter/upgrade-token-router.ts +++ b/deployment/scripts/evm/TokenRouter/upgrade-token-router.ts @@ -40,7 +40,7 @@ async function checkImmutables(tokenRouter: TokenRouter, chain: ChainInfo, match tokenRouter.matchingEngineAddress(), ]); - const localMatchingEngineAddress = getContractAddress("MatchingEngine", matchingEngineChain); + const localMatchingEngineAddress = getContractAddress("MatchingEngineProxy", matchingEngineChain); const matchingEngineAddress = toUniversal("Solana", localMatchingEngineAddress).toString(); const tokenAddress = getDependencyAddress("token", chain.chainId); diff --git a/deployment/scripts/evm/TokenRouter/utils.ts b/deployment/scripts/evm/TokenRouter/utils.ts index c718773b..d62126f6 100644 --- a/deployment/scripts/evm/TokenRouter/utils.ts +++ b/deployment/scripts/evm/TokenRouter/utils.ts @@ -33,7 +33,7 @@ export async function deployImplementation(signer: ethers.Signer, config: TokenR const tokenMessenger = getDependencyAddress("tokenMessenger", config.chainId); const matchingEngineAddress = toUniversal("Solana", (getContractAddress( - "MatchingEngine", + "MatchingEngineProxy", matchingEngineChain ))).toString(); diff --git a/deployment/scripts/solana/initializeMatchingEngine.ts b/deployment/scripts/solana/initializeMatchingEngine.ts index 5b19f740..74d289ed 100644 --- a/deployment/scripts/solana/initializeMatchingEngine.ts +++ b/deployment/scripts/solana/initializeMatchingEngine.ts @@ -15,7 +15,7 @@ import { circle } from "@wormhole-foundation/sdk-base"; solana.runOnSolana("deploy-matching-engine", async (chain, signer, log) => { const config = await getChainConfig("matching-engine", chain.chainId); - const matchingEngineId = getContractAddress("MatchingEngine", chain.chainId) as ProgramId; + const matchingEngineId = getContractAddress("MatchingEngineProxy", chain.chainId) as ProgramId; const env = "Mainnet"; const usdcMint = new PublicKey(circle.usdcContract(env, "Solana")); @@ -50,11 +50,12 @@ async function initialize(matchingEngine: MatchingEngineProgram, signer: SolanaL } const initializeInstructions = []; const priorityFee = ComputeBudgetProgram.setComputeUnitPrice({ microLamports: solana.priorityMicrolamports }); + const feeRecipient = new PublicKey(config.feeRecipient); initializeInstructions.push(await matchingEngine.initializeIx( { owner: signerPubkey, ownerAssistant: new PublicKey(config.ownerAssistant), - feeRecipient: new PublicKey(config.feeRecipient), + feeRecipient, }, auctionParams )); @@ -63,9 +64,9 @@ async function initialize(matchingEngine: MatchingEngineProgram, signer: SolanaL // TODO: this doesn't check if the ATA already exists const splToken = await import("@solana/spl-token"); const assocciatedTokenProgramId = splToken.ASSOCIATED_TOKEN_PROGRAM_ID; - const associatedToken = splToken.getAssociatedTokenAddressSync(usdcMint, signerPubkey, undefined, usdcMint, assocciatedTokenProgramId); + const associatedToken = splToken.getAssociatedTokenAddressSync(usdcMint, feeRecipient, undefined, usdcMint, assocciatedTokenProgramId); const createAtaInstructions = []; - createAtaInstructions.push(splToken.createAssociatedTokenAccountInstruction(signerPubkey, associatedToken, signerPubkey, usdcMint)); + createAtaInstructions.push(splToken.createAssociatedTokenAccountInstruction(signerPubkey, associatedToken, feeRecipient, usdcMint)); createAtaInstructions.push(priorityFee); const createAtaTxid = await solana.ledgerSignAndSend(connection, createAtaInstructions, []); diff --git a/deployment/scripts/solana/registerRoutersInMatchingEngine.ts b/deployment/scripts/solana/registerRoutersInMatchingEngine.ts index c65bc086..eb637d7b 100644 --- a/deployment/scripts/solana/registerRoutersInMatchingEngine.ts +++ b/deployment/scripts/solana/registerRoutersInMatchingEngine.ts @@ -15,7 +15,7 @@ import { TokenRouterProgram } from "@wormhole-foundation/example-liquidity-layer solana.runOnSolana("register-routers-matching-engine", async (chain, signer, log) => { - const matchingEngineId = getContractAddress("MatchingEngine", chain.chainId) as ProgramId; + const matchingEngineId = getContractAddress("MatchingEngineProxy", chain.chainId) as ProgramId; if (chain.network === "Devnet") throw new Error("Devnet is not supported by USDC. Use Mainnet or Testnet.");