bet-test-sdk 1.1.9 → 1.2.1
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/dist/browser/index.js +15 -11
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/types/betState.d.ts +2 -2
- package/dist/browser/types/betState.d.ts.map +1 -1
- package/dist/browser/types/constants.d.ts +1 -1
- package/dist/browser/types/constants.d.ts.map +1 -1
- package/dist/browser/types/curveState.d.ts.map +1 -1
- package/dist/cjs/bet.js +4 -4
- package/dist/cjs/bet.js.map +1 -1
- package/dist/cjs/betState.d.ts +2 -2
- package/dist/cjs/betState.d.ts.map +1 -1
- package/dist/cjs/betState.js +5 -5
- package/dist/cjs/betState.js.map +1 -1
- package/dist/cjs/constants.d.ts +1 -1
- package/dist/cjs/constants.d.ts.map +1 -1
- package/dist/cjs/constants.js +1 -1
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/curveState.d.ts.map +1 -1
- package/dist/cjs/curveState.js +4 -0
- package/dist/cjs/curveState.js.map +1 -1
- package/dist/cjs/idl/bet.json +1 -1
- package/dist/esm/bet.js +4 -4
- package/dist/esm/bet.js.map +1 -1
- package/dist/esm/betState.d.ts +2 -2
- package/dist/esm/betState.d.ts.map +1 -1
- package/dist/esm/betState.js +5 -5
- package/dist/esm/betState.js.map +1 -1
- package/dist/esm/constants.d.ts +1 -1
- package/dist/esm/constants.d.ts.map +1 -1
- package/dist/esm/constants.js +1 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/curveState.d.ts.map +1 -1
- package/dist/esm/curveState.js +4 -0
- package/dist/esm/curveState.js.map +1 -1
- package/dist/esm/idl/bet.json +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
@@ -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 = "E3zXK7VRyn39uuyshkQCriRXUAsR1KKQXaJ55KyDW4bp";
|
7
|
-
const BET_API = "https://
|
7
|
+
const BET_API = "https://betapi.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";
|
@@ -16043,6 +16043,7 @@ class CurveState {
|
|
16043
16043
|
let r = n / i + 1n;
|
16044
16044
|
// Calculate the amount of tokens to be purchased
|
16045
16045
|
let s = this.virtualTokenReserves - r;
|
16046
|
+
s = s < 0n ? 0n : s;
|
16046
16047
|
// Return the minimum of the calculated tokens and real token reserves
|
16047
16048
|
return s < this.realTokenReserves ? s : this.realTokenReserves;
|
16048
16049
|
}
|
@@ -16058,6 +16059,9 @@ class CurveState {
|
|
16058
16059
|
// Calculate the fee amount in the same units
|
16059
16060
|
let a = (n * feeBasisPoints) / DENOMINATOR;
|
16060
16061
|
// Return the net amount after deducting the fee
|
16062
|
+
if (n - a < 0n) {
|
16063
|
+
return 0n;
|
16064
|
+
}
|
16061
16065
|
return n - a;
|
16062
16066
|
}
|
16063
16067
|
getMarketCapSOL() {
|
@@ -16115,8 +16119,8 @@ class BetState {
|
|
16115
16119
|
totalTokenIn;
|
16116
16120
|
migrateType;
|
16117
16121
|
isWithdrawed;
|
16118
|
-
|
16119
|
-
constructor(discriminator, creator, curveState, mint, poolOfSol, poolOfToken, totalSolIn, totalTokenOut, totalSolOut, totalTokenIn, migrateType, isWithdrawed,
|
16122
|
+
isCompleted;
|
16123
|
+
constructor(discriminator, creator, curveState, mint, poolOfSol, poolOfToken, totalSolIn, totalTokenOut, totalSolOut, totalTokenIn, migrateType, isWithdrawed, isCompleted) {
|
16120
16124
|
this.discriminator = discriminator;
|
16121
16125
|
this.creator = creator;
|
16122
16126
|
this.curveState = curveState;
|
@@ -16129,7 +16133,7 @@ class BetState {
|
|
16129
16133
|
this.totalTokenIn = totalTokenIn;
|
16130
16134
|
this.migrateType = migrateType;
|
16131
16135
|
this.isWithdrawed = isWithdrawed;
|
16132
|
-
this.
|
16136
|
+
this.isCompleted = isCompleted;
|
16133
16137
|
}
|
16134
16138
|
static fromBuffer(buffer) {
|
16135
16139
|
const structure = struct$1([
|
@@ -16145,10 +16149,10 @@ class BetState {
|
|
16145
16149
|
u128("totalTokenIn"),
|
16146
16150
|
u8$1("migrateType"),
|
16147
16151
|
bool("isWithdrawed"),
|
16148
|
-
bool("
|
16152
|
+
bool("isCompleted"),
|
16149
16153
|
]);
|
16150
16154
|
let value = structure.decode(buffer);
|
16151
|
-
return new BetState(BigInt(value.discriminator), new PublicKey(value.creator), new PublicKey(value.curveState), new PublicKey(value.mint), new PublicKey(value.poolOfSol), new PublicKey(value.poolOfToken), toBigInt(value.totalSolIn), toBigInt(value.totalTokenOut), toBigInt(value.totalSolOut), toBigInt(value.totalTokenIn), value.migrateType, value.isWithdrawed, value.
|
16155
|
+
return new BetState(BigInt(value.discriminator), new PublicKey(value.creator), new PublicKey(value.curveState), new PublicKey(value.mint), new PublicKey(value.poolOfSol), new PublicKey(value.poolOfToken), toBigInt(value.totalSolIn), toBigInt(value.totalTokenOut), toBigInt(value.totalSolOut), toBigInt(value.totalTokenIn), value.migrateType, value.isWithdrawed, value.isCompleted);
|
16152
16156
|
}
|
16153
16157
|
}
|
16154
16158
|
|
@@ -18527,7 +18531,7 @@ var types = [
|
|
18527
18531
|
type: "bool"
|
18528
18532
|
},
|
18529
18533
|
{
|
18530
|
-
name: "
|
18534
|
+
name: "is_completed",
|
18531
18535
|
type: "bool"
|
18532
18536
|
}
|
18533
18537
|
]
|
@@ -21843,7 +21847,7 @@ class BetSDK {
|
|
21843
21847
|
if (!curveState) {
|
21844
21848
|
throw new Error(`Curve state account not found: ${mint.toBase58()}`);
|
21845
21849
|
}
|
21846
|
-
let buyTokenAmount = curveState.getBuyPrice(buyAmountSol, betState.
|
21850
|
+
let buyTokenAmount = curveState.getBuyPrice(buyAmountSol, betState.isCompleted);
|
21847
21851
|
let buyAmountWithSlippage = calculateWithSlippage(buyTokenAmount, slippageBasisPoints);
|
21848
21852
|
return await this.getBuyInstructions(buyer, mint, buyAmountSol, buyAmountWithSlippage);
|
21849
21853
|
}
|
@@ -21878,7 +21882,7 @@ class BetSDK {
|
|
21878
21882
|
if (!curveState) {
|
21879
21883
|
throw new Error(`Curve state account not found: ${mint.toBase58()}`);
|
21880
21884
|
}
|
21881
|
-
const isCompleted = betState.
|
21885
|
+
const isCompleted = betState.isCompleted;
|
21882
21886
|
let minSolOutput = curveState.getSellPrice(sellTokenAmount, FEE_BASIS_POINTS, isCompleted);
|
21883
21887
|
let minSolOutputWithSlippage = calculateWithSlippage(minSolOutput, slippageBasisPoints);
|
21884
21888
|
return await this.getSellInstructions(seller, mint, sellTokenAmount, minSolOutputWithSlippage);
|
@@ -22123,8 +22127,8 @@ class BetSDK {
|
|
22123
22127
|
console.error("Mint does not exist");
|
22124
22128
|
return null;
|
22125
22129
|
}
|
22126
|
-
if (betStateAccount.
|
22127
|
-
console.error("
|
22130
|
+
if (betStateAccount.isCompleted) {
|
22131
|
+
console.error("Completed");
|
22128
22132
|
return null;
|
22129
22133
|
}
|
22130
22134
|
return curveStateAccount;
|