Skip to content

Commit

Permalink
add blze
Browse files Browse the repository at this point in the history
  • Loading branch information
aperire committed Aug 18, 2023
1 parent 8731444 commit 6ad8e30
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/src/oracle-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export const lpfinanceOracleTokens = [
"9TVjnzpF3X8DHsfVqYWoCGphJxtGYh1PDCFN5QmsHW5t", // MDS
"TuLipcqtGVXP9XR62wM8WWCm6a9vhLs7T1uoWBk6FDs", // TULIP
"DUSTawucrTsGU8hcqRdHDCbuYhCPADMLM2VcCb8VnFnQ", // DUST
"UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M", // UXP
"BLZEEuZUBVqFhj8adcCFPJvPVCiCyVmh3hkJMrU8KuJA", // BLZE
];
14 changes: 3 additions & 11 deletions app/src/token-pair-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ export const tokenPairRegistry: Registry = {
"BWXrrYFhT7bMHmNBFoQFWdsSgA3yXoAnMhDK6Fn1eSEn": [
"9TVjnzpF3X8DHsfVqYWoCGphJxtGYh1PDCFN5QmsHW5t"
],
// MDS
"9TVjnzpF3X8DHsfVqYWoCGphJxtGYh1PDCFN5QmsHW5t": [
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
],
// ATLAS
"ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx": [
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
Expand All @@ -84,14 +80,10 @@ export const tokenPairRegistry: Registry = {
"DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263": [
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
],
// UXP
"UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M": [
// BLZE
"BLZEEuZUBVqFhj8adcCFPJvPVCiCyVmh3hkJMrU8KuJA": [
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
],
// GUAC
"AZsHEMXd36Bj1EMNXhowJajpUXzrKcK57wW4ZGXVa7yR": [
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
],
]
};

export const tokenBRegistry = [
Expand Down
4 changes: 2 additions & 2 deletions ts/1_init_token_pair_native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const initTokenPair = async() => {
new PublicKey("TWAPzC9xaeBpgDNF26z5VAcmxBowVz5uqmTx47LkWUy")
);

let tokenAMint = new PublicKey("9tzZzEHsKnwFL1A3DyFJwj36KnZj3gZ7g4srWp9YTEoh"); // SRB
let tokenAMint = new PublicKey("BLZEEuZUBVqFhj8adcCFPJvPVCiCyVmh3hkJMrU8KuJA"); // BLZE
let tokenBMint = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"); // USDC

let tokenACustodyKey = await spl.getAssociatedTokenAddress(
Expand Down Expand Up @@ -75,7 +75,7 @@ const initTokenPair = async() => {
allowWithdrawals: true,
allowCranks: true,
allowSettlements: false, // block settlements
feeNumerator: new anchor.BN(2),
feeNumerator: new anchor.BN(5),
feeDenominator: new anchor.BN(1000),
settleFeeNumerator: new anchor.BN(0),
settleFeeDenominator: new anchor.BN(1),
Expand Down
61 changes: 61 additions & 0 deletions ts/1_init_token_pair_openbook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// @ts-ignore
// @ts-nocheck
import * as anchor from "@project-serum/anchor";
import { Program } from "@project-serum/anchor";
import { PublicKey, SystemProgram, SYSVAR_RENT_PUBKEY } from "@solana/web3.js";
import * as spl from "@solana/spl-token";
import { Twamm } from "../target/types/twamm"
import { Swap } from "@openbook-dex/swap";
import { TokenListContainer } from "@solana/spl-token-registry";
import { signer, connection } from "./config/config";
import axios from "axios";


const { Wallet } = anchor;

const initTokenPairOpenbook = async() => {
const provider = new anchor.AnchorProvider(connection, new Wallet(signer), anchor.AnchorProvider.defaultOptions())
anchor.setProvider(new anchor.AnchorProvider(connection, new Wallet(signer), anchor.AnchorProvider.defaultOptions()));
let program = anchor.workspace.Twamm as Program<Twamm>

let [multisigKey, multisigBump] = await PublicKey.findProgramAddress(
[Buffer.from(anchor.utils.bytes.utf8.encode("multisig"))],
new PublicKey("TWAPzC9xaeBpgDNF26z5VAcmxBowVz5uqmTx47LkWUy")
);

let [authorityKey, authorityBump] =
await PublicKey.findProgramAddress(
[Buffer.from(anchor.utils.bytes.utf8.encode("transfer_authority"))],
new PublicKey("TWAPzC9xaeBpgDNF26z5VAcmxBowVz5uqmTx47LkWUy")
);

let tokenAMint = new PublicKey("9tzZzEHsKnwFL1A3DyFJwj36KnZj3gZ7g4srWp9YTEoh"); // SRB
let tokenBMint = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"); // USDC

let tokenACustodyKey = await spl.getAssociatedTokenAddress(
tokenAMint,
authorityKey,
true
);

let tokenBCustodyKey = await spl.getAssociatedTokenAddress(
tokenBMint,
authorityKey,
true
);
const tokenList = await axios.get(
"https://github.com/LP-Finance-Inc/token-list/blob/main/legacy-token-list.json"
);

// Init openbook accounts
const client = new Swap(provider, tokenList);
const res = await client.initAccounts({
fromMint: new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),
toMint: new PublicKey("DUALa4FC2yREwZ59PHeu1un4wis36vHRv5hWVBmzykCJ")
}
);
console.log(res);

}
initTokenPairOpenbook();

0 comments on commit 6ad8e30

Please sign in to comment.