@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,18 @@
1
+ import { ethers } from 'ethers';
2
+ export type DepositPrechecksResult = DepositPrechecksResultSuccess | DepositPrechecksResultFailure;
3
+ export interface DepositPrechecksResultSuccess {
4
+ success: true;
5
+ availableBalance: string;
6
+ }
7
+ export interface DepositPrechecksResultFailure {
8
+ success: false;
9
+ reason: string;
10
+ availableBalance?: string;
11
+ }
12
+ export declare const depositPrechecks: ({ provider, agentWalletPkpEthAddress, depositAmountInMicroUsdc, }: {
13
+ provider: ethers.providers.Provider;
14
+ agentWalletPkpEthAddress: string;
15
+ depositAmountInMicroUsdc: string;
16
+ useTestnet?: boolean;
17
+ }) => Promise<DepositPrechecksResult>;
18
+ //# sourceMappingURL=deposit-usdc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deposit-usdc.d.ts","sourceRoot":"","sources":["../../../../src/lib/ability-checks/deposit-usdc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,MAAM,MAAM,sBAAsB,GAAG,6BAA6B,GAAG,6BAA6B,CAAC;AAEnG,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,IAAI,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAKD,eAAO,MAAM,gBAAgB,GAAU,mEAIpC;IACD,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;IACpC,wBAAwB,EAAE,MAAM,CAAC;IACjC,wBAAwB,EAAE,MAAM,CAAC;IACjC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,KAAG,OAAO,CAAC,sBAAsB,CAiCjC,CAAC"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.depositPrechecks = void 0;
4
+ const ethers_1 = require("ethers");
5
+ const vincent_ability_sdk_1 = require("@lit-protocol/vincent-ability-sdk");
6
+ const types_1 = require("../types");
7
+ // https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/bridge2#deposit
8
+ const MIN_USDC_DEPOSIT_AMOUNT = ethers_1.ethers.BigNumber.from('5000000');
9
+ const depositPrechecks = async ({ provider, agentWalletPkpEthAddress, depositAmountInMicroUsdc, }) => {
10
+ const usdcContract = new ethers_1.ethers.Contract(types_1.ARBITRUM_USDC_ADDRESS_MAINNET, vincent_ability_sdk_1.ERC20_ABI, provider);
11
+ const ethBalance = await provider.getBalance(agentWalletPkpEthAddress);
12
+ if (ethBalance.eq(0n)) {
13
+ return {
14
+ success: false,
15
+ reason: `Agent Wallet PKP has no ETH balance. Please fund the Agent Wallet PKP with ETH`,
16
+ };
17
+ }
18
+ const usdcBalance = await usdcContract.balanceOf(agentWalletPkpEthAddress);
19
+ const _depositAmountInMicroUsdc = ethers_1.ethers.BigNumber.from(depositAmountInMicroUsdc);
20
+ if (_depositAmountInMicroUsdc.lt(MIN_USDC_DEPOSIT_AMOUNT)) {
21
+ return {
22
+ success: false,
23
+ reason: `Deposit amount is less than the minimum deposit amount. Minimum deposit amount required: ${ethers_1.ethers.utils.formatUnits(MIN_USDC_DEPOSIT_AMOUNT, 6)} USDC`,
24
+ availableBalance: ethers_1.ethers.utils.formatUnits(usdcBalance, 6),
25
+ };
26
+ }
27
+ if (usdcBalance.lt(_depositAmountInMicroUsdc)) {
28
+ return {
29
+ success: false,
30
+ reason: `Insufficient USDC balance. Attempted deposit amount: ${ethers_1.ethers.utils.formatUnits(depositAmountInMicroUsdc, 6)} USDC, Available balance: ${ethers_1.ethers.utils.formatUnits(usdcBalance, 6)} USDC`,
31
+ availableBalance: ethers_1.ethers.utils.formatUnits(usdcBalance, 6),
32
+ };
33
+ }
34
+ return {
35
+ success: true,
36
+ availableBalance: ethers_1.ethers.utils.formatUnits(usdcBalance, 6),
37
+ };
38
+ };
39
+ exports.depositPrechecks = depositPrechecks;
40
+ //# sourceMappingURL=deposit-usdc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deposit-usdc.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AAC,WAAW,CAAC,wBAAwB,EAAE,CAAC,CAAC,6BAA6B,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC,OAAO;YACjM,gBAAgB,EAAE,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC;SAC3D,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,gBAAgB,EAAE,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC;KAC3D,CAAC;AACJ,CAAC,CAAC;AA1CW,QAAA,gBAAgB,oBA0C3B"}
@@ -0,0 +1,6 @@
1
+ import type { InfoClient } from '@nktkas/hyperliquid';
2
+ export declare const hyperliquidAccountExists: ({ infoClient, ethAddress, }: {
3
+ infoClient: InfoClient;
4
+ ethAddress: string;
5
+ }) => Promise<boolean>;
6
+ //# sourceMappingURL=hyperliquid-account-exists.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hyperliquid-account-exists.d.ts","sourceRoot":"","sources":["../../../../src/lib/ability-checks/hyperliquid-account-exists.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,eAAO,MAAM,wBAAwB,GAAU,6BAG5C;IACD,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB,qBAkBA,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hyperliquidAccountExists = void 0;
4
+ const hyperliquidAccountExists = async ({ infoClient, ethAddress, }) => {
5
+ try {
6
+ await infoClient.clearinghouseState({ user: ethAddress });
7
+ return true;
8
+ }
9
+ catch (error) {
10
+ console.error('[@lit-protocol/vincent-ability-hyperliquid precheck] Error checking clearinghouse state', error);
11
+ const errorMessage = error instanceof Error ? error.message : String(error);
12
+ if (errorMessage.includes('does not exist')) {
13
+ return false;
14
+ }
15
+ else {
16
+ // Unknown error occurred - not a "does not exist" error
17
+ throw error;
18
+ }
19
+ }
20
+ };
21
+ exports.hyperliquidAccountExists = hyperliquidAccountExists;
22
+ //# sourceMappingURL=hyperliquid-account-exists.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hyperliquid-account-exists.js","sourceRoot":"","sources":["../../../../src/lib/ability-checks/hyperliquid-account-exists.ts"],"names":[],"mappings":";;;AAEO,MAAM,wBAAwB,GAAG,KAAK,EAAE,EAC7C,UAAU,EACV,UAAU,GAIX,EAAE,EAAE;IACH,IAAI,CAAC;QACH,MAAM,UAAU,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CACX,yFAAyF,EACzF,KAAK,CACN,CAAC;QAEF,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,IAAI,YAAY,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC5C,OAAO,KAAK,CAAC;QACf,CAAC;aAAM,CAAC;YACN,wDAAwD;YACxD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAxBW,QAAA,wBAAwB,4BAwBnC"}
@@ -0,0 +1,11 @@
1
+ export { hyperliquidAccountExists } from './hyperliquid-account-exists';
2
+ export { depositPrechecks } from './deposit-usdc';
3
+ export { transferPrechecks } from './transfer-usdc';
4
+ export { spotTradePrechecks } from './spot';
5
+ export { perpTradePrechecks } from './perp';
6
+ export { cancelOrderPrechecks, cancelAllOrdersForSymbolPrechecks } from './cancel';
7
+ export { withdrawPrechecks } from './withdraw-usdc';
8
+ export { sendSpotAssetPrechecks } from './send-spot-asset';
9
+ export { sendPerpUsdcPrechecks } from './send-perp-usdc';
10
+ export { isBuilderCodeApproved } from './is-builder-code-approved';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/ability-checks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,iCAAiC,EAAE,MAAM,UAAU,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isBuilderCodeApproved = exports.sendPerpUsdcPrechecks = exports.sendSpotAssetPrechecks = exports.withdrawPrechecks = exports.cancelAllOrdersForSymbolPrechecks = exports.cancelOrderPrechecks = exports.perpTradePrechecks = exports.spotTradePrechecks = exports.transferPrechecks = exports.depositPrechecks = exports.hyperliquidAccountExists = void 0;
4
+ var hyperliquid_account_exists_1 = require("./hyperliquid-account-exists");
5
+ Object.defineProperty(exports, "hyperliquidAccountExists", { enumerable: true, get: function () { return hyperliquid_account_exists_1.hyperliquidAccountExists; } });
6
+ var deposit_usdc_1 = require("./deposit-usdc");
7
+ Object.defineProperty(exports, "depositPrechecks", { enumerable: true, get: function () { return deposit_usdc_1.depositPrechecks; } });
8
+ var transfer_usdc_1 = require("./transfer-usdc");
9
+ Object.defineProperty(exports, "transferPrechecks", { enumerable: true, get: function () { return transfer_usdc_1.transferPrechecks; } });
10
+ var spot_1 = require("./spot");
11
+ Object.defineProperty(exports, "spotTradePrechecks", { enumerable: true, get: function () { return spot_1.spotTradePrechecks; } });
12
+ var perp_1 = require("./perp");
13
+ Object.defineProperty(exports, "perpTradePrechecks", { enumerable: true, get: function () { return perp_1.perpTradePrechecks; } });
14
+ var cancel_1 = require("./cancel");
15
+ Object.defineProperty(exports, "cancelOrderPrechecks", { enumerable: true, get: function () { return cancel_1.cancelOrderPrechecks; } });
16
+ Object.defineProperty(exports, "cancelAllOrdersForSymbolPrechecks", { enumerable: true, get: function () { return cancel_1.cancelAllOrdersForSymbolPrechecks; } });
17
+ var withdraw_usdc_1 = require("./withdraw-usdc");
18
+ Object.defineProperty(exports, "withdrawPrechecks", { enumerable: true, get: function () { return withdraw_usdc_1.withdrawPrechecks; } });
19
+ var send_spot_asset_1 = require("./send-spot-asset");
20
+ Object.defineProperty(exports, "sendSpotAssetPrechecks", { enumerable: true, get: function () { return send_spot_asset_1.sendSpotAssetPrechecks; } });
21
+ var send_perp_usdc_1 = require("./send-perp-usdc");
22
+ Object.defineProperty(exports, "sendPerpUsdcPrechecks", { enumerable: true, get: function () { return send_perp_usdc_1.sendPerpUsdcPrechecks; } });
23
+ var is_builder_code_approved_1 = require("./is-builder-code-approved");
24
+ Object.defineProperty(exports, "isBuilderCodeApproved", { enumerable: true, get: function () { return is_builder_code_approved_1.isBuilderCodeApproved; } });
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/ability-checks/index.ts"],"names":[],"mappings":";;;AAAA,2EAAwE;AAA/D,sIAAA,wBAAwB,OAAA;AACjC,+CAAkD;AAAzC,gHAAA,gBAAgB,OAAA;AACzB,iDAAoD;AAA3C,kHAAA,iBAAiB,OAAA;AAC1B,+BAA4C;AAAnC,0GAAA,kBAAkB,OAAA;AAC3B,+BAA4C;AAAnC,0GAAA,kBAAkB,OAAA;AAC3B,mCAAmF;AAA1E,8GAAA,oBAAoB,OAAA;AAAE,2HAAA,iCAAiC,OAAA;AAChE,iDAAoD;AAA3C,kHAAA,iBAAiB,OAAA;AAC1B,qDAA2D;AAAlD,yHAAA,sBAAsB,OAAA;AAC/B,mDAAyD;AAAhD,uHAAA,qBAAqB,OAAA;AAC9B,uEAAmE;AAA1D,iIAAA,qBAAqB,OAAA"}
@@ -0,0 +1,14 @@
1
+ import type { InfoClient } from '@nktkas/hyperliquid';
2
+ /**
3
+ * Check if a given address has approved a given builder address
4
+ * @param infoClient - Hyperliquid InfoClient instance
5
+ * @param ethAddress - Ethereum address to check approval for
6
+ * @param builderAddress - Builder address to check approval for
7
+ * @returns true if the builder is approved, false otherwise
8
+ */
9
+ export declare const isBuilderCodeApproved: ({ infoClient, ethAddress, builderAddress, }: {
10
+ infoClient: InfoClient;
11
+ ethAddress: string;
12
+ builderAddress: string;
13
+ }) => Promise<boolean>;
14
+ //# sourceMappingURL=is-builder-code-approved.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-builder-code-approved.d.ts","sourceRoot":"","sources":["../../../../src/lib/ability-checks/is-builder-code-approved.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAU,6CAIzC;IACD,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;CACxB,KAAG,OAAO,CAAC,OAAO,CAmBlB,CAAC"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isBuilderCodeApproved = void 0;
4
+ /**
5
+ * Check if a given address has approved a given builder address
6
+ * @param infoClient - Hyperliquid InfoClient instance
7
+ * @param ethAddress - Ethereum address to check approval for
8
+ * @param builderAddress - Builder address to check approval for
9
+ * @returns true if the builder is approved, false otherwise
10
+ */
11
+ const isBuilderCodeApproved = async ({ infoClient, ethAddress, builderAddress, }) => {
12
+ // Call maxBuilderFee to get the maximum builder fee approved for this builder
13
+ // If the builder is not approved, this will return 0
14
+ const maxFee = await infoClient.maxBuilderFee({
15
+ user: ethAddress,
16
+ builder: builderAddress,
17
+ });
18
+ // Builder is approved if maxFee is greater than 0
19
+ const isApproved = typeof maxFee === 'number' && maxFee > 0;
20
+ console.log('[isBuilderCodeApproved] Builder approval check', {
21
+ ethAddress,
22
+ builderAddress,
23
+ maxFee,
24
+ isApproved,
25
+ });
26
+ return isApproved;
27
+ };
28
+ exports.isBuilderCodeApproved = isBuilderCodeApproved;
29
+ //# sourceMappingURL=is-builder-code-approved.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-builder-code-approved.js","sourceRoot":"","sources":["../../../../src/lib/ability-checks/is-builder-code-approved.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACI,MAAM,qBAAqB,GAAG,KAAK,EAAE,EAC1C,UAAU,EACV,UAAU,EACV,cAAc,GAKf,EAAoB,EAAE;IACrB,8EAA8E;IAC9E,qDAAqD;IACrD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,aAAa,CAAC;QAC5C,IAAI,EAAE,UAA2B;QACjC,OAAO,EAAE,cAA+B;KACzC,CAAC,CAAC;IAEH,kDAAkD;IAClD,MAAM,UAAU,GAAG,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,GAAG,CAAC,CAAC;IAE5D,OAAO,CAAC,GAAG,CAAC,gDAAgD,EAAE;QAC5D,UAAU;QACV,cAAc;QACd,MAAM;QACN,UAAU;KACX,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AA3BW,QAAA,qBAAqB,yBA2BhC"}
@@ -0,0 +1,23 @@
1
+ import * as hyperliquid from '@nktkas/hyperliquid';
2
+ export type PerpTradePrechecksResult = PerpTradePrechecksResultSuccess | PerpTradePrechecksResultFailure;
3
+ export interface PerpTradePrechecksResultSuccess {
4
+ success: true;
5
+ availableMargin: string;
6
+ }
7
+ export interface PerpTradePrechecksResultFailure {
8
+ success: false;
9
+ reason: string;
10
+ availableMargin?: string;
11
+ }
12
+ export interface PerpTradeParams {
13
+ symbol: string;
14
+ }
15
+ /**
16
+ * Check if perpetual trade can be executed
17
+ */
18
+ export declare function perpTradePrechecks({ transport, ethAddress, params, }: {
19
+ transport: hyperliquid.HttpTransport;
20
+ ethAddress: string;
21
+ params: PerpTradeParams;
22
+ }): Promise<PerpTradePrechecksResult>;
23
+ //# sourceMappingURL=perp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"perp.d.ts","sourceRoot":"","sources":["../../../../src/lib/ability-checks/perp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AAGnD,MAAM,MAAM,wBAAwB,GAChC,+BAA+B,GAC/B,+BAA+B,CAAC;AAEpC,MAAM,WAAW,+BAA+B;IAC9C,OAAO,EAAE,IAAI,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,+BAA+B;IAC9C,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,SAAS,EACT,UAAU,EACV,MAAM,GACP,EAAE;IACD,SAAS,EAAE,WAAW,CAAC,aAAa,CAAC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,eAAe,CAAC;CACzB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAyCpC"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.perpTradePrechecks = perpTradePrechecks;
4
+ const tslib_1 = require("tslib");
5
+ const ethers_1 = require("ethers");
6
+ const hyperliquid = tslib_1.__importStar(require("@nktkas/hyperliquid"));
7
+ const utils_1 = require("@nktkas/hyperliquid/utils");
8
+ /**
9
+ * Check if perpetual trade can be executed
10
+ */
11
+ async function perpTradePrechecks({ transport, ethAddress, params, }) {
12
+ const converter = await utils_1.SymbolConverter.create({ transport });
13
+ const assetId = converter.getAssetId(params.symbol);
14
+ if (assetId === undefined) {
15
+ return {
16
+ success: false,
17
+ reason: `Perpetual contract ${params.symbol} does not exist`,
18
+ };
19
+ }
20
+ // Check perp balance to ensure user has funds
21
+ const infoClient = new hyperliquid.InfoClient({ transport });
22
+ const perpState = await infoClient.clearinghouseState({
23
+ user: ethAddress,
24
+ });
25
+ // Check if user has any cross margin value or margin summary
26
+ if (!perpState.crossMarginSummary) {
27
+ return {
28
+ success: false,
29
+ reason: 'No perp account found. Please transfer funds to perp account first.',
30
+ };
31
+ }
32
+ // Check if user has available margin
33
+ // accountValue is in USDC with 6 decimals
34
+ const availableMarginBN = ethers_1.ethers.utils.parseUnits(perpState.crossMarginSummary.accountValue, 6);
35
+ if (availableMarginBN.lte(0)) {
36
+ return {
37
+ success: false,
38
+ reason: 'Insufficient perp account balance. Please transfer funds to perp account first.',
39
+ availableMargin: '0',
40
+ };
41
+ }
42
+ return {
43
+ success: true,
44
+ availableMargin: perpState.crossMarginSummary.accountValue,
45
+ };
46
+ }
47
+ //# sourceMappingURL=perp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"perp.js","sourceRoot":"","sources":["../../../../src/lib/ability-checks/perp.ts"],"names":[],"mappings":";;AA0BA,gDAiDC;;AA3ED,mCAAgC;AAChC,yEAAmD;AACnD,qDAA4D;AAqB5D;;GAEG;AACI,KAAK,UAAU,kBAAkB,CAAC,EACvC,SAAS,EACT,UAAU,EACV,MAAM,GAKP;IACC,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,OAAO;YACL,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,sBAAsB,MAAM,CAAC,MAAM,iBAAiB;SAC7D,CAAC;IACJ,CAAC;IAED,8CAA8C;IAC9C,MAAM,UAAU,GAAG,IAAI,WAAW,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;IAC7D,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,kBAAkB,CAAC;QACpD,IAAI,EAAE,UAAU;KACjB,CAAC,CAAC;IAEH,6DAA6D;IAC7D,IAAI,CAAC,SAAS,CAAC,kBAAkB,EAAE,CAAC;QAClC,OAAO;YACL,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,qEAAqE;SAC9E,CAAC;IACJ,CAAC;IAED,qCAAqC;IACrC,0CAA0C;IAC1C,MAAM,iBAAiB,GAAG,eAAM,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,kBAAkB,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;IAEhG,IAAI,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7B,OAAO;YACL,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,iFAAiF;YACzF,eAAe,EAAE,GAAG;SACrB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,eAAe,EAAE,SAAS,CAAC,kBAAkB,CAAC,YAAY;KAC3D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,26 @@
1
+ import * as hyperliquid from '@nktkas/hyperliquid';
2
+ export type SendPerpUsdcPrechecksResult = SendPerpUsdcPrechecksResultSuccess | SendPerpUsdcPrechecksResultFailure;
3
+ export interface SendPerpUsdcPrechecksResultSuccess {
4
+ success: true;
5
+ availableBalance: string;
6
+ requiredBalance: string;
7
+ }
8
+ export interface SendPerpUsdcPrechecksResultFailure {
9
+ success: false;
10
+ reason: string;
11
+ availableBalance?: string;
12
+ requiredBalance?: string;
13
+ }
14
+ export interface SendPerpUsdcParams {
15
+ destination: string;
16
+ amount: string;
17
+ }
18
+ /**
19
+ * Check if sending USDC from perp account to another Hyperliquid perp account can be executed
20
+ */
21
+ export declare function sendPerpUsdcPrechecks({ infoClient, ethAddress, params, }: {
22
+ infoClient: hyperliquid.InfoClient;
23
+ ethAddress: string;
24
+ params: SendPerpUsdcParams;
25
+ }): Promise<SendPerpUsdcPrechecksResult>;
26
+ //# sourceMappingURL=send-perp-usdc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-perp-usdc.d.ts","sourceRoot":"","sources":["../../../../src/lib/ability-checks/send-perp-usdc.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AAEnD,MAAM,MAAM,2BAA2B,GACnC,kCAAkC,GAClC,kCAAkC,CAAC;AAEvC,MAAM,WAAW,kCAAkC;IACjD,OAAO,EAAE,IAAI,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,kCAAkC;IACjD,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,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,EAC1C,UAAU,EACV,UAAU,EACV,MAAM,GACP,EAAE;IACD,UAAU,EAAE,WAAW,CAAC,UAAU,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,kBAAkB,CAAC;CAC5B,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAqCvC"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendPerpUsdcPrechecks = sendPerpUsdcPrechecks;
4
+ const ethers_1 = require("ethers");
5
+ /**
6
+ * Check if sending USDC from perp account to another Hyperliquid perp account can be executed
7
+ */
8
+ async function sendPerpUsdcPrechecks({ infoClient, ethAddress, params, }) {
9
+ // Validate destination address
10
+ if (!ethers_1.ethers.utils.isAddress(params.destination)) {
11
+ return {
12
+ success: false,
13
+ reason: `Invalid destination address: ${params.destination}`,
14
+ };
15
+ }
16
+ // Get perp account balance
17
+ const clearinghouseState = await infoClient.clearinghouseState({
18
+ user: ethAddress,
19
+ });
20
+ const availableUsdcBalance = ethers_1.ethers.utils.parseUnits(clearinghouseState.marginSummary.accountValue, 6);
21
+ console.log('[sendPerpUsdcPrechecks] Available balance:', availableUsdcBalance);
22
+ const requestedAmount = ethers_1.ethers.BigNumber.from(params.amount);
23
+ console.log('[sendPerpUsdcPrechecks] Requested amount:', requestedAmount);
24
+ if (availableUsdcBalance.lt(requestedAmount)) {
25
+ return {
26
+ success: false,
27
+ reason: `Insufficient perp balance for send. Available: ${ethers_1.ethers.utils.formatUnits(availableUsdcBalance, 6)} USDC, Requested: ${ethers_1.ethers.utils.formatUnits(requestedAmount, 6)} USDC`,
28
+ availableBalance: ethers_1.ethers.utils.formatUnits(availableUsdcBalance, 6),
29
+ requiredBalance: ethers_1.ethers.utils.formatUnits(requestedAmount, 6),
30
+ };
31
+ }
32
+ return {
33
+ success: true,
34
+ availableBalance: ethers_1.ethers.utils.formatUnits(availableUsdcBalance, 6),
35
+ requiredBalance: ethers_1.ethers.utils.formatUnits(requestedAmount, 6),
36
+ };
37
+ }
38
+ //# sourceMappingURL=send-perp-usdc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-perp-usdc.js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,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,27 @@
1
+ import * as hyperliquid from '@nktkas/hyperliquid';
2
+ export type SendSpotAssetPrechecksResult = SendSpotAssetPrechecksResultSuccess | SendSpotAssetPrechecksResultFailure;
3
+ export interface SendSpotAssetPrechecksResultSuccess {
4
+ success: true;
5
+ availableBalance: string;
6
+ requiredBalance: string;
7
+ }
8
+ export interface SendSpotAssetPrechecksResultFailure {
9
+ success: false;
10
+ reason: string;
11
+ availableBalance?: string;
12
+ requiredBalance?: string;
13
+ }
14
+ export interface SendSpotAssetParams {
15
+ destination: string;
16
+ token: string;
17
+ amount: string;
18
+ }
19
+ /**
20
+ * Check if sending spot assets to another Hyperliquid spot account can be executed
21
+ */
22
+ export declare function sendSpotAssetPrechecks({ infoClient, ethAddress, params, }: {
23
+ infoClient: hyperliquid.InfoClient;
24
+ ethAddress: string;
25
+ params: SendSpotAssetParams;
26
+ }): Promise<SendSpotAssetPrechecksResult>;
27
+ //# sourceMappingURL=send-spot-asset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-spot-asset.d.ts","sourceRoot":"","sources":["../../../../src/lib/ability-checks/send-spot-asset.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AAEnD,MAAM,MAAM,4BAA4B,GACpC,mCAAmC,GACnC,mCAAmC,CAAC;AAExC,MAAM,WAAW,mCAAmC;IAClD,OAAO,EAAE,IAAI,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,mCAAmC;IAClD,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,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,EAC3C,UAAU,EACV,UAAU,EACV,MAAM,GACP,EAAE;IACD,UAAU,EAAE,WAAW,CAAC,UAAU,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,mBAAmB,CAAC;CAC7B,GAAG,OAAO,CAAC,4BAA4B,CAAC,CA+DxC"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendSpotAssetPrechecks = sendSpotAssetPrechecks;
4
+ const ethers_1 = require("ethers");
5
+ /**
6
+ * Check if sending spot assets to another Hyperliquid spot account can be executed
7
+ */
8
+ async function sendSpotAssetPrechecks({ infoClient, ethAddress, params, }) {
9
+ // Validate destination address
10
+ if (!ethers_1.ethers.utils.isAddress(params.destination)) {
11
+ return {
12
+ success: false,
13
+ reason: `Invalid destination address: ${params.destination}`,
14
+ };
15
+ }
16
+ // Fetch token metadata to get the correct decimal places
17
+ const spotMeta = await infoClient.spotMeta();
18
+ const tokenInfo = spotMeta.tokens.find((t) => t.name === params.token);
19
+ if (!tokenInfo) {
20
+ return {
21
+ success: false,
22
+ reason: `Token ${params.token} not found in spot metadata`,
23
+ };
24
+ }
25
+ // Get spot balances
26
+ const spotClearinghouseState = await infoClient.spotClearinghouseState({
27
+ user: ethAddress,
28
+ });
29
+ // Find the token balance
30
+ const tokenBalance = spotClearinghouseState.balances.find((balance) => balance.coin === params.token);
31
+ if (!tokenBalance) {
32
+ return {
33
+ success: false,
34
+ reason: `No balance found for token: ${params.token}`,
35
+ availableBalance: '0',
36
+ requiredBalance: ethers_1.ethers.utils.formatUnits(params.amount, tokenInfo.weiDecimals),
37
+ };
38
+ }
39
+ // Convert the balance from human-readable format to smallest units using token's weiDecimals
40
+ // weiDecimals represents the exchange precision for amounts
41
+ const availableBalance = ethers_1.ethers.BigNumber.from(ethers_1.ethers.utils.parseUnits(tokenBalance.total, tokenInfo.weiDecimals));
42
+ console.log('[sendAssetPrechecks] Available balance:', availableBalance);
43
+ const requestedAmount = ethers_1.ethers.BigNumber.from(params.amount);
44
+ console.log('[sendAssetPrechecks] Requested amount:', requestedAmount);
45
+ if (availableBalance.lt(requestedAmount)) {
46
+ return {
47
+ success: false,
48
+ reason: `Insufficient ${params.token} balance for send. Available: ${ethers_1.ethers.utils.formatUnits(availableBalance, tokenInfo.weiDecimals)} ${params.token}, Requested: ${ethers_1.ethers.utils.formatUnits(requestedAmount, tokenInfo.weiDecimals)} ${params.token}`,
49
+ availableBalance: ethers_1.ethers.utils.formatUnits(availableBalance, tokenInfo.weiDecimals),
50
+ requiredBalance: ethers_1.ethers.utils.formatUnits(requestedAmount, tokenInfo.weiDecimals),
51
+ };
52
+ }
53
+ return {
54
+ success: true,
55
+ availableBalance: ethers_1.ethers.utils.formatUnits(availableBalance, tokenInfo.weiDecimals),
56
+ requiredBalance: ethers_1.ethers.utils.formatUnits(requestedAmount, tokenInfo.weiDecimals),
57
+ };
58
+ }
59
+ //# sourceMappingURL=send-spot-asset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-spot-asset.js","sourceRoot":"","sources":["../../../../src/lib/ability-checks/send-spot-asset.ts"],"names":[],"mappings":";;AA6BA,wDAuEC;AApGD,mCAAgC;AA0BhC;;GAEG;AACI,KAAK,UAAU,sBAAsB,CAAC,EAC3C,UAAU,EACV,UAAU,EACV,MAAM,GAKP;IACC,+BAA+B;IAC/B,IAAI,CAAC,eAAM,CAAC,KAAK,CAAC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SAAS,CAAC,WAAW,CAAC,CACnE,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,yCAAyC,EAAE,gBAAgB,CAAC,CAAC;IAEzE,MAAM,eAAe,GAAG,eAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7D,OAAO,CAAC,GAAG,CAAC,wCAAwC,EAAE,eAAe,CAAC,CAAC;IAEvE,IAAI,gBAAgB,CAAC,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC;QACzC,OAAO;YACL,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,gBAAgB,MAAM,CAAC,KAAK,iCAAiC,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,gBAAgB,EAAE,SAAS,CAAC,WAAW,CAAC,IAAI,MAAM,CAAC,KAAK,gBAAgB,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,EAAE,SAAS,CAAC,WAAW,CAAC,IAAI,MAAM,CAAC,KAAK,EAAE;YACxP,gBAAgB,EAAE,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,gBAAgB,EAAE,SAAS,CAAC,WAAW,CAAC;YACnF,eAAe,EAAE,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,EAAE,SAAS,CAAC,WAAW,CAAC;SAClF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,gBAAgB,EAAE,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,gBAAgB,EAAE,SAAS,CAAC,WAAW,CAAC;QACnF,eAAe,EAAE,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,EAAE,SAAS,CAAC,WAAW,CAAC;KAClF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,24 @@
1
+ import * as hyperliquid from '@nktkas/hyperliquid';
2
+ export type SpotTradePrechecksResult = SpotTradePrechecksResultSuccess | SpotTradePrechecksResultFailure;
3
+ export interface SpotTradePrechecksResultSuccess {
4
+ success: true;
5
+ }
6
+ export interface SpotTradePrechecksResultFailure {
7
+ success: false;
8
+ reason: string;
9
+ }
10
+ export interface SpotTradeParams {
11
+ symbol: string;
12
+ price: string;
13
+ size: string;
14
+ isBuy: boolean;
15
+ }
16
+ /**
17
+ * Check if spot trade can be executed
18
+ */
19
+ export declare function spotTradePrechecks({ transport, ethAddress, params, }: {
20
+ transport: hyperliquid.HttpTransport;
21
+ ethAddress: string;
22
+ params: SpotTradeParams;
23
+ }): Promise<SpotTradePrechecksResult>;
24
+ //# sourceMappingURL=spot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spot.d.ts","sourceRoot":"","sources":["../../../../src/lib/ability-checks/spot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AAGnD,MAAM,MAAM,wBAAwB,GAChC,+BAA+B,GAC/B,+BAA+B,CAAC;AAEpC,MAAM,WAAW,+BAA+B;IAC9C,OAAO,EAAE,IAAI,CAAC;CACf;AAED,MAAM,WAAW,+BAA+B;IAC9C,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,SAAS,EACT,UAAU,EACV,MAAM,GACP,EAAE;IACD,SAAS,EAAE,WAAW,CAAC,aAAa,CAAC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,eAAe,CAAC;CACzB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CA6FpC"}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.spotTradePrechecks = spotTradePrechecks;
4
+ const tslib_1 = require("tslib");
5
+ const hyperliquid = tslib_1.__importStar(require("@nktkas/hyperliquid"));
6
+ const utils_1 = require("@nktkas/hyperliquid/utils");
7
+ /**
8
+ * Check if spot trade can be executed
9
+ */
10
+ async function spotTradePrechecks({ transport, ethAddress, params, }) {
11
+ try {
12
+ const converter = await utils_1.SymbolConverter.create({ transport });
13
+ const assetId = converter.getAssetId(params.symbol);
14
+ if (assetId === undefined) {
15
+ return {
16
+ success: false,
17
+ reason: `Trading pair ${params.symbol} does not exist`,
18
+ };
19
+ }
20
+ // Check if account exists
21
+ const infoClient = new hyperliquid.InfoClient({ transport });
22
+ try {
23
+ await infoClient.clearinghouseState({ user: ethAddress });
24
+ // If this succeeds, account exists
25
+ }
26
+ catch (error) {
27
+ const errorMessage = error instanceof Error ? error.message : String(error);
28
+ if (errorMessage.includes('does not exist')) {
29
+ return {
30
+ success: false,
31
+ reason: 'Hyperliquid account does not exist. Please deposit first.',
32
+ };
33
+ }
34
+ throw error;
35
+ }
36
+ // Check spot balance to ensure user has funds
37
+ const spotState = await infoClient.spotClearinghouseState({
38
+ user: ethAddress,
39
+ });
40
+ if (!spotState.balances || spotState.balances.length === 0) {
41
+ return {
42
+ success: false,
43
+ reason: 'No spot balance found. Please transfer funds to spot account first.',
44
+ };
45
+ }
46
+ // Parse the trading pair to get base and quote assets
47
+ // Format examples: "BTC/USDC", "ETH/USDC", "BTC/ETH"
48
+ // Note: Format validation is handled by spotTradeParamsSchema in schemas.ts
49
+ const [baseAsset, quoteAsset] = params.symbol.split('/');
50
+ // Check balance based on whether this is a buy or sell
51
+ if (params.isBuy) {
52
+ // For buy orders, check if user has the quote asset (what they're spending)
53
+ const quoteBalance = spotState.balances.find((b) => b.coin === quoteAsset);
54
+ if (!quoteBalance) {
55
+ return {
56
+ success: false,
57
+ reason: `No ${quoteAsset} balance found in spot account. Cannot buy ${baseAsset}.`,
58
+ };
59
+ }
60
+ // Check if quote balance is available (not all locked in orders)
61
+ const availableQuote = parseFloat(quoteBalance.total) - parseFloat(quoteBalance.hold);
62
+ if (availableQuote <= 0) {
63
+ return {
64
+ success: false,
65
+ reason: `Insufficient available ${quoteAsset} balance. All ${quoteAsset} is locked in open orders.`,
66
+ };
67
+ }
68
+ }
69
+ else {
70
+ // For sell orders, check if user has the base asset (what they're selling)
71
+ const baseBalance = spotState.balances.find((b) => b.coin === baseAsset);
72
+ if (!baseBalance) {
73
+ return {
74
+ success: false,
75
+ reason: `No ${baseAsset} balance found in spot account. Cannot sell ${baseAsset}.`,
76
+ };
77
+ }
78
+ // Check if base balance is available (not all locked in orders)
79
+ const availableBase = parseFloat(baseBalance.total) - parseFloat(baseBalance.hold);
80
+ if (availableBase <= 0) {
81
+ return {
82
+ success: false,
83
+ reason: `Insufficient available ${baseAsset} balance. All ${baseAsset} is locked in open orders.`,
84
+ };
85
+ }
86
+ }
87
+ return {
88
+ success: true,
89
+ };
90
+ }
91
+ catch (error) {
92
+ return {
93
+ success: false,
94
+ reason: error instanceof Error ? error.message : String(error),
95
+ };
96
+ }
97
+ }
98
+ //# sourceMappingURL=spot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spot.js","sourceRoot":"","sources":["../../../../src/lib/ability-checks/spot.ts"],"names":[],"mappings":";;AA0BA,gDAqGC;;AA/HD,yEAAmD;AACnD,qDAA4D;AAsB5D;;GAEG;AACI,KAAK,UAAU,kBAAkB,CAAC,EACvC,SAAS,EACT,UAAU,EACV,MAAM,GAKP;IACC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,uBAAe,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;QAC9D,MAAM,OAAO,GAAG,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAEpD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,gBAAgB,MAAM,CAAC,MAAM,iBAAiB;aACvD,CAAC;QACJ,CAAC;QAED,0BAA0B;QAC1B,MAAM,UAAU,GA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;SAC/D,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,26 @@
1
+ import * as hyperliquid from '@nktkas/hyperliquid';
2
+ export type TransferPrechecksResult = TransferPrechecksResultSuccess | TransferPrechecksResultFailure;
3
+ export interface TransferPrechecksResultSuccess {
4
+ success: true;
5
+ availableBalance: string;
6
+ requiredBalance: string;
7
+ }
8
+ export interface TransferPrechecksResultFailure {
9
+ success: false;
10
+ reason: string;
11
+ availableBalance?: string;
12
+ requiredBalance?: string;
13
+ }
14
+ export interface TransferParams {
15
+ amount: string;
16
+ to: 'spot' | 'perp';
17
+ }
18
+ /**
19
+ * Check if transfer between spot and perp accounts can be executed
20
+ */
21
+ export declare function transferPrechecks({ infoClient, ethAddress, params, }: {
22
+ infoClient: hyperliquid.InfoClient;
23
+ ethAddress: string;
24
+ params: TransferParams;
25
+ }): Promise<TransferPrechecksResult>;
26
+ //# sourceMappingURL=transfer-usdc.d.ts.map