@gala-chain/launchpad 1.0.6 → 1.0.8

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.
Files changed (55) hide show
  1. package/lib/package.json +1 -1
  2. package/lib/src/api/types/LaunchpadDtos.d.ts +5 -0
  3. package/lib/src/api/types/LaunchpadDtos.d.ts.map +1 -1
  4. package/lib/src/api/types/LaunchpadDtos.js +16 -1
  5. package/lib/src/api/types/LaunchpadDtos.js.map +1 -1
  6. package/lib/src/chaincode/LaunchpadContract.d.ts +4 -3
  7. package/lib/src/chaincode/LaunchpadContract.d.ts.map +1 -1
  8. package/lib/src/chaincode/LaunchpadContract.js +23 -4
  9. package/lib/src/chaincode/LaunchpadContract.js.map +1 -1
  10. package/lib/src/chaincode/launchpad/buyExactToken.d.ts.map +1 -1
  11. package/lib/src/chaincode/launchpad/buyExactToken.js +9 -1
  12. package/lib/src/chaincode/launchpad/buyExactToken.js.map +1 -1
  13. package/lib/src/chaincode/launchpad/buyWithNative.d.ts.map +1 -1
  14. package/lib/src/chaincode/launchpad/buyWithNative.js +10 -2
  15. package/lib/src/chaincode/launchpad/buyWithNative.js.map +1 -1
  16. package/lib/src/chaincode/launchpad/callMemeTokenOut.d.ts.map +1 -1
  17. package/lib/src/chaincode/launchpad/callMemeTokenOut.js.map +1 -1
  18. package/lib/src/chaincode/launchpad/callNativeTokenIn.d.ts.map +1 -1
  19. package/lib/src/chaincode/launchpad/callNativeTokenIn.js.map +1 -1
  20. package/lib/src/chaincode/launchpad/callNativeTokenOut.d.ts.map +1 -1
  21. package/lib/src/chaincode/launchpad/callNativeTokenOut.js.map +1 -1
  22. package/lib/src/chaincode/launchpad/fetchLaunchpadAdressConfig.d.ts +2 -1
  23. package/lib/src/chaincode/launchpad/fetchLaunchpadAdressConfig.d.ts.map +1 -1
  24. package/lib/src/chaincode/launchpad/fetchLaunchpadAdressConfig.js +1 -1
  25. package/lib/src/chaincode/launchpad/fetchLaunchpadAdressConfig.js.map +1 -1
  26. package/lib/src/chaincode/launchpad/fetchLaunchpadFeeAmount.d.ts +12 -0
  27. package/lib/src/chaincode/launchpad/fetchLaunchpadFeeAmount.d.ts.map +1 -0
  28. package/lib/src/chaincode/launchpad/fetchLaunchpadFeeAmount.js +37 -0
  29. package/lib/src/chaincode/launchpad/fetchLaunchpadFeeAmount.js.map +1 -0
  30. package/lib/src/chaincode/launchpad/finaliseSale.js +3 -3
  31. package/lib/src/chaincode/launchpad/finaliseSale.js.map +1 -1
  32. package/lib/src/chaincode/launchpad/sellExactToken.d.ts.map +1 -1
  33. package/lib/src/chaincode/launchpad/sellExactToken.js +3 -1
  34. package/lib/src/chaincode/launchpad/sellExactToken.js.map +1 -1
  35. package/lib/src/chaincode/launchpad/sellWithNative.d.ts.map +1 -1
  36. package/lib/src/chaincode/launchpad/sellWithNative.js +3 -1
  37. package/lib/src/chaincode/launchpad/sellWithNative.js.map +1 -1
  38. package/lib/tsconfig.tsbuildinfo +1 -1
  39. package/package.json +1 -1
  40. package/src/api/types/LaunchpadDtos.ts +11 -0
  41. package/src/chaincode/LaunchpadContract.ts +25 -5
  42. package/src/chaincode/launchpad/buyExactToken.spec.ts +222 -0
  43. package/src/chaincode/launchpad/buyExactToken.ts +19 -2
  44. package/src/chaincode/launchpad/buyWithNative.spec.ts +221 -0
  45. package/src/chaincode/launchpad/buyWithNative.ts +21 -3
  46. package/src/chaincode/launchpad/callMemeTokenOut.spec.ts +1 -1
  47. package/src/chaincode/launchpad/callMemeTokenOut.ts +1 -0
  48. package/src/chaincode/launchpad/callNativeTokenIn.ts +1 -0
  49. package/src/chaincode/launchpad/callNativeTokenOut.ts +1 -0
  50. package/src/chaincode/launchpad/fetchLaunchpadAdressConfig.ts +5 -2
  51. package/src/chaincode/launchpad/fetchLaunchpadFeeAmount.spec.ts +67 -0
  52. package/src/chaincode/launchpad/fetchLaunchpadFeeAmount.ts +40 -0
  53. package/src/chaincode/launchpad/finaliseSale.ts +3 -3
  54. package/src/chaincode/launchpad/sellExactToken.ts +3 -1
  55. package/src/chaincode/launchpad/sellWithNative.ts +3 -1
