Skip to content

Commit

Permalink
refactor(solana-usdc-usdt-swap): Update for Solana changes
Browse files Browse the repository at this point in the history
  • Loading branch information
wormat committed Sep 20, 2022
1 parent 3aef7e5 commit 328fc19
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 37 deletions.
59 changes: 30 additions & 29 deletions packages/solana-usdc-usdt-swap/src/hexapool.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
import { PublicKey } from "@solana/web3.js";
import type { SwimPoolConstantState } from "@swim-io/solana";
import type { SolanaPoolConstantState } from "@swim-io/solana";

export interface SwimPoolConstantProperties {
export interface SolanaPoolConstantProperties {
readonly numberOfTokens: number;
readonly programId: PublicKey;
readonly stateKey: PublicKey;
readonly authorityKey: PublicKey;
readonly feeDecimals: number;
}

export const hexapool: SwimPoolConstantProperties & SwimPoolConstantState = {
numberOfTokens: 6,
programId: new PublicKey("SWiMDJYFUGj6cPrQ6QYYYWZtvXQdRChSVAygDZDsCHC"),
stateKey: new PublicKey("8cUvGTFvSWx9WPebYYfDxwiJPdGx2EJUtpve6jP9SBma"),
nonce: 0,
authorityKey: new PublicKey("AfhhYsLMXXyDxQ1B7tNqLTXXDHYtDxCzPcnXWXzHAvDb"),
lpMintKey: new PublicKey("BJUH9GJLaMSLV1E7B3SQLCy9eCfyr6zsrwGcpS2MkqR1"),
feeDecimals: 6,
lpDecimalEqualizer: 0,
tokenMintKeys: [
new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"), // solana-usdc
new PublicKey("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"), // solana-usdt
new PublicKey("A9mUU4qviSctJVPJdBJWkb28deg915LYJKrzQ19ji3FM"), // ethereum-usdc
new PublicKey("Dn4noZ5jgGfkntzcQSUZ8czkreiZ1ForXYoV2H8Dm7S1"), // ethereum-usdt
new PublicKey("5RpUwQ8wtdPCZHhu6MERp2RGrpobsbZ6MH5dDHkUjs2"), // bnb-busd
new PublicKey("8qJSyQprMC57TWKaYEmetUR3UUiTP2M3hXdcvFhkZdmv"), // bnb-usdt
],
tokenDecimalEqualizers: [2, 2, 2, 2, 0, 0],
tokenKeys: [
new PublicKey("5uBU2zUG8xTLA6XwwcTFWib1p7EjCBzWbiy44eVASTfV"), // solana-usdc
new PublicKey("Hv7yPYnGs6fpN3o1NZvkima9mKDrRDJtNxf23oKLCjau"), // solana-usdt
new PublicKey("4R6b4aibi46JzAnuA8ZWXrHAsR1oZBTZ8dqkuer3LsbS"), // ethereum-usdc
new PublicKey("2DMUL42YEb4g1HAKXhUxL3Yjfgoj4VvRqKwheorfFcPV"), // ethereum-usdt
new PublicKey("DukQAFyxR41nbbq2FBUDMyrtF2CRmWBREjZaTVj4u9As"), // bnb-busd
new PublicKey("9KMH3p8cUocvQRbJfKRAStKG52xCCWNmEPsJm5gc8fzw"), // bnb-usdt
],
};
export const hexapool: SolanaPoolConstantProperties & SolanaPoolConstantState =
{
numberOfTokens: 6,
programId: new PublicKey("SWiMDJYFUGj6cPrQ6QYYYWZtvXQdRChSVAygDZDsCHC"),
stateKey: new PublicKey("8cUvGTFvSWx9WPebYYfDxwiJPdGx2EJUtpve6jP9SBma"),
nonce: 0,
authorityKey: new PublicKey("AfhhYsLMXXyDxQ1B7tNqLTXXDHYtDxCzPcnXWXzHAvDb"),
lpMintKey: new PublicKey("BJUH9GJLaMSLV1E7B3SQLCy9eCfyr6zsrwGcpS2MkqR1"),
feeDecimals: 6,
lpDecimalEqualizer: 0,
tokenMintKeys: [
new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"), // solana-usdc
new PublicKey("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"), // solana-usdt
new PublicKey("A9mUU4qviSctJVPJdBJWkb28deg915LYJKrzQ19ji3FM"), // ethereum-usdc
new PublicKey("Dn4noZ5jgGfkntzcQSUZ8czkreiZ1ForXYoV2H8Dm7S1"), // ethereum-usdt
new PublicKey("5RpUwQ8wtdPCZHhu6MERp2RGrpobsbZ6MH5dDHkUjs2"), // bnb-busd
new PublicKey("8qJSyQprMC57TWKaYEmetUR3UUiTP2M3hXdcvFhkZdmv"), // bnb-usdt
],
tokenDecimalEqualizers: [2, 2, 2, 2, 0, 0],
tokenKeys: [
new PublicKey("5uBU2zUG8xTLA6XwwcTFWib1p7EjCBzWbiy44eVASTfV"), // solana-usdc
new PublicKey("Hv7yPYnGs6fpN3o1NZvkima9mKDrRDJtNxf23oKLCjau"), // solana-usdt
new PublicKey("4R6b4aibi46JzAnuA8ZWXrHAsR1oZBTZ8dqkuer3LsbS"), // ethereum-usdc
new PublicKey("2DMUL42YEb4g1HAKXhUxL3Yjfgoj4VvRqKwheorfFcPV"), // ethereum-usdt
new PublicKey("DukQAFyxR41nbbq2FBUDMyrtF2CRmWBREjZaTVj4u9As"), // bnb-busd
new PublicKey("9KMH3p8cUocvQRbJfKRAStKG52xCCWNmEPsJm5gc8fzw"), // bnb-usdt
],
};

export const initialGovernanceFeeKey = new PublicKey(
"9Yau6DnqYasBUKcyxQJQZqThvUnqZ32ZQuUCcC2AdT9P",
Expand Down
16 changes: 8 additions & 8 deletions packages/solana-usdc-usdt-swap/src/state.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import type { Connection, PublicKey } from "@solana/web3.js";
import type { SwimPoolState } from "@swim-io/solana";
import { deserializeSwimPool } from "@swim-io/solana";
import type { SolanaPoolState } from "@swim-io/solana";
import { deserializeSolanaPool } from "@swim-io/solana";
import Decimal from "decimal.js";

import type { SwimPoolConstantProperties } from "./hexapool";
import type { SolanaPoolConstantProperties } from "./hexapool";
import { hexapool } from "./hexapool";

interface SwimPoolBalances {
interface SolanaPoolBalances {
readonly tokenBalances: readonly Decimal[];
}

export type SwimPool = SwimPoolConstantProperties &
SwimPoolState &
SwimPoolBalances;
export type SwimPool = SolanaPoolConstantProperties &
SolanaPoolState &
SolanaPoolBalances;

const fetchTokenBalances = async (
solanaConnection: Connection,
Expand All @@ -36,7 +36,7 @@ export const fetchSwimPool = async (
if (accountInfo === null) {
throw new Error("Could not retrieve account info");
}
const poolState = deserializeSwimPool(
const poolState = deserializeSolanaPool(
hexapool.numberOfTokens,
accountInfo.data,
);
Expand Down

0 comments on commit 328fc19

Please sign in to comment.