@oobe-protocol-labs/sap-mcp-server 0.9.38 → 0.9.51

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 (178) hide show
  1. package/dist/config/env.d.ts +19 -0
  2. package/dist/config/env.d.ts.map +1 -1
  3. package/dist/config/env.js +9 -2
  4. package/dist/config/env.js.map +1 -1
  5. package/dist/config/mcp-client-injection.d.ts +1 -1
  6. package/dist/config/mcp-client-injection.d.ts.map +1 -1
  7. package/dist/config/mcp-client-injection.js +35 -0
  8. package/dist/config/mcp-client-injection.js.map +1 -1
  9. package/dist/config/wizard.js +2 -2
  10. package/dist/config/wizard.js.map +1 -1
  11. package/dist/core/constants.d.ts +1 -1
  12. package/dist/core/constants.js +1 -1
  13. package/dist/core/logger.js +1 -1
  14. package/dist/payments/monetization-gate.d.ts +5 -0
  15. package/dist/payments/monetization-gate.d.ts.map +1 -1
  16. package/dist/payments/monetization-gate.js +39 -2
  17. package/dist/payments/monetization-gate.js.map +1 -1
  18. package/dist/payments/prepaid-credit-store.d.ts +111 -0
  19. package/dist/payments/prepaid-credit-store.d.ts.map +1 -0
  20. package/dist/payments/prepaid-credit-store.js +230 -0
  21. package/dist/payments/prepaid-credit-store.js.map +1 -0
  22. package/dist/payments/pricing.d.ts.map +1 -1
  23. package/dist/payments/pricing.js +1 -0
  24. package/dist/payments/pricing.js.map +1 -1
  25. package/dist/payments/schema-validation.d.ts +52 -0
  26. package/dist/payments/schema-validation.d.ts.map +1 -0
  27. package/dist/payments/schema-validation.js +112 -0
  28. package/dist/payments/schema-validation.js.map +1 -0
  29. package/dist/payments/x402-paid-call.d.ts +21 -0
  30. package/dist/payments/x402-paid-call.d.ts.map +1 -1
  31. package/dist/payments/x402-paid-call.js +108 -3
  32. package/dist/payments/x402-paid-call.js.map +1 -1
  33. package/dist/perps/adrena/adrena-builder-commodity.d.ts +63 -0
  34. package/dist/perps/adrena/adrena-builder-commodity.d.ts.map +1 -0
  35. package/dist/perps/adrena/adrena-builder-commodity.js +200 -0
  36. package/dist/perps/adrena/adrena-builder-commodity.js.map +1 -0
  37. package/dist/perps/adrena/adrena-builder-core.d.ts +319 -0
  38. package/dist/perps/adrena/adrena-builder-core.d.ts.map +1 -0
  39. package/dist/perps/adrena/adrena-builder-core.js +516 -0
  40. package/dist/perps/adrena/adrena-builder-core.js.map +1 -0
  41. package/dist/perps/adrena/adrena-builder-liquidity.d.ts +50 -0
  42. package/dist/perps/adrena/adrena-builder-liquidity.d.ts.map +1 -0
  43. package/dist/perps/adrena/adrena-builder-liquidity.js +196 -0
  44. package/dist/perps/adrena/adrena-builder-liquidity.js.map +1 -0
  45. package/dist/perps/adrena/adrena-builder-staking.d.ts +57 -0
  46. package/dist/perps/adrena/adrena-builder-staking.d.ts.map +1 -0
  47. package/dist/perps/adrena/adrena-builder-staking.js +368 -0
  48. package/dist/perps/adrena/adrena-builder-staking.js.map +1 -0
  49. package/dist/perps/adrena/adrena-builder-trading.d.ts +160 -0
  50. package/dist/perps/adrena/adrena-builder-trading.d.ts.map +1 -0
  51. package/dist/perps/adrena/adrena-builder-trading.js +835 -0
  52. package/dist/perps/adrena/adrena-builder-trading.js.map +1 -0
  53. package/dist/perps/adrena/adrena-builder.d.ts +14 -293
  54. package/dist/perps/adrena/adrena-builder.d.ts.map +1 -1
  55. package/dist/perps/adrena/adrena-builder.js +14 -1140
  56. package/dist/perps/adrena/adrena-builder.js.map +1 -1
  57. package/dist/perps/adrena/adrena-constants.d.ts +33 -5
  58. package/dist/perps/adrena/adrena-constants.d.ts.map +1 -1
  59. package/dist/perps/adrena/adrena-constants.js +29 -7
  60. package/dist/perps/adrena/adrena-constants.js.map +1 -1
  61. package/dist/perps/adrena/adrena-idl.d.ts +15084 -0
  62. package/dist/perps/adrena/adrena-idl.d.ts.map +1 -0
  63. package/dist/perps/adrena/adrena-idl.js +29902 -0
  64. package/dist/perps/adrena/adrena-idl.js.map +1 -0
  65. package/dist/perps/adrena/adrena-pda.d.ts +5 -4
  66. package/dist/perps/adrena/adrena-pda.d.ts.map +1 -1
  67. package/dist/perps/adrena/adrena-pda.js +6 -10
  68. package/dist/perps/adrena/adrena-pda.js.map +1 -1
  69. package/dist/perps/adrena/index.d.ts +1 -0
  70. package/dist/perps/adrena/index.d.ts.map +1 -1
  71. package/dist/perps/adrena/index.js +1 -0
  72. package/dist/perps/adrena/index.js.map +1 -1
  73. package/dist/perps/chart-indicators.d.ts +27 -0
  74. package/dist/perps/chart-indicators.d.ts.map +1 -0
  75. package/dist/perps/chart-indicators.js +345 -0
  76. package/dist/perps/chart-indicators.js.map +1 -0
  77. package/dist/perps/chart-tools.d.ts +45 -0
  78. package/dist/perps/chart-tools.d.ts.map +1 -0
  79. package/dist/perps/chart-tools.js +341 -0
  80. package/dist/perps/chart-tools.js.map +1 -0
  81. package/dist/perps/perp-analytics-tools.d.ts +20 -0
  82. package/dist/perps/perp-analytics-tools.d.ts.map +1 -0
  83. package/dist/perps/perp-analytics-tools.js +868 -0
  84. package/dist/perps/perp-analytics-tools.js.map +1 -0
  85. package/dist/perps/perp-constants.d.ts +362 -0
  86. package/dist/perps/perp-constants.d.ts.map +1 -0
  87. package/dist/perps/perp-constants.js +210 -0
  88. package/dist/perps/perp-constants.js.map +1 -0
  89. package/dist/perps/perp-decoders.d.ts +47 -0
  90. package/dist/perps/perp-decoders.d.ts.map +1 -0
  91. package/dist/perps/perp-decoders.js +332 -0
  92. package/dist/perps/perp-decoders.js.map +1 -0
  93. package/dist/policy/policy-engine.d.ts +42 -0
  94. package/dist/policy/policy-engine.d.ts.map +1 -1
  95. package/dist/policy/policy-engine.js +43 -0
  96. package/dist/policy/policy-engine.js.map +1 -1
  97. package/dist/premium/activation-manager.d.ts.map +1 -1
  98. package/dist/premium/activation-manager.js +20 -2
  99. package/dist/premium/activation-manager.js.map +1 -1
  100. package/dist/prompts/context/sap-agent-context.prompt.js +15 -1
  101. package/dist/prompts/context/sap-agent-context.prompt.js.map +1 -1
  102. package/dist/server/server-metadata.d.ts +13 -0
  103. package/dist/server/server-metadata.d.ts.map +1 -1
  104. package/dist/server/server-metadata.js +15 -2
  105. package/dist/server/server-metadata.js.map +1 -1
  106. package/dist/solana/ata-utils.d.ts +39 -0
  107. package/dist/solana/ata-utils.d.ts.map +1 -0
  108. package/dist/solana/ata-utils.js +49 -0
  109. package/dist/solana/ata-utils.js.map +1 -0
  110. package/dist/strategies/trade-journal.d.ts +78 -0
  111. package/dist/strategies/trade-journal.d.ts.map +1 -0
  112. package/dist/strategies/trade-journal.js +92 -0
  113. package/dist/strategies/trade-journal.js.map +1 -0
  114. package/dist/tools/adrena/adrena-commodity-tools.d.ts +15 -0
  115. package/dist/tools/adrena/adrena-commodity-tools.d.ts.map +1 -0
  116. package/dist/tools/adrena/adrena-commodity-tools.js +137 -0
  117. package/dist/tools/adrena/adrena-commodity-tools.js.map +1 -0
  118. package/dist/tools/adrena/adrena-data-tools.d.ts +23 -0
  119. package/dist/tools/adrena/adrena-data-tools.d.ts.map +1 -0
  120. package/dist/tools/adrena/adrena-data-tools.js +437 -0
  121. package/dist/tools/adrena/adrena-data-tools.js.map +1 -0
  122. package/dist/tools/adrena/adrena-helpers.d.ts +46 -0
  123. package/dist/tools/adrena/adrena-helpers.d.ts.map +1 -0
  124. package/dist/tools/adrena/adrena-helpers.js +41 -0
  125. package/dist/tools/adrena/adrena-helpers.js.map +1 -0
  126. package/dist/tools/adrena/adrena-index.d.ts +20 -0
  127. package/dist/tools/adrena/adrena-index.d.ts.map +1 -0
  128. package/dist/tools/adrena/adrena-index.js +75 -0
  129. package/dist/tools/adrena/adrena-index.js.map +1 -0
  130. package/dist/tools/adrena/adrena-limit-order-tools.d.ts +22 -0
  131. package/dist/tools/adrena/adrena-limit-order-tools.d.ts.map +1 -0
  132. package/dist/tools/adrena/adrena-limit-order-tools.js +91 -0
  133. package/dist/tools/adrena/adrena-limit-order-tools.js.map +1 -0
  134. package/dist/tools/adrena/adrena-liquidity-tools.d.ts +15 -0
  135. package/dist/tools/adrena/adrena-liquidity-tools.d.ts.map +1 -0
  136. package/dist/tools/adrena/adrena-liquidity-tools.js +108 -0
  137. package/dist/tools/adrena/adrena-liquidity-tools.js.map +1 -0
  138. package/dist/tools/adrena/adrena-snapshot-tools.d.ts +42 -0
  139. package/dist/tools/adrena/adrena-snapshot-tools.d.ts.map +1 -0
  140. package/dist/tools/adrena/adrena-snapshot-tools.js +124 -0
  141. package/dist/tools/adrena/adrena-snapshot-tools.js.map +1 -0
  142. package/dist/tools/adrena/adrena-staking-tools.d.ts +15 -0
  143. package/dist/tools/adrena/adrena-staking-tools.d.ts.map +1 -0
  144. package/dist/tools/adrena/adrena-staking-tools.js +139 -0
  145. package/dist/tools/adrena/adrena-staking-tools.js.map +1 -0
  146. package/dist/tools/adrena/adrena-trading-tools.d.ts +78 -0
  147. package/dist/tools/adrena/adrena-trading-tools.d.ts.map +1 -0
  148. package/dist/tools/adrena/adrena-trading-tools.js +556 -0
  149. package/dist/tools/adrena/adrena-trading-tools.js.map +1 -0
  150. package/dist/tools/adrena-tools.d.ts +1 -66
  151. package/dist/tools/adrena-tools.d.ts.map +1 -1
  152. package/dist/tools/adrena-tools.js +1 -1061
  153. package/dist/tools/adrena-tools.js.map +1 -1
  154. package/dist/tools/client-sdk-tools.js +1 -1
  155. package/dist/tools/client-sdk-tools.js.map +1 -1
  156. package/dist/tools/memory-tools.d.ts.map +1 -1
  157. package/dist/tools/memory-tools.js +170 -0
  158. package/dist/tools/memory-tools.js.map +1 -1
  159. package/dist/tools/perp-tools.d.ts +6 -174
  160. package/dist/tools/perp-tools.d.ts.map +1 -1
  161. package/dist/tools/perp-tools.js +6 -1716
  162. package/dist/tools/perp-tools.js.map +1 -1
  163. package/dist/tools/premium-tools.d.ts.map +1 -1
  164. package/dist/tools/premium-tools.js +123 -5
  165. package/dist/tools/premium-tools.js.map +1 -1
  166. package/dist/tools/skills-tools.d.ts.map +1 -1
  167. package/dist/tools/skills-tools.js +7 -4
  168. package/dist/tools/skills-tools.js.map +1 -1
  169. package/dist/tools/transaction-tools.d.ts +21 -1
  170. package/dist/tools/transaction-tools.d.ts.map +1 -1
  171. package/dist/tools/transaction-tools.js +114 -30
  172. package/dist/tools/transaction-tools.js.map +1 -1
  173. package/dist/tools/x402-paid-call-tool.d.ts.map +1 -1
  174. package/dist/tools/x402-paid-call-tool.js +288 -0
  175. package/dist/tools/x402-paid-call-tool.js.map +1 -1
  176. package/package.json +3 -2
  177. package/server.json +3 -3
  178. package/skills/sap-clawpump-bridge/SKILL.md +206 -0
