@lit-protocol/vincent-ability-hyperliquid 3.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 (143) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/CONTRIBUTING.md +5 -0
  3. package/README.md +922 -0
  4. package/dist/CHANGELOG.md +21 -0
  5. package/dist/CONTRIBUTING.md +5 -0
  6. package/dist/README.md +922 -0
  7. package/dist/package.json +35 -0
  8. package/dist/src/generated/lit-action.js +9 -0
  9. package/dist/src/generated/vincent-ability-metadata.json +3 -0
  10. package/dist/src/generated/vincent-bundled-ability.d.ts +483 -0
  11. package/dist/src/generated/vincent-bundled-ability.d.ts.map +1 -0
  12. package/dist/src/generated/vincent-bundled-ability.js +15 -0
  13. package/dist/src/generated/vincent-bundled-ability.js.map +1 -0
  14. package/dist/src/generated/vincent-bundled-ability.ts +13 -0
  15. package/dist/src/index.d.ts +13 -0
  16. package/dist/src/index.d.ts.map +1 -0
  17. package/dist/src/index.js +14 -0
  18. package/dist/src/index.js.map +1 -0
  19. package/dist/src/lib/ability-checks/cancel.d.ts +41 -0
  20. package/dist/src/lib/ability-checks/cancel.d.ts.map +1 -0
  21. package/dist/src/lib/ability-checks/cancel.js +58 -0
  22. package/dist/src/lib/ability-checks/cancel.js.map +1 -0
  23. package/dist/src/lib/ability-checks/deposit-usdc.d.ts +18 -0
  24. package/dist/src/lib/ability-checks/deposit-usdc.d.ts.map +1 -0
  25. package/dist/src/lib/ability-checks/deposit-usdc.js +40 -0
  26. package/dist/src/lib/ability-checks/deposit-usdc.js.map +1 -0
  27. package/dist/src/lib/ability-checks/hyperliquid-account-exists.d.ts +6 -0
  28. package/dist/src/lib/ability-checks/hyperliquid-account-exists.d.ts.map +1 -0
  29. package/dist/src/lib/ability-checks/hyperliquid-account-exists.js +22 -0
  30. package/dist/src/lib/ability-checks/hyperliquid-account-exists.js.map +1 -0
  31. package/dist/src/lib/ability-checks/index.d.ts +11 -0
  32. package/dist/src/lib/ability-checks/index.d.ts.map +1 -0
  33. package/dist/src/lib/ability-checks/index.js +25 -0
  34. package/dist/src/lib/ability-checks/index.js.map +1 -0
  35. package/dist/src/lib/ability-checks/is-builder-code-approved.d.ts +14 -0
  36. package/dist/src/lib/ability-checks/is-builder-code-approved.d.ts.map +1 -0
  37. package/dist/src/lib/ability-checks/is-builder-code-approved.js +29 -0
  38. package/dist/src/lib/ability-checks/is-builder-code-approved.js.map +1 -0
  39. package/dist/src/lib/ability-checks/perp.d.ts +23 -0
  40. package/dist/src/lib/ability-checks/perp.d.ts.map +1 -0
  41. package/dist/src/lib/ability-checks/perp.js +47 -0
  42. package/dist/src/lib/ability-checks/perp.js.map +1 -0
  43. package/dist/src/lib/ability-checks/send-perp-usdc.d.ts +26 -0
  44. package/dist/src/lib/ability-checks/send-perp-usdc.d.ts.map +1 -0
  45. package/dist/src/lib/ability-checks/send-perp-usdc.js +38 -0
  46. package/dist/src/lib/ability-checks/send-perp-usdc.js.map +1 -0
  47. package/dist/src/lib/ability-checks/send-spot-asset.d.ts +27 -0
  48. package/dist/src/lib/ability-checks/send-spot-asset.d.ts.map +1 -0
  49. package/dist/src/lib/ability-checks/send-spot-asset.js +59 -0
  50. package/dist/src/lib/ability-checks/send-spot-asset.js.map +1 -0
  51. package/dist/src/lib/ability-checks/spot.d.ts +24 -0
  52. package/dist/src/lib/ability-checks/spot.d.ts.map +1 -0
  53. package/dist/src/lib/ability-checks/spot.js +98 -0
  54. package/dist/src/lib/ability-checks/spot.js.map +1 -0
  55. package/dist/src/lib/ability-checks/transfer-usdc.d.ts +26 -0
  56. package/dist/src/lib/ability-checks/transfer-usdc.d.ts.map +1 -0
  57. package/dist/src/lib/ability-checks/transfer-usdc.js +64 -0
  58. package/dist/src/lib/ability-checks/transfer-usdc.js.map +1 -0
  59. package/dist/src/lib/ability-checks/withdraw-usdc.d.ts +25 -0
  60. package/dist/src/lib/ability-checks/withdraw-usdc.d.ts.map +1 -0
  61. package/dist/src/lib/ability-checks/withdraw-usdc.js +39 -0
  62. package/dist/src/lib/ability-checks/withdraw-usdc.js.map +1 -0
  63. package/dist/src/lib/ability-helpers/approve-builder-code.d.ts +22 -0
  64. package/dist/src/lib/ability-helpers/approve-builder-code.d.ts.map +1 -0
  65. package/dist/src/lib/ability-helpers/approve-builder-code.js +53 -0
  66. package/dist/src/lib/ability-helpers/approve-builder-code.js.map +1 -0
  67. package/dist/src/lib/ability-helpers/cancel-order/cancel-all-orders.d.ts +21 -0
  68. package/dist/src/lib/ability-helpers/cancel-order/cancel-all-orders.d.ts.map +1 -0
  69. package/dist/src/lib/ability-helpers/cancel-order/cancel-all-orders.js +69 -0
  70. package/dist/src/lib/ability-helpers/cancel-order/cancel-all-orders.js.map +1 -0
  71. package/dist/src/lib/ability-helpers/cancel-order/cancel-order.d.ts +25 -0
  72. package/dist/src/lib/ability-helpers/cancel-order/cancel-order.d.ts.map +1 -0
  73. package/dist/src/lib/ability-helpers/cancel-order/cancel-order.js +63 -0
  74. package/dist/src/lib/ability-helpers/cancel-order/cancel-order.js.map +1 -0
  75. package/dist/src/lib/ability-helpers/execute-perp-order.d.ts +65 -0
  76. package/dist/src/lib/ability-helpers/execute-perp-order.d.ts.map +1 -0
  77. package/dist/src/lib/ability-helpers/execute-perp-order.js +110 -0
  78. package/dist/src/lib/ability-helpers/execute-perp-order.js.map +1 -0
  79. package/dist/src/lib/ability-helpers/execute-spot-order.d.ts +50 -0
  80. package/dist/src/lib/ability-helpers/execute-spot-order.d.ts.map +1 -0
  81. package/dist/src/lib/ability-helpers/execute-spot-order.js +84 -0
  82. package/dist/src/lib/ability-helpers/execute-spot-order.js.map +1 -0
  83. package/dist/src/lib/ability-helpers/get-hyperliquid-chain-id.d.ts +3 -0
  84. package/dist/src/lib/ability-helpers/get-hyperliquid-chain-id.d.ts.map +1 -0
  85. package/dist/src/lib/ability-helpers/get-hyperliquid-chain-id.js +15 -0
  86. package/dist/src/lib/ability-helpers/get-hyperliquid-chain-id.js.map +1 -0
  87. package/dist/src/lib/ability-helpers/get-hyperliquid-nonce.d.ts +2 -0
  88. package/dist/src/lib/ability-helpers/get-hyperliquid-nonce.d.ts.map +1 -0
  89. package/dist/src/lib/ability-helpers/get-hyperliquid-nonce.js +10 -0
  90. package/dist/src/lib/ability-helpers/get-hyperliquid-nonce.js.map +1 -0
  91. package/dist/src/lib/ability-helpers/index.d.ts +12 -0
  92. package/dist/src/lib/ability-helpers/index.d.ts.map +1 -0
  93. package/dist/src/lib/ability-helpers/index.js +26 -0
  94. package/dist/src/lib/ability-helpers/index.js.map +1 -0
  95. package/dist/src/lib/ability-helpers/lit-action-pkp-ethers-wallet.d.ts +74 -0
  96. package/dist/src/lib/ability-helpers/lit-action-pkp-ethers-wallet.d.ts.map +1 -0
  97. package/dist/src/lib/ability-helpers/lit-action-pkp-ethers-wallet.js +192 -0
  98. package/dist/src/lib/ability-helpers/lit-action-pkp-ethers-wallet.js.map +1 -0
  99. package/dist/src/lib/ability-helpers/send-deposit-tx.d.ts +15 -0
  100. package/dist/src/lib/ability-helpers/send-deposit-tx.d.ts.map +1 -0
  101. package/dist/src/lib/ability-helpers/send-deposit-tx.js +82 -0
  102. package/dist/src/lib/ability-helpers/send-deposit-tx.js.map +1 -0
  103. package/dist/src/lib/ability-helpers/send-perp-usdc.d.ts +16 -0
  104. package/dist/src/lib/ability-helpers/send-perp-usdc.d.ts.map +1 -0
  105. package/dist/src/lib/ability-helpers/send-perp-usdc.js +49 -0
  106. package/dist/src/lib/ability-helpers/send-perp-usdc.js.map +1 -0
  107. package/dist/src/lib/ability-helpers/send-spot-asset.d.ts +17 -0
  108. package/dist/src/lib/ability-helpers/send-spot-asset.d.ts.map +1 -0
  109. package/dist/src/lib/ability-helpers/send-spot-asset.js +61 -0
  110. package/dist/src/lib/ability-helpers/send-spot-asset.js.map +1 -0
  111. package/dist/src/lib/ability-helpers/sign-tx.d.ts +3 -0
  112. package/dist/src/lib/ability-helpers/sign-tx.d.ts.map +1 -0
  113. package/dist/src/lib/ability-helpers/sign-tx.js +28 -0
  114. package/dist/src/lib/ability-helpers/sign-tx.js.map +1 -0
  115. package/dist/src/lib/ability-helpers/transfer-usdc-to.d.ts +16 -0
  116. package/dist/src/lib/ability-helpers/transfer-usdc-to.d.ts.map +1 -0
  117. package/dist/src/lib/ability-helpers/transfer-usdc-to.js +50 -0
  118. package/dist/src/lib/ability-helpers/transfer-usdc-to.js.map +1 -0
  119. package/dist/src/lib/ability-helpers/withdraw-usdc.d.ts +16 -0
  120. package/dist/src/lib/ability-helpers/withdraw-usdc.d.ts.map +1 -0
  121. package/dist/src/lib/ability-helpers/withdraw-usdc.js +49 -0
  122. package/dist/src/lib/ability-helpers/withdraw-usdc.js.map +1 -0
  123. package/dist/src/lib/constants.d.ts +3 -0
  124. package/dist/src/lib/constants.d.ts.map +1 -0
  125. package/dist/src/lib/constants.js +6 -0
  126. package/dist/src/lib/constants.js.map +1 -0
  127. package/dist/src/lib/lit-action.d.ts +2 -0
  128. package/dist/src/lib/lit-action.d.ts.map +1 -0
  129. package/dist/src/lib/lit-action.js +16 -0
  130. package/dist/src/lib/lit-action.js.map +1 -0
  131. package/dist/src/lib/schemas.d.ts +687 -0
  132. package/dist/src/lib/schemas.d.ts.map +1 -0
  133. package/dist/src/lib/schemas.js +233 -0
  134. package/dist/src/lib/schemas.js.map +1 -0
  135. package/dist/src/lib/types.d.ts +39 -0
  136. package/dist/src/lib/types.d.ts.map +1 -0
  137. package/dist/src/lib/types.js +45 -0
  138. package/dist/src/lib/types.js.map +1 -0
  139. package/dist/src/lib/vincent-ability.d.ts +480 -0
  140. package/dist/src/lib/vincent-ability.d.ts.map +1 -0
  141. package/dist/src/lib/vincent-ability.js +595 -0
  142. package/dist/src/lib/vincent-ability.js.map +1 -0
  143. package/package.json +34 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transfer-usdc.d.ts","sourceRoot":"","sources":["../../../../src/lib/ability-checks/transfer-usdc.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AAEnD,MAAM,MAAM,uBAAuB,GAC/B,8BAA8B,GAC9B,8BAA8B,CAAC;AAEnC,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,IAAI,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,UAAU,EACV,UAAU,EACV,MAAM,GACP,EAAE;IACD,UAAU,EAAE,WAAW,CAAC,UAAU,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,cAAc,CAAC;CACxB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAkEnC"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transferPrechecks = transferPrechecks;
