@gala-chain/launchpad-sdk 3.3.2 → 3.3.4

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 CHANGED
@@ -4,6 +4,53 @@ All notable changes to the Gala Launchpad SDK will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [3.3.4] - 2025-10-01
8
+
9
+ ### Fixed
10
+ - **Launchpad token precision loss in trading DTOs** - Fixed critical bug truncating tokens to 8 decimals
11
+ - `formatForDTO()` now accepts optional `decimals` parameter (defaults to 18)
12
+ - Added `formatGalaForDTO()` helper for GALA amounts (8 decimals - GalaChain requirement)
13
+ - Added `formatLaunchpadTokenForDTO()` helper for launchpad tokens (18 decimals - full precision)
14
+ - Updated all BondingCurveDTOs to use context-aware formatting:
15
+ - `nativeTokenQuantity` (GALA) → Uses `formatGalaForDTO()` (8 decimals)
16
+ - `expectedToken` (Launchpad token) → Uses `formatLaunchpadTokenForDTO()` (18 decimals)
17
+ - `tokenQuantity` (Launchpad token) → Uses `formatLaunchpadTokenForDTO()` (18 decimals)
18
+ - `expectedNativeToken` (GALA) → Uses `formatGalaForDTO()` (8 decimals)
19
+ - Prevents precision loss when trading high-precision launchpad tokens
20
+ - GALA amounts still correctly limited to 8 decimals (GalaChain transaction requirement)
21
+ - Example: Token amount `1000.123456789012345678` now preserved at full 18 decimals instead of truncated to `1000.12345679`
22
+
23
+ ### Added
24
+ - **Decimal Constants** - Token decimal precision constants for type-safe operations
25
+ - `GALA_DECIMALS = 8` - GALA token decimal places (GalaChain standard)
26
+ - `LAUNCHPAD_TOKEN_DECIMALS = 18` - Launchpad token decimal places (ERC-20 standard)
27
+ - `GALA_TOKEN_CLASS_KEY` - GALA token identifier for GalaChain operations
28
+ - Import: `import { GALA_DECIMALS, LAUNCHPAD_TOKEN_DECIMALS } from '@gala-chain/launchpad-sdk'`
29
+ - Provides single source of truth for decimal specifications
30
+ - Prevents hardcoded magic numbers across SDK
31
+
32
+ ### Changed
33
+ - **precision-math.ts** - Now uses `LAUNCHPAD_TOKEN_DECIMALS` constant instead of hardcoded 18
34
+ - Improves code maintainability and clarity
35
+ - Self-documenting code intent
36
+
37
+ ### Benefits
38
+ - ✅ Full precision for launchpad tokens (18 decimals) - no more truncation
39
+ - ✅ Correct precision limits for GALA (8 decimals) - prevents transaction failures
40
+ - ✅ Type-safe decimal constants via const assertions
41
+ - ✅ Context-aware formatting prevents precision bugs
42
+ - ✅ Single source of truth for token specifications
43
+
44
+ ## [3.3.3] - 2025-10-01
45
+
46
+ ### Fixed
47
+ - **fetchLaunchpadTokenSpotPrice calculation** - Fixed critical precision and logic bugs
48
+ - Removed incorrect division by 1e18 (buyResult.amount is already in decimal format, not wei)
49
+ - Switched from `Number()` to `BigNumber.js` for precise calculations
50
+ - Fixes spot prices being off by factor of ~1e18 (showing trillions instead of micro-cents)
51
+ - Prevents precision loss for tokens with many decimal places
52
+ - Example: ANIME token now shows $0.00000004 instead of $20,147,102,880,354
53
+
7
54
  ## [3.3.2] - 2025-09-30
8
55
 
9
56
  ### Added
