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

Commit 488148f

Browse files
committed
deploy: adds Solana config
1 parent f59cf51 commit 488148f

File tree

3 files changed

+96
-26
lines changed

3 files changed

+96
-26
lines changed

deployment/config/config-types.ts

Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,99 @@
11
import { ChainId } from "@wormhole-foundation/sdk-base";
22

3+
// TODO: check if solana has different needs for the TokenRouter
34
export type TokenRouterConfiguration = {
45
// Wormhole Chain ID of the token router configuration
56
chainId: ChainId;
67

78
// Mutable values
9+
/**
10+
* Account with the authority to add
11+
* new token routers among other operations.
12+
*/
813
ownerAssistant: string;
914
fastTransferParameters: {
1015
enabled: boolean;
11-
maxAmount: number;
12-
baseFee: number;
13-
initAuctionFee: number;
16+
/**
17+
* Expressed in μUSDC.
18+
* E.g. 1000000000 is 1000 USDC.
19+
*/
20+
maxAmount: string;
21+
/**
22+
* Expressed in μUSDC.
23+
* E.g. 1250000 is 1.25 USDC.
24+
*/
25+
baseFee: string;
26+
/**
27+
* Expressed in μUSDC.
28+
* E.g. 950000 is 0.95 USDC.
29+
*/
30+
initAuctionFee: string;
1431
};
1532
cctpAllowance: string;
1633
disableRouterEndpoints?: ChainId[];
1734
};
1835

1936
export type MatchingEngineConfiguration = {
20-
// Wormhole Chain ID of the matching engine configuration
37+
/**
38+
* Wormhole Chain ID of the matching engine configuration
39+
*/
2140
chainId: ChainId;
2241

2342
// Immutable values
43+
/**
44+
* The part of the penalty that is awarded to the user when the auction is completed.
45+
* E.g. 400000 is 40%.
46+
*/
2447
userPenaltyRewardBps: string;
48+
/**
49+
* The initial penalty proportion that is incurred once the grace period is over.
50+
* E.g. 250000 is 25%.
51+
*/
2552
initialPenaltyBps: string;
53+
/**
54+
* Auction duration in Solana slots.
55+
*/
2656
auctionDuration: string;
57+
/**
58+
* Auction grace period in Solana slots.
59+
* The grace period of the auction in slots. This is the number of slots the highest bidder
60+
* has to execute the fast order before incurring a penalty.
61+
* This value INCLUDES the `auctionDuration`.
62+
*/
2763
auctionGracePeriod: string;
28-
auctionPenaltyBlocks: string;
64+
/**
65+
* The `securityDeposit` decays over this period.
66+
* Expressed in Solana slots.
67+
*/
68+
auctionPenaltySlots: string;
69+
/**
70+
* minimum offer increment for auctions.
71+
* New offers need to surpass a threshold given by this parameter.
72+
* E.g. 50000 is 5%.
73+
*/
74+
minOfferDeltaBps: string;
75+
/**
76+
* The base security deposit, which will the the additional amount an auction participant must
77+
* deposit to participate in an auction. Expressed in μUSDC.
78+
* E.g. 1000000 is 1 USDC.
79+
*/
80+
securityDepositBase: string;
81+
/**
82+
* Additional security deposit based on the notional of the order amount.
83+
* E.g. 5000 is 0.5%.
84+
*/
85+
securityDepositBps: string;
2986

3087
// Mutable values
88+
/**
89+
* Solana account with the authority to add
90+
* new token routers among other operations.
91+
*/
3192
ownerAssistant: string;
93+
/**
94+
* Fee recipient for relayer service of slow orders, i.e. those that do not
95+
* have an associated auction.
96+
*/
3297
feeRecipient: string;
3398
cctpAllowance: string;
3499
};

