bet-test-sdk 1.0.1 → 1.0.3

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
@@ -26,6 +26,7 @@ npx ts-node example/basic/index.ts
26
26
 
27
27
  ```typescript
28
28
  import dotenv from "dotenv";
29
+ import fs from "fs";
29
30
  import { Connection, Keypair, LAMPORTS_PER_SOL } from "@solana/web3.js";
30
31
  import { DEFAULT_DECIMALS, BetSDK } from "bet-test-sdk";
31
32
  import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";
@@ -4,7 +4,7 @@ import { struct as struct$1, publicKey as publicKey$3, u64 as u64$1, u8 as u8$1,
4
4
  import { getAssociatedTokenAddress, getAccount, createAssociatedTokenAccountInstruction, getAssociatedTokenAddressSync } from '@solana/spl-token';
5
5
 
6
6
  const PROGRAM_ID = "7MTnCi4Q3LeF2ZnfXykdemNmib5Jv2SXvNoUFQ4PLS77";
7
- const BET_API = "https://dev-jeffery.openhub.network/api/api";
7
+ const BET_API = "https://dev-jeffery.openhub.network/api";
8
8
  const BET_STATE_SEED = "bet-state";
9
9
  const CURVE_STATE_SEED = "curve-state";
10
10
  const APP_CONFIG_SEED = "app-config";
@@ -18955,17 +18955,12 @@ class CurveState {
18955
18955
  }
18956
18956
  // Calculate the product of virtual reserves
18957
18957
  let n = this.virtualSolReserves * this.virtualTokenReserves;
18958
- console.log("n", n);
18959
18958
  // Calculate the new virtual sol reserves after the purchase
18960
18959
  let i = this.virtualSolReserves + amount;
18961
- console.log("i", i);
18962
18960
  // Calculate the new virtual token reserves after the purchase
18963
18961
  let r = n / i + 1n;
18964
- console.log("r", r);
18965
18962
  // Calculate the amount of tokens to be purchased
18966
18963
  let s = this.virtualTokenReserves - r;
18967
- console.log("s", s);
18968
- console.log("realSolReserves", this.realSolReserves);
18969
18964
  // Return the minimum of the calculated tokens and real token reserves
18970
18965
  return s < this.realSolReserves ? s : this.realSolReserves;
18971
18966
  }
@@ -20094,7 +20089,7 @@ var instructions = [
20094
20089
  },
20095
20090
  {
20096
20091
  name: "dynamic_amm_program",
20097
- address: "7MTnCi4Q3LeF2ZnfXykdemNmib5Jv2SXvNoUFQ4PLS77"
20092
+ address: "E3zXK7VRyn39uuyshkQCriRXUAsR1KKQXaJ55KyDW4bp"
20098
20093
  }
20099
20094
  ],
20100
20095
  args: [
@@ -21818,7 +21813,7 @@ class BetSDK {
21818
21813
  async createAndBuy(creator, migrateType, createTokenMetadata, buyAmountSol, slippageBasisPoints = 500n, priorityFees, commitment = DEFAULT_COMMITMENT, finality = DEFAULT_FINALITY) {
21819
21814
  let mintKeyPair;
21820
21815
  try {
21821
- const request = await fetch(`${BET_API}/create-token/mint-pair`, {
21816
+ const request = await fetch(`${BET_API}/token/mint-pair`, {
21822
21817
  method: "GET",
21823
21818
  credentials: 'same-origin'
21824
21819
  });
@@ -22019,7 +22014,7 @@ class BetSDK {
22019
22014
  formData.append("telegram", create.telegram || "");
22020
22015
  formData.append("website", create.website || "");
22021
22016
  try {
22022
- const request = await fetch(`${BET_API}/create-token/ipfs`, {
22017
+ const request = await fetch(`${BET_API}/token/ipfs`, {
22023
22018
  method: "POST",
22024
22019
  headers: {
22025
22020
  'Accept': 'application/json',
@@ -22105,9 +22100,9 @@ class AMM {
22105
22100
  }
22106
22101
  getBuyPrice(tokens) {
22107
22102
  const product_of_reserves = this.virtualSolReserves * this.virtualTokenReserves;
22108
- const new_virtualTokenReserves = this.virtualTokenReserves - tokens;
22109
- const new_virtualSolReserves = product_of_reserves / new_virtualTokenReserves + 1n;
22110
- const amount_needed = new_virtualSolReserves > this.virtualSolReserves ? new_virtualSolReserves - this.virtualSolReserves : 0n;
22103
+ const new_virtual_token_reserves = this.virtualTokenReserves - tokens;
22104
+ const new_virtual_sol_reserves = product_of_reserves / new_virtual_token_reserves + 1n;
22105
+ const amount_needed = new_virtual_sol_reserves > this.virtualSolReserves ? new_virtual_sol_reserves - this.virtualSolReserves : 0n;
22111
22106
  return amount_needed > 0n ? amount_needed : 0n;
22112
22107
  }
22113
22108
  applyBuy(token_amount) {