@@ -1 +1 @@
1
- {"version":3,"file":"LaunchpadAPI.d.ts","sourceRoot":"","sources":["../../src/api/LaunchpadAPI.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAWxE,OAAO,EAEL,gBAAgB,EAGhB,WAAW,EAEX,uBAAuB,EACvB,gBAAgB,EAIhB,eAAe,EAEf,uBAAuB,EACvB,eAAe,EAKf,iBAAiB,EAIjB,cAAc,EAEf,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EACL,oBAAoB,EAIrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,sBAAsB,EACtB,yBAA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AG,OAAO,CAAC,MAAM,CAAC;IAgLzD;;;;;;;;;;;;;;OAcG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,uBAAuB,CAAC;IAoCnC;;;;;;;;;;;;;;;;;OAiBG;IACG,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA0BrE;;;;;;;;;;;;;OAaG;IACG,wBAAwB,CAC5B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,OAAO,CAAC;IAkBnB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,yBAAyB,CAC7B,IAAI,EAAE,oBAAoB,GACzB,OAAO,CAAC,uBAAuB,CAAC;IA+DnC;;;;OAIG;IACH,UAAU,IAAI,MAAM;IAIpB;;;;;OAKG;IACH,uBAAuB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM;IAIxD;;;;;OAKG;IACH,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI1C;;;;;OAKG;IACH,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAQnD;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACG,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IA4ChF;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;CA8C/E"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Token decimal precision constants for GalaChain
3
+ *
4
+ * These constants define the decimal places for different token types
5
+ * used in the Gala Launchpad ecosystem. Following EIP-20 standard.
6
+ *
7
+ * @packageDocumentation
8
+ * @category Constants
9
+ */
10
+ /**
11
+ * GALA token decimal places (EIP-20 standard)
12
+ *
13
+ * GALA uses 8 decimal places for all operations. This is a GalaChain
14
+ * requirement - transactions with more than 8 decimal places will fail.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { GALA_DECIMALS } from '@gala-chain/launchpad-sdk';
19
+ *
20
+ * console.log(`GALA has ${GALA_DECIMALS} decimals`); // 8
21
+ * const maxPrecision = parseFloat(galaAmount).toFixed(GALA_DECIMALS);
22
+ * ```
23
+ */
24
+ export declare const GALA_DECIMALS: 8;
25
+ /**
26
+ * Launchpad token decimal places (EIP-20 standard)
27
+ *
28
+ * All tokens created via the Gala Launchpad use 18 decimal places,
29
+ * following the standard ERC-20 convention.
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * import { LAUNCHPAD_TOKEN_DECIMALS } from '@gala-chain/launchpad-sdk';
34
+ *
35
+ * console.log(`Launchpad tokens have ${LAUNCHPAD_TOKEN_DECIMALS} decimals`); // 18
36
+ * const maxPrecision = parseFloat(tokenAmount).toFixed(LAUNCHPAD_TOKEN_DECIMALS);
37
+ * ```
38
+ */
39
+ export declare const LAUNCHPAD_TOKEN_DECIMALS: 18;
40
+ /**
41
+ * GALA token class key for GalaChain operations
42
+ *
43
+ * This is the standard token identifier for GALA on GalaChain.
44
+ * Used for balance queries, transfers, and other token operations.
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * import { GALA_TOKEN_CLASS_KEY } from '@gala-chain/launchpad-sdk';
49
+ *
50
+ * const galaBalance = await galaChainService.fetchTokenBalance({
51
+ * owner: walletAddress,
52
+ * ...GALA_TOKEN_CLASS_KEY,
53
+ * instance: "0"
54
+ * });
55
+ * ```
56
+ */
57
+ export declare const GALA_TOKEN_CLASS_KEY: {
58
+ readonly collection: "GALA";
59
+ readonly category: "Unit";
60
+ readonly type: "none";
61
+ readonly additionalKey: "none";
62
+ };
63
+ //# sourceMappingURL=decimals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decimals.d.ts","sourceRoot":"","sources":["../../src/constants/decimals.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,EAAG,CAAU,CAAC;AAExC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wBAAwB,EAAG,EAAW,CAAC;AAEpD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,oBAAoB;;;;;CAKvB,CAAC"}