configure rpc url
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
parent
3b031cc53d
commit
74bffa9b4f
|
@ -42,17 +42,11 @@ export const TRITON_DEDICATED_URL = process.env.NEXT_PUBLIC_TRITON_TOKEN
|
||||||
|
|
||||||
type CurrentTiersResponse = CurrentTier[]
|
type CurrentTiersResponse = CurrentTier[]
|
||||||
|
|
||||||
async function buildClient(): Promise<MangoClient | undefined> {
|
async function buildClient(rpcUrl: string): Promise<MangoClient | undefined> {
|
||||||
try {
|
try {
|
||||||
const clientKeypair = new Keypair()
|
const clientKeypair = new Keypair()
|
||||||
const options = AnchorProvider.defaultOptions()
|
const options = AnchorProvider.defaultOptions()
|
||||||
|
|
||||||
const rpcUrl = process.env.NEXT_PUBLIC_ENDPOINT || TRITON_DEDICATED_URL
|
|
||||||
console.log(rpcUrl, '@@@@@@@')
|
|
||||||
if (!rpcUrl) {
|
|
||||||
throw new Error('MANGO_RPC_URL environment variable is not set')
|
|
||||||
}
|
|
||||||
|
|
||||||
const connection = new Connection(rpcUrl, options)
|
const connection = new Connection(rpcUrl, options)
|
||||||
const clientWallet = new Wallet(clientKeypair)
|
const clientWallet = new Wallet(clientKeypair)
|
||||||
const clientProvider = new AnchorProvider(connection, clientWallet, options)
|
const clientProvider = new AnchorProvider(connection, clientWallet, options)
|
||||||
|
@ -76,8 +70,14 @@ export default async function handler(
|
||||||
CurrentTiersResponse | { error: string; details: string }
|
CurrentTiersResponse | { error: string; details: string }
|
||||||
>,
|
>,
|
||||||
) {
|
) {
|
||||||
|
const { body } = req
|
||||||
|
console.log(body)
|
||||||
|
if (!('rpcUrl' in body)) {
|
||||||
|
throw new Error(`${body} should contain rpcUrl!`)
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const client = await buildClient()
|
const client = await buildClient(body['rpcUrl'])
|
||||||
|
|
||||||
if (!client) {
|
if (!client) {
|
||||||
console.log('Client build failed')
|
console.log('Client build failed')
|
||||||
|
@ -95,7 +95,6 @@ export default async function handler(
|
||||||
const midPriceImpacts = getMidPriceImpacts(
|
const midPriceImpacts = getMidPriceImpacts(
|
||||||
priceImpacts.length ? priceImpacts : [],
|
priceImpacts.length ? priceImpacts : [],
|
||||||
)
|
)
|
||||||
console.log(midPriceImpacts)
|
|
||||||
|
|
||||||
const tokenThresholds: {
|
const tokenThresholds: {
|
||||||
[symbol: string]: { below1Percent: number; below2Percent: number }
|
[symbol: string]: { below1Percent: number; below2Percent: number }
|
||||||
|
|
Loading…
Reference in New Issue