@gala-chain/launchpad-sdk 0.4.2 → 3.0.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/CHANGELOG.md +7 -0
- package/README.md +358 -75
- package/dist/examples/complete-sdk-demo.d.ts +22 -0
- package/dist/examples/complete-sdk-demo.d.ts.map +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/src/LaunchpadSDK.d.ts +755 -0
- package/dist/src/LaunchpadSDK.d.ts.map +1 -0
- package/dist/{api → src/api}/LaunchpadAPI.d.ts +101 -63
- package/dist/src/api/LaunchpadAPI.d.ts.map +1 -0
- package/dist/{api → src/api}/dto/BondingCurveDTOs.d.ts +8 -5
- package/dist/src/api/dto/BondingCurveDTOs.d.ts.map +1 -0
- package/dist/src/api/dto/TransferTokenDto.d.ts +76 -0
- package/dist/src/api/dto/TransferTokenDto.d.ts.map +1 -0
- package/dist/src/auth/SignatureAuth.d.ts.map +1 -0
- package/dist/src/auth/types.d.ts.map +1 -0
- package/dist/src/config/environments.d.ts +45 -0
- package/dist/src/config/environments.d.ts.map +1 -0
- package/dist/{helpers → src/helpers}/sdk.d.ts +23 -13
- package/dist/src/helpers/sdk.d.ts.map +1 -0
- package/dist/src/helpers/wallet.d.ts.map +1 -0
- package/dist/src/index.d.ts +25 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/services/BundleService.d.ts +197 -0
- package/dist/src/services/BundleService.d.ts.map +1 -0
- package/dist/src/services/DexService.d.ts +84 -0
- package/dist/src/services/DexService.d.ts.map +1 -0
- package/dist/src/services/GalaChainService.d.ts +254 -0
- package/dist/src/services/GalaChainService.d.ts.map +1 -0
- package/dist/src/services/LaunchpadService.d.ts +479 -0
- package/dist/src/services/LaunchpadService.d.ts.map +1 -0
- package/dist/src/services/SignatureService.d.ts.map +1 -0
- package/dist/src/services/TokenClassKeyService.d.ts.map +1 -0
- package/dist/src/services/TokenResolverService.d.ts +154 -0
- package/dist/src/services/TokenResolverService.d.ts.map +1 -0
- package/dist/src/services/WebSocketManager.d.ts.map +1 -0
- package/dist/{api → src}/services/WebSocketService.d.ts +4 -1
- package/dist/src/services/WebSocketService.d.ts.map +1 -0
- package/dist/{types → src/types}/comment.dto.d.ts +14 -5
- package/dist/src/types/comment.dto.d.ts.map +1 -0
- package/dist/{types → src/types}/common.d.ts +36 -1
- package/dist/src/types/common.d.ts.map +1 -0
- package/dist/{types → src/types}/dto.d.ts +19 -0
- package/dist/src/types/dto.d.ts.map +1 -0
- package/dist/{types → src/types}/launchpad.dto.d.ts +216 -30
- package/dist/src/types/launchpad.dto.d.ts.map +1 -0
- package/dist/{types → src/types}/launchpad.validation.d.ts +8 -8
- package/dist/src/types/launchpad.validation.d.ts.map +1 -0
- package/dist/src/types/options.dto.d.ts +281 -0
- package/dist/src/types/options.dto.d.ts.map +1 -0
- package/dist/src/types/result.types.d.ts +120 -0
- package/dist/src/types/result.types.d.ts.map +1 -0
- package/dist/{types → src/types}/trade.dto.d.ts +46 -19
- package/dist/src/types/trade.dto.d.ts.map +1 -0
- package/dist/src/types/transfer.dto.d.ts +161 -0
- package/dist/src/types/transfer.dto.d.ts.map +1 -0
- package/dist/{types → src/types}/user.dto.d.ts +98 -38
- package/dist/src/types/user.dto.d.ts.map +1 -0
- package/dist/src/types/websocket.types.d.ts +82 -0
- package/dist/src/types/websocket.types.d.ts.map +1 -0
- package/dist/src/utils/Logger.d.ts +136 -0
- package/dist/src/utils/Logger.d.ts.map +1 -0
- package/dist/src/utils/SignatureHelper.d.ts +77 -0
- package/dist/src/utils/SignatureHelper.d.ts.map +1 -0
- package/dist/src/utils/adapters.d.ts.map +1 -0
- package/dist/src/utils/agent-config.d.ts.map +1 -0
- package/dist/src/utils/date-utils.d.ts +39 -0
- package/dist/src/utils/date-utils.d.ts.map +1 -0
- package/dist/src/utils/http.d.ts.map +1 -0
- package/dist/src/utils/multipart.d.ts.map +1 -0
- package/dist/src/utils/number-utils.d.ts +57 -0
- package/dist/src/utils/number-utils.d.ts.map +1 -0
- package/dist/src/utils/precision-math.d.ts.map +1 -0
- package/dist/src/utils/slippage-utils.d.ts +70 -0
- package/dist/src/utils/slippage-utils.d.ts.map +1 -0
- package/dist/src/utils/tokenNormalizer.d.ts +111 -0
- package/dist/src/utils/tokenNormalizer.d.ts.map +1 -0
- package/dist/{utils → src/utils}/validation.d.ts +4 -4
- package/dist/src/utils/validation.d.ts.map +1 -0
- package/dist/{utils → src/utils}/wallet.d.ts +2 -2
- package/dist/src/utils/wallet.d.ts.map +1 -0
- package/package.json +10 -12
- package/dist/LaunchpadSDK.d.ts +0 -573
- package/dist/LaunchpadSDK.d.ts.map +0 -1
- package/dist/api/CommentAPI.d.ts +0 -119
- package/dist/api/CommentAPI.d.ts.map +0 -1
- package/dist/api/LaunchpadAPI.d.ts.map +0 -1
- package/dist/api/TradeAPI.d.ts +0 -164
- package/dist/api/TradeAPI.d.ts.map +0 -1
- package/dist/api/Trading.d.ts +0 -176
- package/dist/api/Trading.d.ts.map +0 -1
- package/dist/api/UserAPI.d.ts +0 -426
- package/dist/api/UserAPI.d.ts.map +0 -1
- package/dist/api/WebSocketAPI.d.ts +0 -156
- package/dist/api/WebSocketAPI.d.ts.map +0 -1
- package/dist/api/dto/BondingCurveDTOs.d.ts.map +0 -1
- package/dist/api/services/BundleService.d.ts +0 -105
- package/dist/api/services/BundleService.d.ts.map +0 -1
- package/dist/api/services/SignatureService.d.ts.map +0 -1
- package/dist/api/services/TokenClassKeyService.d.ts.map +0 -1
- package/dist/api/services/WebSocketManager.d.ts.map +0 -1
- package/dist/api/services/WebSocketService.d.ts.map +0 -1
- package/dist/auth/SignatureAuth.d.ts.map +0 -1
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/helpers/sdk.d.ts.map +0 -1
- package/dist/helpers/wallet.d.ts.map +0 -1
- package/dist/index.d.ts +0 -49
- package/dist/index.d.ts.map +0 -1
- package/dist/types/comment.dto.d.ts.map +0 -1
- package/dist/types/common.d.ts.map +0 -1
- package/dist/types/dto.d.ts.map +0 -1
- package/dist/types/launchpad.dto.d.ts.map +0 -1
- package/dist/types/launchpad.validation.d.ts.map +0 -1
- package/dist/types/trade.dto.d.ts.map +0 -1
- package/dist/types/user.dto.d.ts.map +0 -1
- package/dist/utils/VaultCache.d.ts +0 -73
- package/dist/utils/VaultCache.d.ts.map +0 -1
- package/dist/utils/adapters.d.ts.map +0 -1
- package/dist/utils/agent-config.d.ts.map +0 -1
- package/dist/utils/http.d.ts.map +0 -1
- package/dist/utils/multipart.d.ts.map +0 -1
- package/dist/utils/precision-math.d.ts.map +0 -1
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/wallet.d.ts.map +0 -1
- /package/dist/{auth → src/auth}/SignatureAuth.d.ts +0 -0
- /package/dist/{auth → src/auth}/types.d.ts +0 -0
- /package/dist/{helpers → src/helpers}/wallet.d.ts +0 -0
- /package/dist/{api → src}/services/SignatureService.d.ts +0 -0
- /package/dist/{api → src}/services/TokenClassKeyService.d.ts +0 -0
- /package/dist/{api → src}/services/WebSocketManager.d.ts +0 -0
- /package/dist/{utils → src/utils}/adapters.d.ts +0 -0
- /package/dist/{utils → src/utils}/agent-config.d.ts +0 -0
- /package/dist/{utils → src/utils}/http.d.ts +0 -0
- /package/dist/{utils → src/utils}/multipart.d.ts +0 -0
- /package/dist/{utils → src/utils}/precision-math.d.ts +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CommentAPI.d.ts","sourceRoot":"","sources":["../../src/api/CommentAPI.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAEL,mBAAmB,EAGnB,qBAAqB,EAItB,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;GAeG;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;;;;;OAKG;IACH,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAQnD;;;;;;;;;OASG;YACW,uBAAuB;CAGtC"}
|
package/dist/api/TradeAPI.d.ts
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Trade API Controller
|
|
3
|
-
*
|
|
4
|
-
* This controller provides access to trade-related operations including:
|
|
5
|
-
* - Trade creation
|
|
6
|
-
* - Trade listing with filtering
|
|
7
|
-
* - Bundle API trading integration
|
|
8
|
-
*
|
|
9
|
-
* All methods include input validation and handle backend type inconsistencies.
|
|
10
|
-
*/
|
|
11
|
-
import { HttpClient } from '../utils/http';
|
|
12
|
-
import type { LaunchpadAPI } from './LaunchpadAPI';
|
|
13
|
-
import { GetTradesResponse, TradeListParams, FetchSaleDetailsResponse } from '../types/trade.dto';
|
|
14
|
-
/**
|
|
15
|
-
* Trade API controller for trade operations
|
|
16
|
-
*
|
|
17
|
-
* Provides methods for:
|
|
18
|
-
* - Fetching trade listings with optional filtering
|
|
19
|
-
* - Fetching sale details from GalaChain
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* // Get trades for a token with pagination
|
|
24
|
-
* const trades = await sdk.trade.getTrades({
|
|
25
|
-
* tokenName: "MyToken",
|
|
26
|
-
* page: 1,
|
|
27
|
-
* limit: 10
|
|
28
|
-
* });
|
|
29
|
-
*
|
|
30
|
-
* // Fetch sale details from GalaChain
|
|
31
|
-
* const saleDetails = await sdk.trade.fetchSaleDetails({
|
|
32
|
-
* vaultAddress: "service|Token$Unit$MYSYMBOL$address$launchpad"
|
|
33
|
-
* });
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export declare class TradeAPI {
|
|
37
|
-
private readonly http;
|
|
38
|
-
private readonly galaChainHttp;
|
|
39
|
-
private readonly launchpadAPI?;
|
|
40
|
-
constructor(http: HttpClient, galaChainHttp: HttpClient, launchpadAPI?: LaunchpadAPI | undefined);
|
|
41
|
-
/**
|
|
42
|
-
* Gets trades for a token by its tokenName with pagination
|
|
43
|
-
*
|
|
44
|
-
* This method provides a clean, intuitive API for fetching token trades
|
|
45
|
-
* using the token name. Follows the same pattern as CommentAPI.
|
|
46
|
-
*
|
|
47
|
-
* @param tokenName Token name (e.g., "dragnrkti", "rocketri", "unicornri")
|
|
48
|
-
* @param params Optional pagination parameters (page, limit)
|
|
49
|
-
* @returns Promise<GetTradesResponse> Trades with pagination info
|
|
50
|
-
* @throws ValidationError if token name is invalid or not found
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* // Get first page of trades for dragnrkti token
|
|
55
|
-
* const trades = await sdk.trade.getTradesByTokenName("dragnrkti");
|
|
56
|
-
*
|
|
57
|
-
* // Get specific page with custom limit
|
|
58
|
-
* const moreTrades = await sdk.trade.getTradesByTokenName("dragnrkti", { page: 2, limit: 20 });
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
getTradesByTokenName(tokenName: string, params?: TradeListParams): Promise<GetTradesResponse>;
|
|
62
|
-
/**
|
|
63
|
-
* Validates pagination parameters
|
|
64
|
-
*/
|
|
65
|
-
private validatePagination;
|
|
66
|
-
/**
|
|
67
|
-
* Validates TradeListParams for tokenName-based methods
|
|
68
|
-
*/
|
|
69
|
-
private validateTradeListParams;
|
|
70
|
-
/**
|
|
71
|
-
* Validates fetch sale details data
|
|
72
|
-
*/
|
|
73
|
-
private validateFetchSaleDetailsData;
|
|
74
|
-
/**
|
|
75
|
-
* Builds query parameters for trade listing
|
|
76
|
-
* Note: GET /trade/ expects page/limit as STRINGS (backend quirk)
|
|
77
|
-
*
|
|
78
|
-
* @private
|
|
79
|
-
* @param tokenName Token name to filter by
|
|
80
|
-
* @param page Page number
|
|
81
|
-
* @param limit Items per page
|
|
82
|
-
* @returns Query parameters object
|
|
83
|
-
*/
|
|
84
|
-
private buildTradeQueryParams;
|
|
85
|
-
/**
|
|
86
|
-
* Gets current sale details for a token by its tokenName
|
|
87
|
-
*
|
|
88
|
-
* This method provides a clean, intuitive API for fetching current trading pool
|
|
89
|
-
* state using the token name. It automatically resolves the tokenName
|
|
90
|
-
* to the correct vault address internally.
|
|
91
|
-
*
|
|
92
|
-
* @param tokenName Token name (e.g., "dragnrkti", "rocketri", "unicornri")
|
|
93
|
-
* @returns Promise<FetchSaleDetailsResponse> Current trading pool state and bonding curve data
|
|
94
|
-
* @throws ValidationError if token name is invalid or not found
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* ```typescript
|
|
98
|
-
* // Get current sale details for dragnrkti token
|
|
99
|
-
* const saleDetails = await sdk.trade.getSaleDetailsByTokenName("dragnrkti");
|
|
100
|
-
* console.log('Current GALA in vault:', saleDetails.Data.nativeTokenQuantity);
|
|
101
|
-
* console.log('Bonding curve config:', saleDetails.Data.reverseBondingCurveConfiguration);
|
|
102
|
-
* ```
|
|
103
|
-
*/
|
|
104
|
-
getSaleDetailsByTokenName(tokenName: string): Promise<FetchSaleDetailsResponse>;
|
|
105
|
-
/**
|
|
106
|
-
* Internal method for fetching sale details by vault address
|
|
107
|
-
* Used internally by getSaleDetailsByTokenName after vault resolution
|
|
108
|
-
*
|
|
109
|
-
* @private
|
|
110
|
-
* @param data Fetch sale details data with vault address
|
|
111
|
-
* @returns Promise<FetchSaleDetailsResponse> Current trading pool state
|
|
112
|
-
*/
|
|
113
|
-
private fetchSaleDetails;
|
|
114
|
-
/**
|
|
115
|
-
* Gets the authenticated user's address in backend format
|
|
116
|
-
*
|
|
117
|
-
* @returns Address in eth|{40-hex-chars} format
|
|
118
|
-
*/
|
|
119
|
-
getAddress(): string;
|
|
120
|
-
/**
|
|
121
|
-
* Validates a vault address format (exposed for external validation)
|
|
122
|
-
*
|
|
123
|
-
* @param vaultAddress Vault address to validate
|
|
124
|
-
* @returns True if valid vault address format
|
|
125
|
-
*/
|
|
126
|
-
validateVaultAddress(vaultAddress: string): boolean;
|
|
127
|
-
/**
|
|
128
|
-
* Validates a user address format (exposed for external validation)
|
|
129
|
-
*
|
|
130
|
-
* @param userAddress User address to validate
|
|
131
|
-
* @returns True if valid user address format
|
|
132
|
-
*/
|
|
133
|
-
validateUserAddress(userAddress: string): boolean;
|
|
134
|
-
/**
|
|
135
|
-
* Validates an amount string format (exposed for external validation)
|
|
136
|
-
*
|
|
137
|
-
* @param amount Amount string to validate
|
|
138
|
-
* @returns True if valid amount format
|
|
139
|
-
*/
|
|
140
|
-
validateAmount(amount: string): boolean;
|
|
141
|
-
/**
|
|
142
|
-
* Validates a trade type (exposed for external validation)
|
|
143
|
-
*
|
|
144
|
-
* @param tradeType Trade type to validate
|
|
145
|
-
* @returns True if valid trade type
|
|
146
|
-
*/
|
|
147
|
-
validateTradeType(tradeType: string): boolean;
|
|
148
|
-
/**
|
|
149
|
-
* Resolves a token name to its vault address using cached resolution
|
|
150
|
-
*
|
|
151
|
-
* Uses the shared VaultCache for intelligent caching to eliminate
|
|
152
|
-
* redundant API calls for the same tokenName.
|
|
153
|
-
*
|
|
154
|
-
* @private
|
|
155
|
-
* @param tokenName Token name to resolve (e.g., 'dragnrkti', 'rocketri')
|
|
156
|
-
* @returns Promise<string | null> Vault address if found, null otherwise
|
|
157
|
-
*/
|
|
158
|
-
private resolveTokenNameToVault;
|
|
159
|
-
/**
|
|
160
|
-
* Validates address format (supports both eth| and 0x formats)
|
|
161
|
-
*/
|
|
162
|
-
private isValidAddress;
|
|
163
|
-
}
|
|
164
|
-
//# sourceMappingURL=TradeAPI.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TradeAPI.d.ts","sourceRoot":"","sources":["../../src/api/TradeAPI.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EACL,iBAAiB,EAEjB,e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Bonding Curve Implementation
|
|
3
|
-
*
|
|
4
|
-
* This controller provides token trading operations using bonding curves for launchpad tokens.
|
|
5
|
-
* It uses the @gala-chain/connect ChainCallDTO system for proper EIP-712 signature generation
|
|
6
|
-
* and bundle transaction handling.
|
|
7
|
-
*
|
|
8
|
-
* ## Prerequisites:
|
|
9
|
-
* - Launchpad backend with bonding curve support
|
|
10
|
-
* - Bundle backend for transaction processing
|
|
11
|
-
* - WebSocket endpoint for transaction monitoring
|
|
12
|
-
*
|
|
13
|
-
* ## Four Trading Methods - Complete Coverage
|
|
14
|
-
*
|
|
15
|
-
* ### 1. buyNative() - Spend exact GALA amount
|
|
16
|
-
* - **Input**: Amount of GALA you want to spend
|
|
17
|
-
* - **Output**: Tokens you'll receive (calculated by bonding curve)
|
|
18
|
-
* - **Use case**: "I want to spend exactly 100 GALA to buy tokens"
|
|
19
|
-
* - **Method**: BuyWithNative
|
|
20
|
-
*
|
|
21
|
-
* ### 2. buyExact() - Buy exact token amount
|
|
22
|
-
* - **Input**: Exact amount of tokens you want to buy
|
|
23
|
-
* - **Output**: GALA cost (calculated by bonding curve)
|
|
24
|
-
* - **Use case**: "I want exactly 10 tokens, show me the GALA cost"
|
|
25
|
-
* - **Method**: BuyExactToken
|
|
26
|
-
*
|
|
27
|
-
* ### 3. sellExact() - Sell exact token amount
|
|
28
|
-
* - **Input**: Exact amount of tokens you want to sell
|
|
29
|
-
* - **Output**: GALA you'll receive (calculated by bonding curve)
|
|
30
|
-
* - **Use case**: "I want to sell exactly 100 tokens for GALA"
|
|
31
|
-
* - **Method**: SellExactToken
|
|
32
|
-
*
|
|
33
|
-
* ### 4. sellNative() - Receive exact GALA amount
|
|
34
|
-
* - **Input**: Amount of GALA you want to receive
|
|
35
|
-
* - **Output**: Tokens you need to sell (calculated by bonding curve)
|
|
36
|
-
* - **Use case**: "I want to get exactly 10 GALA, how many tokens do I sell?"
|
|
37
|
-
* - **Method**: SellWithNative
|
|
38
|
-
*
|
|
39
|
-
* ## Key Features:
|
|
40
|
-
* - EIP-712 signature generation for all wallet types
|
|
41
|
-
* - Bundle transaction processing with stringsInstructions
|
|
42
|
-
* - Slippage protection for all operations
|
|
43
|
-
* - WebSocket monitoring for transaction completion
|
|
44
|
-
* - Full compatibility with frontend implementation
|
|
45
|
-
*
|
|
46
|
-
* @category Trading
|
|
47
|
-
* @since 2.0.0
|
|
48
|
-
*/
|
|
49
|
-
import { HttpClient } from '../utils/http';
|
|
50
|
-
import type { ApiResponse } from '../types/common';
|
|
51
|
-
import type { LaunchpadAPI } from './LaunchpadAPI';
|
|
52
|
-
export declare class Trading {
|
|
53
|
-
private walletProvider;
|
|
54
|
-
private userAddress;
|
|
55
|
-
private httpClient;
|
|
56
|
-
private debug;
|
|
57
|
-
private launchpadAPI?;
|
|
58
|
-
private signatureService;
|
|
59
|
-
private bundleService;
|
|
60
|
-
private tokenKeyService;
|
|
61
|
-
constructor(walletProvider: any, userAddress: string, httpClient: HttpClient, debug?: boolean, launchpadAPI?: LaunchpadAPI | undefined);
|
|
62
|
-
/**
|
|
63
|
-
* Buy tokens with unified, simplified API (replaces buyNativeByTokenName/buyExactByTokenName)
|
|
64
|
-
*
|
|
65
|
-
* @param tokenName Token name (e.g., "dragnrkti", "rocketri", "unicornri")
|
|
66
|
-
* @param options Trading options
|
|
67
|
-
* @param options.amount Amount to trade (GALA for 'native', tokens for 'exact')
|
|
68
|
-
* @param options.type Trading type: 'native' = spend GALA, 'exact' = buy exact tokens
|
|
69
|
-
* @param options.slippage Optional slippage percentage (default: 5%)
|
|
70
|
-
* @param options.buyerAddress Optional buyer address (defaults to authenticated user)
|
|
71
|
-
* @returns Promise<ApiResponse> Transaction result
|
|
72
|
-
* @throws ValidationError if parameters are invalid or token not found
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```typescript
|
|
76
|
-
* // Buy tokens by spending exactly 100 GALA
|
|
77
|
-
* const result = await sdk.trading.buyToken("dragnrkti", {
|
|
78
|
-
* amount: "100",
|
|
79
|
-
* type: "native",
|
|
80
|
-
* slippage: 5
|
|
81
|
-
* });
|
|
82
|
-
*
|
|
83
|
-
* // Buy exactly 50 tokens
|
|
84
|
-
* const result = await sdk.trading.buyToken("dragnrkti", {
|
|
85
|
-
* amount: "50",
|
|
86
|
-
* type: "exact",
|
|
87
|
-
* slippage: 3
|
|
88
|
-
* });
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
buyToken(tokenName: string, options: {
|
|
92
|
-
amount: string;
|
|
93
|
-
type: 'native' | 'exact';
|
|
94
|
-
slippage?: number;
|
|
95
|
-
buyerAddress?: string;
|
|
96
|
-
}): Promise<ApiResponse>;
|
|
97
|
-
/**
|
|
98
|
-
* Sell tokens with unified, simplified API (replaces sellExactByTokenName/sellNativeByTokenName)
|
|
99
|
-
*
|
|
100
|
-
* @param tokenName Token name (e.g., "dragnrkti", "rocketri", "unicornri")
|
|
101
|
-
* @param options Trading options
|
|
102
|
-
* @param options.amount Amount to trade (tokens for 'exact', GALA for 'native')
|
|
103
|
-
* @param options.type Trading type: 'exact' = sell exact tokens, 'native' = receive exact GALA
|
|
104
|
-
* @param options.slippage Optional slippage percentage (default: 5%)
|
|
105
|
-
* @param options.sellerAddress Optional seller address (defaults to authenticated user)
|
|
106
|
-
* @returns Promise<ApiResponse> Transaction result
|
|
107
|
-
* @throws ValidationError if parameters are invalid or token not found
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* ```typescript
|
|
111
|
-
* // Sell exactly 50 tokens
|
|
112
|
-
* const result = await sdk.trading.sellToken("dragnrkti", {
|
|
113
|
-
* amount: "50",
|
|
114
|
-
* type: "exact",
|
|
115
|
-
* slippage: 5
|
|
116
|
-
* });
|
|
117
|
-
*
|
|
118
|
-
* // Sell tokens to receive exactly 25 GALA
|
|
119
|
-
* const result = await sdk.trading.sellToken("dragnrkti", {
|
|
120
|
-
* amount: "25",
|
|
121
|
-
* type: "native",
|
|
122
|
-
* slippage: 3
|
|
123
|
-
* });
|
|
124
|
-
* ```
|
|
125
|
-
*/
|
|
126
|
-
sellToken(tokenName: string, options: {
|
|
127
|
-
amount: string;
|
|
128
|
-
type: 'exact' | 'native';
|
|
129
|
-
slippage?: number;
|
|
130
|
-
sellerAddress?: string;
|
|
131
|
-
}): Promise<ApiResponse>;
|
|
132
|
-
/**
|
|
133
|
-
* Execute bundle transaction with signature generation
|
|
134
|
-
*/
|
|
135
|
-
private executeBundleTransaction;
|
|
136
|
-
/**
|
|
137
|
-
* Get the authenticated user's address
|
|
138
|
-
*/
|
|
139
|
-
getAddress(): string;
|
|
140
|
-
/**
|
|
141
|
-
* Extract token symbol from vault address
|
|
142
|
-
* Format: service|Token$Unit$SYMBOL$eth:address$launchpad
|
|
143
|
-
*/
|
|
144
|
-
private extractTokenSymbolFromVault;
|
|
145
|
-
/**
|
|
146
|
-
* Validate token symbol format
|
|
147
|
-
*/
|
|
148
|
-
private validateTokenSymbol;
|
|
149
|
-
/**
|
|
150
|
-
* Validate amount format
|
|
151
|
-
*/
|
|
152
|
-
private validateAmount;
|
|
153
|
-
/**
|
|
154
|
-
* Validate vault address format
|
|
155
|
-
*/
|
|
156
|
-
private validateVaultAddress;
|
|
157
|
-
/**
|
|
158
|
-
* Fetch real vault address for a token from the launchpad API
|
|
159
|
-
*
|
|
160
|
-
* @param tokenSymbol Token symbol to search for (e.g., 'ANIME')
|
|
161
|
-
* @returns Real vault address from the API or null if not found
|
|
162
|
-
*/
|
|
163
|
-
fetchRealVaultAddress(tokenSymbol: string): Promise<string | null>;
|
|
164
|
-
/**
|
|
165
|
-
* Resolves a token name to its vault address using cached resolution
|
|
166
|
-
*
|
|
167
|
-
* Uses the shared VaultCache for intelligent caching to eliminate
|
|
168
|
-
* redundant API calls for the same tokenName.
|
|
169
|
-
*
|
|
170
|
-
* @private
|
|
171
|
-
* @param tokenName Token name to resolve (e.g., 'dragnrkti', 'rocketri')
|
|
172
|
-
* @returns Promise<string | null> Vault address if found, null otherwise
|
|
173
|
-
*/
|
|
174
|
-
private resolveTokenNameToVault;
|
|
175
|
-
}
|
|
176
|
-
//# sourceMappingURL=Trading.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Trading.d.ts","sourceRoot":"","sources":["../../src/api/Trading.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAQnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGnD,qBAAa,OAAO;IAMhB,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,YAAY,CAAC;IATvB,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,eAAe,CAAuB;gBAGpC,cAAc,EAAE,GAAG,EACnB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,UAAU,EACtB,KAAK,GAAE,OAAe,EACtB,YAAY,CAAC,EAAE,YAAY,YAAA;IAWrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACG,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE;QACzC,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;QACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,GAAG,OAAO,CAAC,WAAW,CAAC;IAgExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACG,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE;QAC1C,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,OA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