@gala-chain/launchpad 1.0.7 → 1.0.9
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/lib/package.json +1 -1
- package/lib/src/api/types/LaunchpadDtos.d.ts +2 -1
- package/lib/src/api/types/LaunchpadDtos.d.ts.map +1 -1
- package/lib/src/api/types/LaunchpadDtos.js +5 -1
- package/lib/src/api/types/LaunchpadDtos.js.map +1 -1
- package/lib/src/chaincode/launchpad/buyExactToken.d.ts.map +1 -1
- package/lib/src/chaincode/launchpad/buyExactToken.js +3 -2
- package/lib/src/chaincode/launchpad/buyExactToken.js.map +1 -1
- package/lib/src/chaincode/launchpad/buyWithNative.d.ts.map +1 -1
- package/lib/src/chaincode/launchpad/buyWithNative.js +2 -1
- package/lib/src/chaincode/launchpad/buyWithNative.js.map +1 -1
- package/lib/src/chaincode/launchpad/finaliseSale.js +3 -3
- package/lib/src/chaincode/launchpad/finaliseSale.js.map +1 -1
- package/lib/src/chaincode/launchpad/sellExactToken.d.ts.map +1 -1
- package/lib/src/chaincode/launchpad/sellExactToken.js +2 -1
- package/lib/src/chaincode/launchpad/sellExactToken.js.map +1 -1
- package/lib/src/chaincode/launchpad/sellWithNative.d.ts.map +1 -1
- package/lib/src/chaincode/launchpad/sellWithNative.js +2 -1
- package/lib/src/chaincode/launchpad/sellWithNative.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/api/types/LaunchpadDtos.ts +4 -1
- package/src/chaincode/launchpad/buyExactToken.spec.ts +51 -1
- package/src/chaincode/launchpad/buyExactToken.ts +3 -2
- package/src/chaincode/launchpad/buyWithNative.ts +2 -1
- package/src/chaincode/launchpad/finaliseSale.ts +3 -3
- package/src/chaincode/launchpad/sellExactToken.ts +2 -1
- package/src/chaincode/launchpad/sellWithNative.ts +2 -1
package/package.json
CHANGED
|
@@ -309,6 +309,9 @@ export class TradeResDto {
|
|
|
309
309
|
|
|
310
310
|
@IsString()
|
|
311
311
|
public uniqueKey: string;
|
|
312
|
+
|
|
313
|
+
@IsString()
|
|
314
|
+
public totalTokenSold: string;
|
|
312
315
|
}
|
|
313
316
|
|
|
314
317
|
export class FetchSaleDto extends ChainCallDTO {
|
|
@@ -400,5 +403,5 @@ export class BatchSubmitAuthoritiesResDto extends ChainCallDTO {
|
|
|
400
403
|
|
|
401
404
|
export class TransactionFeeResDto {
|
|
402
405
|
@IsNumber()
|
|
403
|
-
feeAmount;
|
|
406
|
+
feeAmount: number;
|
|
404
407
|
}
|
|
@@ -67,7 +67,7 @@ describe("buyWithNative", () => {
|
|
|
67
67
|
// Initialize sale with manual values
|
|
68
68
|
sale = new LaunchpadSale(
|
|
69
69
|
vaultAddress,
|
|
70
|
-
|
|
70
|
+
currencyInstance.instanceKeyObj(),
|
|
71
71
|
undefined,
|
|
72
72
|
users.testUser1.identityKey
|
|
73
73
|
);
|
|
@@ -182,6 +182,56 @@ describe("buyWithNative", () => {
|
|
|
182
182
|
expect(buyTokenRes.Data?.outputQuantity).toEqual("5430");
|
|
183
183
|
});
|
|
184
184
|
|
|
185
|
+
test("User should be able to finalise sale , if fee is configured", async () => {
|
|
186
|
+
//Given
|
|
187
|
+
salelaunchpadGalaBalance = plainToInstance(TokenBalance, {
|
|
188
|
+
...launchpadgala.tokenBalance(),
|
|
189
|
+
owner: vaultAddress,
|
|
190
|
+
quantity: new BigNumber("0")
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
saleCurrencyBalance = plainToInstance(TokenBalance, {
|
|
194
|
+
...currency.tokenBalance(),
|
|
195
|
+
owner: vaultAddress,
|
|
196
|
+
quantity: new BigNumber("2e+7")
|
|
197
|
+
});
|
|
198
|
+
userlaunchpadGalaBalance = plainToInstance(TokenBalance, {
|
|
199
|
+
...launchpadgala.tokenBalance(),
|
|
200
|
+
owner: users.testUser1.identityKey,
|
|
201
|
+
quantity: new BigNumber("100000000")
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
const launchpadConfig = new LaunchpadFeeConfig(users.testUser2.identityKey, Number("0.001"), [
|
|
205
|
+
users.testUser2.identityKey
|
|
206
|
+
]);
|
|
207
|
+
|
|
208
|
+
const { ctx, contract } = fixture(LaunchpadContract)
|
|
209
|
+
.registeredUsers(users.testUser1)
|
|
210
|
+
.savedState(
|
|
211
|
+
currencyClass,
|
|
212
|
+
currencyInstance,
|
|
213
|
+
launchpadGalaClass,
|
|
214
|
+
launchpadGalaInstance,
|
|
215
|
+
sale,
|
|
216
|
+
salelaunchpadGalaBalance,
|
|
217
|
+
saleCurrencyBalance,
|
|
218
|
+
userlaunchpadGalaBalance,
|
|
219
|
+
userCurrencyBalance,
|
|
220
|
+
launchpadConfig
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
const dto = new ExactTokenQuantityDto(vaultAddress, new BigNumber("10000000"));
|
|
224
|
+
|
|
225
|
+
dto.uniqueKey = randomUniqueKey();
|
|
226
|
+
dto.sign(users.testUser1.privateKey);
|
|
227
|
+
|
|
228
|
+
//When
|
|
229
|
+
const buyTokenRes = await contract.BuyExactToken(ctx, dto);
|
|
230
|
+
|
|
231
|
+
//Then
|
|
232
|
+
expect(buyTokenRes.Data?.isFinalized).toBe(true);
|
|
233
|
+
});
|
|
234
|
+
|
|
185
235
|
it("should throw error if user has insufficient funds incuding the transaction fees", async () => {
|
|
186
236
|
//Given
|
|
187
237
|
const launchpadConfig = new LaunchpadFeeConfig(users.testUser2.identityKey, Number("0.32"), [
|
|
@@ -89,7 +89,7 @@ export async function buyExactToken(
|
|
|
89
89
|
// Transfer transaction fees
|
|
90
90
|
const launchpadFeeAddressConfiguration = await fetchLaunchpadFeeAddress(ctx);
|
|
91
91
|
if (launchpadFeeAddressConfiguration && transactionFees) {
|
|
92
|
-
const totalRequired = new BigNumber(
|
|
92
|
+
const totalRequired = nativeTokensToBuy.plus(new BigNumber(transactionFees));
|
|
93
93
|
|
|
94
94
|
const buyerBalance = await fetchOrCreateBalance(ctx, ctx.callingUser, sale.nativeToken);
|
|
95
95
|
if (buyerBalance.getQuantityTotal().lt(totalRequired)) {
|
|
@@ -151,6 +151,7 @@ export async function buyExactToken(
|
|
|
151
151
|
userAddress: ctx.callingUser,
|
|
152
152
|
isFinalized: isSaleFinalized,
|
|
153
153
|
functionName: "BuyExactToken",
|
|
154
|
-
uniqueKey: buyTokenDTO.uniqueKey
|
|
154
|
+
uniqueKey: buyTokenDTO.uniqueKey,
|
|
155
|
+
totalTokenSold: sale.fetchTokensSold()
|
|
155
156
|
};
|
|
156
157
|
}
|
|
@@ -155,6 +155,7 @@ export async function buyWithNative(
|
|
|
155
155
|
userAddress: ctx.callingUser,
|
|
156
156
|
isFinalized: isSaleFinalized,
|
|
157
157
|
functionName: "BuyWithNative",
|
|
158
|
-
uniqueKey: buyTokenDTO.uniqueKey
|
|
158
|
+
uniqueKey: buyTokenDTO.uniqueKey,
|
|
159
|
+
totalTokenSold: sale.fetchTokensSold()
|
|
159
160
|
};
|
|
160
161
|
}
|
|
@@ -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.
|
|
55
|
-
const ownerAllocationPercentage = feeAllocation ? feeAllocation.ownerAllocationPercentage : 0.
|
|
56
|
-
const liquidityAllocationPercentage = feeAllocation ? feeAllocation.liquidityAllocationPercentage : 0.
|
|
54
|
+
const platformFeePercentage = feeAllocation ? feeAllocation.platformFeePercentage : 0.01;
|
|
55
|
+
const ownerAllocationPercentage = feeAllocation ? feeAllocation.ownerAllocationPercentage : 0.05;
|
|
56
|
+
const liquidityAllocationPercentage = feeAllocation ? feeAllocation.liquidityAllocationPercentage : 0.94;
|
|
57
57
|
|
|
58
58
|
const nativeToken = sale.fetchNativeTokenInstanceKey();
|
|
59
59
|
const memeToken = sale.fetchSellingTokenInstanceKey();
|
|
@@ -133,6 +133,7 @@ export async function sellExactToken(
|
|
|
133
133
|
userAddress: ctx.callingUser,
|
|
134
134
|
isFinalized: false,
|
|
135
135
|
functionName: "SellExactToken",
|
|
136
|
-
uniqueKey: sellTokenDTO.uniqueKey
|
|
136
|
+
uniqueKey: sellTokenDTO.uniqueKey,
|
|
137
|
+
totalTokenSold: sale.fetchTokensSold()
|
|
137
138
|
};
|
|
138
139
|
}
|
|
@@ -132,6 +132,7 @@ export async function sellWithNative(
|
|
|
132
132
|
userAddress: ctx.callingUser,
|
|
133
133
|
isFinalized: false,
|
|
134
134
|
functionName: "SellWithNative",
|
|
135
|
-
uniqueKey: sellTokenDTO.uniqueKey
|
|
135
|
+
uniqueKey: sellTokenDTO.uniqueKey,
|
|
136
|
+
totalTokenSold: sale.fetchTokensSold()
|
|
136
137
|
};
|
|
137
138
|
}
|