Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced Deployment scripts + values #210

Open
wants to merge 8 commits into
base: deployment-scripts
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Binary file added audits/2024-06-07-sec3-composable-intents.pdf
Binary file not shown.
Binary file added audits/2024-06-25-ottersec-composable-intents.pdf
Binary file not shown.
Binary file not shown.
28 changes: 14 additions & 14 deletions deployment/config/mainnet/token-router.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"fastTransferParameters": {
"enabled": true,
"maxAmount": "1000000000",
"baseFee": "1250000",
"initAuctionFee": "950000"
"baseFee": "10000",
"initAuctionFee": "60000"
},
"cctpAllowance": "18446744073709551615"
},
Expand All @@ -16,8 +16,8 @@
"fastTransferParameters": {
"enabled": true,
"maxAmount": "1000000000",
"baseFee": "1250000",
"initAuctionFee": "950000"
"baseFee": "10000",
"initAuctionFee": "60000"
},
"cctpAllowance": "115792089237316195423570985008687907853269984665640564039457584007913129639935"
},
Expand All @@ -27,8 +27,8 @@
"fastTransferParameters": {
"enabled": true,
"maxAmount": "1000000000",
"baseFee": "1250000",
"initAuctionFee": "950000"
"baseFee": "10000",
"initAuctionFee": "60000"
},
"cctpAllowance": "115792089237316195423570985008687907853269984665640564039457584007913129639935"
},
Expand All @@ -38,8 +38,8 @@
"fastTransferParameters": {
"enabled": true,
"maxAmount": "1000000000",
"baseFee": "1250000",
"initAuctionFee": "950000"
"baseFee": "10000",
"initAuctionFee": "60000"
},
"cctpAllowance": "115792089237316195423570985008687907853269984665640564039457584007913129639935"
},
Expand All @@ -49,8 +49,8 @@
"fastTransferParameters": {
"enabled": true,
"maxAmount": "1000000000",
"baseFee": "1250000",
"initAuctionFee": "950000"
"baseFee": "10000",
"initAuctionFee": "60000"
},
"cctpAllowance": "115792089237316195423570985008687907853269984665640564039457584007913129639935"
},
Expand All @@ -60,8 +60,8 @@
"fastTransferParameters": {
"enabled": true,
"maxAmount": "1000000000",
"baseFee": "1250000",
"initAuctionFee": "950000"
"baseFee": "10000",
"initAuctionFee": "60000"
},
"cctpAllowance": "115792089237316195423570985008687907853269984665640564039457584007913129639935"
},
Expand All @@ -71,8 +71,8 @@
"fastTransferParameters": {
"enabled": true,
"maxAmount": "1000000000",
"baseFee": "1250000",
"initAuctionFee": "950000"
"baseFee": "10000",
"initAuctionFee": "60000"
},
"cctpAllowance": "115792089237316195423570985008687907853269984665640564039457584007913129639935"
}
Expand Down
4 changes: 3 additions & 1 deletion deployment/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,6 @@ export function getVerifyCommand({
`;

return command;
}
}

export const capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
45 changes: 45 additions & 0 deletions deployment/scripts/solana/closeProposal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {
ComputeBudgetProgram,
Connection,
PublicKey,
} from "@solana/web3.js";
import "dotenv/config";
import { MatchingEngineProgram, ProgramId } from "@wormhole-foundation/example-liquidity-layer-solana/matchingEngine";
import { solana, getLocalDependencyAddress, env } from "../../helpers";
import { capitalize } from "../../helpers/utils";
import { circle } from "@wormhole-foundation/sdk-base";

solana.runOnSolana("close-proposal", async (chain, signer, log) => {
const matchingEngineId = getLocalDependencyAddress("matchingEngineProxy", chain) as ProgramId;
const canonicalEnv = capitalize(env);
if (canonicalEnv !== "Mainnet" && canonicalEnv !== "Testnet") {
throw new Error(`Unsupported environment: ${env} must be Mainnet or Testnet`);
}

const usdcMint = new PublicKey(circle.usdcContract(canonicalEnv, "Solana"));
const connection = new Connection(chain.rpc, solana.connectionCommitmentLevel);
const matchingEngine = new MatchingEngineProgram(connection, matchingEngineId, usdcMint);

log('Matching Engine Program ID:', matchingEngineId.toString());

log("Proposal to be closed", await matchingEngine.fetchProposal());

if (solana.priorityMicrolamports === undefined || solana.priorityMicrolamports === 0) {
log(`(!) PRIORITY_MICROLAMPORTS is undefined or zero, your transaction may not land during congestion.`)
}

const priorityFee = ComputeBudgetProgram.setComputeUnitPrice({ microLamports: solana.priorityMicrolamports });
const ownerOrAssistant = new PublicKey(await signer.getAddress());

const closeProposalIx = await matchingEngine.closeProposalIx({
ownerOrAssistant,
});

try {
const closeTxSig = await solana.ledgerSignAndSend(connection, [closeProposalIx, priorityFee], []);
console.log(`Close Proposal Transaction ID: ${closeTxSig}`);
} catch (error) {
console.error('Failed to close proposal:', error);
}

});
35 changes: 35 additions & 0 deletions deployment/scripts/solana/fetchProposal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {
ComputeBudgetProgram,
Connection,
PublicKey,
} from "@solana/web3.js";
import "dotenv/config";
import { MatchingEngineProgram } from "@wormhole-foundation/example-liquidity-layer-solana/matchingEngine";
import { solana, getLocalDependencyAddress, env, capitalize } from "../../helpers";
import { ProgramId } from "@wormhole-foundation/example-liquidity-layer-solana/matchingEngine";
import { circle } from "@wormhole-foundation/sdk-base";

solana.runOnSolana("fetch-proposal", async (chain, signer, log) => {
const matchingEngineId = getLocalDependencyAddress("matchingEngineProxy", chain) as ProgramId;

const canonicalEnv = capitalize(env);

if (canonicalEnv !== "Mainnet" && canonicalEnv !== "Testnet") {
throw new Error(`Unsupported environment: ${env} must be Mainnet or Testnet.`);
}

const usdcMint = new PublicKey(circle.usdcContract(canonicalEnv, "Solana"));
const connection = new Connection(chain.rpc, solana.connectionCommitmentLevel);
const matchingEngine = new MatchingEngineProgram(connection, matchingEngineId, usdcMint);

log('Matching Engine Program ID:', matchingEngineId.toString());

const proposal = await matchingEngine.fetchProposal();
log('Proposal:', proposal);

if (proposal.slotEnactedAt !== null) {
log(`Proposal has already been enacted at slot ${proposal.slotEnactedAt.toNumber()}`);
} else {
log('Proposal has not been enacted yet. Update must be submitted after slot ' + proposal.slotEnactDelay.toNumber());
}
});
49 changes: 49 additions & 0 deletions deployment/scripts/solana/proposeAuctionParameters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import {
ComputeBudgetProgram,
Connection,
PublicKey,
} from "@solana/web3.js";
import "dotenv/config";
import { MatchingEngineProgram, ProgramId } from "@wormhole-foundation/example-liquidity-layer-solana/matchingEngine";
import { capitalize, env, getLocalDependencyAddress, getMatchingEngineAuctionParameters, solana } from "../../helpers";
import { circle } from "@wormhole-foundation/sdk-base";

solana.runOnSolana("propose-auction-parameters", async (chain, signer, log) => {
const matchingEngineId = getLocalDependencyAddress("matchingEngineProxy", chain) as ProgramId;
const canonicalEnv = capitalize(env);
if (canonicalEnv !== "Mainnet" && canonicalEnv !== "Testnet") {
throw new Error(`Unsupported environment: ${env}. Must be Mainnet or Testnet.`);
}

const usdcMint = new PublicKey(circle.usdcContract(canonicalEnv, "Solana"));
const connection = new Connection(chain.rpc, solana.connectionCommitmentLevel);
const matchingEngine = new MatchingEngineProgram(connection, matchingEngineId, usdcMint);

log('Matching Engine Program ID:', matchingEngineId.toString());
log('Current Matching Engine Auction parameters:', await matchingEngine.fetchAuctionParameters());
log('\nTo-be-proposed Matching Engine Auction parameters:', getMatchingEngineAuctionParameters(chain));

if (solana.priorityMicrolamports === undefined || solana.priorityMicrolamports === 0) {
log(`(!) PRIORITY_MICROLAMPORTS is undefined or zero, your transaction may not land during congestion.`);
}

const priorityFee = ComputeBudgetProgram.setComputeUnitPrice({ microLamports: solana.priorityMicrolamports });
const ownerOrAssistant = new PublicKey(await signer.getAddress());

const proposeIx = await matchingEngine.proposeAuctionParametersIx({
ownerOrAssistant,
}, getMatchingEngineAuctionParameters(chain));

try {
const proposeTxSig = await solana.ledgerSignAndSend(connection, [proposeIx, priorityFee], []);
log(`Propose Transaction ID: ${proposeTxSig}.`)

const proposal = await matchingEngine.fetchProposal();
log(`The proposal has been published at slot ${proposal.slotProposedAt.toNumber()}.`);
log(`You must wait up to slot ${proposal.slotEnactDelay.toNumber()} to submit the auction parameters update.`);
}
catch (error) {
console.error('Failed to send transaction:', error);
}

});
86 changes: 36 additions & 50 deletions deployment/scripts/solana/updateAuctionParameters.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,43 @@
import {
ComputeBudgetProgram,
Connection,
PublicKey,
ComputeBudgetProgram,
Connection,
PublicKey,
} from "@solana/web3.js";
import "dotenv/config";
import { MatchingEngineProgram } from "@wormhole-foundation/example-liquidity-layer-solana/matchingEngine";
import { solana, getLocalDependencyAddress, env, getMatchingEngineAuctionParameters } from "../../helpers";
import { ProgramId } from "@wormhole-foundation/example-liquidity-layer-solana/matchingEngine";
import { MatchingEngineProgram, ProgramId } from "@wormhole-foundation/example-liquidity-layer-solana/matchingEngine";
import { env, getLocalDependencyAddress, getMatchingEngineAuctionParameters, solana } from "../../helpers";
import { capitalize } from "../../helpers/utils";
import { circle } from "@wormhole-foundation/sdk-base";

solana.runOnSolana("update-auction-parameters", async (chain, signer, log) => {
const matchingEngineId = getLocalDependencyAddress("matchingEngineProxy", chain) as ProgramId;

const capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
const canonicalEnv = capitalize(env);

if (canonicalEnv !== "Mainnet" && canonicalEnv !== "Testnet") {
throw new Error(`Unsupported environment: ${env} must be Mainnet or Testnet`);
}

const usdcMint = new PublicKey(circle.usdcContract(canonicalEnv, "Solana"));
const connection = new Connection(chain.rpc, solana.connectionCommitmentLevel);
const matchingEngine = new MatchingEngineProgram(connection, matchingEngineId, usdcMint);

log('Matching Engine Program ID:', matchingEngineId.toString());
log('Current Matching Engine Auction parameters:', await matchingEngine.fetchAuctionParameters());
log('\nTo-be-updated Matching Engine Auction parameters:', getMatchingEngineAuctionParameters(chain));

log('Proposing new Matching Engine Auction parameters...')

const priorityFee = ComputeBudgetProgram.setComputeUnitPrice({ microLamports: solana.priorityMicrolamports });
const ownerOrAssistant = new PublicKey(await signer.getAddress());

const proposeInstructions = [];
const proposeIx = await matchingEngine.proposeAuctionParametersIx({
ownerOrAssistant,
}, getMatchingEngineAuctionParameters(chain));

proposeInstructions.push(proposeIx, priorityFee);
const proposeTxSig = await solana.ledgerSignAndSend(connection, proposeInstructions, []);

console.log(`Propose Transaction ID: ${proposeTxSig}, wait for confirmation...`);

await connection.confirmTransaction(proposeTxSig, 'confirmed');

const updateInstructions = [];
const updateIx = await matchingEngine.updateAuctionParametersIx({
owner: ownerOrAssistant,
});
updateInstructions.push(updateIx, priorityFee);
const updateTxSig = await solana.ledgerSignAndSend(connection, updateInstructions, []);

await connection.confirmTransaction(updateTxSig, 'confirmed');

console.log(`Update Transaction ID: ${updateTxSig}, wait for confirmation...`);
const matchingEngineId = getLocalDependencyAddress("matchingEngineProxy", chain) as ProgramId;
const canonicalEnv = capitalize(env);
if (canonicalEnv !== "Mainnet" && canonicalEnv !== "Testnet") {
throw new Error(`Unsupported environment: ${env} must be Mainnet or Testnet`);
}

const usdcMint = new PublicKey(circle.usdcContract(canonicalEnv, "Solana"));
const connection = new Connection(chain.rpc, solana.connectionCommitmentLevel);
const matchingEngine = new MatchingEngineProgram(connection, matchingEngineId, usdcMint);

log('Matching Engine Program ID:', matchingEngineId.toString());
log('Current Matching Engine Auction parameters:', await matchingEngine.fetchAuctionParameters());
log('\nTo-be-proposed Matching Engine Auction parameters:', getMatchingEngineAuctionParameters(chain));

if (solana.priorityMicrolamports === undefined || solana.priorityMicrolamports === 0) {
log(`(!) PRIORITY_MICROLAMPORTS is undefined or zero, your transaction may not land during congestion.`)
}

const priorityFee = ComputeBudgetProgram.setComputeUnitPrice({ microLamports: solana.priorityMicrolamports });

const ownerOrAssistant = new PublicKey(await signer.getAddress());
const updateIx = await matchingEngine.updateAuctionParametersIx({
owner: ownerOrAssistant,
});
try {
const updateTxSig = await solana.ledgerSignAndSend(connection, [updateIx, priorityFee], []);
log(`Update Transaction ID: ${updateTxSig}`);
} catch (error) {
console.error('Failed to send transaction:', error);
}
});
9 changes: 9 additions & 0 deletions solana/programs/matching-engine/src/events/auction_closed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use anchor_lang::prelude::*;

use crate::state::Auction;

#[event]
#[derive(Debug)]
pub struct AuctionClosed {
pub auction: Auction,
}
3 changes: 3 additions & 0 deletions solana/programs/matching-engine/src/events/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
mod auction_closed;
pub use auction_closed::*;

mod auction_settled;
pub use auction_settled::*;

Expand Down
Loading