4
+ const ethers_1 = require("ethers");
5
+ /**
6
+ * Check if transfer between spot and perp accounts can be executed
7
+ */
8
+ async function transferPrechecks({ infoClient, ethAddress, params, }) {
9
+ // Transfer to spot means we're transferring FROM perp
10
+ // Transfer to perp means we're transferring FROM spot
11
+ if (params.to === 'spot') {
12
+ // Check perp account balance
13
+ const clearinghouseState = await infoClient.clearinghouseState({
14
+ user: ethAddress,
15
+ });
16
+ const availableUsdcBalance = ethers_1.ethers.utils.parseUnits(clearinghouseState.marginSummary.accountValue, 6);
17
+ const requestedAmount = ethers_1.ethers.BigNumber.from(params.amount);
18
+ if (availableUsdcBalance.lt(requestedAmount)) {
19
+ return {
20
+ success: false,
21
+ reason: `Insufficient perp balance. Available: ${ethers_1.ethers.utils.formatUnits(availableUsdcBalance, 6)} USDC, Requested: ${ethers_1.ethers.utils.formatUnits(requestedAmount, 6)} USDC`,
22
+ availableBalance: ethers_1.ethers.utils.formatUnits(availableUsdcBalance, 6),
23
+ requiredBalance: ethers_1.ethers.utils.formatUnits(requestedAmount, 6),
24
+ };
25
+ }
26
+ return {
27
+ success: true,
28
+ availableBalance: ethers_1.ethers.utils.formatUnits(availableUsdcBalance, 6),
29
+ requiredBalance: ethers_1.ethers.utils.formatUnits(requestedAmount, 6),
30
+ };
31
+ }
32
+ else {
33
+ // Check spot account balance
34
+ const spotState = await infoClient.spotClearinghouseState({
35
+ user: ethAddress,
36
+ });
37
+ // Find USDC balance in spot account
38
+ const usdcBalance = spotState.balances.find((b) => b.coin === 'USDC');
39
+ if (!usdcBalance) {
40
+ return {
41
+ success: false,
42
+ reason: 'No USDC balance found in spot account',
43
+ availableBalance: '0',
44
+ };
45
+ }
46
+ // When returned from the Hyperliquid API, the balance is in 8 decimals
47
+ const availableUsdcBalance = ethers_1.ethers.utils.parseUnits(usdcBalance.total, 8);
48
+ const requestedAmount = ethers_1.ethers.BigNumber.from(params.amount);
49
+ if (availableUsdcBalance.lt(requestedAmount)) {
50
+ return {
51
+ success: false,
52
+ reason: `Insufficient spot balance. Available: ${ethers_1.ethers.utils.formatUnits(availableUsdcBalance, 8)} USDC, Requested: ${ethers_1.ethers.utils.formatUnits(requestedAmount, 6)} USDC`,
53
+ availableBalance: availableUsdcBalance.toString(),
54
+ requiredBalance: ethers_1.ethers.utils.formatUnits(requestedAmount, 6),
55
+ };
56
+ }
57
+ return {
58
+ success: true,
59
+ availableBalance: availableUsdcBalance.toString(),
60
+ requiredBalance: requestedAmount.toString(),
61
+ };
62
+ }
63
+ }
64
+ //# sourceMappingURL=transfer-usdc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transfer-usdc.js","sourceRoot":"","sources":["../../../../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-0,0 +1,25 @@
1
+ import * as hyperliquid from '@nktkas/hyperliquid';
2
+ export type WithdrawPrechecksResult = WithdrawPrechecksResultSuccess | WithdrawPrechecksResultFailure;
3
+ export interface WithdrawPrechecksResultSuccess {
4
+ success: true;
5
+ availableBalance: string;
6
+ requiredBalance: string;
7
+ }
8
+ export interface WithdrawPrechecksResultFailure {
9
+ success: false;
10
+ reason: string;
11
+ availableBalance?: string;
12
+ requiredBalance?: string;
13
+ }
14
+ export interface WithdrawParams {
15
+ amount: string;
16
+ }
17
+ /**
18
+ * Check if withdrawal from Hyperliquid to L1 can be executed
19
+ */
20
+ export declare function withdrawPrechecks({ infoClient, ethAddress, params, }: {
21
+ infoClient: hyperliquid.InfoClient;
22
+ ethAddress: string;
23
+ params: WithdrawParams;
24
+ }): Promise<WithdrawPrechecksResult>;
25
+ //# sourceMappingURL=withdraw-usdc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withdraw-usdc.d.ts","sourceRoot":"","sources":["../../../../src/lib/ability-checks/withdraw-usdc.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AAEnD,MAAM,MAAM,uBAAuB,GAC/B,8BAA8B,GAC9B,8BAA8B,CAAC;AAEnC,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,IAAI,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,UAAU,EACV,UAAU,EACV,MAAM,GACP,EAAE;IACD,UAAU,EAAE,WAAW,CAAC,UAAU,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,cAAc,CAAC;CACxB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAsCnC"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withdrawPrechecks = withdrawPrechecks;
4
+ const ethers_1 = require("ethers");
5
+ /**
6
+ * Check if withdrawal from Hyperliquid to L1 can be executed
7
+ */
8
+ async function withdrawPrechecks({ infoClient, ethAddress, params, }) {
9
+ // Withdrawal comes from perp account
10
+ const clearinghouseState = await infoClient.clearinghouseState({
11
+ user: ethAddress,
12
+ });
13
+ const availableUsdcBalance = ethers_1.ethers.utils.parseUnits(clearinghouseState.marginSummary.accountValue, 6);
14
+ const requestedAmount = ethers_1.ethers.BigNumber.from(params.amount);
15
+ const minimumWithdrawAmount = ethers_1.ethers.utils.parseUnits('1', 6); // 1 USDC minimum (withdrawal fee)
16
+ // Check if requested amount is at least 1 USDC
17
+ if (requestedAmount.lt(minimumWithdrawAmount)) {
18
+ return {
19
+ success: false,
20
+ reason: `Withdrawal amount must be at least 1 USDC due to withdrawal fee. Requested: ${ethers_1.ethers.utils.formatUnits(requestedAmount, 6)} USDC`,
21
+ availableBalance: ethers_1.ethers.utils.formatUnits(availableUsdcBalance, 6),
22
+ requiredBalance: ethers_1.ethers.utils.formatUnits(minimumWithdrawAmount, 6),
23
+ };
24
+ }
25
+ if (availableUsdcBalance.lt(requestedAmount)) {
26
+ return {
27
+ success: false,
28
+ reason: `Insufficient perp balance for withdrawal. Available: ${ethers_1.ethers.utils.formatUnits(availableUsdcBalance, 6)} USDC, Requested: ${ethers_1.ethers.utils.formatUnits(requestedAmount, 6)} USDC`,
29
+ availableBalance: ethers_1.ethers.utils.formatUnits(availableUsdcBalance, 6),
30
+ requiredBalance: ethers_1.ethers.utils.formatUnits(requestedAmount, 6),
31
+ };
32
+ }
33
+ return {
34
+ success: true,
35
+ availableBalance: ethers_1.ethers.utils.formatUnits(availableUsdcBalance, 6),
36
+ requiredBalance: ethers_1.ethers.utils.formatUnits(requestedAmount, 6),
37
+ };
38
+ }
39
+ //# sourceMappingURL=withdraw-usdc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withdraw-usdc.js","sourceRoot":"","sources":["../../../../src/lib/ability-checks/withdraw-usdc.ts"],"names":[],"mappings":";;AA2BA,8CA8CC;AAzED,mCAAgC;AAwBhC;;GAEG;AACI,KAAK,UAAU,iBAAiB,CAAC,EACtC,UAAU,EACV,UAAU,EACV,MAAM,GAKP;IACC,qCAAqC;IACrC,MAAM,kBAAkB,GAAG,MAAM,UAAU,CAAC,kBAAkB,CAAC;QAC7D,IAAI,EAAE,UAAU;KACjB,CAAC,CAAC;IAEH,MAAM,oBAAoB,GAAG,eAAM,CAAC,KAAK,CAAC,UAAU,CAClD,kBAAkB,CAAC,aAAa,CAAC,YAAY,EAC7C,CAAC,CACF,CAAC;IAEF,MAAM,eAAe,GAAG,eAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7D,MAAM,qBAAqB,GAAG,eAAM,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,kCAAkC;IAEjG,+CAA+C;IAC/C,IAAI,eAAe,CAAC,EAAE,CAAC,qBAAqB,CAAC,EAAE,CAAC;QAC9C,OAAO;YACL,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,+EAA+E,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC,CAAC,OAAO;YAC1I,gBAAgB,EAAE,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,oBAAoB,EAAE,CAAC,CAAC;YACnE,eAAe,EAAE,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,qBAAqB,EAAE,CAAC,CAAC;SACpE,CAAC;IACJ,CAAC;IAED,IAAI,oBAAoB,CAAC,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC;QAC7C,OAAO;YACL,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,wDAAwD,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,oBAAoB,EAAE,CAAC,CAAC,qBAAqB,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC,CAAC,OAAO;YACzL,gBAAgB,EAAE,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,oBAAoB,EAAE,CAAC,CAAC;YACnE,eAAe,EAAE,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC,CAAC;SAC9D,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,gBAAgB,EAAE,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,oBAAoB,EAAE,CAAC,CAAC;QACnE,eAAe,EAAE,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC,CAAC;KAC9D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,22 @@
1
+ import * as hyperliquid from '@nktkas/hyperliquid';
2
+ import { SuccessResponse } from '@nktkas/hyperliquid/api/exchange';
3
+ export type ApproveBuilderCodeResult = {
4
+ approveResult: SuccessResponse | hyperliquid.ErrorResponse;
5
+ };
6
+ /**
7
+ * Approve a builder code (builder address) with a maximum fee rate on Hyperliquid
8
+ * @param transport - Hyperliquid HTTP transport instance
9
+ * @param pkpPublicKey - PKP public key for signing
10
+ * @param builderAddress - Builder address to approve
11
+ * @param maxFeeRate - Maximum fee rate as a percentage string (e.g., "0.01" for 0.01%)
12
+ * @param useTestnet - Whether to use testnet (default: false)
13
+ * @returns Approval result from Hyperliquid
14
+ */
15
+ export declare function approveBuilderCode({ transport, pkpPublicKey, builderAddress, maxFeeRate, useTestnet, }: {
16
+ transport: hyperliquid.HttpTransport;
17
+ pkpPublicKey: string;
18
+ builderAddress: string;
19
+ maxFeeRate: string;
20
+ useTestnet?: boolean;
21
+ }): Promise<ApproveBuilderCodeResult>;
22
+ //# sourceMappingURL=approve-builder-code.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approve-builder-code.d.ts","sourceRoot":"","sources":["../../../../src/lib/ability-helpers/approve-builder-code.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAGL,eAAe,EAEhB,MAAM,kCAAkC,CAAC;AAQ1C,MAAM,MAAM,wBAAwB,GAAG;IACrC,aAAa,EAAE,eAAe,GAAG,WAAW,CAAC,aAAa,CAAC;CAC5D,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,SAAS,EACT,YAAY,EACZ,cAAc,EACd,UAAU,EACV,UAAkB,GACnB,EAAE;IACD,SAAS,EAAE,WAAW,CAAC,aAAa,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CA6CpC"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.approveBuilderCode = approveBuilderCode;
4
+ const exchange_1 = require("@nktkas/hyperliquid/api/exchange");
5
+ const signing_1 = require("@nktkas/hyperliquid/signing");
6
+ const vincent_ability_sdk_1 = require("@lit-protocol/vincent-ability-sdk");
7
+ const lit_action_pkp_ethers_wallet_1 = require("./lit-action-pkp-ethers-wallet");
8
+ const get_hyperliquid_nonce_1 = require("./get-hyperliquid-nonce");
9
+ const get_hyperliquid_chain_id_1 = require("./get-hyperliquid-chain-id");
10
+ /**
11
+ * Approve a builder code (builder address) with a maximum fee rate on Hyperliquid
12
+ * @param transport - Hyperliquid HTTP transport instance
13
+ * @param pkpPublicKey - PKP public key for signing
14
+ * @param builderAddress - Builder address to approve
15
+ * @param maxFeeRate - Maximum fee rate as a percentage string (e.g., "0.01" for 0.01%)
16
+ * @param useTestnet - Whether to use testnet (default: false)
17
+ * @returns Approval result from Hyperliquid
18
+ */
19
+ async function approveBuilderCode({ transport, pkpPublicKey, builderAddress, maxFeeRate, useTestnet = false, }) {
20
+ const pkpWallet = new lit_action_pkp_ethers_wallet_1.LitActionPkpEthersWallet(pkpPublicKey);
21
+ const nonce = await (0, get_hyperliquid_nonce_1.getHyperliquidNonce)();
22
+ // Ensure maxFeeRate has the % suffix (required by Hyperliquid schema)
23
+ const maxFeeRateWithPercent = maxFeeRate.endsWith('%') ? maxFeeRate : `${maxFeeRate}%`;
24
+ // Construct approve builder fee action
25
+ const approveAction = (0, exchange_1.parser)(exchange_1.ApproveBuilderFeeRequest.entries.action)({
26
+ type: 'approveBuilderFee',
27
+ signatureChainId: (0, get_hyperliquid_chain_id_1.getHyperliquidChainId)(useTestnet),
28
+ hyperliquidChain: (0, get_hyperliquid_chain_id_1.getHyperliquidChainName)(useTestnet),
29
+ maxFeeRate: maxFeeRateWithPercent,
30
+ builder: builderAddress,
31
+ nonce,
32
+ });
33
+ // ApproveBuilderFee is a user-signed action that uses EIP-712 typed data
34
+ const signature = await (0, signing_1.signUserSignedAction)({
35
+ wallet: pkpWallet,
36
+ action: approveAction,
37
+ types: exchange_1.ApproveBuilderFeeTypes,
38
+ });
39
+ const approveResult = await Lit.Actions.runOnce({ waitForResponse: true, name: 'HyperLiquidApproveBuilderFeeRequest' }, async () => {
40
+ return JSON.stringify({
41
+ result: await transport.request('exchange', {
42
+ action: approveAction,
43
+ signature,
44
+ nonce,
45
+ }),
46
+ }, vincent_ability_sdk_1.bigIntReplacer, 2);
47
+ });
48
+ const parsedApproveResult = JSON.parse(approveResult);
49
+ return {
50
+ approveResult: parsedApproveResult.result,
51
+ };
52
+ }
53
+ //# sourceMappingURL=approve-builder-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approve-builder-code.js","sourceRoot":"","sources":["../../../../src/lib/ability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AO,CAAC,UAAU,EAAE;gBAC1C,MAAM,EAAE,aAAa;gBACrB,SAAS;gBACT,KAAK;aACN,CAAC;SACH,EACD,oCAAc,EACd,CAAC,CACF,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,MAAM,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACtD,OAAO;QACL,aAAa,EAAE,mBAAmB,CAAC,MAAqD;KACzF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,21 @@
1
+ import * as hyperliquid from '@nktkas/hyperliquid';
2
+ import { CancelResponse } from '@nktkas/hyperliquid/api/exchange';
3
+ export type CancelAllOrdersResult = CancelAllOrdersResultSuccess | CancelAllOrdersResultFailure;
4
+ export interface CancelAllOrdersResultSuccess {
5
+ status: 'success';
6
+ cancelResult: CancelResponse;
7
+ }
8
+ export interface CancelAllOrdersResultFailure {
9
+ status: 'error';
10
+ reason: string;
11
+ }
12
+ /**
13
+ * Cancel all open spot orders for a specific symbol
14
+ */
15
+ export declare function cancelAllOrdersForSymbol({ transport, pkpPublicKey, symbol, useTestnet, }: {
16
+ transport: hyperliquid.HttpTransport;
17
+ pkpPublicKey: string;
18
+ symbol: string;
19
+ useTestnet?: boolean;
20
+ }): Promise<CancelAllOrdersResult>;
21
+ //# sourceMappingURL=cancel-all-orders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancel-all-orders.d.ts","sourceRoot":"","sources":["../../../../../src/lib/ability-helpers/cancel-order/cancel-all-orders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAiB,cAAc,EAAU,MAAM,kCAAkC,CAAC;AAMzF,MAAM,MAAM,qBAAqB,GAAG,4BAA4B,GAAG,4BAA4B,CAAC;AAEhG,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,SAAS,CAAC;IAClB,YAAY,EAAE,cAAc,CAAC;CAC9B;AAED,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAsB,wBAAwB,CAAC,EAC7C,SAAS,EACT,YAAY,EACZ,MAAM,EACN,UAAkB,GACnB,EAAE;IACD,SAAS,EAAE,WAAW,CAAC,aAAa,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAsEjC"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cancelAllOrdersForSymbol = cancelAllOrdersForSymbol;
4
+ const tslib_1 = require("tslib");
5
+ const hyperliquid = tslib_1.__importStar(require("@nktkas/hyperliquid"));
6
+ const utils_1 = require("@nktkas/hyperliquid/utils");
7
+ const exchange_1 = require("@nktkas/hyperliquid/api/exchange");
8
+ const signing_1 = require("@nktkas/hyperliquid/signing");
9
+ const lit_action_pkp_ethers_wallet_1 = require("../lit-action-pkp-ethers-wallet");
10
+ const get_hyperliquid_nonce_1 = require("../get-hyperliquid-nonce");
11
+ /**
12
+ * Cancel all open spot orders for a specific symbol
13
+ */
14
+ async function cancelAllOrdersForSymbol({ transport, pkpPublicKey, symbol, useTestnet = false, }) {
15
+ // Get converter for symbol to asset ID
16
+ const converter = await utils_1.SymbolConverter.create({ transport });
17
+ const assetId = converter.getAssetId(symbol);
18
+ if (assetId === undefined) {
19
+ throw new Error(`Failed to get asset ID for ${symbol}. The trading pair may not exist.`);
20
+ }
21
+ // Create PKP wallet
22
+ const pkpWallet = new lit_action_pkp_ethers_wallet_1.LitActionPkpEthersWallet(pkpPublicKey);
23
+ const pkpAddress = await pkpWallet.getAddress();
24
+ // Get all open orders for this user
25
+ const infoClient = new hyperliquid.InfoClient({ transport });
26
+ const openOrders = await infoClient.openOrders({
27
+ user: pkpAddress,
28
+ });
29
+ // Filter orders for the specific symbol/asset
30
+ const ordersToCancel = openOrders
31
+ .filter((order) => order.coin === symbol)
32
+ .map((order) => ({
33
+ a: assetId,
34
+ o: order.oid,
35
+ }));
36
+ if (ordersToCancel.length === 0) {
37
+ return {
38
+ status: 'error',
39
+ reason: 'No open orders to cancel',
40
+ };
41
+ }
42
+ const nonce = await (0, get_hyperliquid_nonce_1.getHyperliquidNonce)();
43
+ // Construct cancel action for all orders
44
+ const cancelAction = (0, exchange_1.parser)(exchange_1.CancelRequest.entries.action)({
45
+ type: 'cancel',
46
+ cancels: ordersToCancel,
47
+ });
48
+ // Sign and send
49
+ const signature = await (0, signing_1.signL1Action)({
50
+ wallet: pkpWallet,
51
+ action: cancelAction,
52
+ nonce,
53
+ isTestnet: useTestnet,
54
+ });
55
+ const cancelResult = await Lit.Actions.runOnce({ waitForResponse: true, name: 'HyperLiquidCancelAllOrdersRequest' }, async () => {
56
+ return JSON.stringify(await transport.request('exchange', {
57
+ action: cancelAction,
58
+ signature,
59
+ nonce,
60
+ }));
61
+ });
62
+ const parsedCancelResult = JSON.parse(cancelResult);
63
+ console.log('[cancelAllSpotOrders] Cancel result', parsedCancelResult);
64
+ return {
65
+ status: 'success',
66
+ cancelResult: parsedCancelResult.result,
67
+ };
68
+ }
69
+ //# sourceMappingURL=cancel-all-orders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancel-all-orders.js","sourceRoot":"","sources":["../../../../../src/lib/ability-helpers/cancel-order/cancel-all-orders.ts"],"names":[],"mappings":";;AAuBA,4DAgFC;;AAvGD,yEAAmD;AACnD,qDAA4D;AAC5D,+DAAyF;AACzF,yDAA2D;AAE3D,kFAA2E;AAC3E,oEAA+D;AAc/D;;GAEG;AACI,KAAK,UAAU,wBAAwB,CAAC,EAC7C,SAAS,EACT,YAAY,EACZ,MAAM,EACN,UAAU,GAAG,KAAK,GAMnB;IACC,uCAAuC;IACvC,MAAM,SAAS,GAAG,MAAM,uBAAe,CAAC,MAAM,CAA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IAAA,sBAAY,EAAC;QACnC,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,YAAY;QACpB,KAAK;QACL,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,OAAO,CAC5C,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,EAAE,mCAAmC,EAAE,EACpE,KAAK,IAAI,EAAE;QACT,OAAO,IAAI,CAAC,SAAS,CACnB,MAAM,SAAS,CAAC,OAAO,CAAC,UAAU,EAAE;YAClC,MAAM,EAAE,YAAY;YACpB,SAAS;YACT,KAAK;SACN,CAAC,CACH,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,MAAM,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,qCAAqC,EAAE,kBAAkB,CAAC,CAAC;IAEvE,OAAO;QACL,MAAM,EAAE,SAAS;QACjB,YAAY,EAAE,kBAAkB,CAAC,MAAwB;KAC1D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,25 @@
1
+ import * as hyperliquid from '@nktkas/hyperliquid';
2
+ import { CancelResponse } from '@nktkas/hyperliquid/api/exchange';
3
+ export interface CancelSpotOrderParams {
4
+ symbol: string;
5
+ orderId: number;
6
+ }
7
+ export type CancelOrderResult = CancelOrderResultSuccess | CancelOrderResultFailure;
8
+ export interface CancelOrderResultSuccess {
9
+ status: 'success';
10
+ cancelResult: CancelResponse;
11
+ }
12
+ export interface CancelOrderResultFailure {
13
+ status: 'error';
14
+ reason: string;
15
+ }
16
+ /**
17
+ * Cancel a specific spot order on Hyperliquid
18
+ */
19
+ export declare function cancelOrder({ transport, pkpPublicKey, params, useTestnet, }: {
20
+ transport: hyperliquid.HttpTransport;
21
+ pkpPublicKey: string;
22
+ params: CancelSpotOrderParams;
23
+ useTestnet?: boolean;
24
+ }): Promise<CancelOrderResult>;
25
+ //# sourceMappingURL=cancel-order.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancel-order.d.ts","sourceRoot":"","sources":["../../../../../src/lib/ability-helpers/cancel-order/cancel-order.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAiB,cAAc,EAAU,MAAM,kCAAkC,CAAC;AAOzF,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,iBAAiB,GAAG,wBAAwB,GAAG,wBAAwB,CAAC;AAEpF,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,SAAS,CAAC;IAClB,YAAY,EAAE,cAAc,CAAC;CAC9B;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,EAChC,SAAS,EACT,YAAY,EACZ,MAAM,EACN,UAAkB,GACnB,EAAE;IACD,SAAS,EAAE,WAAW,CAAC,aAAa,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,qBAAqB,CAAC;IAC9B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAiE7B"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cancelOrder = cancelOrder;
4
+ const utils_1 = require("@nktkas/hyperliquid/utils");
5
+ const exchange_1 = require("@nktkas/hyperliquid/api/exchange");
6
+ const signing_1 = require("@nktkas/hyperliquid/signing");
7
+ const vincent_ability_sdk_1 = require("@lit-protocol/vincent-ability-sdk");
8
+ const lit_action_pkp_ethers_wallet_1 = require("../lit-action-pkp-ethers-wallet");
9
+ const get_hyperliquid_nonce_1 = require("../get-hyperliquid-nonce");
10
+ /**
11
+ * Cancel a specific spot order on Hyperliquid
12
+ */
13
+ async function cancelOrder({ transport, pkpPublicKey, params, useTestnet = false, }) {
14
+ // Get converter for symbol to asset ID
15
+ const converter = await utils_1.SymbolConverter.create({ transport });
16
+ const assetId = converter.getAssetId(params.symbol);
17
+ if (assetId === undefined) {
18
+ throw new Error(`Failed to get asset ID for ${params.symbol}. The trading pair may not exist.`);
19
+ }
20
+ // Create PKP wallet
21
+ const pkpWallet = new lit_action_pkp_ethers_wallet_1.LitActionPkpEthersWallet(pkpPublicKey);
22
+ const nonce = await (0, get_hyperliquid_nonce_1.getHyperliquidNonce)();
23
+ // Construct cancel action
24
+ const cancelAction = (0, exchange_1.parser)(exchange_1.CancelRequest.entries.action)({
25
+ type: 'cancel',
26
+ cancels: [
27
+ {
28
+ a: assetId,
29
+ o: params.orderId,
30
+ },
31
+ ],
32
+ });
33
+ // Sign and send
34
+ const signature = await (0, signing_1.signL1Action)({
35
+ wallet: pkpWallet,
36
+ action: cancelAction,
37
+ nonce,
38
+ isTestnet: useTestnet,
39
+ });
40
+ const cancelResult = await Lit.Actions.runOnce({ waitForResponse: true, name: 'HyperLiquidCancelOrderRequest' }, async () => {
41
+ return JSON.stringify({
42
+ result: await transport.request('exchange', {
43
+ action: cancelAction,
44
+ signature,
45
+ nonce,
46
+ }),
47
+ }, vincent_ability_sdk_1.bigIntReplacer, 2);
48
+ });
49
+ const parsedCancelResult = JSON.parse(cancelResult);
50
+ console.log('[cancelSpotOrder] Cancel result', parsedCancelResult);
51
+ const cancelStatus = parsedCancelResult.result.response.data.statuses[0];
52
+ if (typeof cancelStatus === 'object' && cancelStatus.error !== undefined) {
53
+ return {
54
+ status: 'error',
55
+ reason: cancelStatus.error,
56
+ };
57
+ }
58
+ return {
59
+ status: 'success',
60
+ cancelResult: parsedCancelResult.result,
61
+ };
62
+ }
63
+ //# sourceMappingURL=cancel-order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancel-order.js","sourceRoot":"","sources":["../../../../../src/lib/ability-helpers/cancel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IAAI,EAAE;QACT,OAAO,IAAI,CAAC,SAAS,CACnB;YACE,MAAM,EAAE,MAAM,SAAS,CAAC,OAAO,CAAC,UAAU,EAAE;gBAC1C,MAAM,EAAE,YAAY;gBACpB,SAAS;gBACT,KAAK;aACN,CAAC;SACH,EACD,oCAAc,EACd,CAAC,CACF,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,MAAM,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,iCAAiC,EAAE,kBAAkB,CAAC,CAAC;IAEnE,MAAM,YAAY,GAAG,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEzE,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACzE,OAAO;YACL,MAAM,EAAE,OAAO;YACf,MAAM,EAAE,YAAY,CAAC,KAAK;SAC3B,CAAC;IACJ,CAAC;IAED,OAAO;QACL,MAAM,EAAE,SAAS;QACjB,YAAY,EAAE,kBAAkB,CAAC,MAAwB;KAC1D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,65 @@
1
+ import * as hyperliquid from '@nktkas/hyperliquid';
2
+ import { OrderResponse } from '@nktkas/hyperliquid/api/exchange';
3
+ export type TimeInForce = 'Gtc' | 'Ioc' | 'Alo';
4
+ export interface PerpTradeParams {
5
+ symbol: string;
6
+ price: string;
7
+ size: string;
8
+ isLong: boolean;
9
+ /**
10
+ * Reduce-only flag. If true, order will only reduce existing position.
11
+ * Use this to close positions - the order will only fill up to the position size.
12
+ * @default false
13
+ */
14
+ reduceOnly?: boolean;
15
+ /**
16
+ * Order type configuration.
17
+ * - For limit orders: specify { type: 'limit', tif: 'Gtc' | 'Ioc' | 'Alo' }
18
+ * - For market orders: specify { type: 'market' }
19
+ * @default { type: 'limit', tif: 'Gtc' }
20
+ */
21
+ orderType?: {
22
+ type: 'limit';
23
+ tif: TimeInForce;
24
+ } | {
25
+ type: 'market';
26
+ };
27
+ /**
28
+ * Leverage configuration.
29
+ * Required parameter - must specify leverage (1-10x) and margin type.
30
+ */
31
+ leverage: {
32
+ leverage: number;
33
+ isCross: boolean;
34
+ };
35
+ /**
36
+ * Builder fee configuration.
37
+ * Applies to both long and short orders for perpetuals.
38
+ * Fee is specified in tenths of basis points (e.g., 10 = 0.01% = 1 basis point).
39
+ * Maximum builder fee is 0.1% (100 tenths of basis points) for perps.
40
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#builder-codes
41
+ */
42
+ builderFee?: {
43
+ builderAddress: string;
44
+ feeInTenthsOfBps: number;
45
+ };
46
+ }
47
+ export type PerpOrderResult = PerpOrderResultSuccess | PerpOrderResultFailure;
48
+ export interface PerpOrderResultSuccess {
49
+ status: 'success';
50
+ orderResult: OrderResponse;
51
+ }
52
+ export interface PerpOrderResultFailure {
53
+ status: 'error';
54
+ error: string;
55
+ }
56
+ /**
57
+ * Execute a perpetual trade on Hyperliquid
58
+ */
59
+ export declare function executePerpOrder({ transport, pkpPublicKey, params, useTestnet, }: {
60
+ transport: hyperliquid.HttpTransport;
61
+ pkpPublicKey: string;
62
+ params: PerpTradeParams;
63
+ useTestnet?: boolean;
64
+ }): Promise<PerpOrderResult>;
65
+ //# sourceMappingURL=execute-perp-order.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-perp-order.d.ts","sourceRoot":"","sources":["../../../../src/lib/ability-helpers/execute-perp-order.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAEL,aAAa,EAGd,MAAM,kCAAkC,CAAC;AAO1C,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAEhD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,SAAS,CAAC,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,WAAW,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,QAAQ,CAAA;KAAE,CAAC;IACrE;;;OAGG;IACH,QAAQ,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;IACF;;;;;;OAMG;IACH,UAAU,CAAC,EAAE;QACX,cAAc,EAAE,MAAM,CAAC;QACvB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH;AAED,MAAM,MAAM,eAAe,GAAG,sBAAsB,GAAG,sBAAsB,CAAC;AAE9E,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,SAAS,CAAC;IAClB,WAAW,EAAE,aAAa,CAAC;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,SAAS,EACT,YAAY,EACZ,MAAM,EACN,UAAkB,GACnB,EAAE;IACD,SAAS,EAAE,WAAW,CAAC,aAAa,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,OAAO,CAAC,eAAe,CAAC,CAsJ3B"}
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executePerpOrder = executePerpOrder;
4
+ const utils_1 = require("@nktkas/hyperliquid/utils");
5
+ const exchange_1 = require("@nktkas/hyperliquid/api/exchange");
6
+ const signing_1 = require("@nktkas/hyperliquid/signing");
7
+ const vincent_ability_sdk_1 = require("@lit-protocol/vincent-ability-sdk");
8
+ const lit_action_pkp_ethers_wallet_1 = require("./lit-action-pkp-ethers-wallet");
9
+ const get_hyperliquid_nonce_1 = require("./get-hyperliquid-nonce");
10
+ /**
11
+ * Execute a perpetual trade on Hyperliquid
12
+ */
13
+ async function executePerpOrder({ transport, pkpPublicKey, params, useTestnet = false, }) {
14
+ // Get converter for symbol to asset ID
15
+ const converter = await utils_1.SymbolConverter.create({ transport });
16
+ const assetId = converter.getAssetId(params.symbol);
17
+ if (assetId === undefined) {
18
+ throw new Error(`Failed to get asset ID for ${params.symbol}. The perpetual contract may not exist.`);
19
+ }
20
+ // Create PKP wallet
21
+ const pkpWallet = new lit_action_pkp_ethers_wallet_1.LitActionPkpEthersWallet(pkpPublicKey);
22
+ // Set leverage if specified
23
+ if (params.leverage) {
24
+ const leverageNonceResponse = await Lit.Actions.runOnce({ waitForResponse: true, name: 'HyperLiquidPerpLeverageNonce' }, async () => {
25
+ return Date.now().toString();
26
+ });
27
+ const leverageNonce = parseInt(leverageNonceResponse);
28
+ const updateLeverageAction = (0, exchange_1.parser)(exchange_1.UpdateLeverageRequest.entries.action)({
29
+ type: 'updateLeverage',
30
+ asset: assetId,
31
+ isCross: params.leverage.isCross,
32
+ leverage: params.leverage.leverage,
33
+ });
34
+ const leverageSignature = await (0, signing_1.signL1Action)({
35
+ wallet: pkpWallet,
36
+ action: updateLeverageAction,
37
+ nonce: leverageNonce,
38
+ isTestnet: useTestnet,
39
+ });
40
+ await Lit.Actions.runOnce({ waitForResponse: true, name: 'HyperLiquidPerpLeverageRequest' }, async () => {
41
+ return JSON.stringify(await transport.request('exchange', {
42
+ action: updateLeverageAction,
43
+ signature: leverageSignature,
44
+ nonce: leverageNonce,
45
+ }));
46
+ });
47
+ console.log(`[executePerpOrder] Set leverage to ${params.leverage.leverage}x (${params.leverage.isCross ? 'cross' : 'isolated'})`);
48
+ }
49
+ const nonce = await (0, get_hyperliquid_nonce_1.getHyperliquidNonce)();
50
+ // Determine order type configuration
51
+ const orderType = params.orderType || { type: 'limit', tif: 'Gtc' };
52
+ // Construct order type field based on orderType
53
+ const orderTypeField = orderType.type === 'market'
54
+ ? { limit: { tif: 'FrontendMarket' } }
55
+ : { limit: { tif: orderType.tif } };
56
+ // Construct order action
57
+ const orderActionParams = {
58
+ type: 'order',
59
+ orders: [
60
+ {
61
+ a: assetId,
62
+ b: params.isLong, // true for long (buy), false for short (sell)
63
+ p: params.price,
64
+ s: params.size,
65
+ r: params.reduceOnly ?? false, // reduce only (true to close positions, false for opening)
66
+ t: orderTypeField,
67
+ },
68
+ ],
69
+ grouping: 'na',
70
+ };
71
+ // Add builder fee if provided
72
+ // Builder codes apply to both long and short orders for perpetuals
73
+ if (params.builderFee) {
74
+ orderActionParams.builder = {
75
+ b: params.builderFee.builderAddress,
76
+ f: params.builderFee.feeInTenthsOfBps,
77
+ };
78
+ }
79
+ const orderAction = (0, exchange_1.parser)(exchange_1.OrderRequest.entries.action)(orderActionParams);
80
+ // Sign and send
81
+ const signature = await (0, signing_1.signL1Action)({
82
+ wallet: pkpWallet,
83
+ action: orderAction,
84
+ nonce,
85
+ isTestnet: useTestnet,
86
+ });
87
+ const orderResult = await Lit.Actions.runOnce({ waitForResponse: true, name: 'HyperLiquidPerpOrderRequest' }, async () => {
88
+ return JSON.stringify({
89
+ result: await transport.request('exchange', {
90
+ action: orderAction,
91
+ signature,
92
+ nonce,
93
+ }),
94
+ }, vincent_ability_sdk_1.bigIntReplacer, 2);
95
+ });
96
+ const parsedOrderResult = JSON.parse(orderResult);
97
+ console.log('[executePerpOrder] Order result', parsedOrderResult);
98
+ const perpOrderStatus = parsedOrderResult.result.response.data.statuses[0];
99
+ if (perpOrderStatus.error !== undefined) {
100
+ return {
101
+ status: 'error',
102
+ error: perpOrderStatus.error,
103
+ };
104
+ }
105
+ return {
106
+ status: 'success',
107
+ orderResult: parsedOrderResult.result,
108
+ };
109
+ }
110
+ //# sourceMappingURL=execute-perp-order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-perp-order.js","sourceRoot":"","sources":["../../../../src/lib/ability-helpers/execute-perp-order.ts"],"names":[],"mappings":";;AAsEA,4CAgKC;AArOD,qDAA4D;AAC5D,+DAK0C;AAC1C,yDAA2D;AAC3D,2EAAmE;AAEnE,iFAA0E;AAC1E,mEAA8D;AAuD9D;;GAEG;AACI,KAAK,UAAU,gBAAgB,CAAC,EACrC,SAAS,EACT,YAAY,EACZ,MAAM,EACN,UAAU,GAAG,KAAK,GAMnB;IACC,uCAAuC;IACvC,MAAM,SAAS,GAAG,MAAM,uBAAe,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;IAC9D,MAAM,OAAO,GAAG,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEpD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,8BAA8B,MAAM,CAAC,MAAM,yCAAyC,CACrF,CAAC;IACJ,CAAC;IAED,oBAAoB;IACpB,MAAM,SAAS,GAAG,IAAI,uDAAwB,CAAC,YAAY,CAAC,CAAC;IAE7D,4BAA4B;IAC5B,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,MAAM,qBAAqB,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,OAAO,CACrD,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,EAAE,8BAA8B,EAAE,EAC/D,KAAK,IAAI,EAAE;YACT,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;QAC/B,CAAC,CACF,CAAC;QACF,MAAM,aAAa,GAAG,QAAQ,CAAC,qBAAqB,CAAC,CAAC;QAEtD,MAAM,oBAAoB,GAAG,IAAA,iBAAM,EAAC,gCAAqB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACxE,IAAI,EAAE,gBAAgB;YACtB,KAAK,EAAE,OAAO;YACd,OAAO,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