diff --git a/packages/stableswap-sdk/src/calculator/amounts.ts b/packages/stableswap-sdk/src/calculator/amounts.ts index bc888a947..bc3ce8d41 100644 --- a/packages/stableswap-sdk/src/calculator/amounts.ts +++ b/packages/stableswap-sdk/src/calculator/amounts.ts @@ -1,11 +1,11 @@ import type { Token } from "@saberhq/token-utils"; import { Fraction, ONE, TokenAmount, ZERO } from "@saberhq/token-utils"; -import JSBI from "jsbi"; +import { default as JSBI } from "jsbi"; import mapValues from "lodash.mapvalues"; -import type { IExchangeInfo } from "../entities/exchange"; -import type { Fees } from "../state/fees"; -import { computeD, computeY } from "./curve"; +import type { IExchangeInfo } from "../entities/exchange.js"; +import type { Fees } from "../state/fees.js"; +import { computeD, computeY } from "./curve.js"; /** * Calculates the current virtual price of the exchange. diff --git a/packages/stableswap-sdk/src/calculator/amounts.unit.test.ts b/packages/stableswap-sdk/src/calculator/amounts.unit.test.ts index 25f164937..b6d05a1b7 100644 --- a/packages/stableswap-sdk/src/calculator/amounts.unit.test.ts +++ b/packages/stableswap-sdk/src/calculator/amounts.unit.test.ts @@ -2,19 +2,19 @@ import type { BigintIsh } from "@saberhq/token-utils"; import { Percent, Token as SToken, TokenAmount } from "@saberhq/token-utils"; import { PublicKey } from "@solana/web3.js"; import BN from "bn.js"; -import JSBI from "jsbi"; +import { default as JSBI } from "jsbi"; import mapValues from "lodash.mapvalues"; -import { SWAP_PROGRAM_ID } from "../constants"; -import type { IExchangeInfo } from "../entities/exchange"; -import { RECOMMENDED_FEES, ZERO_FEES } from "../state/fees"; +import { SWAP_PROGRAM_ID } from "../constants.js"; +import type { IExchangeInfo } from "../entities/exchange.js"; +import { RECOMMENDED_FEES, ZERO_FEES } from "../state/fees.js"; import { calculateEstimatedMintAmount, calculateEstimatedSwapOutputAmount, calculateEstimatedWithdrawAmount, calculateEstimatedWithdrawOneAmount, calculateVirtualPrice, -} from "./amounts"; +} from "./amounts.js"; const exchange = { swapAccount: new PublicKey("YAkoNb6HKmSxQN9L8hiBE5tPJRsniSSMzND1boHmZxe"), diff --git a/packages/stableswap-sdk/src/calculator/curve.ts b/packages/stableswap-sdk/src/calculator/curve.ts index c41abd14b..2517a20fd 100644 --- a/packages/stableswap-sdk/src/calculator/curve.ts +++ b/packages/stableswap-sdk/src/calculator/curve.ts @@ -1,5 +1,5 @@ import { ONE, ZERO } from "@saberhq/token-utils"; -import JSBI from "jsbi"; +import { default as JSBI } from "jsbi"; const N_COINS = JSBI.BigInt(2); // n diff --git a/packages/stableswap-sdk/src/calculator/curve.unit.test.ts b/packages/stableswap-sdk/src/calculator/curve.unit.test.ts index db902c183..e8f638c8c 100644 --- a/packages/stableswap-sdk/src/calculator/curve.unit.test.ts +++ b/packages/stableswap-sdk/src/calculator/curve.unit.test.ts @@ -1,7 +1,7 @@ import type { BigintIsh } from "@saberhq/token-utils"; -import JSBI from "jsbi"; +import { default as JSBI } from "jsbi"; -import { computeD, computeY } from "./curve"; +import { computeD, computeY } from "./curve.js"; const assertBN = (actual: BigintIsh, expected: BigintIsh) => { expect(actual.toString()).toEqual(expected.toString()); diff --git a/packages/stableswap-sdk/src/calculator/index.ts b/packages/stableswap-sdk/src/calculator/index.ts index 4582aad78..f60ccfa92 100644 --- a/packages/stableswap-sdk/src/calculator/index.ts +++ b/packages/stableswap-sdk/src/calculator/index.ts @@ -1,3 +1,3 @@ -export * from "./amounts"; -export * from "./curve"; -export * from "./price"; +export * from "./amounts.js"; +export * from "./curve.js"; +export * from "./price.js"; diff --git a/packages/stableswap-sdk/src/calculator/price.ts b/packages/stableswap-sdk/src/calculator/price.ts index 193fd3ef1..493ce0bcb 100644 --- a/packages/stableswap-sdk/src/calculator/price.ts +++ b/packages/stableswap-sdk/src/calculator/price.ts @@ -1,8 +1,8 @@ import { Price, TokenAmount } from "@saberhq/token-utils"; import BN from "bn.js"; -import type { IExchangeInfo } from ".."; -import { calculateEstimatedSwapOutputAmount } from ".."; +import type { IExchangeInfo } from "../index.js"; +import { calculateEstimatedSwapOutputAmount } from "../index.js"; /** * Gets the price of the second token in the swap, i.e. "Token 1", with respect to "Token 0". diff --git a/packages/stableswap-sdk/src/entities/exchange.ts b/packages/stableswap-sdk/src/entities/exchange.ts index 0410d4895..27c5834cc 100644 --- a/packages/stableswap-sdk/src/entities/exchange.ts +++ b/packages/stableswap-sdk/src/entities/exchange.ts @@ -8,14 +8,14 @@ import { } from "@saberhq/token-utils"; import type { Connection, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; -import type JSBI from "jsbi"; -import invariant from "tiny-invariant"; +import type { default as JSBI } from "jsbi"; +import { default as invariant } from "tiny-invariant"; -import { SWAP_PROGRAM_ID } from "../constants"; -import { StableSwap } from "../stable-swap"; -import type { StableSwapState } from "../state"; -import type { Fees } from "../state/fees"; -import { loadProgramAccount } from "../util/account"; +import { SWAP_PROGRAM_ID } from "../constants.js"; +import { StableSwap } from "../stable-swap.js"; +import type { Fees } from "../state/fees.js"; +import type { StableSwapState } from "../state/index.js"; +import { loadProgramAccount } from "../util/account.js"; /** * Reserve information. diff --git a/packages/stableswap-sdk/src/entities/index.ts b/packages/stableswap-sdk/src/entities/index.ts index a6fff7815..34a3e1822 100644 --- a/packages/stableswap-sdk/src/entities/index.ts +++ b/packages/stableswap-sdk/src/entities/index.ts @@ -1 +1 @@ -export * from "./exchange"; +export * from "./exchange.js"; diff --git a/packages/stableswap-sdk/src/index.ts b/packages/stableswap-sdk/src/index.ts index 036e12eca..d15e45083 100644 --- a/packages/stableswap-sdk/src/index.ts +++ b/packages/stableswap-sdk/src/index.ts @@ -1,8 +1,8 @@ -export * from "./calculator"; -export * from "./constants"; -export * from "./entities"; -export * from "./events"; -export * from "./instructions"; -export * from "./stable-swap"; -export * from "./state"; -export * from "./util"; +export * from "./calculator/index.js"; +export * from "./constants.js"; +export * from "./entities/index.js"; +export * from "./events.js"; +export * from "./instructions/index.js"; +export * from "./stable-swap.js"; +export * from "./state/index.js"; +export * from "./util/index.js"; diff --git a/packages/stableswap-sdk/src/instructions/admin.ts b/packages/stableswap-sdk/src/instructions/admin.ts index 57322c038..ec6b4f284 100644 --- a/packages/stableswap-sdk/src/instructions/admin.ts +++ b/packages/stableswap-sdk/src/instructions/admin.ts @@ -2,9 +2,11 @@ import type { u64 } from "@saberhq/token-utils"; import * as BufferLayout from "@solana/buffer-layout"; import type { PublicKey, TransactionInstruction } from "@solana/web3.js"; -import type { StableSwapState } from "../state"; -import type { Fees } from "../state/fees"; -import { encodeFees, ZERO_FEES } from "../state/fees"; +import type { Fees } from "../state/fees.js"; +import { encodeFees, ZERO_FEES } from "../state/fees.js"; +import type { StableSwapState } from "../state/index.js"; +import type { StableSwapConfig } from "./common.js"; +import { buildInstruction } from "./common.js"; import { ApplyNewAdminIXLayout, PauseIXLayout, @@ -13,9 +15,7 @@ import { SetNewFeesIXLayout, StopRampAIXLayout, UnpauseIXLayout, -} from "."; -import type { StableSwapConfig } from "./common"; -import { buildInstruction } from "./common"; +} from "./layouts.js"; /** * Admin instruction. diff --git a/packages/stableswap-sdk/src/instructions/index.ts b/packages/stableswap-sdk/src/instructions/index.ts index 89989c29c..1d83d94d3 100644 --- a/packages/stableswap-sdk/src/instructions/index.ts +++ b/packages/stableswap-sdk/src/instructions/index.ts @@ -1,4 +1,4 @@ -export * from "./admin"; -export type { StableSwapConfig } from "./common"; -export * from "./layouts"; -export * from "./swap"; +export * from "./admin.js"; +export type { StableSwapConfig } from "./common.js"; +export * from "./layouts.js"; +export * from "./swap.js"; diff --git a/packages/stableswap-sdk/src/instructions/layouts.ts b/packages/stableswap-sdk/src/instructions/layouts.ts index 0f06b57c5..e869c6eeb 100644 --- a/packages/stableswap-sdk/src/instructions/layouts.ts +++ b/packages/stableswap-sdk/src/instructions/layouts.ts @@ -1,10 +1,10 @@ import { Uint64Layout } from "@saberhq/token-utils"; import * as BufferLayout from "@solana/buffer-layout"; -import type { RawFees } from "../state/layout"; -import { FeesLayout } from "../state/layout"; -import type { AdminInstruction } from "."; -import type { StableSwapInstruction } from "./swap"; +import type { RawFees } from "../state/layout.js"; +import { FeesLayout } from "../state/layout.js"; +import type { AdminInstruction } from "./admin.js"; +import type { StableSwapInstruction } from "./swap.js"; export const InitializeSwapIXLayout = BufferLayout.struct<{ instruction: StableSwapInstruction.INITIALIZE; diff --git a/packages/stableswap-sdk/src/instructions/swap.ts b/packages/stableswap-sdk/src/instructions/swap.ts index 9de172200..87131ca9c 100644 --- a/packages/stableswap-sdk/src/instructions/swap.ts +++ b/packages/stableswap-sdk/src/instructions/swap.ts @@ -1,17 +1,17 @@ import type { u64 } from "@saberhq/token-utils"; import type { PublicKey, TransactionInstruction } from "@solana/web3.js"; -import type { Fees, RawFees } from "../state"; -import { encodeFees, ZERO_FEES } from "../state"; -import type { StableSwapConfig } from "./common"; -import { buildInstruction } from "./common"; +import type { Fees, RawFees } from "../state/index.js"; +import { encodeFees, ZERO_FEES } from "../state/index.js"; +import type { StableSwapConfig } from "./common.js"; +import { buildInstruction } from "./common.js"; import { DepositIXLayout, InitializeSwapIXLayout, SwapIXLayout, WithdrawIXLayout, WithdrawOneIXLayout, -} from "./layouts"; +} from "./layouts.js"; /** * Instruction enum. diff --git a/packages/stableswap-sdk/src/stable-swap.ts b/packages/stableswap-sdk/src/stable-swap.ts index 801cd784f..67b2b256f 100644 --- a/packages/stableswap-sdk/src/stable-swap.ts +++ b/packages/stableswap-sdk/src/stable-swap.ts @@ -4,14 +4,14 @@ import { TOKEN_PROGRAM_ID } from "@saberhq/token-utils"; import type { Connection, TransactionInstruction } from "@solana/web3.js"; import { PublicKey } from "@solana/web3.js"; -import { SWAP_PROGRAM_ID } from "./constants"; -import type { IExchange } from "./entities/exchange"; -import type { StableSwapConfig } from "./instructions"; -import * as instructions from "./instructions"; -import type { StableSwapState } from "./state"; -import { decodeSwap } from "./state"; -import { StableSwapLayout } from "./state/layout"; -import { loadProgramAccount } from "./util/account"; +import { SWAP_PROGRAM_ID } from "./constants.js"; +import type { IExchange } from "./entities/exchange.js"; +import type { StableSwapConfig } from "./instructions/index.js"; +import * as instructions from "./instructions/index.js"; +import type { StableSwapState } from "./state/index.js"; +import { decodeSwap } from "./state/index.js"; +import { StableSwapLayout } from "./state/layout.js"; +import { loadProgramAccount } from "./util/account.js"; export interface StableSwapInfo { config: StableSwapConfig; diff --git a/packages/stableswap-sdk/src/state/fees.ts b/packages/stableswap-sdk/src/state/fees.ts index df531afb5..e47791732 100644 --- a/packages/stableswap-sdk/src/state/fees.ts +++ b/packages/stableswap-sdk/src/state/fees.ts @@ -1,6 +1,6 @@ import { Percent, u64 } from "@saberhq/token-utils"; -import type { RawFees } from "./layout"; +import type { RawFees } from "./layout.js"; export type Fees = { trade: Percent; diff --git a/packages/stableswap-sdk/src/state/index.ts b/packages/stableswap-sdk/src/state/index.ts index 7ce284ec6..a66967262 100644 --- a/packages/stableswap-sdk/src/state/index.ts +++ b/packages/stableswap-sdk/src/state/index.ts @@ -1,13 +1,13 @@ import { u64 } from "@saberhq/token-utils"; import { PublicKey } from "@solana/web3.js"; -import type { SwapTokenInfo } from "../instructions/swap"; -import type { Fees } from "./fees"; -import { decodeFees } from "./fees"; -import { StableSwapLayout } from "./layout"; +import type { SwapTokenInfo } from "../instructions/swap.js"; +import type { Fees } from "./fees.js"; +import { decodeFees } from "./fees.js"; +import { StableSwapLayout } from "./layout.js"; -export * from "./fees"; -export * from "./layout"; +export * from "./fees.js"; +export * from "./layout.js"; /** * State of a StableSwap, read from the swap account. diff --git a/packages/stableswap-sdk/src/util/index.ts b/packages/stableswap-sdk/src/util/index.ts index 922af22a0..132944f25 100644 --- a/packages/stableswap-sdk/src/util/index.ts +++ b/packages/stableswap-sdk/src/util/index.ts @@ -1,2 +1,2 @@ -export * from "./account"; -export * from "./initialize"; +export * from "./account.js"; +export * from "./initialize.js"; diff --git a/packages/stableswap-sdk/src/util/initialize.ts b/packages/stableswap-sdk/src/util/initialize.ts index 8e58a9c9a..3e3590c1c 100644 --- a/packages/stableswap-sdk/src/util/initialize.ts +++ b/packages/stableswap-sdk/src/util/initialize.ts @@ -15,20 +15,20 @@ import type { } from "@solana/web3.js"; import { Keypair, PublicKey, SystemProgram } from "@solana/web3.js"; -import { SWAP_PROGRAM_ID, ZERO_TS } from "../constants"; +import { SWAP_PROGRAM_ID, ZERO_TS } from "../constants.js"; import type { InitializeSwapInstruction, SwapTokenInfo, -} from "../instructions/swap"; -import { initializeSwapInstruction as createInitializeStableSwapInstruction } from "../instructions/swap"; -import { findSwapAuthorityKey, StableSwap } from "../stable-swap"; -import { ZERO_FEES } from "../state/fees"; -import { StableSwapLayout } from "../state/layout"; -import type { TransactionInstructions } from "./instructions"; +} from "../instructions/swap.js"; +import { initializeSwapInstruction as createInitializeStableSwapInstruction } from "../instructions/swap.js"; +import { findSwapAuthorityKey, StableSwap } from "../stable-swap.js"; +import { ZERO_FEES } from "../state/fees.js"; +import { StableSwapLayout } from "../state/layout.js"; +import type { TransactionInstructions } from "./instructions.js"; import { createMutableTransactionInstructions, mergeInstructions, -} from "./instructions"; +} from "./instructions.js"; export type ISeedPoolAccountsFn = (args: { tokenAAccount: PublicKey; diff --git a/tsconfig.json b/tsconfig.json index 30940dcfd..187d539e0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,5 +4,6 @@ "noEmit": true, "jsxImportSource": "react", "types": ["jest"] - } + }, + "include": ["packages/"] }