Skip to content

Commit

Permalink
Merge pull request #40 from Polymarket/feature/large-orders
Browse files Browse the repository at this point in the history
large-orders endpoint
  • Loading branch information
poly-rodr authored Jun 29, 2022
2 parents 2291741 + ce7b26e commit 2b5adc7
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
31 changes: 31 additions & 0 deletions examples/getLargeOrders.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ethers } from "ethers";
import { config as dotenvConfig } from "dotenv";
import { resolve } from "path";
import { ApiKeyCreds, ClobClient } from "../src";

dotenvConfig({ path: resolve(__dirname, "../.env") });

async function main() {
const provider = new ethers.providers.JsonRpcProvider(process.env.RPC_URL);
const pk = new ethers.Wallet(`${process.env.PK}`);
const wallet = pk.connect(provider);
console.log(`Address: ${await wallet.getAddress()}`);

const host = process.env.CLOB_API_URL || "http://localhost:8080";
const creds: ApiKeyCreds = {
key: `${process.env.CLOB_API_KEY}`,
secret: `${process.env.CLOB_SECRET}`,
passphrase: `${process.env.CLOB_PASS_PHRASE}`,
};
const clobClient = new ClobClient(host, wallet, creds);

const resp = await clobClient.getLargeOrders();
console.log(resp);

// Filtered
const filtered = await clobClient.getLargeOrders("1000");
console.log(filtered);
console.log(`Done!`);
}

main();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@polymarket/clob-client",
"description": "Typescript client for Polymarket's CLOB",
"version": "1.0.32",
"version": "1.0.33",
"contributors": [
{
"name": "Jonathan Amenechi",
Expand Down
6 changes: 6 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
ORDER_HISTORY,
DERIVE_API_KEY,
GET_LAST_TRADE_PRICE,
GET_LARGE_ORDERS,
} from "./endpoints";
import { OrderBuilder } from "./order-builder/builder";

Expand Down Expand Up @@ -96,6 +97,11 @@ export class ClobClient {
return get(`${this.host}${GET_LAST_TRADE_PRICE}?market=${tokenID}`);
}


public async getLargeOrders(minValue: string = ""): Promise<any> {
return get(`${this.host}${GET_LARGE_ORDERS}?min_value=${minValue}`);
}

// L1 Authed

/**
Expand Down
2 changes: 2 additions & 0 deletions src/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ export const CANCEL = "/order";
export const CANCEL_ALL = "/cancel-all";

export const GET_LAST_TRADE_PRICE = "/last-trade-price";

export const GET_LARGE_ORDERS = "/large-orders";

0 comments on commit 2b5adc7

Please sign in to comment.