bet-test-sdk 1.1.1 → 1.1.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/dist/browser/index.js +74 -0
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/types/bet.d.ts +5 -0
- package/dist/browser/types/bet.d.ts.map +1 -1
- package/dist/browser/types/types.d.ts +1 -0
- package/dist/browser/types/types.d.ts.map +1 -1
- package/dist/cjs/bet.d.ts +5 -0
- package/dist/cjs/bet.d.ts.map +1 -1
- package/dist/cjs/bet.js +74 -0
- package/dist/cjs/bet.js.map +1 -1
- package/dist/cjs/types.d.ts +1 -0
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/esm/bet.d.ts +5 -0
- package/dist/esm/bet.d.ts.map +1 -1
- package/dist/esm/bet.js +74 -0
- package/dist/esm/bet.js.map +1 -1
- package/dist/esm/types.d.ts +1 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
@@ -21987,6 +21987,7 @@ class BetSDK {
|
|
21987
21987
|
formData.append("name", create.name);
|
21988
21988
|
formData.append("symbol", create.symbol);
|
21989
21989
|
formData.append("description", create.description);
|
21990
|
+
formData.append("createdOn", create.createdOn || "");
|
21990
21991
|
formData.append("twitter", create.twitter || "");
|
21991
21992
|
formData.append("telegram", create.telegram || "");
|
21992
21993
|
formData.append("discord", create.discord || "");
|
@@ -22043,6 +22044,79 @@ class BetSDK {
|
|
22043
22044
|
: initRealReservedToken;
|
22044
22045
|
return BigInt(bigAmount.toString().split(".")[0]);
|
22045
22046
|
}
|
22047
|
+
// Buy: Fixed sol amount in, estimated token amount out
|
22048
|
+
async getTokenAmountOut(mint, solAmountIn, slippageBasisPoints) {
|
22049
|
+
const curveStateAccount = await this.getValidCurveState(mint);
|
22050
|
+
if (!curveStateAccount) {
|
22051
|
+
return 0n;
|
22052
|
+
}
|
22053
|
+
let shouldOutTokens = curveStateAccount.getBuyPrice(solAmountIn, false);
|
22054
|
+
if (slippageBasisPoints) {
|
22055
|
+
shouldOutTokens -= (shouldOutTokens * slippageBasisPoints) / 10000n;
|
22056
|
+
}
|
22057
|
+
return shouldOutTokens;
|
22058
|
+
}
|
22059
|
+
// Buy: Fixed token amount out, estimated sol amount in
|
22060
|
+
async getMinSolAmountIn(mint, tokenAmountOut, slippageBasisPoints) {
|
22061
|
+
const curveStateAccount = await this.getValidCurveState(mint);
|
22062
|
+
if (!curveStateAccount) {
|
22063
|
+
return 0n;
|
22064
|
+
}
|
22065
|
+
let shouldOutTokens = tokenAmountOut > curveStateAccount.virtualTokenReserves - curveStateAccount.realTokenReserves
|
22066
|
+
? curveStateAccount.virtualTokenReserves - curveStateAccount.realTokenReserves
|
22067
|
+
: tokenAmountOut;
|
22068
|
+
let minSolAmountIn = (shouldOutTokens * curveStateAccount.virtualSolReserves) /
|
22069
|
+
(curveStateAccount.virtualTokenReserves - shouldOutTokens) +
|
22070
|
+
1n;
|
22071
|
+
if (slippageBasisPoints) {
|
22072
|
+
minSolAmountIn += (minSolAmountIn * slippageBasisPoints) / 10000n;
|
22073
|
+
}
|
22074
|
+
let fee = (minSolAmountIn * FEE_BASIS_POINTS) / 10000n;
|
22075
|
+
return minSolAmountIn + fee;
|
22076
|
+
}
|
22077
|
+
// Sell: Fixed token amount in, estimated sol amount out
|
22078
|
+
async getSolAmountOut(mint, tokenAmountIn, slippageBasisPoints) {
|
22079
|
+
const curveStateAccount = await this.getValidCurveState(mint);
|
22080
|
+
if (!curveStateAccount) {
|
22081
|
+
return 0n;
|
22082
|
+
}
|
22083
|
+
let shouldOutTokens = curveStateAccount.getSellPrice(tokenAmountIn, FEE_BASIS_POINTS, false);
|
22084
|
+
if (slippageBasisPoints) {
|
22085
|
+
shouldOutTokens -= (shouldOutTokens * slippageBasisPoints) / 10000n;
|
22086
|
+
}
|
22087
|
+
return shouldOutTokens;
|
22088
|
+
}
|
22089
|
+
// Sell: Fixed sol amount out, estimated token amount in
|
22090
|
+
async getMinTokenAmountIn(mint, solAmountOut, slippageBasisPoints) {
|
22091
|
+
const curveStateAccount = await this.getValidCurveState(mint);
|
22092
|
+
if (!curveStateAccount) {
|
22093
|
+
return 0n;
|
22094
|
+
}
|
22095
|
+
let shouldOutSols = solAmountOut > curveStateAccount.virtualSolReserves - curveStateAccount.realSolReserves
|
22096
|
+
? curveStateAccount.virtualSolReserves - curveStateAccount.realSolReserves
|
22097
|
+
: solAmountOut;
|
22098
|
+
let minTokenAmountIn = (shouldOutSols * curveStateAccount.virtualTokenReserves) /
|
22099
|
+
(curveStateAccount.virtualSolReserves - shouldOutSols) +
|
22100
|
+
1n;
|
22101
|
+
if (slippageBasisPoints) {
|
22102
|
+
minTokenAmountIn += (minTokenAmountIn * slippageBasisPoints) / 10000n;
|
22103
|
+
}
|
22104
|
+
let fee = (minTokenAmountIn * FEE_BASIS_POINTS) / 10000n;
|
22105
|
+
return minTokenAmountIn + fee;
|
22106
|
+
}
|
22107
|
+
async getValidCurveState(mint) {
|
22108
|
+
const curveStateAccount = await this.getCurveStateAccount(mint);
|
22109
|
+
const betStateAccount = await this.getBetStateAccount(mint);
|
22110
|
+
if (!curveStateAccount || !betStateAccount) {
|
22111
|
+
console.error("Mint does not exist");
|
22112
|
+
return null;
|
22113
|
+
}
|
22114
|
+
if (betStateAccount.isCompted) {
|
22115
|
+
console.error("Compted");
|
22116
|
+
return null;
|
22117
|
+
}
|
22118
|
+
return curveStateAccount;
|
22119
|
+
}
|
22046
22120
|
//EVENTS
|
22047
22121
|
addEventListener(eventType, callback) {
|
22048
22122
|
return this.program.addEventListener(eventType, (event, slot, signature) => {
|