bet-test-sdk 1.2.5 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -159,6 +159,9 @@ async getMinTokenAmountIn(
159
159
  solAmountOut: bigint,
160
160
  slippageBasisPoints?: bigint
161
161
  ): Promise<bigint>
162
+
163
+ // Get mint's curve state progress
164
+ async curveStateProgress(mint: PublicKey): Promise<number>
162
165
  ```
163
166
 
164
167
  ## Usage Example
@@ -1,7 +1,7 @@
1
1
  import { PublicKey, SendTransactionError, SystemProgram, TransactionInstruction, Transaction, ComputeBudgetProgram, TransactionMessage, VersionedTransaction, Keypair } from '@solana/web3.js';
2
2
  import * as borsh from '@coral-xyz/borsh';
3
3
  import { struct as struct$1, publicKey as publicKey$3, u64 as u64$1, u8 as u8$1, bool } from '@coral-xyz/borsh';
4
- import { getAssociatedTokenAddress, getAccount, createAssociatedTokenAccountInstruction, getAssociatedTokenAddressSync } from '@solana/spl-token';
4
+ import { getAssociatedTokenAddressSync, getAssociatedTokenAddress, getAccount, createAssociatedTokenAccountInstruction } from '@solana/spl-token';
5
5
 
6
6
  const PROGRAM_ID = "E3zXK7VRyn39uuyshkQCriRXUAsR1KKQXaJ55KyDW4bp";
7
7
  const BET_API = "https://uatapi.terminus.bet/api";
@@ -15960,6 +15960,17 @@ const getTxDetails = async (connection, sig, commitment = DEFAULT_COMMITMENT, fi
15960
15960
  commitment: finality,
15961
15961
  });
15962
15962
  };
15963
+ const getSPLBalance = async (connection, mintAddress, pubKey, allowOffCurve = false) => {
15964
+ try {
15965
+ let ata = getAssociatedTokenAddressSync(mintAddress, pubKey, allowOffCurve);
15966
+ const balance = await connection.getTokenAccountBalance(ata, "processed");
15967
+ return balance.value.uiAmount;
15968
+ }
15969
+ catch (e) {
15970
+ console.log("[getSPLBalance]", e);
15971
+ }
15972
+ return null;
15973
+ };
15963
15974
 
15964
15975
  var MigrateType;
15965
15976
  (function (MigrateType) {
@@ -22133,6 +22144,25 @@ class BetSDK {
22133
22144
  }
22134
22145
  return curveStateAccount;
22135
22146
  }
22147
+ // Get mint's curve state progress
22148
+ async curveStateProgress(mint) {
22149
+ try {
22150
+ const betStateAccount = await this.getBetStateAccount(mint);
22151
+ if (!betStateAccount) {
22152
+ return 0;
22153
+ }
22154
+ let poolOfTokenBalance = await getSPLBalance(this.connection, mint, betStateAccount.poolOfToken);
22155
+ if (!poolOfTokenBalance) {
22156
+ return 0;
22157
+ }
22158
+ poolOfTokenBalance /= Math.pow(10, DEFAULT_DECIMALS);
22159
+ return 100 - ((poolOfTokenBalance - 260869565) * 100) / 739130435; // 85SOL
22160
+ }
22161
+ catch (error) {
22162
+ console.error("error", error);
22163
+ return 0;
22164
+ }
22165
+ }
22136
22166
  //EVENTS
22137
22167
  addEventListener(eventType, callback) {
22138
22168
  return this.program.addEventListener(eventType, (event, slot, signature) => {
@@ -22222,5 +22252,5 @@ class AMM {
22222
22252
  }
22223
22253
  }
22224
22254
 
22225
- export { AMM, APP_CONFIG_SEED, BET_API, BET_STATE_SEED, BetSDK, BetState, CURVE_STATE_SEED, CurveState, DEFAULT_COMMITMENT, DEFAULT_CURVE_INITIALIZE_INIT_RESERVED_TOKEN, DEFAULT_CURVE_INITIALIZE_SUPPLY, DEFAULT_CURVE_INITIALIZE_TOKEN_DEMICAL, DEFAULT_CURVE_INITIALIZE_VITUAL_RESERVED_TOKEN, DEFAULT_CURVE_INITIALIZE_VITUAL_SOL_TOKEN, DEFAULT_DECIMALS, DEFAULT_FINALITY, DENOMINATOR, FEE_BASIS_POINTS, FEE_RECIVED_ACCOUNT_SEED, FEE_STORE_SEED, MigrateDex, MigrateType, POOL_SEED, PROGRAM_ID, REACH_CURVE_SOL_AMOUNT, TOKEN_ACCOUNT_DATA, TOKEN_MINT_AUTHORITY_SEED, buildVersionedTx, calculateWithSlippage, getTxDetails, sendTx, toCompleteEvent, toCreateEvent, toTradeEvent };
22255
+ export { AMM, APP_CONFIG_SEED, BET_API, BET_STATE_SEED, BetSDK, BetState, CURVE_STATE_SEED, CurveState, DEFAULT_COMMITMENT, DEFAULT_CURVE_INITIALIZE_INIT_RESERVED_TOKEN, DEFAULT_CURVE_INITIALIZE_SUPPLY, DEFAULT_CURVE_INITIALIZE_TOKEN_DEMICAL, DEFAULT_CURVE_INITIALIZE_VITUAL_RESERVED_TOKEN, DEFAULT_CURVE_INITIALIZE_VITUAL_SOL_TOKEN, DEFAULT_DECIMALS, DEFAULT_FINALITY, DENOMINATOR, FEE_BASIS_POINTS, FEE_RECIVED_ACCOUNT_SEED, FEE_STORE_SEED, MigrateDex, MigrateType, POOL_SEED, PROGRAM_ID, REACH_CURVE_SOL_AMOUNT, TOKEN_ACCOUNT_DATA, TOKEN_MINT_AUTHORITY_SEED, buildVersionedTx, calculateWithSlippage, getSPLBalance, getTxDetails, sendTx, toCompleteEvent, toCreateEvent, toTradeEvent };
22226
22256
  //# sourceMappingURL=index.js.map