@gala-chain/launchpad-sdk 8.0.1 → 8.1.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 (39) hide show
  1. package/dist/LaunchpadSDK.d.ts +12 -6
  2. package/dist/LaunchpadSDK.d.ts.map +1 -1
  3. package/dist/api/LaunchpadAPI.d.ts +33 -7
  4. package/dist/api/LaunchpadAPI.d.ts.map +1 -1
  5. package/dist/auth/SessionAuthService.d.ts.map +1 -1
  6. package/dist/constants/version.generated.d.ts +1 -1
  7. package/dist/index.browser.d.ts +3 -1
  8. package/dist/index.browser.d.ts.map +1 -1
  9. package/dist/index.browser.esm.js +1 -1
  10. package/dist/index.cjs +1 -1
  11. package/dist/index.esm.js +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/launchpad/sell-fee-ceiling.d.ts +66 -0
  14. package/dist/launchpad/sell-fee-ceiling.d.ts.map +1 -0
  15. package/dist/launchpad/writes.d.ts +30 -2
  16. package/dist/launchpad/writes.d.ts.map +1 -1
  17. package/dist/native.cjs +1 -1
  18. package/dist/native.esm.js +1 -1
  19. package/dist/schemas/launchpad.d.ts +4 -4
  20. package/dist/schemas/launchpad.d.ts.map +1 -1
  21. package/dist/services/BundleService.d.ts +9 -1
  22. package/dist/services/BundleService.d.ts.map +1 -1
  23. package/dist/services/GalaChainService.d.ts +0 -49
  24. package/dist/services/GalaChainService.d.ts.map +1 -1
  25. package/dist/services/TradingQuotesService.d.ts +3 -5
  26. package/dist/services/TradingQuotesService.d.ts.map +1 -1
  27. package/dist/signing/index.d.ts +1 -1
  28. package/dist/signing/index.d.ts.map +1 -1
  29. package/dist/signing/signers.d.ts +17 -4
  30. package/dist/signing/signers.d.ts.map +1 -1
  31. package/dist/types/launchpad.dto.d.ts +0 -12
  32. package/dist/types/launchpad.dto.d.ts.map +1 -1
  33. package/dist/types/session-auth.dto.d.ts +2 -4
  34. package/dist/types/session-auth.dto.d.ts.map +1 -1
  35. package/dist/utils/trade-quote.d.ts +32 -0
  36. package/dist/utils/trade-quote.d.ts.map +1 -0
  37. package/package.json +2 -2
  38. package/dist/signing/eip712.d.ts +0 -13
  39. package/dist/signing/eip712.d.ts.map +0 -1
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Default reverse-bonding-curve fee ceiling for sells.
3
+ *
4
+ * On chain a sell pays a reverse-bonding-curve (RBC) fee, and `extraFees.maxAcceptableReverseBondingCurveFee`
5
+ * is the most the seller accepts to pay (launchpad-chaincode `payReverseBondingCurveFee`):
6
+ *
7
+ * - the field absent means "no ceiling" (the check is skipped);
8
+ * - any value present, `'0'` included, is a ceiling: a non-zero fee above it fails the sell with
9
+ * "Fee exceeds maximum acceptable amount".
10
+ *
11
+ * A caller that names no ceiling therefore must not get `'0'` (every sell with an RBC fee would be
12
+ * rejected) and should not get "no ceiling" either. The launchpad frontend quotes the sell and
13
+ * allows the quoted fee plus a 1% fee slippage; this module does the same, from the same backend
14
+ * quote endpoint, and an explicit `extraFees` always wins.
15
+ *
16
+ * @packageDocumentation
17
+ */
18
+ import type { AmountCalculationResult } from '../types/launchpad.dto';
19
+ /** Which sell the ceiling is for. */
20
+ export type SellFeeCeilingMethod = 'SellExactToken' | 'SellWithNative';
21
+ /** What a ceiling resolver needs to know about the sell. */
22
+ export interface SellFeeCeilingRequest {
23
+ /** `SellExactToken` (quantity is tokens sold) or `SellWithNative` (quantity is GALA received). */
24
+ method: SellFeeCeilingMethod;
25
+ /** The sale vault. */
26
+ vaultAddress: string;
27
+ /** The trade quantity exactly as it goes into the DTO. */
28
+ quantity: string;
29
+ /** The launchpad token name when the caller already has it (saves a lookup). */
30
+ tokenName?: string;
31
+ /** Fee slippage override; defaults to the SDK's `maxAcceptableReverseBondingCurveFeeSlippageFactor`. */
32
+ feeSlippageFactor?: number;
33
+ }
34
+ /** Resolves the fee ceiling (decimal string, GALA) for a sell. */
35
+ export type SellFeeCeilingResolver = (request: SellFeeCeilingRequest) => Promise<string>;
36
+ /** Collaborators of the default resolver. */
37
+ export interface SellFeeCeilingDeps {
38
+ /** Quote a trade through the backend (`GET /v1/trading/quote`). */
39
+ getTradeQuote(params: {
40
+ tokenName: string;
41
+ amount: string;
42
+ type: 'MEME' | 'NATIVE';
43
+ method: 'IN' | 'OUT';
44
+ }): Promise<AmountCalculationResult>;
45
+ /** Find the token name of a vault (the quote endpoint is keyed by token name). */
46
+ findTokenNameByVault(vaultAddress: string, symbol: string): Promise<string | undefined>;
47
+ /** The SDK-wide default fee slippage factor, read at call time. */
48
+ defaultFeeSlippageFactor(): number;
49
+ }
50
+ /**
51
+ * The quoted fee plus fee slippage, rounded UP to the chain's 8 decimals so the ceiling can never
52
+ * end up below the fee the chain computes (the chain also rounds its fee up).
53
+ *
54
+ * @example
55
+ * feeCeilingFromQuotedFee('0.00003328', 0.01) // '0.00003362'
56
+ */
57
+ export declare function feeCeilingFromQuotedFee(quotedFee: string, feeSlippageFactor: number): string;
58
+ /**
59
+ * Build the default resolver: quote the sell, allow the quoted fee plus fee slippage.
60
+ *
61
+ * A sell of an exact token quantity is quoted as MEME/IN (tokens in, GALA out); a sell for an
62
+ * exact GALA amount is quoted as NATIVE/OUT. Both quotes carry the fee the chain will compute for
63
+ * that payout.
64
+ */
65
+ export declare function createSellFeeCeilingResolver(deps: SellFeeCeilingDeps): SellFeeCeilingResolver;
66
+ //# sourceMappingURL=sell-fee-ceiling.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sell-fee-ceiling.d.ts","sourceRoot":"","sources":["../../src/launchpad/sell-fee-ceiling.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAOtE,qCAAqC;AACrC,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAEvE,4DAA4D;AAC5D,MAAM,WAAW,qBAAqB;IACpC,kGAAkG;IAClG,MAAM,EAAE,oBAAoB,CAAC;IAC7B,sBAAsB;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,gFAAgF;IAChF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wGAAwG;IACxG,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,kEAAkE;AAClE,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,EAAE,qBAAqB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAEzF,6CAA6C;AAC7C,MAAM,WAAW,kBAAkB;IACjC,mEAAmE;IACnE,aAAa,CAAC,MAAM,EAAE;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;QACxB,MAAM,EAAE,IAAI,GAAG,KAAK,CAAC;KACtB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACrC,kFAAkF;IAClF,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACxF,mEAAmE;IACnE,wBAAwB,IAAI,MAAM,CAAC;CACpC;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAqB5F;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,kBAAkB,GAAG,sBAAsB,CAa7F"}
@@ -1,5 +1,6 @@
1
- import type { LaunchTokenData } from '../types/launchpad.dto.js';
1
+ import type { LaunchTokenData, ReverseBondingCurveConfiguration } from '../types/launchpad.dto.js';
2
2
  import type { BundleSubmission } from './bundle-submission.js';