deployment/config/testnet/matching-engine.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"initialPenaltyBps": "",
88
"auctionDuration": "",
99
"auctionGracePeriod": "",
10-
"auctionPenaltyBlocks": ""
10+
"auctionPenaltySlots": ""
1111
},
1212
{
1313
"chainId": 5,
@@ -17,7 +17,7 @@
1717
"initialPenaltyBps": "",
1818
"auctionDuration": "",
1919
"auctionGracePeriod": "",
20-
"auctionPenaltyBlocks": ""
20+
"auctionPenaltySlots": ""
2121
},
2222
{
2323
"chainId": 6,
@@ -27,7 +27,7 @@
2727
"initialPenaltyBps": "",
2828
"auctionDuration": "",
2929
"auctionGracePeriod": "",
30-
"auctionPenaltyBlocks": ""
30+
"auctionPenaltySlots": ""
3131
},
3232
{
3333
"chainId": 23,
@@ -37,7 +37,7 @@
3737
"initialPenaltyBps": "",
3838
"auctionDuration": "",
3939
"auctionGracePeriod": "",
40-
"auctionPenaltyBlocks": ""
40+
"auctionPenaltySlots": ""
4141
},
4242
{
4343
"chainId": 24,
@@ -47,7 +47,7 @@
4747
"initialPenaltyBps": "",
4848
"auctionDuration": "",
4949
"auctionGracePeriod": "",
50-
"auctionPenaltyBlocks": ""
50+
"auctionPenaltySlots": ""
5151
},
5252
{
5353
"chainId": 30,
@@ -57,6 +57,6 @@
5757
"initialPenaltyBps": "",
5858
"auctionDuration": "",
5959
"auctionGracePeriod": "",
60-
"auctionPenaltyBlocks": ""
60+
"auctionPenaltySlots": ""
6161
}
6262
]

deployment/scripts/solana/initializeMatchingEngine.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,6 @@ import { ProgramId } from "@wormhole-foundation/example-liquidity-layer-solana/m
1212
import { SolanaLedgerSigner } from "@xlabs-xyz/ledger-signer-solana";
1313
import { circle } from "@wormhole-foundation/sdk-base";
1414

15-
16-
const AUCTION_PARAMS: AuctionParameters = {
17-
userPenaltyRewardBps: 400000, // 40%
18-
initialPenaltyBps: 250000, // 25%
19-
duration: 5, // slots
20-
gracePeriod: 10, // slots
21-
penaltyPeriod: 20, // slots
22-
minOfferDeltaBps: 50000, // 5%
23-
securityDepositBase: uint64ToBN(1000000n), // 1 USDC
24-
securityDepositBps: 5000, // 0.5%
25-
};
26-
2715
runOnSolana("deploy-matching-engine", async (chain, signer, log) => {
2816
const config = await getChainConfig<MatchingEngineConfiguration>("matching-engine", chain.chainId);
2917
const matchingEngineId = getContractAddress("MatchingEngine", chain.chainId) as ProgramId;
@@ -49,13 +37,23 @@ async function initialize(matchingEngine: MatchingEngineProgram, signer: SolanaL
4937
}
5038

5139
const signerPubkey = new PublicKey(await signer.getAddress());
40+
const auctionParams: AuctionParameters = {
41+
userPenaltyRewardBps: toIntegerNumber(config.userPenaltyRewardBps, "userPenaltyRewardBps"),
42+
initialPenaltyBps: toIntegerNumber(config.initialPenaltyBps, "initialPenaltyBps"),
43+
duration: toIntegerNumber(config.auctionDuration, "duration"),
44+
gracePeriod: toIntegerNumber(config.auctionGracePeriod, "gracePeriod"),
45+
penaltyPeriod: toIntegerNumber(config.auctionPenaltySlots, "penaltyPeriod"),
46+
minOfferDeltaBps: toIntegerNumber(config.minOfferDeltaBps, "minOfferDeltaBps"),
47+
securityDepositBase: uint64ToBN(BigInt(config.securityDepositBase)),
48+
securityDepositBps: toIntegerNumber(config.securityDepositBps, "securityDepositBps"),
49+
}
5250
const initializeIx = await matchingEngine.initializeIx(
5351
{
5452
owner: signerPubkey,
55-
ownerAssistant: signerPubkey,
56-
feeRecipient: signerPubkey,
53+
ownerAssistant: new PublicKey(config.ownerAssistant),
54+
feeRecipient: new PublicKey(config.feeRecipient),
5755
},
58-
AUCTION_PARAMS,
56+
auctionParams
5957
);
6058

6159
const splToken = await import("@solana/spl-token");
@@ -72,3 +70,10 @@ async function initialize(matchingEngine: MatchingEngineProgram, signer: SolanaL
7270
log(`InitializeTxid ${initializeTxid}`);
7371
}
7472

73+
function toIntegerNumber(text: string, name: string): number {
74+
const res = Number(text);
75+
if (!Number.isSafeInteger(res)) {
76+
throw new Error(`${name} is not a safe integer. Received ${text}`)
77+
}
78+
return res;
79+
}

0 commit comments

Comments
 (0)