Skip to content

Commit a89d24b

Browse files
committed
clean
1 parent 547608d commit a89d24b

File tree

1 file changed

+48
-42
lines changed
  • pages/express-relay/integrate-as-searcher

1 file changed

+48
-42
lines changed

pages/express-relay/integrate-as-searcher/svm.mdx

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -127,48 +127,54 @@ See the following examples of how to construct a bid object via the SDKs:
127127
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).
128128

129129
```typescript copy
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> {
136-
const order = opportunity.order;
137-
const limoClient = new limo.LimoClient(
138-
this.connectionSvm,
139-
order.state.globalConfig
140-
);
141-
142-
const ixsTakeOrder = await this.generateTakeOrderIxs(limoClient, order);
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-
);
151-
152-
const bidAmount = await this.getBidAmount(order);
153-
154-
const config = await this.getExpressRelayConfig();
155-
const bid = await this.client.constructSvmBid(
156-
txRaw,
157-
this.searcher.publicKey,
158-
getPdaAuthority(limoClient.getProgramID(), order.state.globalConfig),
159-
order.address,
160-
bidAmount,
161-
new anchor.BN(Math.round(Date.now() / 1000 + DAY_IN_SECONDS)),
162-
this.chainId,
163-
config.relayerSigner,
164-
config.feeReceiverRelayer
165-
);
166-
167-
bid.transaction.recentBlockhash =
168-
this.latestChainUpdate[this.chainId].blockhash;
169-
bid.transaction.sign(this.searcher);
170-
return bid;
171-
}
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> {
142+
const order = opportunity.order;
143+
const limoClient = new limo.LimoClient(
144+
this.connectionSvm,
145+
order.state.globalConfig
146+
);
147+
148+
const ixsTakeOrder = await this.generateTakeOrderIxs(limoClient, order);
149+
const feeInstruction = ComputeBudgetProgram.setComputeUnitPrice({
150+
microLamports:
151+
this.latestChainUpdate[this.chainId].latestPrioritizationFee,
152+
});
153+
const txRaw = new anchor.web3.Transaction().add(
154+
feeInstruction,
155+
...ixsTakeOrder
156+
);
157+
158+
const bidAmount = await this.getBidAmount(order);
159+
160+
const config = await this.getExpressRelayConfig();
161+
const bid = await this.client.constructSvmBid(
162+
txRaw,
163+
this.searcher.publicKey,
164+
getPdaAuthority(limoClient.getProgramID(), order.state.globalConfig),
165+
order.address,
166+
bidAmount,
167+
new anchor.BN(Math.round(Date.now() / 1000 + DAY_IN_SECONDS)),
168+
this.chainId,
169+
config.relayerSigner,
170+
config.feeReceiverRelayer
171+
);
172+
173+
bid.transaction.recentBlockhash =
174+
this.latestChainUpdate[this.chainId].blockhash;
175+
bid.transaction.sign(this.searcher);
176+
return bid;
177+
}
172178
```
173179

174180
</Tabs.Tab>

0 commit comments

Comments
 (0)