bet-test-sdk 1.2.5 → 1.2.7
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 +14 -11
- package/dist/browser/index.js +32 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/types/bet.d.ts +1 -0
- package/dist/browser/types/bet.d.ts.map +1 -1
- package/dist/browser/types/util.d.ts +1 -0
- package/dist/browser/types/util.d.ts.map +1 -1
- package/dist/cjs/bet.d.ts +1 -0
- package/dist/cjs/bet.d.ts.map +1 -1
- package/dist/cjs/bet.js +19 -0
- package/dist/cjs/bet.js.map +1 -1
- package/dist/cjs/util.d.ts +1 -0
- package/dist/cjs/util.d.ts.map +1 -1
- package/dist/cjs/util.js +14 -1
- package/dist/cjs/util.js.map +1 -1
- package/dist/esm/bet.d.ts +1 -0
- package/dist/esm/bet.d.ts.map +1 -1
- package/dist/esm/bet.js +21 -2
- package/dist/esm/bet.js.map +1 -1
- package/dist/esm/util.d.ts +1 -0
- package/dist/esm/util.d.ts.map +1 -1
- package/dist/esm/util.js +12 -0
- package/dist/esm/util.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
## Important
|
4
4
|
|
5
|
-
Never click links in this repository
|
5
|
+
Never click any links in this repository or its issues that lead you away from GitHub. Do not run any code that others post without reading and understanding it first. This software is provided "as is" without warranty.
|
6
6
|
|
7
7
|
## Overview
|
8
8
|
|
9
|
-
The `BetSDK` is designed to interact with the bet.com decentralized application. It provides methods for creating, buying, and selling tokens
|
9
|
+
The `BetSDK` is designed to interact with the bet.com decentralized application. It provides methods for creating, buying, and selling tokens on the Solana blockchain. The SDK manages the necessary transactions and interactions with the bet.com program.
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
@@ -15,8 +15,7 @@ npm i bet-test-sdk
|
|
15
15
|
`
|
16
16
|
|
17
17
|
## Notice (for developers)
|
18
|
-
If you
|
19
|
-
consider installing plugins such as node-polyfills OR add the crypto-browserify alias to the configuration file.
|
18
|
+
If you encounter an error regarding the `crypto` module when building a front-end project with frameworks such as React, Vue, or Next.js, consider installing a polyfill (for example, the node-polyfills plugin) or adding a crypto-browserify alias to your build configuration.
|
20
19
|
|
21
20
|
For example:
|
22
21
|
```
|
@@ -38,6 +37,7 @@ resolve: {
|
|
38
37
|
```
|
39
38
|
|
40
39
|
### BetSDK transaction
|
40
|
+
|
41
41
|
Get BetSDK transaction-related methods.
|
42
42
|
|
43
43
|
#### getCreateAndBuyInstructions
|
@@ -72,9 +72,9 @@ async getCreateAndBuyInstructions(
|
|
72
72
|
- `name`: Token name.
|
73
73
|
- `symbol`: Token symbol.
|
74
74
|
- `description`: Token description.
|
75
|
-
- `migrateDex`: After completing the bet curve, the
|
75
|
+
- `migrateDex`: After completing the bet curve, the decentralized exchange (DEX) you wish to migrate to currently supports only Raydium and Meteora. The MigrateType can be imported from the SDK.
|
76
76
|
- `file`: Token logo file
|
77
|
-
- `createdOn`:
|
77
|
+
- `createdOn`: Specifies the platform on which the token was created.
|
78
78
|
- `twitter`: X link
|
79
79
|
- `telegram`: Telegram link
|
80
80
|
- `discord`: Discord link
|
@@ -83,7 +83,7 @@ async getCreateAndBuyInstructions(
|
|
83
83
|
- Creates a new token and buys it.
|
84
84
|
- **Parameters**:
|
85
85
|
- `creator`: The public key of the token creator.
|
86
|
-
- `createTokenMetadata`: Metadata for the token.(
|
86
|
+
- `createTokenMetadata`: Metadata for the token. (For the createTokenMetadata object, the migrateType property specifies that after completing the bet curve, the DEX you wish to migrate to currently supports only Raydium and Meteora. The MigrateType can be imported from the SDK.)
|
87
87
|
- `buyAmountSol`: Amount of SOL to buy.
|
88
88
|
- `slippageBasisPoints`: Slippage in basis points (default: 500).
|
89
89
|
- `commitment`: Commitment level (default: DEFAULT_COMMITMENT).
|
@@ -159,13 +159,16 @@ 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
|
165
168
|
|
166
|
-
First
|
169
|
+
First, create a `.env` file and set your RPC URL as shown in the `.env.example` file.
|
167
170
|
|
168
|
-
Then
|
171
|
+
Then, run the command below to generate a new account, and fund this account with at least 0.004 SOL.
|
169
172
|
|
170
173
|
`
|
171
174
|
npx ts-node example/basic/index.ts
|
@@ -329,7 +332,7 @@ main();
|
|
329
332
|
|
330
333
|
### BetSDK Class
|
331
334
|
|
332
|
-
The `BetSDK` class provides methods
|
335
|
+
The `BetSDK` class provides methods for interacting with the Bet protocol. Below are the method signatures and descriptions.
|
333
336
|
|
334
337
|
|
335
338
|
#### createAndBuy
|
@@ -515,7 +518,7 @@ npx ts-node example/events/events.ts
|
|
515
518
|
|
516
519
|
## Disclaimer
|
517
520
|
|
518
|
-
This software is provided "as is
|
521
|
+
This software is provided "as is" without any warranty, express or implied, including, but not limited to, the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claims, damages, or other liabilities, whether arising from a contract, tort, or any other legal theory in connection with the software or its use.
|
519
522
|
|
520
523
|
**Use at your own risk.** The authors take no responsibility for any harm or damage caused by the use of this software. Users are responsible for ensuring the suitability and safety of this software for their specific use cases.
|
521
524
|
|
package/dist/browser/index.js
CHANGED
@@ -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
|
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
|