read flash privilege from agent config

This commit is contained in:
UjjwalGupta49
2025-01-07 15:12:29 +05:30
parent ac7059eefb
commit 02c3f226c3
3 changed files with 5 additions and 4 deletions

View File

@@ -94,7 +94,7 @@ export async function flashCloseTrade(
priceWithSlippage,
sideEnum,
poolConfig,
get_flash_privilege(),
get_flash_privilege(agent),
tradingAccounts.nftTradingAccountPk,
tradingAccounts.nftReferralAccountPK,
tradingAccounts.nftOwnerRebateTokenAccountPk,

View File

@@ -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!,

View File

@@ -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",
@@ -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;