From e29f2fae3ad31f3422bd5ef9f27913b1db6b6445 Mon Sep 17 00:00:00 2001 From: 00xSam Date: Mon, 2 Dec 2024 21:22:05 +0800 Subject: [PATCH] chore: testing submodule --- ts-client/.turbo/turbo-build.log | 4 ++++ ts-client/eslint.config.js | 4 ++++ ts-client/package.json | 23 +++++++++-------------- ts-client/src/vault/index.ts | 6 ++++++ ts-client/tsconfig.json | 2 +- 5 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 ts-client/.turbo/turbo-build.log create mode 100644 ts-client/eslint.config.js diff --git a/ts-client/.turbo/turbo-build.log b/ts-client/.turbo/turbo-build.log new file mode 100644 index 0000000..d5a476a --- /dev/null +++ b/ts-client/.turbo/turbo-build.log @@ -0,0 +1,4 @@ + +> @meteora-ag/vault-sdk@2.2.1 build /Users/mcsam/Development/meteora-monorepo/packages/vault-sdk/ts-client +> rm -rf dist && tsc -p tsconfig.build.json && tsc -p tsconfig.esm.json + diff --git a/ts-client/eslint.config.js b/ts-client/eslint.config.js new file mode 100644 index 0000000..3cdf625 --- /dev/null +++ b/ts-client/eslint.config.js @@ -0,0 +1,4 @@ +import { config } from "@repo/config/eslint/base"; + +/** @type {import("eslint").Linter.Config} */ +export default config; \ No newline at end of file diff --git a/ts-client/package.json b/ts-client/package.json index ec98e73..d5b1ef4 100644 --- a/ts-client/package.json +++ b/ts-client/package.json @@ -1,5 +1,5 @@ { - "name": "@mercurial-finance/vault-sdk", + "name": "@meteora-ag/vault-sdk", "version": "2.2.1", "description": "Mercurial Vault SDK is a typescript library that allows you to interact with Mercurial v2's vault.", "main": "dist/cjs/index.js", @@ -13,21 +13,10 @@ "dist" ], "keywords": [], - "author": "mercurial-finance", + "author": "meteora-ag", "license": "MIT", - "dependencies": { - "@coral-xyz/anchor": "^0.28.0", - "@solana/buffer-layout": "^4.0.1", - "@solana/spl-token": "^0.4.6", - "@solana/spl-token-registry": "^0.2.4574", - "@solana/web3.js": "^1.91.6", - "bn.js": "5.2.1", - "cross-fetch": "^3.1.5", - "decimal.js": "10.3.1", - "jsbi": "4.3.0" - }, "devDependencies": { - "@tsconfig/recommended": "^1.0.1", + "@repo/config": "workspace:*", "@types/bn.js": "^5.1.0", "@types/chai": "^4.3.1", "@types/jest": "^27.5.1", @@ -39,6 +28,12 @@ "ts-mocha": "^10.0.0", "typescript": "^5.5.4" }, + "peerDependencies": { + "bn.js": "^5.2.1", + "@coral-xyz/anchor": "^0.28.0", + "@solana/spl-token": "^0.4.9", + "@solana/web3.js": "^1.95.3" + }, "directories": { "test": "tests" }, diff --git a/ts-client/src/vault/index.ts b/ts-client/src/vault/index.ts index a9ce9ed..098365f 100644 --- a/ts-client/src/vault/index.ts +++ b/ts-client/src/vault/index.ts @@ -142,6 +142,8 @@ const getVaultState = async ( vaultState.lpMint, vaultState.tokenMint, ]); + if (!vaultLpAccount || !vaultAccount) throw new Error('Missing vault account'); + const vaultLpMint = unpackMint(vaultState.lpMint, vaultLpAccount, vaultLpAccount?.owner); const vaultMint = unpackMint(vaultState.tokenMint, vaultAccount, vaultAccount?.owner); @@ -164,6 +166,8 @@ const getVaultStateByPda = async (vaultPda: PublicKey, program: VaultProgram): P vaultState.lpMint, vaultState.tokenMint, ]); + if (!vaultLpAccount || !vaultAccount) throw new Error('Missing vault account'); + const vaultLpMint = unpackMint(vaultState.lpMint, vaultLpAccount, vaultLpAccount?.owner); const vaultMint = unpackMint(vaultState.tokenMint, vaultAccount, vaultAccount?.owner); @@ -720,6 +724,8 @@ export default class VaultImpl implements VaultImplementation { // opt.strategy reserved for testing const selectedStrategy = await this.getStrategyWithHighestLiquidity(); + if (!selectedStrategy) throw new Error('No strategy with highest liquidity found'); + const currentLiquidity = new BN(selectedStrategy.strategyState.currentLiquidity); const availableAmount = currentLiquidity.add(vaultLiquidity); diff --git a/ts-client/tsconfig.json b/ts-client/tsconfig.json index ab6dc97..0c1c6fd 100644 --- a/ts-client/tsconfig.json +++ b/ts-client/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "@tsconfig/recommended/tsconfig.json", + "extends": "@repo/config/typescript/react-library", "compilerOptions": { "outDir": "dist", "lib": ["dom", "dom.iterable", "esnext"],