-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- /boks - /midpoints - /prices - /last-trades-prices
- Loading branch information
Showing
9 changed files
with
157 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { ethers } from "ethers"; | ||
import { config as dotenvConfig } from "dotenv"; | ||
import { resolve } from "path"; | ||
import { BookParams, Chain, ClobClient } from "../src"; | ||
|
||
dotenvConfig({ path: resolve(__dirname, "../.env") }); | ||
|
||
async function main() { | ||
const wallet = new ethers.Wallet(`${process.env.PK}`); | ||
const chainId = parseInt(`${process.env.CHAIN_ID || Chain.MUMBAI}`) as Chain; | ||
console.log(`Address: ${await wallet.getAddress()}, chainId: ${chainId}`); | ||
|
||
const host = process.env.CLOB_API_URL || "http://localhost:8080"; | ||
const clobClient = new ClobClient(host, chainId, wallet); | ||
|
||
const YES = "1343197538147866997676250008839231694243646439454152539053893078719042421992"; | ||
const NO = "16678291189211314787145083999015737376658799626183230671758641503291735614088"; | ||
|
||
const lastTradesPrices = await clobClient.getLastTradesPrices([ | ||
{ token_id: YES }, | ||
{ token_id: NO }, | ||
] as BookParams[]); | ||
|
||
console.log(lastTradesPrices); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { ethers } from "ethers"; | ||
import { config as dotenvConfig } from "dotenv"; | ||
import { resolve } from "path"; | ||
import { ApiKeyCreds, BookParams, Chain, ClobClient } from "../src"; | ||
|
||
dotenvConfig({ path: resolve(__dirname, "../.env") }); | ||
|
||
async function main() { | ||
const wallet = new ethers.Wallet(`${process.env.PK}`); | ||
const chainId = parseInt(`${process.env.CHAIN_ID || Chain.MUMBAI}`) as Chain; | ||
console.log(`Address: ${await wallet.getAddress()}, chainId: ${chainId}`); | ||
|
||
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, chainId, wallet, creds); | ||
|
||
const YES = "1343197538147866997676250008839231694243646439454152539053893078719042421992"; | ||
const NO = "16678291189211314787145083999015737376658799626183230671758641503291735614088"; | ||
|
||
const midpoints = await clobClient.getMidpoints([ | ||
{ token_id: YES }, | ||
{ token_id: NO }, | ||
] as BookParams[]); | ||
|
||
console.log(midpoints); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { config as dotenvConfig } from "dotenv"; | ||
import { resolve } from "path"; | ||
import { BookParams, Chain, ClobClient } from "../src"; | ||
|
||
dotenvConfig({ path: resolve(__dirname, "../.env") }); | ||
|
||
async function main() { | ||
const host = process.env.CLOB_API_URL || "http://localhost:8080"; | ||
const chainId = parseInt(`${process.env.CHAIN_ID || Chain.MUMBAI}`) as Chain; | ||
const clobClient = new ClobClient(host, chainId); | ||
|
||
const YES = "1343197538147866997676250008839231694243646439454152539053893078719042421992"; | ||
const NO = "16678291189211314787145083999015737376658799626183230671758641503291735614088"; | ||
|
||
const orderbooks = await clobClient.getOrderBooks([ | ||
{ token_id: YES }, | ||
{ token_id: NO }, | ||
] as BookParams[]); | ||
console.log("orderbooks", orderbooks); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ethers } from "ethers"; | ||
import { config as dotenvConfig } from "dotenv"; | ||
import { resolve } from "path"; | ||
import { ApiKeyCreds, BookParams, Chain, ClobClient, Side } from "../src"; | ||
|
||
dotenvConfig({ path: resolve(__dirname, "../.env") }); | ||
|
||
async function main() { | ||
const wallet = new ethers.Wallet(`${process.env.PK}`); | ||
const chainId = parseInt(`${process.env.CHAIN_ID || Chain.MUMBAI}`) as Chain; | ||
console.log(`Address: ${await wallet.getAddress()}, chainId: ${chainId}`); | ||
|
||
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, chainId, wallet, creds); | ||
|
||
const YES = "1343197538147866997676250008839231694243646439454152539053893078719042421992"; | ||
const NO = "16678291189211314787145083999015737376658799626183230671758641503291735614088"; | ||
|
||
const prices = await clobClient.getPrices([ | ||
{ token_id: YES, side: Side.BUY }, | ||
{ token_id: YES, side: Side.SELL }, | ||
{ token_id: NO, side: Side.BUY }, | ||
{ token_id: NO, side: Side.SELL }, | ||
] as BookParams[]); | ||
|
||
console.log(prices); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters