@gala-chain/launchpad 1.0.10 → 1.0.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gala-chain/launchpad",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "GalaChain Launchpad Chaincode",
5
5
  "main": "lib/src/index.js",
6
6
  "types": "lib/src/index.d.ts",
@@ -25,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "@gala-chain/api": "~2.3.4",
27
27
  "@gala-chain/chaincode": "~2.3.4",
28
- "@gala-chain/dex": "1.0.19",
28
+ "@gala-chain/dex": "1.0.20",
29
29
  "@grpc/grpc-js": "1.10.10",
30
30
  "decimal.js": "^10.5.0",
31
31
  "dotenv": "^16.0.1",
@@ -21,7 +21,7 @@ export const ErrorCode = {
21
21
 
22
22
  export class SlippageToleranceExceededError extends ChainError {
23
23
  constructor(message: string) {
24
- super(message, 412);
24
+ super(`Slippage tolerance exceeded: ${message}`, 412);
25
25
  }
26
26
  }
27
27
 
@@ -82,7 +82,7 @@ export async function buyExactToken(
82
82
  // Ensure the expected native token amount is not less than the actual amount required
83
83
  if (buyTokenDTO.expectedNativeToken && buyTokenDTO.expectedNativeToken.comparedTo(nativeTokensToBuy) < 0) {
84
84
  throw new SlippageToleranceExceededError(
85
- "Gala tokens expected to perform this operation are less than the actual amount required."
85
+ `expected ${buyTokenDTO.expectedNativeToken.toString()}, but at least ${nativeTokensToBuy.toString()} are required to complete this operation. Increase the expected amount or adjust your slippage tolerance.`
86
86
  );
87
87
  }
88
88
 
@@ -13,7 +13,6 @@
13
13
  * limitations under the License.
14
14
  */
15
15
  import {
16
- GalaChainResponse,
17
16
  TokenBalance,
18
17
  TokenClass,
19
18
  TokenClassKey,
@@ -101,7 +101,7 @@ export async function buyWithNative(
101
101
  // Check for slippage condition
102
102
  if (buyTokenDTO.expectedToken && buyTokenDTO.expectedToken.comparedTo(tokensToBuy) > 0) {
103
103
  throw new SlippageToleranceExceededError(
104
- "Tokens expected from this operation are more than the actual amount that will be provided."
104
+ `expected ${buyTokenDTO.expectedToken.toString()}, but only ${tokensToBuy.toString()} tokens can be provided. Reduce the expected amount or adjust your slippage tolerance.`
105
105
  );
106
106
  }
107
107
 
@@ -13,7 +13,7 @@
13
13
  * limitations under the License.
14
14
  */
15
15
  import { TokenBalance, TokenClass, TokenInstance, randomUniqueKey } from "@gala-chain/api";
16
- import { currency, fixture, users } from "@gala-chain/test";
16
+ import { fixture, users } from "@gala-chain/test";
17
17
  import BigNumber from "bignumber.js";
18
18
  import { plainToInstance } from "class-transformer";
19
19
 
@@ -98,7 +98,7 @@ export async function finalizeSale(ctx: GalaChainContext, sale: LaunchpadSale):
98
98
  const poolDTO = new CreatePoolDto(
99
99
  areTokensSorted ? nativeTokenClassKey : sellingTokenClassKey,
100
100
  areTokensSorted ? sellingTokenClassKey : nativeTokenClassKey,
101
- 3000,
101
+ 10000, // TODO: make this configurable
102
102
  sqrtPrice
103
103
  );
104
104
 
@@ -136,10 +136,10 @@ export async function finalizeSale(ctx: GalaChainContext, sale: LaunchpadSale):
136
136
  const expectedTokenDTO = new GetAddLiquidityEstimationDto(
137
137
  token0,
138
138
  token1,
139
- 3000,
139
+ 10000, // TODO: make this configurable
140
140
  liquidityAmount,
141
- -887220,
142
- 887220,
141
+ -887200,
142
+ 887200,
143
143
  zeroForOne
144
144
  );
145
145
 
@@ -151,9 +151,9 @@ export async function finalizeSale(ctx: GalaChainContext, sale: LaunchpadSale):
151
151
  const positionDto = new AddLiquidityDTO(
152
152
  token0,
153
153
  token1,
154
- 3000,
155
- -887220,
156
- 887220,
154
+ 10000, // TODO: make this configurable
155
+ -887200,
156
+ 887200,
157
157
  amount0,
158
158
  amount1,
159
159
  amount0.times(0.9999999),
@@ -67,7 +67,7 @@ export async function sellExactToken(
67
67
  sellTokenDTO.expectedNativeToken.comparedTo(nativeTokensToProvide) > 0
68
68
  ) {
69
69
  throw new SlippageToleranceExceededError(
70
- "Expected Gala tokens from this operation exceeds the actual amount that will be provided."
70
+ `expected ${sellTokenDTO.expectedNativeToken.toString()}, but only ${nativeTokensToProvide.toString()} tokens can be provided. Reduce the expected amount or adjust your slippage tolerance.`
71
71
  );
72
72
  }
73
73
 
@@ -83,7 +83,7 @@ export async function sellWithNative(
83
83
  // Enforce slippage tolerance
84
84
  if (sellTokenDTO.expectedToken && sellTokenDTO.expectedToken.comparedTo(tokensToSell) < 0) {
85
85
  throw new SlippageToleranceExceededError(
86
- "Token amount expected to cost for this operation is less than the the actual amount required."
86
+ `expected ${sellTokenDTO.expectedToken.toString()}, but at least ${tokensToSell.toString()} tokens are required. Increase the expected amount or adjust your slippage tolerance.`
87
87
  );
88
88
  }
89
89