3
+ import type { SellFeeCeilingResolver } from './sell-fee-ceiling.js';
3
4
  import type { LaunchpadWriteTransport } from './transport.js';
4
5
  /** Common fee fields copied into every frontend trade DTO. */
5
6
  export interface LaunchpadExtraFees {
@@ -10,9 +11,23 @@ export interface LaunchpadTradeInput {
10
11
  vaultAddress: string;
11
12
  quantity: string;
12
13
  expectedAmount: string;
14
+ /**
15
+ * The most reverse-bonding-curve fee (GALA) a sell may pay. Omit it on a sell and the SDK quotes
16
+ * the fee and allows it plus the SDK fee slippage; pass it to take over (an explicit `'0'` means
17
+ * "reject any fee", which the chain does for every sell on a pool that charges one). Buys pay no
18
+ * such fee and ignore the value.
19
+ */
13
20
  extraFees?: LaunchpadExtraFees;
21
+ /** The launchpad token name of `vaultAddress`; saves the SDK one lookup when it quotes a sell. */
22
+ tokenName?: string;
14
23
  uniqueKey?: string;
15
24
  }
25
+ /**
26
+ * Reverse bonding curve (sell fee) configuration a CreateSale carries when the caller names none:
27
+ * 10% at the start of the curve to 50% at the end, the documented defaults and the bundler's
28
+ * allowed range (min >= 0.1, max <= 0.5).
29
+ */
30
+ export declare const DEFAULT_REVERSE_BONDING_CURVE_CONFIGURATION: Readonly<ReverseBondingCurveConfiguration>;
16
31
  /** Input for a CreateSale bundler write. */
17
32
  export interface CreateSaleInput extends Omit<LaunchTokenData, 'tokenImage'> {
18
33
  tokenImage: string;
@@ -22,10 +37,17 @@ export interface CreateSaleInput extends Omit<LaunchTokenData, 'tokenImage'> {
22
37
  export declare class LaunchpadWrites {
23
38
  private readonly transport;
24
39
  private readonly walletAddress;
25
- /** Construct launchpad write methods around an injected transport. */
40
+ private readonly sellFeeCeiling;
41
+ /**
42
+ * Construct launchpad write methods around an injected transport.
43
+ *
44
+ * `sellFeeCeiling` supplies the fee ceiling of a sell that names no `extraFees`; without it such a
45
+ * sell is refused instead of being sent with a ceiling the chain would reject.
46
+ */
26
47
  constructor(options: {
27
48
  transport: LaunchpadWriteTransport;
28
49
  walletAddress: string;
50
+ sellFeeCeiling?: SellFeeCeilingResolver;
29
51
  });
30
52
  /**
31
53
  * Create a sale using the frontend's CreateSale DTO and instruction set.
@@ -70,5 +92,11 @@ export declare class LaunchpadWrites {
70
92
  */
71
93
  sellExactToken(input: LaunchpadTradeInput): Promise<BundleSubmission>;
72
94
  private submitTrade;
95
+ /**
96
+ * The `extraFees` of a trade whose caller named none. Buys pay no reverse-bonding-curve fee, so
97
+ * their ceiling is moot. A sell must carry a ceiling the chain accepts: the chain treats a
98
+ * present `'0'` as "accept nothing", so the default is the quoted fee plus fee slippage.
99
+ */
100
+ private defaultExtraFees;
73
101
  }
74
102
  //# sourceMappingURL=writes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"writes.d.ts","sourceRoot":"","sources":["../../src/launchpad/writes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,KAAK,EAAwB,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEpF,8DAA8D;AAC9D,MAAM,WAAW,kBAAkB;IACjC,mCAAmC,EAAE,MAAM,CAAC;CAC7C;AAED,2CAA2C;AAC3C,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,4CAA4C;AAC5C,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC;IAC1E,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wFAAwF;AACxF,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0B;IACpD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IAEvC,sEAAsE;gBACnD,OAAO,EAAE;QAAE,SAAS,EAAE,uBAAuB,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;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