@gauntlet-xyz/sdk 2.0.0 → 2.3.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 (70) hide show
  1. package/README.md +82 -1
  2. package/dist/api/activity.d.ts +70 -0
  3. package/dist/api/activity.d.ts.map +1 -0
  4. package/dist/api/activity.js +154 -0
  5. package/dist/api/activity.js.map +1 -0
  6. package/dist/api/caip.d.ts +29 -0
  7. package/dist/api/caip.d.ts.map +1 -0
  8. package/dist/api/caip.js +38 -0
  9. package/dist/api/caip.js.map +1 -0
  10. package/dist/api/client.d.ts +114 -0
  11. package/dist/api/client.d.ts.map +1 -0
  12. package/dist/api/client.js +109 -0
  13. package/dist/api/client.js.map +1 -0
  14. package/dist/api/decimal.d.ts +21 -0
  15. package/dist/api/decimal.d.ts.map +1 -0
  16. package/dist/api/decimal.js +44 -0
  17. package/dist/api/decimal.js.map +1 -0
  18. package/dist/api/errors.d.ts +32 -0
  19. package/dist/api/errors.d.ts.map +1 -0
  20. package/dist/api/errors.js +41 -0
  21. package/dist/api/errors.js.map +1 -0
  22. package/dist/api/generated.d.ts +1461 -0
  23. package/dist/api/generated.d.ts.map +1 -0
  24. package/dist/api/generated.js +6 -0
  25. package/dist/api/generated.js.map +1 -0
  26. package/dist/api/http.d.ts +16 -0
  27. package/dist/api/http.d.ts.map +1 -0
  28. package/dist/api/http.js +39 -0
  29. package/dist/api/http.js.map +1 -0
  30. package/dist/api/index.d.ts +14 -0
  31. package/dist/api/index.d.ts.map +1 -0
  32. package/dist/api/index.js +8 -0
  33. package/dist/api/index.js.map +1 -0
  34. package/dist/api/positionHistory.d.ts +44 -0
  35. package/dist/api/positionHistory.d.ts.map +1 -0
  36. package/dist/api/positionHistory.js +126 -0
  37. package/dist/api/positionHistory.js.map +1 -0
  38. package/dist/client.d.ts +6 -0
  39. package/dist/client.d.ts.map +1 -1
  40. package/dist/client.js +2 -0
  41. package/dist/client.js.map +1 -1
  42. package/dist/evm/abis/provisionerV2.d.ts +224 -0
  43. package/dist/evm/abis/provisionerV2.d.ts.map +1 -1
  44. package/dist/evm/abis/provisionerV2.js +59 -0
  45. package/dist/evm/abis/provisionerV2.js.map +1 -1
  46. package/dist/evm/aeraContracts/v2.d.ts +1369 -25
  47. package/dist/evm/aeraContracts/v2.d.ts.map +1 -1
  48. package/dist/index.d.ts +1 -0
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +1 -0
  51. package/dist/index.js.map +1 -1
  52. package/dist/privy/index.d.ts +52 -0
  53. package/dist/privy/index.d.ts.map +1 -0
  54. package/dist/privy/index.js +51 -0
  55. package/dist/privy/index.js.map +1 -0
  56. package/manifest/vaults.json +299 -5
  57. package/package.json +2 -2
  58. package/src/api/activity.ts +219 -0
  59. package/src/api/caip.ts +61 -0
  60. package/src/api/client.ts +201 -0
  61. package/src/api/decimal.ts +49 -0
  62. package/src/api/errors.ts +64 -0
  63. package/src/api/generated.ts +1461 -0
  64. package/src/api/http.ts +62 -0
  65. package/src/api/index.ts +65 -0
  66. package/src/api/positionHistory.ts +167 -0
  67. package/src/client.ts +7 -1
  68. package/src/evm/abis/provisionerV2.ts +59 -0
  69. package/src/index.ts +2 -0
  70. package/src/privy/index.ts +95 -0
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Converts an API decimal string (human units, e.g. `"1250.5"`) into base-unit
3
+ * bigint at the given token decimals (e.g. `1250500000n` for 6 decimals).
4
+ *
5
+ * The conversion is exact: a value with more significant fractional digits
6
+ * than `decimals` throws `DecimalPrecisionError` rather than rounding.
7
+ * Hand-rolled instead of viem's `parseUnits`, which silently rounds excess
8
+ * precision (`parseUnits('1.0000005', 6)` → `1000001n`) — unacceptable for
9
+ * financial amounts.
10
+ */
11
+ export declare function decimalToBigInt(value: string, decimals: number): bigint;
12
+ /**
13
+ * Formats a base-unit bigint back into the API's human decimal-string
14
+ * representation (no trailing fractional zeros, no exponent notation).
15
+ */
16
+ export declare function bigIntToDecimal(value: bigint, decimals: number): string;
17
+ /** Vault shares are always reported in 18-decimal units by the Gaia API. */
18
+ export declare const SHARE_DECIMALS = 18;
19
+ /** Parses an API share amount (decimal string) into base-unit bigint (1e18). */
20
+ export declare function sharesToBigInt(value: string): bigint;
21
+ //# sourceMappingURL=decimal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../src/api/decimal.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAcvE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKvE;AAED,4EAA4E;AAC5E,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD"}
@@ -0,0 +1,44 @@
1
+ import { formatUnits } from 'viem';
2
+ import { DecimalPrecisionError, InvalidDecimalError } from './errors';
3
+ const DECIMAL_RE = /^(-?)(\d+)(?:\.(\d+))?$/;
4
+ /**
5
+ * Converts an API decimal string (human units, e.g. `"1250.5"`) into base-unit
6
+ * bigint at the given token decimals (e.g. `1250500000n` for 6 decimals).
7
+ *
8
+ * The conversion is exact: a value with more significant fractional digits
9
+ * than `decimals` throws `DecimalPrecisionError` rather than rounding.
10
+ * Hand-rolled instead of viem's `parseUnits`, which silently rounds excess
11
+ * precision (`parseUnits('1.0000005', 6)` → `1000001n`) — unacceptable for
12
+ * financial amounts.
13
+ */
14
+ export function decimalToBigInt(value, decimals) {
15
+ if (!Number.isInteger(decimals) || decimals < 0) {
16
+ throw new InvalidDecimalError(`decimals=${decimals}`);
17
+ }
18
+ const match = DECIMAL_RE.exec(value);
19
+ if (!match)
20
+ throw new InvalidDecimalError(value);
21
+ const [, sign, whole, frac = ''] = match;
22
+ if (frac.length > decimals && !/^0*$/.test(frac.slice(decimals))) {
23
+ throw new DecimalPrecisionError(value, decimals);
24
+ }
25
+ const scaled = BigInt(whole + frac.slice(0, decimals).padEnd(decimals, '0'));
26
+ return sign === '-' ? -scaled : scaled;
27
+ }
28
+ /**
29
+ * Formats a base-unit bigint back into the API's human decimal-string
30
+ * representation (no trailing fractional zeros, no exponent notation).
31
+ */
32
+ export function bigIntToDecimal(value, decimals) {
33
+ if (!Number.isInteger(decimals) || decimals < 0) {
34
+ throw new InvalidDecimalError(`decimals=${decimals}`);
35
+ }
36
+ return formatUnits(value, decimals);
37
+ }
38
+ /** Vault shares are always reported in 18-decimal units by the Gaia API. */
39
+ export const SHARE_DECIMALS = 18;
40
+ /** Parses an API share amount (decimal string) into base-unit bigint (1e18). */
41
+ export function sharesToBigInt(value) {
42
+ return decimalToBigInt(value, SHARE_DECIMALS);
43
+ }
44
+ //# sourceMappingURL=decimal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decimal.js","sourceRoot":"","sources":["../../src/api/decimal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEtE,MAAM,UAAU,GAAG,yBAAyB,CAAC;AAE7C;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,QAAgB;IAC7D,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,mBAAmB,CAAC,YAAY,QAAQ,EAAE,CAAC,CAAC;IACxD,CAAC;IACD,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrC,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAEjD,MAAM,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,EAAE,CAAC,GAAG,KAAK,CAAC;IACzC,IAAI,IAAI,CAAC,MAAM,GAAG,QAAQ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;QACjE,MAAM,IAAI,qBAAqB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;IAC7E,OAAO,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;AACzC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,QAAgB;IAC7D,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,mBAAmB,CAAC,YAAY,QAAQ,EAAE,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AACtC,CAAC;AAED,4EAA4E;AAC5E,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAEjC,gFAAgF;AAChF,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAO,eAAe,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { GauntletSDKError } from '../errors';
2
+ export declare class GauntletApiError extends GauntletSDKError {
3
+ readonly status: number;
4
+ readonly path: string;
5
+ /** Machine-readable code from the API error envelope (e.g. `NOT_FOUND`), when present. */
6
+ readonly code?: string;
7
+ constructor(params: {
8
+ status: number;
9
+ path: string;
10
+ message: string;
11
+ code?: string;
12
+ });
13
+ }
14
+ export declare class InvalidDecimalError extends GauntletSDKError {
15
+ readonly value: string;
16
+ constructor(value: string);
17
+ }
18
+ export declare class DecimalPrecisionError extends GauntletSDKError {
19
+ readonly value: string;
20
+ readonly decimals: number;
21
+ constructor(value: string, decimals: number);
22
+ }
23
+ export declare class InvalidCaipIdError extends GauntletSDKError {
24
+ readonly id: string;
25
+ constructor(id: string);
26
+ }
27
+ export declare class SettlementTimeoutError extends GauntletSDKError {
28
+ readonly requestHash: string;
29
+ readonly timeoutMs: number;
30
+ constructor(requestHash: string, timeoutMs: number);
31
+ }
32
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/api/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,qBAAa,gBAAiB,SAAQ,gBAAgB;IACpD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0FAA0F;IAC1F,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;gBAEX,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;CASrF;AAED,qBAAa,mBAAoB,SAAQ,gBAAgB;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,KAAK,EAAE,MAAM;CAK1B;AAED,qBAAa,qBAAsB,SAAQ,gBAAgB;IACzD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAQ5C;AAED,qBAAa,kBAAmB,SAAQ,gBAAgB;IACtD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;gBAER,EAAE,EAAE,MAAM;CAKvB;AAED,qBAAa,sBAAuB,SAAQ,gBAAgB;IAC1D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAEf,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAMnD"}
@@ -0,0 +1,41 @@
1
+ import { GauntletSDKError } from '../errors';
2
+ export class GauntletApiError extends GauntletSDKError {
3
+ constructor(params) {
4
+ super(`Gauntlet API request to "${params.path}" failed with ${params.status}: ${params.message}`);
5
+ this.name = 'GauntletApiError';
6
+ this.status = params.status;
7
+ this.path = params.path;
8
+ this.code = params.code;
9
+ }
10
+ }
11
+ export class InvalidDecimalError extends GauntletSDKError {
12
+ constructor(value) {
13
+ super(`Value "${value}" is not a valid decimal string`);
14
+ this.name = 'InvalidDecimalError';
15
+ this.value = value;
16
+ }
17
+ }
18
+ export class DecimalPrecisionError extends GauntletSDKError {
19
+ constructor(value, decimals) {
20
+ super(`Decimal "${value}" has more fractional digits than the token's ${decimals} decimals; converting would lose precision`);
21
+ this.name = 'DecimalPrecisionError';
22
+ this.value = value;
23
+ this.decimals = decimals;
24
+ }
25
+ }
26
+ export class InvalidCaipIdError extends GauntletSDKError {
27
+ constructor(id) {
28
+ super(`"${id}" is not a valid CAIP-10 vault id (expected "{chainId}:{address}")`);
29
+ this.name = 'InvalidCaipIdError';
30
+ this.id = id;
31
+ }
32
+ }
33
+ export class SettlementTimeoutError extends GauntletSDKError {
34
+ constructor(requestHash, timeoutMs) {
35
+ super(`Request "${requestHash}" did not settle within ${timeoutMs}ms`);
36
+ this.name = 'SettlementTimeoutError';
37
+ this.requestHash = requestHash;
38
+ this.timeoutMs = timeoutMs;
39
+ }
40
+ }
41
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/api/errors.ts"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