|
|
1 an în urmă | |
|---|---|---|
| .. | ||
| src | 5c8e372ef6 Initial version of js sdk for express relay (#1281) | 1 an în urmă |
| .eslintrc.js | 5c8e372ef6 Initial version of js sdk for express relay (#1281) | 1 an în urmă |
| .gitignore | 5c8e372ef6 Initial version of js sdk for express relay (#1281) | 1 an în urmă |
| README.md | 5c8e372ef6 Initial version of js sdk for express relay (#1281) | 1 an în urmă |
| package-lock.json | 5c8e372ef6 Initial version of js sdk for express relay (#1281) | 1 an în urmă |
| package.json | 5c8e372ef6 Initial version of js sdk for express relay (#1281) | 1 an în urmă |
| tsconfig.json | 5c8e372ef6 Initial version of js sdk for express relay (#1281) | 1 an în urmă |
Utility library for interacting with the Pyth Express Relay API.
$ npm install --save @pythnetwork/express-relay-evm-js
$ yarn add @pythnetwork/express-relay-evm-js
To generate the latest type declarations from the server openapi schema, run:
npm run generate-api-types
import {
Client,
OpportunityParams,
BidInfo,
} from "@pythnetwork/express-relay-evm-js";
const client = new Client({ baseUrl: "https://per-staging.dourolabs.app/" });
function calculateOpportunityBid(
opportunity: OpportunityParams
): BidInfo | null {
// searcher implementation here
// if the opportunity is not suitable for the searcher, return null
}
const opportunities = await client.getOpportunities();
for (const opportunity of opportunities) {
const bidInfo = calculateOpportunityBid(order);
if (bidInfo === null) continue;
const opportunityBid = await client.signOpportunityBid(
opportunity,
bidInfo,
privateKey // searcher private key with appropriate permissions and assets
);
await client.submitOpportunityBid(opportunityBid);
}
There is an example searcher in examples directory.
This example fetches OpportunityParams from the specified endpoint,
creates a fixed bid on each opportunity and signs them with the provided private key, and finally submits them back to the server. You can run it with
npm run simple-searcher. A full command looks like this:
npm run simple-searcher -- \
--endpoint https://per-staging.dourolabs.app/ \
--bid 100000 \
--chain-id op_sepolia \
--private-key <YOUR-PRIVATE-KEY>