Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated flash privilege settings and improved token support #151

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
read flash privilege from agent config
  • Loading branch information
UjjwalGupta49 committed Jan 7, 2025
commit 02c3f226c3e589a17c7c04849f2d48d44248bef5
2 changes: 1 addition & 1 deletion src/tools/flash_close_trade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export async function flashCloseTrade(
priceWithSlippage,
sideEnum,
poolConfig,
get_flash_privilege(),
get_flash_privilege(agent),
tradingAccounts.nftTradingAccountPk,
tradingAccounts.nftReferralAccountPK,
tradingAccounts.nftOwnerRebateTokenAccountPk,
Expand Down
2 changes: 1 addition & 1 deletion src/tools/flash_open_trade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export async function flashOpenTrade(
positionSize,
side === "long" ? Side.Long : Side.Short,
poolConfig,
get_flash_privilege(),
get_flash_privilege(agent),
tradingAccounts.nftTradingAccountPk,
tradingAccounts.nftReferralAccountPK,
tradingAccounts.nftOwnerRebateTokenAccountPk!,
Expand Down
5 changes: 3 additions & 2 deletions src/utils/flashUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from "flash-sdk";
import { Cluster, PublicKey, Connection, Keypair } from "@solana/web3.js";
import { getAssociatedTokenAddressSync } from "@solana/spl-token";
import { SolanaAgentKit } from "../index";

const POOL_NAMES = [
"Crypto.1",
Expand Down Expand Up @@ -285,9 +286,9 @@ export function createPerpClient(
);
}

const FLASH_PRIVILEGE = process.env.FLASH_PRIVILEGE || "None";
export function get_flash_privilege(agent: SolanaAgentKit): Privilege {
const FLASH_PRIVILEGE = agent.config.FLASH_PRIVILEGE || "None";

export function get_flash_privilege(): Privilege {
switch (FLASH_PRIVILEGE.toLowerCase()) {
case "referral":
return Privilege.Referral;
Expand Down
Loading