-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: arena improvements & better cu limit for flashloans
- Loading branch information
1 parent
618a5cc
commit 634b679
Showing
12 changed files
with
175 additions
and
180 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { getCalculatedPrioritizationFeeByPercentile } from "@mrgnlabs/mrgn-common"; | ||
import { Connection } from "@solana/web3.js"; | ||
import { NextApiRequest, NextApiResponse } from "next"; | ||
|
||
const enum PriotitizationFeeLevels { | ||
LOW = 2500, | ||
MEDIAN = 5000, | ||
HIGH = 7500, | ||
MAX = 10000, | ||
} | ||
/* | ||
Get jito tip data for at least 50 percentile result | ||
*/ | ||
export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
// use abort controller to restrict fetch to 5 seconds | ||
const controller = new AbortController(); | ||
const timeoutId = setTimeout(() => { | ||
controller.abort(); | ||
}, 5000); | ||
|
||
const connection = new Connection(process.env.PRIVATE_RPC_ENDPOINT_OVERRIDE || ""); | ||
|
||
// Fetch from API and update cache | ||
try { | ||
const data = await getCalculatedPrioritizationFeeByPercentile( | ||
connection, | ||
{ | ||
lockedWritableAccounts: [], // TODO: investigate this | ||
percentile: PriotitizationFeeLevels.HIGH, | ||
fallback: false, | ||
}, | ||
20 | ||
); | ||
|
||
clearTimeout(timeoutId); | ||
|
||
// cache for 4 minutes | ||
res.setHeader("Cache-Control", "s-maxage=30, stale-while-revalidate=59"); | ||
res.status(200).json(data); | ||
} catch (error) { | ||
console.error("Error:", error); | ||
res.status(500).json({ error: "Error fetching data" }); | ||
} | ||
} |
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
Oops, something went wrong.