-
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.
- Loading branch information
1 parent
40b6972
commit c72e3bb
Showing
1 changed file
with
19 additions
and
10 deletions.
There are no files selected for viewing
29 changes: 19 additions & 10 deletions
29
orca/whirlpool/whirlpools_sdk/00b_base_without_env_vars.ts
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 |
---|---|---|
@@ -1,16 +1,25 @@ | ||
import { WhirlpoolContext, AccountFetcher, ORCA_WHIRLPOOL_PROGRAM_ID, buildWhirlpoolClient } from "@orca-so/whirlpools-sdk"; | ||
const { Wallet } = require("@project-serum/anchor"); // v0.20.1 bug, import for Wallet is not possible | ||
import { WhirlpoolContext, ORCA_WHIRLPOOL_PROGRAM_ID, buildWhirlpoolClient } from "@orca-so/whirlpools-sdk"; | ||
import { Wallet } from "@coral-xyz/anchor"; | ||
import { Keypair, Connection } from "@solana/web3.js"; | ||
|
||
const RPC_ENDPOINT_URL="https://ssc-dao.genesysgo.net" | ||
// bash$ ts-node this_script.ts | ||
|
||
// you need to use your RPC endpoint (Public RPC is just for example) | ||
const RPC_ENDPOINT_URL= "https://api.mainnet-beta.solana.com"; | ||
const COMMITMENT = "confirmed"; | ||
|
||
const connection = new Connection(RPC_ENDPOINT_URL, COMMITMENT); | ||
const wallet = new Wallet(Keypair.generate()); // dummy | ||
async function main() { | ||
const connection = new Connection(RPC_ENDPOINT_URL, COMMITMENT); | ||
|
||
const ctx = WhirlpoolContext.from(connection, wallet, ORCA_WHIRLPOOL_PROGRAM_ID); | ||
const fetcher = new AccountFetcher(ctx.connection); | ||
const client = buildWhirlpoolClient(ctx, fetcher); | ||
// create dummy wallet with temporary keypair | ||
const wallet = new Wallet(Keypair.generate()); | ||
|
||
const ctx = WhirlpoolContext.from(connection, wallet, ORCA_WHIRLPOOL_PROGRAM_ID); | ||
const fetcher = ctx.fetcher; | ||
const client = buildWhirlpoolClient(ctx); | ||
|
||
console.log("connection endpoint", ctx.connection.rpcEndpoint); | ||
console.log("wallet", ctx.wallet.publicKey.toBase58()); | ||
} | ||
|
||
console.log("connection endpoint", ctx.connection.rpcEndpoint); | ||
console.log("wallet", ctx.wallet.publicKey.toBase58()); | ||
main(); |