bet-test-sdk 1.0.8 → 1.1.0

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
@@ -60,8 +60,9 @@ const createAndBuyToken = async (sdk, testAccount) => {
60
60
  description: "TST-B: A test token",
61
61
  file: await fs.openAsBlob("example/basic/test.jpg"),
62
62
  migrateDex: MigrateDex.Meteora,
63
- twitter: "https://example.x.com.com",
63
+ twitter: "https://example.x.com",
64
64
  telegram: "https://example.t.me",
65
+ discord: "https://example.discord.com",
65
66
  website: "https://www.example.com",
66
67
  };
67
68
 
@@ -15885,10 +15885,9 @@ new PublicKey("11111111111111111111111111111111");
15885
15885
 
15886
15886
  const DEFAULT_COMMITMENT = "finalized";
15887
15887
  const DEFAULT_FINALITY = "finalized";
15888
- const calculateWithSlippageBuy = (amount, basisPoints) => {
15889
- return amount + (amount * basisPoints) / 10000n;
15890
- };
15891
- const calculateWithSlippageSell = (amount, basisPoints) => {
15888
+ // token amount => token amount
15889
+ // sol amount => sol amount
15890
+ const calculateWithSlippage = (amount, basisPoints) => {
15892
15891
  return amount - (amount * basisPoints) / 10000n;
15893
15892
  };
15894
15893
  async function sendTx(connection, tx, payer, signers, priorityFees, commitment = DEFAULT_COMMITMENT, finality = DEFAULT_FINALITY) {
@@ -16043,7 +16042,7 @@ class CurveState {
16043
16042
  // Calculate the amount of tokens to be purchased
16044
16043
  let s = this.virtualTokenReserves - r;
16045
16044
  // Return the minimum of the calculated tokens and real token reserves
16046
- return s < this.realSolReserves ? s : this.realSolReserves;
16045
+ return s < this.realTokenReserves ? s : this.realTokenReserves;
16047
16046
  }
16048
16047
  getSellPrice(amount, feeBasisPoints, isCompted) {
16049
16048
  if (isCompted) {
@@ -16054,10 +16053,8 @@ class CurveState {
16054
16053
  }
16055
16054
  // Calculate the proportional amount of virtual sol reserves to be received
16056
16055
  let n = (amount * this.virtualSolReserves) / (this.virtualTokenReserves + amount);
16057
- console.log("n::::::::::::::", n);
16058
16056
  // Calculate the fee amount in the same units
16059
16057
  let a = (n * feeBasisPoints) / 10000n;
16060
- console.log("a::::::::::::::", a);
16061
16058
  // Return the net amount after deducting the fee
16062
16059
  return n - a;
16063
16060
  }
@@ -21825,7 +21822,7 @@ class BetSDK {
21825
21822
  }
21826
21823
  if (buyAmountSol > 0) {
21827
21824
  const buyTokenAmount = this.getInitialBuyPrice(buyAmountSol); // token amount
21828
- const buyTokenAmountWithSlippage = calculateWithSlippageBuy(// token amount with slippage
21825
+ const buyTokenAmountWithSlippage = calculateWithSlippage(// token amount with slippage
21829
21826
  buyTokenAmount, slippageBasisPoints);
21830
21827
  const buyTx = await this.getBuyInstructions(creator, mintKeyPair.publicKey, buyAmountSol, buyTokenAmountWithSlippage);
21831
21828
  newTx.add(buyTx);
@@ -21860,9 +21857,9 @@ class BetSDK {
21860
21857
  if (!curveState) {
21861
21858
  throw new Error(`Curve state account not found: ${mint.toBase58()}`);
21862
21859
  }
21863
- let buyAmount = curveState.getBuyPrice(buyAmountSol, betState.isCompted);
21864
- let buyAmountWithSlippage = calculateWithSlippageBuy(buyAmountSol, slippageBasisPoints);
21865
- return await this.getBuyInstructions(buyer, mint, buyAmount, buyAmountWithSlippage);
21860
+ let buyTokenAmount = curveState.getBuyPrice(buyAmountSol, betState.isCompted);
21861
+ let buyAmountWithSlippage = calculateWithSlippage(buyTokenAmount, slippageBasisPoints);
21862
+ return await this.getBuyInstructions(buyer, mint, buyAmountSol, buyAmountWithSlippage);
21866
21863
  }
21867
21864
  //buy
21868
21865
  async getBuyInstructions(buyer, mint, solAmount, minTokenAmount, commitment = DEFAULT_COMMITMENT) {
@@ -21897,7 +21894,7 @@ class BetSDK {
21897
21894
  }
21898
21895
  const isComplete = betState.isCompted;
21899
21896
  let minSolOutput = curveState.getSellPrice(sellTokenAmount, FEE_BASIS_POINTS, isComplete);
21900
- let minSolOutputWithSlippage = calculateWithSlippageSell(minSolOutput, slippageBasisPoints);
21897
+ let minSolOutputWithSlippage = calculateWithSlippage(minSolOutput, slippageBasisPoints);
21901
21898
  return await this.getSellInstructions(seller, mint, sellTokenAmount, minSolOutputWithSlippage);
21902
21899
  }
21903
21900
  async getSellInstructions(seller, mint, sellTokenAmount, minAmountSol) {
@@ -22008,6 +22005,7 @@ class BetSDK {
22008
22005
  formData.append("description", create.description);
22009
22006
  formData.append("twitter", create.twitter || "");
22010
22007
  formData.append("telegram", create.telegram || "");
22008
+ formData.append("discord", create.discord || "");
22011
22009
  formData.append("website", create.website || "");
22012
22010
  try {
22013
22011
  const request = await fetch(`${BET_API}/token/ipfs`, {
@@ -22052,9 +22050,9 @@ class BetSDK {
22052
22050
  const initRealReservedToken = new BigNumber(DEFAULT_CURVE_INITIALIZE_INIT_RESERVED_TOKEN);
22053
22051
  const buyAmount = amount.toString();
22054
22052
  let n = initVirtualSol.multipliedBy(initVirtualToken); // K
22055
- let i = initVirtualSol.plus(buyAmount); // added sol
22053
+ let i = initVirtualSol.plus(buyAmount);
22056
22054
  let r = n.dividedBy(i).plus(1);
22057
- let s = initVirtualToken.minus(r); // .dividedBy(1000) sol-decimal=9, token-decimal=6
22055
+ let s = initVirtualToken.minus(r);
22058
22056
  const compared = s.comparedTo(initRealReservedToken);
22059
22057
  const bigAmount = compared <= 0
22060
22058
  ? s
@@ -22150,5 +22148,5 @@ class AMM {
22150
22148
  }
22151
22149
  }
22152
22150
 
22153
- 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, 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, calculateWithSlippageBuy, calculateWithSlippageSell, getTxDetails, sendTx, toCompleteEvent, toCreateEvent, toTradeEvent };
22151
+ 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, 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 };
22154
22152
  //# sourceMappingURL=index.js.map