@@ -0,0 +1,67 @@
1
+ /*
2
+ * Copyright (c) Gala Games Inc. All rights reserved.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+ import { ChainCallDTO, GalaChainErrorResponse, NotFoundError } from "@gala-chain/api";
16
+ import { fixture, users } from "@gala-chain/test";
17
+ import { plainToInstance } from "class-transformer";
18
+
19
+ import { LaunchpadFeeConfig, TransactionFeeResDto } from "../../api/types";
20
+ import { LaunchpadContract } from "../LaunchpadContract";
21
+
22
+ describe("fetchLaunchpadFeeAmount", () => {
23
+ it("Should return the feeAmount when LaunchpadFeeConfig exists", async () => {
24
+ //Given
25
+ const launchpadConfig = new LaunchpadFeeConfig(users.testUser2.identityKey, Number("0.32"), [
26
+ users.testUser2.identityKey
27
+ ]);
28
+
29
+ const { ctx, contract } = fixture(LaunchpadContract)
30
+ .registeredUsers(users.testUser3)
31
+ .savedState(launchpadConfig);
32
+
33
+ const dto = new ChainCallDTO();
34
+
35
+ dto.sign(users.testUser3.privateKey);
36
+
37
+ //When
38
+ const res = await contract.FetchLaunchpadFeeAmount(ctx, dto);
39
+
40
+ const expectedRes = plainToInstance(TransactionFeeResDto, {
41
+ feeAmount: 0.32
42
+ });
43
+
44
+ //Then
45
+ expect(res.Data).toEqual(expectedRes);
46
+ });
47
+
48
+ it("Should revert when LaunchpadFeeConfig does not exists", async () => {
49
+ //Given
50
+
51
+ const { ctx, contract } = fixture(LaunchpadContract).registeredUsers(users.testUser3);
52
+
53
+ const dto = new ChainCallDTO();
54
+
55
+ dto.sign(users.testUser3.privateKey);
56
+
57
+ //When
58
+ const res = await contract.FetchLaunchpadFeeAmount(ctx, dto);
59
+
60
+ //Then
61
+ expect(res).toEqual(
62
+ new GalaChainErrorResponse(
63
+ new NotFoundError("Platform fee configuration has yet to be defined. Fee amount is not available.")
64
+ )
65
+ );
66
+ });
67
+ });
@@ -0,0 +1,40 @@
1
+ /*
2
+ * Copyright (c) Gala Games Inc. All rights reserved.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+ import { ChainCallDTO, NotFoundError } from "@gala-chain/api";
16
+ import { GalaChainContext } from "@gala-chain/chaincode";
17
+
18
+ import { TransactionFeeResDto } from "../../api/types";
19
+ import { fetchLaunchpadFeeAddress } from "../utils";
20
+
21
+ /**
22
+ * @dev The fetchLaunchpadFeeAmount function retrieves the configured fee amount
23
+ * for Launchpad transactions. If no fee configuration is found, it throws a NotFoundError.
24
+ * @param ctx GalaChainContext – The execution context providing access to the GalaChain environment.
25
+ * @returns TransactionFeeResDto – An object containing:
26
+ * - feeAmount – The configured transaction fee amount for Launchpad transactions.
27
+ */
28
+ export async function fetchLaunchpadFeeAmount(
29
+ ctx: GalaChainContext,
30
+ dto: ChainCallDTO
31
+ ): Promise<TransactionFeeResDto> {
32
+ const feeConfig = await fetchLaunchpadFeeAddress(ctx);
33
+
34
+ if (!feeConfig) {
35
+ throw new NotFoundError("Platform fee configuration has yet to be defined. Fee amount is not available.");
36
+ }
37
+ return {
38
+ feeAmount: feeConfig.feeAmount
39
+ };
40
+ }
@@ -51,9 +51,9 @@ export async function finalizeSale(ctx: GalaChainContext, sale: LaunchpadSale):
51
51
  throw new PreConditionFailedError("Platform fee configuration is yet to be defined.");
52
52
  }
53
53
 
54
- const platformFeePercentage = feeAllocation ? feeAllocation.platformFeePercentage : 0.1;
55
- const ownerAllocationPercentage = feeAllocation ? feeAllocation.ownerAllocationPercentage : 0.6;
56
- const liquidityAllocationPercentage = feeAllocation ? feeAllocation.liquidityAllocationPercentage : 0.3;
54
+ const platformFeePercentage = feeAllocation ? feeAllocation.platformFeePercentage : 0.01;
55
+ const ownerAllocationPercentage = feeAllocation ? feeAllocation.ownerAllocationPercentage : 0.5;
56
+ const liquidityAllocationPercentage = feeAllocation ? feeAllocation.liquidityAllocationPercentage : 0.94;
57
57
 
58
58
  const nativeToken = sale.fetchNativeTokenInstanceKey();
59
59
  const memeToken = sale.fetchSellingTokenInstanceKey();
@@ -132,6 +132,8 @@ export async function sellExactToken(
132
132
  vaultAddress: sellTokenDTO.vaultAddress,
133
133
  userAddress: ctx.callingUser,
134
134
  isFinalized: false,
135
- functionName: "SellExactToken"
135
+ functionName: "SellExactToken",
136
+ uniqueKey: sellTokenDTO.uniqueKey,
137
+ totalTokenSold: sale.fetchTokensSold()
136
138
  };
137
139
  }
@@ -131,6 +131,8 @@ export async function sellWithNative(
131
131
  vaultAddress: sellTokenDTO.vaultAddress,
132
132
  userAddress: ctx.callingUser,
133
133
  isFinalized: false,
134
- functionName: "SellWithNative"
134
+ functionName: "SellWithNative",
135
+ uniqueKey: sellTokenDTO.uniqueKey,
136
+ totalTokenSold: sale.fetchTokensSold()
135
137
  };
136
138
  }