@@ -127,45 +127,48 @@ See the following examples of how to construct a bid object via the SDKs:
127
127
Below is an excerpt of example code. See the full example in the [ Typescript SDK] ( https://github.com/pyth-network/per/blob/4be711525948cf24c0ebd4ebab007dc7f51b7069/sdk/js/src/examples/simpleSearcherLimo.ts ) .
128
128
129
129
``` typescript copy
130
- import { OpportunitySvm } from " ../index" ;
131
- import { BidSvm } from " ../types" ;
132
-
133
- import * as anchor from " @coral-xyz/anchor" ;
134
- import * as limo from " @kamino-finance/limo-sdk" ;
135
-
136
- /**
137
- * Generates a bid for a given opportunity. The transaction in this bid transfers assets from the searcher's wallet to fulfill the limit order.
138
- * @param opportunity The SVM opportunity to bid on
139
- * @returns The generated bid object
140
- */
141
- async generateBid (opportunity : OpportunitySvm ): Promise < BidSvm > {
130
+ /**
131
+ * Generates a bid for a given opportunity. The transaction in this bid transfers assets from the searcher's wallet to fulfill the limit order.
132
+ * @param opportunity The SVM opportunity to bid on
133
+ * @returns The generated bid object
134
+ */
135
+ async generateBid (opportunity : OpportunitySvm ): Promise < BidSvm > {
142
136
const order = opportunity .order ;
143
137
const limoClient = new limo .LimoClient (
144
138
this .connectionSvm ,
145
139
order .state .globalConfig
146
140
);
147
141
148
142
const ixsTakeOrder = await this .generateTakeOrderIxs (limoClient , order );
149
- const txRaw = new anchor .web3 .Transaction ().add (... ixsTakeOrder );
143
+ const feeInstruction = ComputeBudgetProgram .setComputeUnitPrice ({
144
+ microLamports:
145
+ this .latestChainUpdate [this .chainId ].latestPrioritizationFee ,
146
+ });
147
+ const txRaw = new anchor .web3 .Transaction ().add (
148
+ feeInstruction ,
149
+ ... ixsTakeOrder
150
+ );
150
151
151
- const bidData = await this .getBidData ( limoClient , order );
152
+ const bidAmount = await this .getBidAmount ( order );
152
153
154
+ const config = await this .getExpressRelayConfig ();
153
155
const bid = await this .client .constructSvmBid (
154
156
txRaw ,
155
157
this .searcher .publicKey ,
156
- bidData . router ,
158
+ getPdaAuthority ( limoClient . getProgramID (), order . state . globalConfig ) ,
157
159
order .address ,
158
- bidData . bidAmount ,
160
+ bidAmount ,
159
161
new anchor .BN (Math .round (Date .now () / 1000 + DAY_IN_SECONDS )),
160
162
this .chainId ,
161
- bidData .relayerSigner ,
162
- bidData . relayerFeeReceiver
163
+ config .relayerSigner ,
164
+ config . feeReceiverRelayer
163
165
);
164
166
165
- bid.transaction.recentBlockhash = this .recentBlockhash [this .chainId ];
167
+ bid.transaction.recentBlockhash =
168
+ this.latestChainUpdate[this .chainId ].blockhash;
166
169
bid.transaction.sign(this.searcher);
167
170
return bid;
168
- }
171
+ }
169
172
```
170
173
171
174
</Tabs.Tab>
@@ -193,24 +196,32 @@ async def assess_opportunity(self, opp: OpportunitySvm) -> BidSvm | None:
193
196
A bid object if the opportunity is worth taking to be submitted to the Express Relay server, otherwise None.
194
197
"""
195
198
order: OrderStateAndAddress = {"address": opp.order_address, "state": opp.order}
199
+
196
200
ixs_take_order = await self.generate_take_order_ixs(order)
197
- bid_data = await self .get_bid_data(order)
201
+ bid_amount = await self.get_bid_amount(order)
202
+ router = self.limo_client.get_pda_authority(
203
+ self.limo_client.get_program_id(), order["state"].global_config
204
+ )
198
205
199
206
submit_bid_ix = self.client.get_svm_submit_bid_instruction(
200
207
searcher=self.private_key.pubkey(),
201
- router = bid_data. router,
208
+ router=router,
202
209
permission_key=order["address"],
203
- bid_amount = bid_data. bid_amount,
210
+ bid_amount=bid_amount,
204
211
deadline=DEADLINE,
205
212
chain_id=self.chain_id,
206
- fee_receiver_relayer = bid_data.relayer_fee_receiver,
207
- relayer_signer = bid_data.relayer_signer,
213
+ fee_receiver_relayer=(await self.get_metadata()).fee_receiver_relayer,
214
+ relayer_signer=(await self.get_metadata()).relayer_signer,
215
+ )
216
+ latest_chain_update = self.latest_chain_update[self.chain_id]
217
+ fee_instruction = set_compute_unit_price(
218
+ latest_chain_update.latest_prioritization_fee
208
219
)
209
220
transaction = Transaction.new_with_payer(
210
- [submit_bid_ix] + ixs_take_order, self .private_key.pubkey()
221
+ [fee_instruction, submit_bid_ix] + ixs_take_order, self.private_key.pubkey()
211
222
)
212
223
transaction.partial_sign(
213
- [self .private_key], recent_blockhash = self .recent_blockhash[ self .chain_id]
224
+ [self.private_key], recent_blockhash=latest_chain_update.blockhash
214
225
)
215
226
bid = BidSvm(transaction=transaction, chain_id=self.chain_id)
216
227
return bid
@@ -247,9 +258,9 @@ const generateBid = async (opportunity: OpportunitySvm, recentBlockhash: Blockha
247
258
...
248
259
}
249
260
250
- const handleOpporunity = async (opportunity : Opportunity ) => {
261
+ const handleOpportunity = async (opportunity: Opportunity) => {
251
262
...
252
- const bid = await generateBid (opportunity as OpportunitySvm , this . recentBlockhash [ this . chainId ] );
263
+ const bid = await this. generateBid(opportunity as OpportunitySvm);
253
264
await client.submitBid(bid);
254
265
}
255
266
` ` `
@@ -266,7 +277,7 @@ async def generate_bid(opp: OpportunitySvm) -> BidSvm:
266
277
...
267
278
268
279
def opportunity_callback(opportunity: Opportunity):
269
- bid = generate_bid (typing.cast(OpportunitySvm, opportunity ))
280
+ bid = await self.assess_opportunity (typing.cast(OpportunitySvm, opp ))
270
281
await client.submit_bid(bid, subscribe_to_updates=True)
271
282
` ` `
272
283
@@ -278,7 +289,7 @@ Searchers can submit bids through an HTTP POST call to the [`/v1/bids`](https://
278
289
curl -X POST https://pyth-express-relay-mainnet.asymmetric.re/v1/bids \
279
290
-H "Content-Type: application/json" \
280
291
-d '{
281
- "chain_id": "development- solana",
292
+ "chain_id": "solana",
282
293
"transaction": "SGVsbG8sIFdvcmxkIQ=="
283
294
}'
284
295
` ` `
@@ -294,7 +305,7 @@ Searchers can submit bids via Websocket to avoid additional network round-trips
294
305
"method": "post_bid",
295
306
"params": {
296
307
"bid": {
297
- " chain_id" : " development- solana" ,
308
+ "chain_id": "solana",
298
309
"transaction": "SGVsbG8sIFdvcmxkIQ=="
299
310
}
300
311
}
0 commit comments