@gala-chain/launchpad 1.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.
Files changed (200) hide show
  1. package/.dev-env +7 -0
  2. package/.dockerignore +9 -0
  3. package/.eslintignore +4 -0
  4. package/.eslintrc.json +37 -0
  5. package/.github/workflows/publish-on-tag.yml +72 -0
  6. package/.github/workflows/test-on-push.yml +32 -0
  7. package/.nvmrc +1 -0
  8. package/.prettierignore +4 -0
  9. package/.prettierrc +12 -0
  10. package/Dockerfile +31 -0
  11. package/LICENSE +201 -0
  12. package/README.md +2 -0
  13. package/api-config.json +16 -0
  14. package/e2e/__snapshots__/api.spec.ts.snap +2482 -0
  15. package/e2e/api-config.json +17 -0
  16. package/e2e/api.spec.ts +48 -0
  17. package/e2e/jest.config.js +42 -0
  18. package/e2e/tsconfig.json +10 -0
  19. package/jest.config.ts +27 -0
  20. package/lib/jest.config.d.ts +13 -0
  21. package/lib/jest.config.d.ts.map +1 -0
  22. package/lib/jest.config.js +28 -0
  23. package/lib/jest.config.js.map +1 -0
  24. package/lib/package.json +54 -0
  25. package/lib/src/api/index.d.ts +4 -0
  26. package/lib/src/api/index.d.ts.map +1 -0
  27. package/lib/src/api/index.js +21 -0
  28. package/lib/src/api/index.js.map +1 -0
  29. package/lib/src/api/types/LaunchpadDtos.d.ts +102 -0
  30. package/lib/src/api/types/LaunchpadDtos.d.ts.map +1 -0
  31. package/lib/src/api/types/LaunchpadDtos.js +410 -0
  32. package/lib/src/api/types/LaunchpadDtos.js.map +1 -0
  33. package/lib/src/api/types/LaunchpadFeeConfig.d.ts +9 -0
  34. package/lib/src/api/types/LaunchpadFeeConfig.d.ts.map +1 -0
  35. package/lib/src/api/types/LaunchpadFeeConfig.js +56 -0
  36. package/lib/src/api/types/LaunchpadFeeConfig.js.map +1 -0
  37. package/lib/src/api/types/LaunchpadFinalizeAllocation.d.ts +10 -0
  38. package/lib/src/api/types/LaunchpadFinalizeAllocation.d.ts.map +1 -0
  39. package/lib/src/api/types/LaunchpadFinalizeAllocation.js +70 -0
  40. package/lib/src/api/types/LaunchpadFinalizeAllocation.js.map +1 -0
  41. package/lib/src/api/types/LaunchpadSale.d.ts +35 -0
  42. package/lib/src/api/types/LaunchpadSale.d.ts.map +1 -0
  43. package/lib/src/api/types/LaunchpadSale.js +195 -0
  44. package/lib/src/api/types/LaunchpadSale.js.map +1 -0
  45. package/lib/src/api/types/index.d.ts +5 -0
  46. package/lib/src/api/types/index.d.ts.map +1 -0
  47. package/lib/src/api/types/index.js +22 -0
  48. package/lib/src/api/types/index.js.map +1 -0
  49. package/lib/src/api/utils/error.d.ts +20 -0
  50. package/lib/src/api/utils/error.d.ts.map +1 -0
  51. package/lib/src/api/utils/error.js +35 -0
  52. package/lib/src/api/utils/error.js.map +1 -0
  53. package/lib/src/api/utils/index.d.ts +2 -0
  54. package/lib/src/api/utils/index.d.ts.map +1 -0
  55. package/lib/src/api/utils/index.js +19 -0
  56. package/lib/src/api/utils/index.js.map +1 -0
  57. package/lib/src/api/validators/decorators.d.ts +19 -0
  58. package/lib/src/api/validators/decorators.d.ts.map +1 -0
  59. package/lib/src/api/validators/decorators.js +391 -0
  60. package/lib/src/api/validators/decorators.js.map +1 -0
  61. package/lib/src/api/validators/index.d.ts +2 -0
  62. package/lib/src/api/validators/index.d.ts.map +1 -0
  63. package/lib/src/api/validators/index.js +19 -0
  64. package/lib/src/api/validators/index.js.map +1 -0
  65. package/lib/src/chaincode/LaunchpadContract.d.ts +20 -0
  66. package/lib/src/chaincode/LaunchpadContract.d.ts.map +1 -0
  67. package/lib/src/chaincode/LaunchpadContract.js +217 -0
  68. package/lib/src/chaincode/LaunchpadContract.js.map +1 -0
  69. package/lib/src/chaincode/dexLaunchpadFeeGate.d.ts +14 -0
  70. package/lib/src/chaincode/dexLaunchpadFeeGate.d.ts.map +1 -0
  71. package/lib/src/chaincode/dexLaunchpadFeeGate.js +47 -0
  72. package/lib/src/chaincode/dexLaunchpadFeeGate.js.map +1 -0
  73. package/lib/src/chaincode/index.d.ts +2 -0
  74. package/lib/src/chaincode/index.d.ts.map +1 -0
  75. package/lib/src/chaincode/index.js +19 -0
  76. package/lib/src/chaincode/index.js.map +1 -0
  77. package/lib/src/chaincode/launchpad/buyExactToken.d.ts +20 -0
  78. package/lib/src/chaincode/launchpad/buyExactToken.d.ts.map +1 -0
  79. package/lib/src/chaincode/launchpad/buyExactToken.js +113 -0
  80. package/lib/src/chaincode/launchpad/buyExactToken.js.map +1 -0
  81. package/lib/src/chaincode/launchpad/buyWithNative.d.ts +22 -0
  82. package/lib/src/chaincode/launchpad/buyWithNative.d.ts.map +1 -0
  83. package/lib/src/chaincode/launchpad/buyWithNative.js +106 -0
  84. package/lib/src/chaincode/launchpad/buyWithNative.js.map +1 -0
  85. package/lib/src/chaincode/launchpad/callMemeTokenIn.d.ts +27 -0
  86. package/lib/src/chaincode/launchpad/callMemeTokenIn.d.ts.map +1 -0
  87. package/lib/src/chaincode/launchpad/callMemeTokenIn.js +76 -0
  88. package/lib/src/chaincode/launchpad/callMemeTokenIn.js.map +1 -0
  89. package/lib/src/chaincode/launchpad/callMemeTokenOut.d.ts +25 -0
  90. package/lib/src/chaincode/launchpad/callMemeTokenOut.d.ts.map +1 -0
  91. package/lib/src/chaincode/launchpad/callMemeTokenOut.js +56 -0
  92. package/lib/src/chaincode/launchpad/callMemeTokenOut.js.map +1 -0
  93. package/lib/src/chaincode/launchpad/callNativeTokenIn.d.ts +25 -0
  94. package/lib/src/chaincode/launchpad/callNativeTokenIn.d.ts.map +1 -0
  95. package/lib/src/chaincode/launchpad/callNativeTokenIn.js +51 -0
  96. package/lib/src/chaincode/launchpad/callNativeTokenIn.js.map +1 -0
  97. package/lib/src/chaincode/launchpad/callNativeTokenOut.d.ts +26 -0
  98. package/lib/src/chaincode/launchpad/callNativeTokenOut.d.ts.map +1 -0
  99. package/lib/src/chaincode/launchpad/callNativeTokenOut.js +60 -0
  100. package/lib/src/chaincode/launchpad/callNativeTokenOut.js.map +1 -0
  101. package/lib/src/chaincode/launchpad/configureLaunchpadFeeConfig.d.ts +4 -0
  102. package/lib/src/chaincode/launchpad/configureLaunchpadFeeConfig.d.ts.map +1 -0
  103. package/lib/src/chaincode/launchpad/configureLaunchpadFeeConfig.js +58 -0
  104. package/lib/src/chaincode/launchpad/configureLaunchpadFeeConfig.js.map +1 -0
  105. package/lib/src/chaincode/launchpad/createSale.d.ts +26 -0
  106. package/lib/src/chaincode/launchpad/createSale.d.ts.map +1 -0
  107. package/lib/src/chaincode/launchpad/createSale.js +129 -0
  108. package/lib/src/chaincode/launchpad/createSale.js.map +1 -0
  109. package/lib/src/chaincode/launchpad/fees.d.ts +6 -0
  110. package/lib/src/chaincode/launchpad/fees.d.ts.map +1 -0
  111. package/lib/src/chaincode/launchpad/fees.js +85 -0
  112. package/lib/src/chaincode/launchpad/fees.js.map +1 -0
  113. package/lib/src/chaincode/launchpad/fetchLaunchpadAdressConfig.d.ts +4 -0
  114. package/lib/src/chaincode/launchpad/fetchLaunchpadAdressConfig.d.ts.map +1 -0
  115. package/lib/src/chaincode/launchpad/fetchLaunchpadAdressConfig.js +36 -0
  116. package/lib/src/chaincode/launchpad/fetchLaunchpadAdressConfig.js.map +1 -0
  117. package/lib/src/chaincode/launchpad/fetchSaleDetails.d.ts +19 -0
  118. package/lib/src/chaincode/launchpad/fetchSaleDetails.d.ts.map +1 -0
  119. package/lib/src/chaincode/launchpad/fetchSaleDetails.js +49 -0
  120. package/lib/src/chaincode/launchpad/fetchSaleDetails.js.map +1 -0
  121. package/lib/src/chaincode/launchpad/finaliseSale.d.ts +4 -0
  122. package/lib/src/chaincode/launchpad/finaliseSale.d.ts.map +1 -0
  123. package/lib/src/chaincode/launchpad/finaliseSale.js +144 -0
  124. package/lib/src/chaincode/launchpad/finaliseSale.js.map +1 -0
  125. package/lib/src/chaincode/launchpad/finalizeTokenAllocation.d.ts +4 -0
  126. package/lib/src/chaincode/launchpad/finalizeTokenAllocation.d.ts.map +1 -0
  127. package/lib/src/chaincode/launchpad/finalizeTokenAllocation.js +43 -0
  128. package/lib/src/chaincode/launchpad/finalizeTokenAllocation.js.map +1 -0
  129. package/lib/src/chaincode/launchpad/index.d.ts +15 -0
  130. package/lib/src/chaincode/launchpad/index.d.ts.map +1 -0
  131. package/lib/src/chaincode/launchpad/index.js +32 -0
  132. package/lib/src/chaincode/launchpad/index.js.map +1 -0
  133. package/lib/src/chaincode/launchpad/preMintCalculation.d.ts +17 -0
  134. package/lib/src/chaincode/launchpad/preMintCalculation.d.ts.map +1 -0
  135. package/lib/src/chaincode/launchpad/preMintCalculation.js +56 -0
  136. package/lib/src/chaincode/launchpad/preMintCalculation.js.map +1 -0
  137. package/lib/src/chaincode/launchpad/sellExactToken.d.ts +22 -0
  138. package/lib/src/chaincode/launchpad/sellExactToken.d.ts.map +1 -0
  139. package/lib/src/chaincode/launchpad/sellExactToken.js +102 -0
  140. package/lib/src/chaincode/launchpad/sellExactToken.js.map +1 -0
  141. package/lib/src/chaincode/launchpad/sellWithNative.d.ts +23 -0
  142. package/lib/src/chaincode/launchpad/sellWithNative.d.ts.map +1 -0
  143. package/lib/src/chaincode/launchpad/sellWithNative.js +97 -0
  144. package/lib/src/chaincode/launchpad/sellWithNative.js.map +1 -0
  145. package/lib/src/chaincode/utils/index.d.ts +2 -0
  146. package/lib/src/chaincode/utils/index.d.ts.map +1 -0
  147. package/lib/src/chaincode/utils/index.js +19 -0
  148. package/lib/src/chaincode/utils/index.js.map +1 -0
  149. package/lib/src/chaincode/utils/launchpadSaleUtils.d.ts +11 -0
  150. package/lib/src/chaincode/utils/launchpadSaleUtils.d.ts.map +1 -0
  151. package/lib/src/chaincode/utils/launchpadSaleUtils.js +65 -0
  152. package/lib/src/chaincode/utils/launchpadSaleUtils.js.map +1 -0
  153. package/lib/src/cli.d.ts +3 -0
  154. package/lib/src/cli.d.ts.map +1 -0
  155. package/lib/src/cli.js +41 -0
  156. package/lib/src/cli.js.map +1 -0
  157. package/lib/src/index.d.ts +14 -0
  158. package/lib/src/index.d.ts.map +1 -0
  159. package/lib/src/index.js +32 -0
  160. package/lib/src/index.js.map +1 -0
  161. package/lib/tsconfig.tsbuildinfo +1 -0
  162. package/package.json +54 -0
  163. package/src/api/index.ts +18 -0
  164. package/src/api/types/LaunchpadDtos.ts +362 -0
  165. package/src/api/types/LaunchpadFeeConfig.ts +45 -0
  166. package/src/api/types/LaunchpadFinalizeAllocation.ts +65 -0
  167. package/src/api/types/LaunchpadSale.ts +200 -0
  168. package/src/api/types/index.ts +19 -0
  169. package/src/api/utils/error.ts +32 -0
  170. package/src/api/utils/index.ts +16 -0
  171. package/src/api/validators/decorators.spec.ts +277 -0
  172. package/src/api/validators/decorators.ts +401 -0
  173. package/src/api/validators/index.ts +16 -0
  174. package/src/chaincode/LaunchpadContract.ts +211 -0
  175. package/src/chaincode/dexLaunchpadFeeGate.ts +43 -0
  176. package/src/chaincode/index.ts +16 -0
  177. package/src/chaincode/launchpad/buyExactToken.ts +128 -0
  178. package/src/chaincode/launchpad/buyWithNative.ts +120 -0
  179. package/src/chaincode/launchpad/callMemeTokenIn.ts +82 -0
  180. package/src/chaincode/launchpad/callMemeTokenOut.ts +80 -0
  181. package/src/chaincode/launchpad/callNativeTokenIn.ts +71 -0
  182. package/src/chaincode/launchpad/callNativeTokenOut.ts +81 -0
  183. package/src/chaincode/launchpad/configureLaunchpadFeeConfig.ts +69 -0
  184. package/src/chaincode/launchpad/createSale.ts +157 -0
  185. package/src/chaincode/launchpad/fees.ts +105 -0
  186. package/src/chaincode/launchpad/fetchLaunchpadAdressConfig.ts +38 -0
  187. package/src/chaincode/launchpad/fetchSaleDetails.ts +53 -0
  188. package/src/chaincode/launchpad/finaliseSale.ts +217 -0
  189. package/src/chaincode/launchpad/finalizeTokenAllocation.ts +47 -0
  190. package/src/chaincode/launchpad/index.ts +28 -0
  191. package/src/chaincode/launchpad/preMintCalculation.ts +61 -0
  192. package/src/chaincode/launchpad/sellExactToken.ts +122 -0
  193. package/src/chaincode/launchpad/sellWithNative.ts +112 -0
  194. package/src/chaincode/utils/index.ts +15 -0
  195. package/src/chaincode/utils/launchpadSaleUtils.ts +68 -0
  196. package/src/cli.ts +63 -0
  197. package/src/index.ts +32 -0
  198. package/tsconfig.base.json +29 -0
  199. package/tsconfig.json +19 -0
  200. package/tsconfig.spec.json +11 -0
