Skip to content

Commit 933651f

Browse files
committed
feat: add jup referral key script
1 parent 26504fa commit 933651f

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

scripts/jup-referral-addresses.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { PublicKey } from "@solana/web3.js";
2+
3+
const REFERRAL_PROGRAM_ID = new PublicKey(
4+
"REFER4ZgmyYx9c6He5XfaTMiGfdLwRnkV4RPp9t9iF3",
5+
);
6+
const REFERRAL_ACCOUNT_PUBKEY = new PublicKey(
7+
"Mm7HcujSK2JzPW4eX7g4oqTXbWYDuFxapNMHXe8yp1B",
8+
);
9+
10+
type BankDbEntry = {
11+
mint: string;
12+
symbol: string;
13+
asset_tag: number;
14+
};
15+
16+
function getJupReferralFeeAccount(mint: PublicKey): string {
17+
const [feeAccount] = PublicKey.findProgramAddressSync(
18+
[
19+
Buffer.from("referral_ata"),
20+
REFERRAL_ACCOUNT_PUBKEY.toBuffer(),
21+
mint.toBuffer(),
22+
],
23+
REFERRAL_PROGRAM_ID,
24+
);
25+
return feeAccount.toBase58();
26+
}
27+
28+
async function main() {
29+
const apiResponse = await fetch("https://app.0.xyz/api/banks/db");
30+
const bankDb = (await apiResponse.json()) as BankDbEntry[];
31+
32+
const rows = bankDb
33+
.filter((entry) => entry.asset_tag !== 2)
34+
.map((entry) => {
35+
const mint = new PublicKey(entry.mint);
36+
return {
37+
Symbol: entry.symbol,
38+
Mint: entry.mint,
39+
"Jup Referral Key": getJupReferralFeeAccount(mint),
40+
};
41+
});
42+
43+
// Sort alphabetically by symbol
44+
rows.sort((a, b) => a.Symbol.localeCompare(b.Symbol));
45+
46+
console.log(`\nFound ${rows.length} banks\n`);
47+
console.table(rows);
48+
}
49+
50+
main().catch((err) => {
51+
console.error(err);
52+
});

0 commit comments

Comments
 (0)