@@ -0,0 +1,516 @@
1
+ /**
2
+ * @name perps/adrena/adrena-builder-core
3
+ * @description Shared types, helpers, and utilities for Adrena perps builders.
4
+ *
5
+ * This module contains the common infrastructure used by all builder modules:
6
+ * types (PositionSide, AdrenaPool, TokenBalance, BalanceCheck, UnsignedTransactionResult),
7
+ * IDL loading, and all helper functions.
8
+ *
9
+ * @module perps/adrena/adrena-builder-core
10
+ */
11
+ import { PublicKey, Transaction, ComputeBudgetProgram, } from '@solana/web3.js';
12
+ import { AnchorProvider, Program } from '@coral-xyz/anchor';
13
+ import BN from 'bn.js';
14
+ import { createAssociatedTokenAccountIdempotentInstruction, getAssociatedTokenAddressSync } from '@solana/spl-token';
15
+ import { logger } from '../../core/logger.js';
16
+ import { ADRENA_PROGRAM_ID, ADRENA_MAIN_POOL_ADDRESS, ADRENA_DATA_API_BASE_URL, ADRENA_COMMODITIES_POOL_ADDRESS, ADRENA_CUSTODIES, ADRENA_TOKEN_MINTS, SYSTEM_PROGRAM_ID, } from './adrena-constants.js';
17
+ import { ADRENA_IDL } from './adrena-idl.js';
18
+ import { deriveCortexPda, deriveUserProfilePda, } from './adrena-pda.js';
19
+ // ─── IDL Loading ──────────────────────────────────────────────────────────────
20
+ /** Cached parsed IDL object. */
21
+ let cachedIdl = null;
22
+ /**
23
+ * Load the vendored Adrena IDL.
24
+ * The IDL is embedded as a TypeScript module so `tsc` includes it in the
25
+ * compiled output without requiring a separate file copy step.
26
+ * @returns Parsed Anchor IDL.
27
+ */
28
+ function loadAdrenaIdl() {
29
+ if (cachedIdl)
30
+ return cachedIdl;
31
+ // The IDL is imported as a typed constant from adrena-idl.ts.
32
+ cachedIdl = ADRENA_IDL;
33
+ return cachedIdl;
34
+ }
35
+ // ─── Helpers ──────────────────────────────────────────────────────────────────
36
+ /**
37
+ * Convert a bigint to a BN instance for Anchor instruction encoding.
38
+ * Anchor 0.30.x uses @coral-xyz/borsh which requires BN, not native BigInt.
39
+ * @param value — bigint value.
40
+ * @returns BN instance.
41
+ */
42
+ export function toBN(value) {
43
+ return new BN(value.toString());
44
+ }
45
+ /**
46
+ * Convert a bigint or null to a BN or null for optional Anchor fields.
47
+ * @param value — bigint or null.
48
+ * @returns BN instance or null.
49
+ */
50
+ export function toBNOrNull(value) {
51
+ return value === null ? null : new BN(value.toString());
52
+ }
53
+ /**
54
+ * Get pool public key by name.
55
+ * @param poolName — Pool identifier.
56
+ * @returns Pool public key.
57
+ */
58
+ export function getPoolPublicKey(poolName) {
59
+ const addr = poolName === 'commodities-pool' ? ADRENA_COMMODITIES_POOL_ADDRESS : ADRENA_MAIN_POOL_ADDRESS;
60
+ return new PublicKey(addr);
61
+ }
62
+ /**
63
+ * Get custody public key by symbol.
64
+ * @param symbol — Token symbol (e.g. "JITOSOL", "USDC").
65
+ * @param poolName — Pool identifier.
66
+ * @returns Custody public key.
67
+ */
68
+ export function getCustodyPublicKey(symbol, poolName = 'main-pool') {
69
+ const sym = symbol.toUpperCase();
70
+ // Special case: USDC collateral in the commodities pool uses a different
71
+ // custody address than main-pool USDC.
72
+ if (sym === 'USDC' && poolName === 'commodities-pool') {
73
+ const commoditiesUsdc = ADRENA_CUSTODIES['USDC_COMMODITIES'];
74
+ if (commoditiesUsdc)
75
+ return new PublicKey(commoditiesUsdc.address);
76
+ }
77
+ const custody = ADRENA_CUSTODIES[sym];
78
+ if (!custody) {
79
+ throw new Error(`Unknown custody symbol: ${symbol}. Supported: ${Object.keys(ADRENA_CUSTODIES).join(', ')}`);
80
+ }
81
+ if (poolName === 'commodities-pool' && custody.pool !== ADRENA_COMMODITIES_POOL_ADDRESS) {
82
+ throw new Error(`Custody ${symbol} is not in the commodities pool`);
83
+ }
84
+ return new PublicKey(custody.address);
85
+ }
86
+ /**
87
+ * Get token mint by symbol.
88
+ * @param symbol — Token symbol.
89
+ * @returns Mint public key.
90
+ */
91
+ export function getMintPublicKey(symbol) {
92
+ const mint = ADRENA_TOKEN_MINTS[symbol.toUpperCase()];
93
+ if (!mint) {
94
+ throw new Error(`Unknown token mint: ${symbol}. Supported: ${Object.keys(ADRENA_TOKEN_MINTS).join(', ')}`);
95
+ }
96
+ return new PublicKey(mint);
97
+ }
98
+ /**
99
+ * Build a CreateAssociatedTokenAccountIdempotent instruction using @solana/spl-token.
100
+ * This instruction creates the ATA if it doesn't exist, and is a no-op if it does.
101
+ *
102
+ * @param owner — Wallet public key that will own the ATA.
103
+ * @param mint — Token mint public key.
104
+ * @param payer — Fee payer public key (usually the owner).
105
+ * @returns TransactionInstruction for CreateAssociatedTokenAccountIdempotent.
106
+ */
107
+ export function createAtaIdempotentIx(owner, mint, payer) {
108
+ const ata = getAssociatedTokenAddressSync(mint, owner);
109
+ return createAssociatedTokenAccountIdempotentInstruction(payer, ata, owner, mint);
110
+ }
111
+ /**
112
+ * Fetch the current USD price for a token from the Adrena Data API.
113
+ * Uses the same format as the Adrena SDK's DataApiClient.getLatestPrices():
114
+ * GET https://datapi.adrena.trade/last-trading-prices
115
+ * Response: { data: { autonom: { prices: [{ symbol, price, exponent }] } } }
116
+ *
117
+ * The price is a string at 10-decimal precision; adjust by exponent to get USD float.
118
+ * Returns the price as a BigInt scaled by 10^10 (PRICE_DECIMALS).
119
+ *
120
+ * @param principalToken — Token symbol (SOL, BONK, BTC, etc.)
121
+ * JITOSOL maps to SOL (same as the SDK).
122
+ * @returns Price as BigInt scaled by 10^10, or BigInt(0) if fetch fails.
123
+ */
124
+ export async function fetchOraclePrice(principalToken, side) {
125
+ try {
126
+ // JITOSOL uses SOL price (same as SDK: getPythPrice(principalToken === "JITOSOL" ? "SOL" : principalToken))
127
+ const symbol = principalToken.toUpperCase() === 'JITOSOL' ? 'SOL' : principalToken.toUpperCase();
128
+ const apiUrl = `${ADRENA_DATA_API_BASE_URL}/last-trading-prices`;
129
+ const response = await fetch(apiUrl, { signal: AbortSignal.timeout(10_000) });
130
+ if (!response.ok)
131
+ return BigInt(0);
132
+ const json = await response.json();
133
+ const prices = json?.data?.autonom?.prices;
134
+ if (!prices?.length)
135
+ return BigInt(0);
136
+ // Find the price entry — symbols are like "SOLUSD", "BTCUSD", "BONKUSD"
137
+ const priceEntry = prices.find(p => p.symbol.toUpperCase() === `${symbol}USD` || p.symbol.toUpperCase() === symbol);
138
+ if (!priceEntry)
139
+ return BigInt(0);
140
+ // price is at 10-decimal precision; adjust by exponent to get USD float
141
+ const usdPrice = Number(priceEntry.price) * Math.pow(10, priceEntry.exponent ?? -10);
142
+ if (usdPrice <= 0)
143
+ return BigInt(0);
144
+ // Scale to 10^10 (PRICE_DECIMALS) and apply 0.3% slippage
145
+ // SDK uses: short → price * 0.997, long → price * 1.003
146
+ const slippageMultiplier = side === 'short' ? 0.997 : side === 'long' ? 1.003 : 1.0;
147
+ const scaled = Math.floor(usdPrice * slippageMultiplier * Math.pow(10, 10));
148
+ return BigInt(scaled);
149
+ }
150
+ catch {
151
+ // Data API unavailable — return 0
152
+ }
153
+ return BigInt(0);
154
+ }
155
+ /**
156
+ * Read the collateral custody token account address from the on-chain custody account.
157
+ * The custody account stores the tokenAccount at byte offset 80 (after the 8-byte
158
+ * Anchor discriminator + 2 boolean flags + 1 decimal byte + 5 padding + 32 pool).
159
+ *
160
+ * This is more reliable than PDA derivation because the seed layout may differ
161
+ * from what the IDL declares.
162
+ *
163
+ * @param connection — Solana RPC connection.
164
+ * @param custodyAddress — The custody PDA public key.
165
+ * @returns The token account public key stored in the custody account.
166
+ */
167
+ export async function readCustodyTokenAccount(connection, custodyAddress) {
168
+ const accountInfo = await connection.getAccountInfo(custodyAddress);
169
+ if (!accountInfo || accountInfo.data.length < 112) {
170
+ throw new Error(`Custody account ${custodyAddress.toBase58()} not found or too small`);
171
+ }
172
+ // tokenAccount is at offset 80 (32 bytes)
173
+ return new PublicKey(accountInfo.data.subarray(80, 112));
174
+ }
175
+ /**
176
+ * Read pool/custody metadata from the on-chain custody account.
177
+ *
178
+ * Fields and their byte offsets (all little-endian):
179
+ * - maxInitialLeverage: u32 at offset 176 (in BPS, 1000000 = 100x)
180
+ * - maxLeverage: u32 at offset 180 (in BPS, 1000000 = 100x)
181
+ * - maxPositionLockedUsd: u128 at offset 184 (scaled by 1e6)
182
+ * - openInterestLongUsd: u128 at offset 408 (scaled by 1e6)
183
+ * - openInterestShortUsd: u128 at offset 608 (scaled by 1e6)
184
+ *
185
+ * Leverage values are divided by 10000 for human-readable form.
186
+ * USD values are divided by 1e6 for human-readable form.
187
+ *
188
+ * @param connection — Solana RPC connection.
189
+ * @param custodyAddress — The custody PDA public key.
190
+ * @returns PoolMetadata with human-readable values.
191
+ */
192
+ export async function readCustodyMetadata(connection, custodyAddress) {
193
+ const accountInfo = await connection.getAccountInfo(custodyAddress);
194
+ if (!accountInfo || accountInfo.data.length < 624) {
195
+ throw new Error(`Custody account ${custodyAddress.toBase58()} not found or too small for metadata (need >= 624 bytes, got ${accountInfo?.data.length ?? 0})`);
196
+ }
197
+ const data = accountInfo.data;
198
+ // maxInitialLeverage: u32 LE at offset 176 (BPS)
199
+ const maxInitialLeverageBps = data.readUInt32LE(176);
200
+ // maxLeverage: u32 LE at offset 180 (BPS)
201
+ const maxLeverageBps = data.readUInt32LE(180);
202
+ // maxPositionLockedUsd: u128 LE at offset 184 (scaled by 1e6)
203
+ // u128 = 16 bytes, read as two u64s (low, high) and combine
204
+ const maxPositionLockedUsdRaw = data.readBigUInt64LE(184) | (data.readBigUInt64LE(192) << 64n);
205
+ // openInterestLongUsd: u128 LE at offset 408 (scaled by 1e6)
206
+ const openInterestLongUsdRaw = data.readBigUInt64LE(408) | (data.readBigUInt64LE(416) << 64n);
207
+ // openInterestShortUsd: u128 LE at offset 608 (scaled by 1e6)
208
+ const openInterestShortUsdRaw = data.readBigUInt64LE(608) | (data.readBigUInt64LE(616) << 64n);
209
+ return {
210
+ maxInitialLeverage: maxInitialLeverageBps / 10000,
211
+ maxLeverage: maxLeverageBps / 10000,
212
+ maxPositionLockedUsd: Number(maxPositionLockedUsdRaw) / 1e6,
213
+ openInterestLongUsd: Number(openInterestLongUsdRaw) / 1e6,
214
+ openInterestShortUsd: Number(openInterestShortUsdRaw) / 1e6,
215
+ };
216
+ }
217
+ /**
218
+ * Validate that the requested leverage does not exceed the custody's
219
+ * maxInitialLeverage. Throws a clear error if it does.
220
+ *
221
+ * @param leverage — Requested leverage (human-readable, e.g. 3 = 3x).
222
+ * @param maxInitialLeverageBps — Max initial leverage in BPS (e.g. 1000000 = 100x).
223
+ * @param principalToken — Token symbol for the error message.
224
+ */
225
+ export function validateLeverage(leverage, maxInitialLeverageBps, principalToken) {
226
+ const leverageBps = Math.floor(leverage * 10000);
227
+ if (leverageBps > maxInitialLeverageBps) {
228
+ const maxLeverage = maxInitialLeverageBps / 10000;
229
+ const suggested = Math.floor(maxLeverage * 100) / 100; // round down to 2 decimals
230
+ throw new Error(`Leverage ${leverage} exceeds maxInitialLeverage ${maxLeverage} for ${principalToken}. Suggested leverage: ${suggested} or lower.`);
231
+ }
232
+ }
233
+ /**
234
+ * Fetch all Adrena-relevant token balances for a wallet: USDC, JITOSOL, WBTC, BONK, and SOL.
235
+ *
236
+ * For SPL tokens, reads the Associated Token Account (ATA) balance via
237
+ * `connection.getParsedTokenAccountsByOwner`. For SOL, reads lamports via
238
+ * `connection.getBalance`.
239
+ *
240
+ * @param connection — Solana RPC connection.
241
+ * @param owner — Wallet public key.
242
+ * @returns Array of TokenBalance for each supported token (including zero balances).
243
+ */
244
+ export async function getWalletTokenBalances(connection, owner) {
245
+ const balances = [];
246
+ const solBalanceLamports = await connection.getBalance(owner, 'confirmed');
247
+ balances.push({
248
+ symbol: 'SOL',
249
+ mint: 'So11111111111111111111111111111111111111112',
250
+ balance: solBalanceLamports / 1e9,
251
+ balanceRaw: String(solBalanceLamports),
252
+ decimals: 9,
253
+ ata: '',
254
+ ataExists: true,
255
+ });
256
+ for (const [symbol, mintStr] of Object.entries(ADRENA_TOKEN_MINTS)) {
257
+ const mint = new PublicKey(mintStr);
258
+ const ata = getAssociatedTokenAddressSync(mint, owner);
259
+ const custodyInfo = ADRENA_CUSTODIES[symbol];
260
+ const decimals = custodyInfo?.decimals ?? 6;
261
+ try {
262
+ const ataInfo = await connection.getAccountInfo(ata, 'confirmed');
263
+ if (!ataInfo || !ataInfo.data || ataInfo.data.length < 64) {
264
+ balances.push({
265
+ symbol,
266
+ mint: mintStr,
267
+ balance: 0,
268
+ balanceRaw: '0',
269
+ decimals,
270
+ ata: ata.toBase58(),
271
+ ataExists: false,
272
+ });
273
+ continue;
274
+ }
275
+ // Token account layout: amount is at offset 64 (u64 LE), but we should use
276
+ // getParsedAccountInfo for reliability.
277
+ const parsed = await connection.getParsedAccountInfo(ata, 'confirmed');
278
+ const parsedData = parsed.value?.data;
279
+ const amountStr = parsedData?.parsed?.info?.tokenAmount?.amount ?? '0';
280
+ const amount = Number(amountStr);
281
+ const humanReadable = amount / Math.pow(10, decimals);
282
+ balances.push({
283
+ symbol,
284
+ mint: mintStr,
285
+ balance: humanReadable,
286
+ balanceRaw: amountStr,
287
+ decimals,
288
+ ata: ata.toBase58(),
289
+ ataExists: true,
290
+ });
291
+ }
292
+ catch {
293
+ balances.push({
294
+ symbol,
295
+ mint: mintStr,
296
+ balance: 0,
297
+ balanceRaw: '0',
298
+ decimals,
299
+ ata: ata.toBase58(),
300
+ ataExists: false,
301
+ });
302
+ }
303
+ }
304
+ return balances;
305
+ }
306
+ /**
307
+ * Pre-flight balance check: compare requested collateral/amount against the
308
+ * wallet's actual token balance, and check SOL for fees.
309
+ *
310
+ * Returns a BalanceCheck object that can be embedded in the UnsignedTransactionResult
311
+ * so the agent/user sees balances and warnings before signing.
312
+ *
313
+ * @param connection — Solana RPC connection.
314
+ * @param owner — Wallet public key.
315
+ * @param requiredToken — Token symbol required (e.g. "USDC", "JITOSOL").
316
+ * @param requiredAmount — Human-readable amount required.
317
+ * @returns BalanceCheck with all balances and sufficiency flags.
318
+ */
319
+ export async function checkSufficientBalance(connection, owner, requiredToken, requiredAmount) {
320
+ const balances = await getWalletTokenBalances(connection, owner);
321
+ const required = requiredToken.toUpperCase();
322
+ const requiredBalance = balances.find(b => b.symbol === required);
323
+ const available = requiredBalance?.balance ?? 0;
324
+ const solBalance = balances.find(b => b.symbol === 'SOL')?.balance ?? 0;
325
+ const shortfall = Math.max(0, requiredAmount - available);
326
+ return {
327
+ wallet: owner.toBase58(),
328
+ balances,
329
+ requiredToken: required,
330
+ requiredAmount,
331
+ availableBalance: available,
332
+ sufficient: available >= requiredAmount,
333
+ shortfall,
334
+ solBalance,
335
+ solSufficientForFees: solBalance >= 0.005,
336
+ };
337
+ }
338
+ /**
339
+ * Check if a user profile PDA exists on-chain. If it doesn't, build an
340
+ * init_user_profile instruction to create it before any Adrena position operation.
341
+ *
342
+ * @param connection — Solana RPC connection.
343
+ * @param owner — Wallet public key that needs a user profile.
344
+ * @returns Array of pre-instructions (empty if profile exists, or [initUserProfile] if not).
345
+ */
346
+ export async function ensureUserProfileInstructions(connection, owner) {
347
+ const userProfile = deriveUserProfilePda(owner);
348
+ try {
349
+ const accountInfo = await connection.getAccountInfo(userProfile);
350
+ if (accountInfo && accountInfo.data.length > 0) {
351
+ return []; // Profile exists, no instruction needed.
352
+ }
353
+ }
354
+ catch {
355
+ // Account check failed — assume profile doesn't exist and try to init.
356
+ }
357
+ // Profile doesn't exist — build init_user_profile instruction.
358
+ const program = createAdrenaProgram(connection);
359
+ const cortex = deriveCortexPda();
360
+ // user_nickname PDA: ['nickname', nickname_string]
361
+ // Use a default nickname derived from the wallet address.
362
+ const nickname = owner.toBase58().slice(0, 10);
363
+ const [userNickname] = PublicKey.findProgramAddressSync([Buffer.from('nickname'), Buffer.from(nickname)], new PublicKey(ADRENA_PROGRAM_ID));
364
+ // referrer_profile is optional in the IDL ("optional": true).
365
+ // Anchor 0.30.x handles this by passing null — the instruction builder
366
+ // omits the account and the program treats it as "no referrer".
367
+ // Passing PublicKey.default or cortex doesn't work because the program
368
+ // checks the account discriminator (AccountDiscriminatorMismatch).
369
+ const ix = await buildInstruction(program, 'initUserProfile', [
370
+ {
371
+ nickname,
372
+ profilePicture: 0,
373
+ wallpaper: 0,
374
+ title: 0,
375
+ team: 0,
376
+ continent: 0,
377
+ },
378
+ ], {
379
+ user: owner,
380
+ caller: owner,
381
+ payer: owner,
382
+ userProfile,
383
+ userNickname,
384
+ referrerProfile: null,
385
+ cortex,
386
+ systemProgram: new PublicKey(SYSTEM_PROGRAM_ID),
387
+ });
388
+ return [ix];
389
+ }
390
+ /**
391
+ * Always return a CreateAssociatedTokenAccountIdempotent instruction.
392
+ * The instruction is a no-op if the ATA already exists, so it's safe to always include.
393
+ *
394
+ * @param _connection — Unused (kept for API compatibility).
395
+ * @param owner — Wallet public key.
396
+ * @param mint — Token mint public key.
397
+ * @param payer — Fee payer public key.
398
+ * @returns Array with a single CreateAssociatedTokenAccountIdempotent instruction.
399
+ */
400
+ export async function ensureAtaInstructions(_connection, owner, mint, payer) {
401
+ return [createAtaIdempotentIx(owner, mint, payer)];
402
+ }
403
+ /**
404
+ * Create an Anchor Program instance from the vendored IDL.
405
+ * @param connection — Solana RPC connection.
406
+ * @returns Anchor Program instance.
407
+ */
408
+ export function createAdrenaProgram(connection) {
409
+ const idl = loadAdrenaIdl();
410
+ const provider = new AnchorProvider(connection, {}, { commitment: 'confirmed' });
411
+ return new Program(idl, provider);
412
+ }
413
+ /**
414
+ * Convert an Anchor instruction to a @solana/web3.js TransactionInstruction.
415
+ * Anchor's `Instruction` namespace returns instructions with keys and data
416
+ * that can be directly mapped to TransactionInstruction.
417
+ * @param program — Anchor Program instance.
418
+ * @param ixName — Instruction name (camelCase).
419
+ * @param args — Instruction arguments.
420
+ * @param accounts — Account public keys by name.
421
+ * @returns web3.js TransactionInstruction.
422
+ */
423
+ export async function buildInstruction(program, ixName, args, accounts) {
424
+ // Anchor v0.30 exposes methods via program.methods.
425
+ // .instruction() is async and returns a Promise<TransactionInstruction>.
426
+ // For optional accounts (null values), Anchor handles them internally
427
+ // when passed as null in the accounts object.
428
+ const methods = program.methods;
429
+ const ixBuilder = methods[ixName];
430
+ if (!ixBuilder) {
431
+ throw new Error(`Adrena instruction not found in IDL: ${ixName}`);
432
+ }
433
+ const ixWithArgs = ixBuilder(...args);
434
+ const ixWithAccounts = ixWithArgs.accounts(accounts);
435
+ return await ixWithAccounts.instruction();
436
+ }
437
+ export async function serializeUnsignedTx(connection, feePayer, instructions) {
438
+ const blockhash = await connection.getLatestBlockhash();
439
+ // Priority fee: prepend ComputeBudgetProgram.setComputeUnitPrice when
440
+ // SAP_MCP_PRIORITY_FEE_MICRO_LAMPORTS > 0. Default 0 = disabled.
441
+ const PRIORITY_FEE_MICRO_LAMPORTS = Number(process.env['SAP_MCP_PRIORITY_FEE_MICRO_LAMPORTS'] ?? '0');
442
+ const allInstructions = PRIORITY_FEE_MICRO_LAMPORTS > 0
443
+ ? [ComputeBudgetProgram.setComputeUnitPrice({ microLamports: PRIORITY_FEE_MICRO_LAMPORTS }), ...instructions]
444
+ : instructions;
445
+ const tx = new Transaction({
446
+ recentBlockhash: blockhash.blockhash,
447
+ feePayer,
448
+ });
449
+ tx.add(...allInstructions);
450
+ // Simulate the transaction to extract program logs before serializing.
451
+ // This helps diagnose failures (e.g. InsufficientCollateral, MinLeverage)
452
+ // without needing to sign and submit.
453
+ let simulationLogs;
454
+ let simulationError;
455
+ let simulationUnitsConsumed;
456
+ try {
457
+ const simulation = await connection.simulateTransaction(tx);
458
+ if (simulation.value.logs && simulation.value.logs.length > 0) {
459
+ simulationLogs = simulation.value.logs;
460
+ logger.debug('Adrena builder simulation logs', {
461
+ logs: simulation.value.logs,
462
+ unitsConsumed: simulation.value.unitsConsumed,
463
+ err: simulation.value.err,
464
+ });
465
+ }
466
+ if (simulation.value.err !== null && simulation.value.err !== undefined) {
467
+ simulationError = JSON.stringify(simulation.value.err);
468
+ }
469
+ simulationUnitsConsumed = simulation.value.unitsConsumed ?? undefined;
470
+ }
471
+ catch {
472
+ // Simulation is best-effort — don't fail the build if simulation fails.
473
+ }
474
+ return {
475
+ transactionBase64: tx.serialize({
476
+ requireAllSignatures: false,
477
+ verifySignatures: false,
478
+ }).toString('base64'),
479
+ simulationLogs,
480
+ simulationError,
481
+ simulationUnitsConsumed,
482
+ priorityFeeMicroLamports: PRIORITY_FEE_MICRO_LAMPORTS > 0 ? PRIORITY_FEE_MICRO_LAMPORTS : undefined,
483
+ };
484
+ }
485
+ /**
486
+ * Build the result object for a builder function.
487
+ * @param transactionBase64 — Serialized unsigned transaction.
488
+ * @param feePayer — Fee payer public key.
489
+ * @param instructionNames — List of instruction names.
490
+ * @param positionAddress — Optional position PDA.
491
+ * @param balanceCheck — Optional pre-flight balance check result.
492
+ * @param warning — Optional warning message (e.g. insufficient balance).
493
+ * @param poolMetadata — Optional pool/custody metadata (for open-position builders).
494
+ * @returns Unsigned transaction result.
495
+ */
496
+ export function buildResult(transactionBase64, feePayer, instructionNames, positionAddress, balanceCheck, warning, poolMetadata) {
497
+ return {
498
+ transactionBase64,
499
+ encoding: 'base64',
500
+ feePayer: feePayer.toBase58(),
501
+ instructions: instructionNames,
502
+ ...(positionAddress ? { positionAddress: positionAddress.toBase58() } : {}),
503
+ nextTool: 'sap_payments_finalize_transaction',
504
+ finalizeArgs: {
505
+ transactionBase64,
506
+ submit: false,
507
+ },
508
+ ...(balanceCheck ? { balanceCheck } : {}),
509
+ ...(poolMetadata ? { poolMetadata } : {}),
510
+ ...(warning ? { warning } : {}),
511
+ };
512
+ }
513
+ // ─── Re-exports ─────────────────────────────────────────────────────────────────
514
+ export { ADRENA_CUSTODIES, ADRENA_TOKEN_MINTS, ADRENA_PROGRAM_ID, ADRENA_MAIN_POOL_ADDRESS, ADRENA_COMMODITIES_POOL_ADDRESS, } from './adrena-constants.js';
515
+ export { deriveCortexPda, deriveOraclePda, deriveTransferAuthorityPda, deriveUserProfilePda, derivePositionPda, deriveLimitOrderBookPda, deriveCollateralEscrowPda, deriveLpTokenMintPda, deriveStakingPda, deriveUserStakingPda, deriveGenesisLockPda, deriveLmTokenTreasuryPda, deriveLmTokenMintPda, deriveGovernanceTokenMintPda, deriveStakingStakedTokenVaultPda, deriveStakingRewardTokenVaultPda, deriveStakingLmRewardTokenVaultPda, deriveAta, } from './adrena-pda.js';
516
+ //# sourceMappingURL=adrena-builder-core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adrena-builder-core.js","sourceRoot":"","sources":["../../../src/perps/adrena/adrena-builder-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,SAAS,EACT,WAAW,EAGX,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,OAAO,EAAY,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvB,OAAO,EAAE,iDAAiD,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AACrH,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,EACxB,+BAA+B,EAC/B,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACL,eAAe,EACf,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAEzB,iFAAiF;AAEjF,gCAAgC;AAChC,IAAI,SAAS,GAAe,IAAI,CAAC;AAEjC;;;;;GAKG;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ACpB,4BAA4B,EAC5B,gCAAgC,EAChC,gCAAgC,EAChC,kCAAkC,EAClC,SAAS,GACV,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @name perps/adrena/adrena-builder-liquidity
3
+ * @description Liquidity and swap builders for the Adrena perps protocol.
4
+ *
5
+ * Contains builders for adding liquidity, removing liquidity, and swapping tokens.
6
+ *
7
+ * @module perps/adrena/adrena-builder-liquidity
8
+ */
9
+ import { PublicKey, Connection } from '@solana/web3.js';
10
+ import { type AdrenaPool, type UnsignedTransactionResult } from './adrena-builder-core.js';
11
+ /**
12
+ * @name buildAddLiquidity
13
+ * @description Build an unsigned transaction to add liquidity to an Adrena pool.
14
+ *
15
+ * @param connection — Solana RPC connection.
16
+ * @param owner — Liquidity provider and fee payer.
17
+ * @param collateralToken — Collateral token to deposit.
18
+ * @param amountIn — Amount in human-readable units.
19
+ * @param minLpAmountOut — Minimum LP tokens to receive (0 for no slippage protection).
20
+ * @param poolName — Pool to add liquidity to.
21
+ * @returns Unsigned transaction result.
22
+ */
23
+ export declare function buildAddLiquidity(connection: Connection, owner: PublicKey, collateralToken: string, amountIn: number, minLpAmountOut?: bigint, poolName?: AdrenaPool): Promise<UnsignedTransactionResult>;
24
+ /**
25
+ * @name buildRemoveLiquidity
26
+ * @description Build an unsigned transaction to remove liquidity from an Adrena pool.
27
+ *
28
+ * @param connection — Solana RPC connection.
29
+ * @param owner — Liquidity provider and fee payer.
30
+ * @param collateralToken — Collateral token to receive.
31
+ * @param lpAmountIn — LP tokens to burn (raw, 6 decimals).
32
+ * @param minAmountOut — Minimum collateral to receive (raw, 0 for no slippage protection).
33
+ * @param poolName — Pool to remove liquidity from.
34
+ * @returns Unsigned transaction result.
35
+ */
36
+ export declare function buildRemoveLiquidity(connection: Connection, owner: PublicKey, collateralToken: string, lpAmountIn: bigint, minAmountOut?: bigint, poolName?: AdrenaPool): Promise<UnsignedTransactionResult>;
37
+ /**
38
+ * @name buildSwap
39
+ * @description Build an unsigned transaction to swap tokens through an Adrena pool.
40
+ *
41
+ * @param connection — Solana RPC connection.
42
+ * @param owner — Swapper and fee payer.
43
+ * @param fromToken — Token to swap from.
44
+ * @param toToken — Token to swap to.
45
+ * @param amountIn — Amount in human-readable units.
46
+ * @param minAmountOut — Minimum amount to receive (raw, 0 for no slippage protection).
47
+ * @returns Unsigned transaction result.
48
+ */
49
+ export declare function buildSwap(connection: Connection, owner: PublicKey, fromToken: string, toToken: string, amountIn: number, minAmountOut?: bigint): Promise<UnsignedTransactionResult>;
50
+ //# sourceMappingURL=adrena-builder-liquidity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adrena-builder-liquidity.d.ts","sourceRoot":"","sources":["../../../src/perps/adrena/adrena-builder-liquidity.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,SAAS,EACT,UAAU,EACX,MAAM,iBAAiB,CAAC;AAczB,OAAO,EACL,KAAK,UAAU,EAEf,KAAK,yBAAyB,EAY/B,MAAM,0BAA0B,CAAC;AAIlC;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,SAAS,EAChB,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,EAChB,cAAc,GAAE,MAAW,EAC3B,QAAQ,GAAE,UAAwB,GACjC,OAAO,CAAC,yBAAyB,CAAC,CAkDpC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,SAAS,EAChB,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,MAAM,EAClB,YAAY,GAAE,MAAW,EACzB,QAAQ,GAAE,UAAwB,GACjC,OAAO,CAAC,yBAAyB,CAAC,CAwDpC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,SAAS,CAC7B,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,SAAS,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,YAAY,GAAE,MAAW,GACxB,OAAO,CAAC,yBAAyB,CAAC,CAmDpC"}