@@ -0,0 +1,217 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LaunchpadContract = void 0;
4
+ const tslib_1 = require("tslib");
5
+ /*
6
+ * Copyright (c) Gala Games Inc. All rights reserved.
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ const chaincode_1 = require("@gala-chain/chaincode");
20
+ const package_json_1 = require("../../package.json");
21
+ const types_1 = require("../api/types");
22
+ const dexLaunchpadFeeGate_1 = require("./dexLaunchpadFeeGate");
23
+ const launchpad_1 = require("./launchpad");
24
+ class LaunchpadContract extends chaincode_1.GalaContract {
25
+ constructor() {
26
+ super("Launchpad", package_json_1.version);
27
+ }
28
+ async CreateSale(ctx, dto) {
29
+ return (0, launchpad_1.createSale)(ctx, dto);
30
+ }
31
+ async FetchSaleDetails(ctx, dto) {
32
+ return (0, launchpad_1.fetchSaleDetails)(ctx, dto);
33
+ }
34
+ async BuyExactToken(ctx, dto) {
35
+ return (0, launchpad_1.buyExactToken)(ctx, dto);
36
+ }
37
+ async SellExactToken(ctx, dto) {
38
+ return (0, launchpad_1.sellExactToken)(ctx, dto);
39
+ }
40
+ async BuyWithNative(ctx, dto) {
41
+ return (0, launchpad_1.buyWithNative)(ctx, dto);
42
+ }
43
+ async SellWithNative(ctx, dto) {
44
+ return (0, launchpad_1.sellWithNative)(ctx, dto);
45
+ }
46
+ async ConfigureLaunchpadFeeAddress(ctx, dto) {
47
+ return (0, launchpad_1.configureLaunchpadFeeAddress)(ctx, dto);
48
+ }
49
+ async FinalizeTokenAllocation(ctx, dto) {
50
+ return (0, launchpad_1.finalizeTokenAllocation)(ctx, dto);
51
+ }
52
+ async CallNativeTokenIn(ctx, dto) {
53
+ return (0, launchpad_1.callNativeTokenIn)(ctx, dto);
54
+ }
55
+ async CallMemeTokenOut(ctx, dto) {
56
+ return (0, launchpad_1.callMemeTokenOut)(ctx, dto);
57
+ }
58
+ async CallNativeTokenOut(ctx, dto) {
59
+ return (0, launchpad_1.callNativeTokenOut)(ctx, dto);
60
+ }
61
+ async CallMemeTokenIn(ctx, dto) {
62
+ return (0, launchpad_1.callMemeTokenIn)(ctx, dto);
63
+ }
64
+ async CalculatePreMintTokens(dto) {
65
+ return (0, launchpad_1.calculatePreMintTokens)(dto);
66
+ }
67
+ async FetchLaunchpadFeeConfig(ctx) {
68
+ return (0, launchpad_1.fetchLaunchpadFeeConfig)(ctx);
69
+ }
70
+ }
71
+ exports.LaunchpadContract = LaunchpadContract;
72
+ tslib_1.__decorate([
73
+ (0, chaincode_1.Submit)({
74
+ in: types_1.CreateTokenSaleDTO,
75
+ out: types_1.CreateSaleResDto,
76
+ before: dexLaunchpadFeeGate_1.createSaleFeeGate
77
+ }),
78
+ tslib_1.__metadata("design:type", Function),
79
+ tslib_1.__metadata("design:paramtypes", [chaincode_1.GalaChainContext, types_1.CreateTokenSaleDTO]),
80
+ tslib_1.__metadata("design:returntype", Promise)
81
+ ], LaunchpadContract.prototype, "CreateSale", null);
82
+ tslib_1.__decorate([
83
+ (0, chaincode_1.GalaTransaction)({
84
+ type: chaincode_1.EVALUATE,
85
+ in: types_1.FetchSaleDto,
86
+ out: types_1.LaunchpadSale
87
+ }),
88
+ tslib_1.__metadata("design:type", Function),
89
+ tslib_1.__metadata("design:paramtypes", [chaincode_1.GalaChainContext, types_1.FetchSaleDto]),
90
+ tslib_1.__metadata("design:returntype", Promise)
91
+ ], LaunchpadContract.prototype, "FetchSaleDetails", null);
92
+ tslib_1.__decorate([
93
+ (0, chaincode_1.Submit)({
94
+ in: types_1.ExactTokenQuantityDto,
95
+ out: types_1.TradeResDto,
96
+ before: dexLaunchpadFeeGate_1.buyExactTokenFeeGate
97
+ }),
98
+ tslib_1.__metadata("design:type", Function),
99
+ tslib_1.__metadata("design:paramtypes", [chaincode_1.GalaChainContext, types_1.ExactTokenQuantityDto]),
100
+ tslib_1.__metadata("design:returntype", Promise)
101
+ ], LaunchpadContract.prototype, "BuyExactToken", null);
102
+ tslib_1.__decorate([
103
+ (0, chaincode_1.Submit)({
104
+ in: types_1.ExactTokenQuantityDto,
105
+ out: types_1.TradeResDto,
106
+ before: dexLaunchpadFeeGate_1.sellExactTokenFeeGate
107
+ }),
108
+ tslib_1.__metadata("design:type", Function),
109
+ tslib_1.__metadata("design:paramtypes", [chaincode_1.GalaChainContext, types_1.ExactTokenQuantityDto]),
110
+ tslib_1.__metadata("design:returntype", Promise)
111
+ ], LaunchpadContract.prototype, "SellExactToken", null);
112
+ tslib_1.__decorate([
113
+ (0, chaincode_1.Submit)({
114
+ in: types_1.NativeTokenQuantityDto,
115
+ out: types_1.TradeResDto,
116
+ before: dexLaunchpadFeeGate_1.buyWithNativeFeeGate
117
+ }),
118
+ tslib_1.__metadata("design:type", Function),
119
+ tslib_1.__metadata("design:paramtypes", [chaincode_1.GalaChainContext, types_1.NativeTokenQuantityDto]),
120
+ tslib_1.__metadata("design:returntype", Promise)
121
+ ], LaunchpadContract.prototype, "BuyWithNative", null);
122
+ tslib_1.__decorate([
123
+ (0, chaincode_1.Submit)({
124
+ in: types_1.NativeTokenQuantityDto,
125
+ out: types_1.TradeResDto,
126
+ before: dexLaunchpadFeeGate_1.sellWithNativeFeeGate
127
+ }),
128
+ tslib_1.__metadata("design:type", Function),
129
+ tslib_1.__metadata("design:paramtypes", [chaincode_1.GalaChainContext, types_1.NativeTokenQuantityDto]),
130
+ tslib_1.__metadata("design:returntype", Promise)
131
+ ], LaunchpadContract.prototype, "SellWithNative", null);
132
+ tslib_1.__decorate([
133
+ (0, chaincode_1.Submit)({
134
+ in: types_1.ConfigureLaunchpadFeeAddressDto,
135
+ out: types_1.LaunchpadFeeConfig,
136
+ allowedOrgs: ["CuratorOrg"]
137
+ }),
138
+ tslib_1.__metadata("design:type", Function),
139
+ tslib_1.__metadata("design:paramtypes", [chaincode_1.GalaChainContext,
140
+ types_1.ConfigureLaunchpadFeeAddressDto]),
141
+ tslib_1.__metadata("design:returntype", Promise)
142
+ ], LaunchpadContract.prototype, "ConfigureLaunchpadFeeAddress", null);
143
+ tslib_1.__decorate([
144
+ (0, chaincode_1.Submit)({
145
+ in: types_1.FinalizeTokenAllocationDto,
146
+ out: types_1.LaunchpadFinalizeFeeAllocation,
147
+ allowedOrgs: ["CuratorOrg"]
148
+ }),
149
+ tslib_1.__metadata("design:type", Function),
150
+ tslib_1.__metadata("design:paramtypes", [chaincode_1.GalaChainContext,
151
+ types_1.FinalizeTokenAllocationDto]),
152
+ tslib_1.__metadata("design:returntype", Promise)
153
+ ], LaunchpadContract.prototype, "FinalizeTokenAllocation", null);
154
+ tslib_1.__decorate([
155
+ (0, chaincode_1.GalaTransaction)({
156
+ type: chaincode_1.EVALUATE,
157
+ in: types_1.ExactTokenQuantityDto,
158
+ out: types_1.TradeCalculationResDto
159
+ }),
160
+ tslib_1.__metadata("design:type", Function),
161
+ tslib_1.__metadata("design:paramtypes", [chaincode_1.GalaChainContext,
162
+ types_1.ExactTokenQuantityDto]),
163
+ tslib_1.__metadata("design:returntype", Promise)
164
+ ], LaunchpadContract.prototype, "CallNativeTokenIn", null);
165
+ tslib_1.__decorate([
166
+ (0, chaincode_1.GalaTransaction)({
167
+ type: chaincode_1.EVALUATE,
168
+ in: types_1.NativeTokenQuantityDto,
169
+ out: types_1.TradeCalculationResDto
170
+ }),
171
+ tslib_1.__metadata("design:type", Function),
172
+ tslib_1.__metadata("design:paramtypes", [chaincode_1.GalaChainContext,
173
+ types_1.NativeTokenQuantityDto]),
174
+ tslib_1.__metadata("design:returntype", Promise)
175
+ ], LaunchpadContract.prototype, "CallMemeTokenOut", null);
176
+ tslib_1.__decorate([
177
+ (0, chaincode_1.GalaTransaction)({
178
+ type: chaincode_1.EVALUATE,
179
+ in: types_1.ExactTokenQuantityDto,
180
+ out: types_1.TradeCalculationResDto
181
+ }),
182
+ tslib_1.__metadata("design:type", Function),
183
+ tslib_1.__metadata("design:paramtypes", [chaincode_1.GalaChainContext,
184
+ types_1.ExactTokenQuantityDto]),
185
+ tslib_1.__metadata("design:returntype", Promise)
186
+ ], LaunchpadContract.prototype, "CallNativeTokenOut", null);
187
+ tslib_1.__decorate([
188
+ (0, chaincode_1.GalaTransaction)({
189
+ type: chaincode_1.EVALUATE,
190
+ in: types_1.NativeTokenQuantityDto,
191
+ out: types_1.TradeCalculationResDto
192
+ }),
193
+ tslib_1.__metadata("design:type", Function),
194
+ tslib_1.__metadata("design:paramtypes", [chaincode_1.GalaChainContext,
195
+ types_1.NativeTokenQuantityDto]),
196
+ tslib_1.__metadata("design:returntype", Promise)
197
+ ], LaunchpadContract.prototype, "CallMemeTokenIn", null);
198
+ tslib_1.__decorate([
199
+ (0, chaincode_1.GalaTransaction)({
200
+ type: chaincode_1.EVALUATE,
201
+ in: types_1.PreMintCalculationDto,
202
+ out: String
203
+ }),
204
+ tslib_1.__metadata("design:type", Function),
205
+ tslib_1.__metadata("design:paramtypes", [types_1.PreMintCalculationDto]),
206
+ tslib_1.__metadata("design:returntype", Promise)
207
+ ], LaunchpadContract.prototype, "CalculatePreMintTokens", null);
208
+ tslib_1.__decorate([
209
+ (0, chaincode_1.Evaluate)({
210
+ out: types_1.LaunchpadFeeConfig,
211
+ allowedOrgs: ["CuratorOrg"]
212
+ }),
213
+ tslib_1.__metadata("design:type", Function),
214
+ tslib_1.__metadata("design:paramtypes", [chaincode_1.GalaChainContext]),
215
+ tslib_1.__metadata("design:returntype", Promise)
216
+ ], LaunchpadContract.prototype, "FetchLaunchpadFeeConfig", null);
217
+ //# sourceMappingURL=LaunchpadContract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LaunchpadContract.js","sourceRoot":"","sources":["../../../src/chaincode/LaunchpadContract.ts"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;GAaG;AACH,qDAO+B;AAE/B,qDAA6C;AAC7C,wCAcsB;AACtB,+DAM+B;AAC/B,2CAeqB;AAErB,MAAa,iBAAkB,SAAQ,wBAAY;IACjD;QACE,KAAK,CAAC,WAAW,EAAE,sBAAO,CAAC,CAAC;IAC9B,CAAC;IAOY,AAAN,KAAK,CAAC,UAAU,CAAC,GAAqB,EAAE,GAAuB;QACpE,OAAO,IAAA,sBAAU,EAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC9B,CAAC;IAOY,AAAN,KAAK,CAAC,gBAAgB,CAAC,GAAqB,EAAE,GAAiB;QACpE,OAAO,IAAA,4BAAgB,EAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACpC,CAAC;IAOY,AAAN,KAAK,CAAC,aAAa,CAAC,GAAqB,EAAE,GAA0B;QAC1E,OAAO,IAAA,yBAAa,EAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACjC,CAAC;IAOY,AAAN,KAAK,CAAC,cAAc,CAAC,GAAqB,EAAE,GAA0B;QAC3E,OAAO,IAAA,0BAAc,EAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAClC,CAAC;IAOY,AAAN,KAAK,CAAC,aAAa,CAAC,GAAqB,EAAE,GAA2B;QAC3E,OAAO,IAAA,yBAAa,EAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACjC,CAAC;IAOY,AAAN,KAAK,CAAC,cAAc,CAAC,GAAqB,EAAE,GAA2B;QAC5E,OAAO,IAAA,0BAAc,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,EAAE,oBAAQ;QACd,EAAE,EAAE,6BAAqB;QACzB,GAAG,EAAE,8BAAsB;KAC5B,CAAC;;6CAEK,4BAAgB;QAChB,6BAAqB;;0DAG3B;AAOY;IALZ,IAAA,2BAAe,EAAC;QACf,IAAI,EAAE,oBAAQ;QACd,EAAE,EAAE,8BAAsB;QAC1B,GAAG,EAAE,8BAAsB;KAC5B,CAAC;;6CAEK,4BAAgB;QAChB,8BAAsB;;yDAG5B;AAOY;IALZ,IAAA,2BAAe,EAAC;QACf,IAAI,EAAE,oBAAQ;QACd,EAAE,EAAE,6BAAqB;QACzB,GAAG,EAAE,8BAAsB;KAC5B,CAAC;;6CAEK,4BAAgB;QAChB,6BAAqB;;2DAG3B;AAOY;IALZ,IAAA,2BAAe,EAAC;QACf,IAAI,EAAE,oBAAQ;QACd,EAAE,EAAE,8BAAsB;QAC1B,GAAG,EAAE,8BAAsB;KAC5B,CAAC;;6CAEK,4BAAgB;QAChB,8BAAsB;;wDAG5B;AAOY;IALZ,IAAA,2BAAe,EAAC;QACf,IAAI,EAAE,oBAAQ;QACd,EAAE,EAAE,6BAAqB;QACzB,GAAG,EAAE,MAAM;KACZ,CAAC;;6CACuC,6BAAqB;;+DAE7D;AAMY;IAJZ,IAAA,oBAAQ,EAAC;QACR,GAAG,EAAE,0BAAkB;QACvB,WAAW,EAAE,CAAC,YAAY,CAAC;KAC5B,CAAC;;6CACwC,4BAAgB;;gEAEzD"}
@@ -0,0 +1,14 @@
1
+ import { GalaChainContext } from "@gala-chain/chaincode";
2
+ export declare enum FeeGateCodes {
3
+ CreateSale = "CreateSale",
4
+ BuyExactToken = "BuyExactToken",
5
+ SellExactToken = "SellExactToken",
6
+ BuyWithNative = "BuyWithNative",
7
+ SellWithNative = "SellWithNative"
8
+ }
9
+ export declare function createSaleFeeGate(ctx: GalaChainContext): Promise<void>;
10
+ export declare function buyExactTokenFeeGate(ctx: GalaChainContext): Promise<void>;
11
+ export declare function sellExactTokenFeeGate(ctx: GalaChainContext): Promise<void>;
12
+ export declare function buyWithNativeFeeGate(ctx: GalaChainContext): Promise<void>;
13
+ export declare function sellWithNativeFeeGate(ctx: GalaChainContext): Promise<void>;
14
+ //# sourceMappingURL=dexLaunchpadFeeGate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dexLaunchpadFeeGate.d.ts","sourceRoot":"","sources":["../../../src/chaincode/dexLaunchpadFeeGate.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,gBAAgB,EAAe,MAAM,uBAAuB,CAAC;AAEtE,oBAAY,YAAY;IACtB,UAAU,eAAe;IACzB,aAAa,kBAAkB;IAC/B,cAAc,mBAAmB;IACjC,aAAa,kBAAkB;IAC/B,cAAc,mBAAmB;CAClC;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,iBAE5D;AAED,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,gBAAgB,iBAE/D;AAED,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,gBAAgB,iBAEhE;AAED,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,gBAAgB,iBAE/D;AAED,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,gBAAgB,iBAEhE"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sellWithNativeFeeGate = exports.buyWithNativeFeeGate = exports.sellExactTokenFeeGate = exports.buyExactTokenFeeGate = exports.createSaleFeeGate = exports.FeeGateCodes = void 0;
4
+ /*
5
+ * Copyright (c) Gala Games Inc. All rights reserved.
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ const chaincode_1 = require("@gala-chain/chaincode");
19
+ var FeeGateCodes;
20
+ (function (FeeGateCodes) {
21
+ FeeGateCodes["CreateSale"] = "CreateSale";
22
+ FeeGateCodes["BuyExactToken"] = "BuyExactToken";
23
+ FeeGateCodes["SellExactToken"] = "SellExactToken";
24
+ FeeGateCodes["BuyWithNative"] = "BuyWithNative";
25
+ FeeGateCodes["SellWithNative"] = "SellWithNative";
26
+ })(FeeGateCodes || (exports.FeeGateCodes = FeeGateCodes = {}));
27
+ async function createSaleFeeGate(ctx) {
28
+ return (0, chaincode_1.galaFeeGate)(ctx, { feeCode: FeeGateCodes.CreateSale });
29
+ }
30
+ exports.createSaleFeeGate = createSaleFeeGate;
31
+ async function buyExactTokenFeeGate(ctx) {
32
+ return (0, chaincode_1.galaFeeGate)(ctx, { feeCode: FeeGateCodes.BuyExactToken });
33
+ }
34
+ exports.buyExactTokenFeeGate = buyExactTokenFeeGate;
35
+ async function sellExactTokenFeeGate(ctx) {
36
+ return (0, chaincode_1.galaFeeGate)(ctx, { feeCode: FeeGateCodes.SellExactToken });
37
+ }
38
+ exports.sellExactTokenFeeGate = sellExactTokenFeeGate;
39
+ async function buyWithNativeFeeGate(ctx) {
40
+ return (0, chaincode_1.galaFeeGate)(ctx, { feeCode: FeeGateCodes.BuyWithNative });
41
+ }
42
+ exports.buyWithNativeFeeGate = buyWithNativeFeeGate;
43
+ async function sellWithNativeFeeGate(ctx) {
44
+ return (0, chaincode_1.galaFeeGate)(ctx, { feeCode: FeeGateCodes.SellWithNative });
45
+ }
46
+ exports.sellWithNativeFeeGate = sellWithNativeFeeGate;
47
+ //# sourceMappingURL=dexLaunchpadFeeGate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dexLaunchpadFeeGate.js","sourceRoot":"","sources":["../../../src/chaincode/dexLaunchpadFeeGate.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;GAaG;AACH,qDAAsE;AAEtE,IAAY,YAMX;AAND,WAAY,YAAY;IACtB,yCAAyB,CAAA;IACzB,+CAA+B,CAAA;IAC/B,iDAAiC,CAAA;IACjC,+CAA+B,CAAA;IAC/B,iDAAiC,CAAA;AACnC,CAAC,EANW,YAAY,4BAAZ,YAAY,QAMvB;AAEM,KAAK,UAAU,iBAAiB,CAAC,GAAqB;IAC3D,OAAO,IAAA,uBAAW,EAAC,GAAG,EAAE,EAAE,OAAO,EAAE,YAAY,CAAC,UAAU,EAAE,CAAC,CAAC;AAChE,CAAC;AAFD,8CAEC;AAEM,KAAK,UAAU,oBAAoB,CAAC,GAAqB;IAC9D,OAAO,IAAA,uBAAW,EAAC,GAAG,EAAE,EAAE,OAAO,EAAE,YAAY,CAAC,aAAa,EAAE,CAAC,CAAC;AACnE,CAAC;AAFD,oDAEC;AAEM,KAAK,UAAU,qBAAqB,CAAC,GAAqB;IAC/D,OAAO,IAAA,uBAAW,EAAC,GAAG,EAAE,EAAE,OAAO,EAAE,YAAY,CAAC,cAAc,EAAE,CAAC,CAAC;AACpE,CAAC;AAFD,sDAEC;AAEM,KAAK,UAAU,oBAAoB,CAAC,GAAqB;IAC9D,OAAO,IAAA,uBAAW,EAAC,GAAG,EAAE,EAAE,OAAO,EAAE,YAAY,CAAC,aAAa,EAAE,CAAC,CAAC;AACnE,CAAC;AAFD,oDAEC;AAEM,KAAK,UAAU,qBAAqB,CAAC,GAAqB;IAC/D,OAAO,IAAA,uBAAW,EAAC,GAAG,EAAE,EAAE,OAAO,EAAE,YAAY,CAAC,cAAc,EAAE,CAAC,CAAC;AACpE,CAAC;AAFD,sDAEC"}
@@ -0,0 +1,2 @@
1
+ export * from "./LaunchpadContract";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chaincode/index.ts"],"names":[],"mappings":"AAeA,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) Gala Games Inc. All rights reserved.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ const tslib_1 = require("tslib");
18
+ tslib_1.__exportStar(require("./LaunchpadContract"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/chaincode/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAEH,8DAAoC"}
@@ -0,0 +1,20 @@
1
+ import { GalaChainContext } from "@gala-chain/chaincode";
2
+ import { ExactTokenQuantityDto, TradeResDto } from "../../api/types";
3
+ /**
4
+ * Executes the purchase of an exact amount of tokens in a token sale.
5
+ *
6
+ * This function validates the sale, calculates the required native tokens,
7
+ * and performs the token transfer to complete the purchase. If the purchase
8
+ * consumes all tokens in the sale, the sale is marked as finalized.
9
+ *
10
+ * @param ctx - The context object providing access to the GalaChain environment.
11
+ * @param buyTokenDTO - The data transfer object containing the sale address,
12
+ * token amount to buy, and optional expected native token amount.
13
+ *
14
+ * @returns A promise that resolves to a `TradeResDto` containing the updated
15
+ * balances of the purchased token and the native token for the buyer.
16
+ *
17
+ * @throws DefaultError if the expected native tokens are insufficient to complete the purchase.
18
+ */
19
+ export declare function buyExactToken(ctx: GalaChainContext, buyTokenDTO: ExactTokenQuantityDto): Promise<TradeResDto>;
20
+ //# sourceMappingURL=buyExactToken.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buyExactToken.d.ts","sourceRoot":"","sources":["../../../../src/chaincode/launchpad/buyExactToken.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,gBAAgB,EAAkD,MAAM,uBAAuB,CAAC;AAGzG,OAAO,EAAE,qBAAqB,EAAiB,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAUpF;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,gBAAgB,EACrB,WAAW,EAAE,qBAAqB,GACjC,OAAO,CAAC,WAAW,CAAC,CAiFtB"}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buyExactToken = void 0;
4
+ /*
5
+ * Copyright (c) Gala Games Inc. All rights reserved.
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ const chaincode_1 = require("@gala-chain/chaincode");
19
+ const bignumber_js_1 = require("bignumber.js");
20
+ const types_1 = require("../../api/types");
21
+ const error_1 = require("../../api/utils/error");
22
+ const utils_1 = require("../utils");
23
+ const callNativeTokenIn_1 = require("./callNativeTokenIn");
24
+ const finaliseSale_1 = require("./finaliseSale");
25
+ bignumber_js_1.BigNumber.config({
26
+ ROUNDING_MODE: bignumber_js_1.BigNumber.ROUND_UP
27
+ });
28
+ /**
29
+ * Executes the purchase of an exact amount of tokens in a token sale.
30
+ *
31
+ * This function validates the sale, calculates the required native tokens,
32
+ * and performs the token transfer to complete the purchase. If the purchase
33
+ * consumes all tokens in the sale, the sale is marked as finalized.
34
+ *
35
+ * @param ctx - The context object providing access to the GalaChain environment.
36
+ * @param buyTokenDTO - The data transfer object containing the sale address,
37
+ * token amount to buy, and optional expected native token amount.
38
+ *
39
+ * @returns A promise that resolves to a `TradeResDto` containing the updated
40
+ * balances of the purchased token and the native token for the buyer.
41
+ *
42
+ * @throws DefaultError if the expected native tokens are insufficient to complete the purchase.
43
+ */
44
+ async function buyExactToken(ctx, buyTokenDTO) {
45
+ let isSaleFinalized = false;
46
+ // Fetch and validate the sale based on the provided vault address
47
+ const sale = await (0, utils_1.fetchAndValidateSale)(ctx, buyTokenDTO.vaultAddress);
48
+ const tokenLeftInVault = new bignumber_js_1.BigNumber(sale.sellingTokenQuantity);
49
+ // Calculate the required amount of native tokens to buy the specified token amount
50
+ const callNativeTokenInResult1 = await (0, callNativeTokenIn_1.callNativeTokenIn)(ctx, buyTokenDTO);
51
+ let nativeTokensToBuy = new bignumber_js_1.BigNumber(callNativeTokenInResult1.calculatedQuantity);
52
+ const nativeToken = sale.fetchNativeTokenInstanceKey();
53
+ const memeToken = sale.fetchSellingTokenInstanceKey();
54
+ // If the requested token amount exceeds what's available, adjust it and recalculate native tokens needed
55
+ if (tokenLeftInVault.lte(buyTokenDTO.tokenQuantity)) {
56
+ buyTokenDTO.tokenQuantity = tokenLeftInVault;
57
+ const callNativeTokenInResult2 = await (0, callNativeTokenIn_1.callNativeTokenIn)(ctx, buyTokenDTO);
58
+ nativeTokensToBuy = new bignumber_js_1.BigNumber(callNativeTokenInResult2.calculatedQuantity);
59
+ isSaleFinalized = true;
60
+ }
61
+ // Check if the native tokens used exceed the market cap, finalizing the sale if true
62
+ if (nativeTokensToBuy
63
+ .plus(new bignumber_js_1.BigNumber(sale.nativeTokenQuantity))
64
+ .gte(new bignumber_js_1.BigNumber(types_1.LaunchpadSale.MARKET_CAP))) {
65
+ isSaleFinalized = true;
66
+ }
67
+ // Ensure the expected native token amount is not less than the actual amount required
68
+ if (buyTokenDTO.expectedNativeToken && buyTokenDTO.expectedNativeToken.comparedTo(nativeTokensToBuy) < 0) {
69
+ throw new error_1.SlippageToleranceExceededError("Gala tokens expected to perform this operation are less than the actual amount required.");
70
+ }
71
+ // Transfer native tokens from the buyer to the vault
72
+ await (0, chaincode_1.transferToken)(ctx, {
73
+ from: ctx.callingUser,
74
+ to: buyTokenDTO.vaultAddress,
75
+ tokenInstanceKey: nativeToken,
76
+ quantity: nativeTokensToBuy,
77
+ allowancesToUse: [],
78
+ authorizedOnBehalf: undefined
79
+ });
80
+ // Transfer meme tokens from the vault to the buyer
81
+ await (0, chaincode_1.transferToken)(ctx, {
82
+ from: buyTokenDTO.vaultAddress,
83
+ to: ctx.callingUser,
84
+ tokenInstanceKey: memeToken,
85
+ quantity: buyTokenDTO.tokenQuantity,
86
+ allowancesToUse: [],
87
+ authorizedOnBehalf: {
88
+ callingOnBehalf: buyTokenDTO.vaultAddress,
89
+ callingUser: ctx.callingUser
90
+ }
91
+ });
92
+ // Update the sale record with the purchased token details
93
+ sale.buyToken(buyTokenDTO.tokenQuantity, nativeTokensToBuy);
94
+ await (0, chaincode_1.putChainObject)(ctx, sale);
95
+ // If the sale is finalized, create a V3 pool and add liquidity
96
+ if (isSaleFinalized) {
97
+ await (0, finaliseSale_1.finalizeSale)(ctx, sale);
98
+ }
99
+ // Return the updated balance response
100
+ const token = await (0, chaincode_1.fetchTokenClass)(ctx, sale.sellingToken);
101
+ return {
102
+ inputQuantity: nativeTokensToBuy.toFixed(),
103
+ outputQuantity: buyTokenDTO.tokenQuantity.toFixed(),
104
+ tokenName: token.name,
105
+ tradeType: "Buy",
106
+ vaultAddress: buyTokenDTO.vaultAddress,
107
+ userAddress: ctx.callingUser,
108
+ isFinalized: isSaleFinalized,
109
+ functionName: "BuyExactToken"
110
+ };
111
+ }
112
+ exports.buyExactToken = buyExactToken;
113
+ //# sourceMappingURL=buyExactToken.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buyExactToken.js","sourceRoot":"","sources":["../../../../src/chaincode/launchpad/buyExactToken.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;GAaG;AACH,qDAAyG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EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC5D,OAAO;QACL,aAAa,EAAE,iBAAiB,CAAC,OAAO,EAAE;QAC1C,cAAc,EAAE,WAAW,CAAC,aAAa,CAAC,OAAO,EAAE;QACnD,SAAS,EAAE,KAAK,CAAC,IAAI;QACrB,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,WAAW,CAAC,YAAY;QACtC,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,WAAW,EAAE,eAAe;QAC5B,YAAY,EAAE,eAAe;KAC9B,CAAC;AACJ,CAAC;AApFD,sCAoFC"}
@@ -0,0 +1,22 @@
1
+ import { GalaChainContext } from "@gala-chain/chaincode";
2
+ import { NativeTokenQuantityDto, TradeResDto } from "../../api/types";
3
+ /**
4
+ * Executes the purchase of tokens using a specified amount of native tokens.
5
+ *
6
+ * This function validates the sale, calculates the amount of tokens that can
7
+ * be purchased with the provided native tokens, and performs the token transfer
8
+ * to complete the purchase. If the purchase consumes all tokens in the sale,
9
+ * the sale is marked as finalized.
10
+ *
11
+ * @param ctx - The context object providing access to the GalaChain environment.
12
+ * @param buyTokenDTO - The data transfer object containing the sale address,
13
+ * native token amount to spend, and optional expected token amount.
14
+ *
15
+ * @returns A promise that resolves to a `TradeResDto` containing the updated
16
+ * balances of the purchased token and the native token for the buyer.
17
+ *
18
+ * @throws DefaultError if the expected tokens to be received are less than the
19
+ * actual amount provided by the operation.
20
+ */
21
+ export declare function buyWithNative(ctx: GalaChainContext, buyTokenDTO: NativeTokenQuantityDto): Promise<TradeResDto>;
22
+ //# sourceMappingURL=buyWithNative.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buyWithNative.d.ts","sourceRoot":"","sources":["../../../../src/chaincode/launchpad/buyWithNative.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,gBAAgB,EAAkD,MAAM,uBAAuB,CAAC;AAGzG,OAAO,EAAwC,sBAAsB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAW5G;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,gBAAgB,EACrB,WAAW,EAAE,sBAAsB,GAClC,OAAO,CAAC,WAAW,CAAC,CAsEtB"}
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buyWithNative = void 0;
4
+ /*
5
+ * Copyright (c) Gala Games Inc. All rights reserved.
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ const chaincode_1 = require("@gala-chain/chaincode");
19
+ const bignumber_js_1 = require("bignumber.js");
20
+ const types_1 = require("../../api/types");
21
+ const error_1 = require("../../api/utils/error");
22
+ const utils_1 = require("../utils");
23
+ const callMemeTokenOut_1 = require("./callMemeTokenOut");
24
+ const callNativeTokenIn_1 = require("./callNativeTokenIn");
25
+ const finaliseSale_1 = require("./finaliseSale");
26
+ bignumber_js_1.BigNumber.config({
27
+ ROUNDING_MODE: bignumber_js_1.BigNumber.ROUND_UP
28
+ });
29
+ /**
30
+ * Executes the purchase of tokens using a specified amount of native tokens.
31
+ *
32
+ * This function validates the sale, calculates the amount of tokens that can
33
+ * be purchased with the provided native tokens, and performs the token transfer
34
+ * to complete the purchase. If the purchase consumes all tokens in the sale,
35
+ * the sale is marked as finalized.
36
+ *
37
+ * @param ctx - The context object providing access to the GalaChain environment.
38
+ * @param buyTokenDTO - The data transfer object containing the sale address,
39
+ * native token amount to spend, and optional expected token amount.
40
+ *
41
+ * @returns A promise that resolves to a `TradeResDto` containing the updated
42
+ * balances of the purchased token and the native token for the buyer.
43
+ *
44
+ * @throws DefaultError if the expected tokens to be received are less than the
45
+ * actual amount provided by the operation.
46
+ */
47
+ async function buyWithNative(ctx, buyTokenDTO) {
48
+ let isSaleFinalized = false;
49
+ const sale = await (0, utils_1.fetchAndValidateSale)(ctx, buyTokenDTO.vaultAddress);
50
+ const tokensLeftInVault = new bignumber_js_1.BigNumber(sale.sellingTokenQuantity);
51
+ const callMemeTokenOutResult = await (0, callMemeTokenOut_1.callMemeTokenOut)(ctx, buyTokenDTO);
52
+ let tokensToBuy = new bignumber_js_1.BigNumber(callMemeTokenOutResult.calculatedQuantity);
53
+ const nativeToken = sale.fetchNativeTokenInstanceKey();
54
+ const memeToken = sale.fetchSellingTokenInstanceKey();
55
+ if (tokensLeftInVault.comparedTo(tokensToBuy) <= 0) {
56
+ tokensToBuy = tokensLeftInVault;
57
+ const nativeTokensrequiredToBuyDto = new types_1.ExactTokenQuantityDto(buyTokenDTO.vaultAddress, tokensToBuy);
58
+ const callNativeTokenInResult = await (0, callNativeTokenIn_1.callNativeTokenIn)(ctx, nativeTokensrequiredToBuyDto);
59
+ buyTokenDTO.nativeTokenQuantity = new bignumber_js_1.BigNumber(callNativeTokenInResult.calculatedQuantity);
60
+ isSaleFinalized = true;
61
+ }
62
+ if (buyTokenDTO.nativeTokenQuantity
63
+ .plus(new bignumber_js_1.BigNumber(sale.nativeTokenQuantity))
64
+ .gte(new bignumber_js_1.BigNumber(types_1.LaunchpadSale.MARKET_CAP)))
65
+ isSaleFinalized = true;
66
+ if (buyTokenDTO.expectedToken && buyTokenDTO.expectedToken.comparedTo(tokensToBuy) > 0) {
67
+ throw new error_1.SlippageToleranceExceededError("Tokens expected from this operation are more than the the actual amount that will be provided.");
68
+ }
69
+ await (0, chaincode_1.transferToken)(ctx, {
70
+ from: ctx.callingUser,
71
+ to: buyTokenDTO.vaultAddress,
72
+ tokenInstanceKey: nativeToken,
73
+ quantity: buyTokenDTO.nativeTokenQuantity,
74
+ allowancesToUse: [],
75
+ authorizedOnBehalf: undefined
76
+ });
77
+ await (0, chaincode_1.transferToken)(ctx, {
78
+ from: buyTokenDTO.vaultAddress,
79
+ to: ctx.callingUser,
80
+ tokenInstanceKey: memeToken,
81
+ quantity: tokensToBuy,
82
+ allowancesToUse: [],
83
+ authorizedOnBehalf: {
84
+ callingOnBehalf: buyTokenDTO.vaultAddress,
85
+ callingUser: ctx.callingUser
86
+ }
87
+ });
88
+ sale.buyToken(tokensToBuy, buyTokenDTO.nativeTokenQuantity);
89
+ await (0, chaincode_1.putChainObject)(ctx, sale);
90
+ if (isSaleFinalized) {
91
+ await (0, finaliseSale_1.finalizeSale)(ctx, sale);
92
+ }
93
+ const token = await (0, chaincode_1.fetchTokenClass)(ctx, sale.sellingToken);
94
+ return {
95
+ inputQuantity: buyTokenDTO.nativeTokenQuantity.toFixed(),
96
+ outputQuantity: tokensToBuy.toFixed(),
97
+ tokenName: token.name,
98
+ tradeType: "Buy",
99
+ vaultAddress: buyTokenDTO.vaultAddress,
100
+ userAddress: ctx.callingUser,
101
+ isFinalized: isSaleFinalized,
102
+ functionName: "BuyWithNative"
103
+ };
104
+ }
105
+ exports.buyWithNative = buyWithNative;
106
+ //# sourceMappingURL=buyWithNative.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buyWithNative.js","sourceRoot":"","sources":["../../../../src/chaincode/launchpad/buyWithNative.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;GAaG;AACH,qDAAyG;AACzG,+CAAyC;AAEzC,2CAA4G;AAC5G,iDAAuE;AACvE,oCAAgD;AAChD,yDAAsD;AACtD,2DAAwD;AACxD,iDAA8C;AAE9C,wBAAS,CAAC,MAAM,CAAC;IACf,aAAa,EAAE,wBAAS,CAAC,QAAQ;CAClC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACI,KAAK,UAAU,aAAa,CACjC,GAAqB,EACrB,WAAmC;IAEnC,IAAI,eAAe,GAAG,KAAK,CAAC;IAC5B,MAAM,I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 +1,27 @@
1
+ import { GalaChainContext } from "@gala-chain/chaincode";
2
+ import { NativeTokenQuantityDto } from "../../api/types";
3
+ /**
4
+ * Calculates the number of tokens that can be sold in exchange for a specified amount
5
+ * of native tokens using a bonding curve mechanism.
6
+ *
7
+ * This function retrieves the sale details and applies the bonding curve formula
8
+ * to determine the number of tokens the user can sell based on the provided native token amount.
9
+ *
10
+ * @param ctx - The context object that provides access to the GalaChain environment.
11
+ * @param sellTokenDTO - An object containing the sale details:
12
+ * - `vaultAddress`: The address of the sale.
13
+ * - `nativeTokenAmount`: The amount of native tokens to be recieved from sale.
14
+ * - `expectedToken` (optional): The expected amount of tokens to be sold.
15
+ *
16
+ * @returns A promise that resolves to a string representing the calculated amount of
17
+ * tokens to be sent, rounded up to 18 decimal places.
18
+ *
19
+ * @throws Error if the calculation results in an invalid amount (e.g., `InvalidAmountError`).
20
+ */
21
+ export declare function callMemeTokenIn(ctx: GalaChainContext, sellTokenDTO: NativeTokenQuantityDto): Promise<{
22
+ calculatedQuantity: string;
23
+ extraFees: {
24
+ reverseBondingCurve: string;
25
+ };
26
+ }>;
27
+ //# sourceMappingURL=callMemeTokenIn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callMemeTokenIn.d.ts","sourceRoot":"","sources":["../../../../src/chaincode/launchpad/callMemeTokenIn.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzD,OAAO,EAAiB,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAmCxE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,gBAAgB,EAAE,YAAY,EAAE,sBAAsB;;;;;GAShG"}