@augustdigital/sdk 8.3.1 → 8.5.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 (204) hide show
  1. package/lib/abis/ERC20_Bytes32.d.ts +4 -0
  2. package/lib/abis/ERC20_Bytes32.js +4 -0
  3. package/lib/abis/ERC4626.d.ts +1 -0
  4. package/lib/abis/ERC4626.js +1 -0
  5. package/lib/abis/ERC721.d.ts +1 -0
  6. package/lib/abis/ERC721.js +1 -0
  7. package/lib/abis/FeeOracle.js +1 -0
  8. package/lib/abis/LendingPool.js +1 -0
  9. package/lib/abis/LendingPoolV2.js +1 -0
  10. package/lib/abis/Multicall3.js +3 -0
  11. package/lib/abis/OFT.d.ts +20 -0
  12. package/lib/abis/OFT.js +20 -0
  13. package/lib/abis/SmartAccount.d.ts +1 -0
  14. package/lib/abis/SmartAccount.js +3 -0
  15. package/lib/abis/SwapRouter.d.ts +1 -0
  16. package/lib/abis/SwapRouter.js +1 -0
  17. package/lib/abis/UniversalSignatureValidator.js +3 -0
  18. package/lib/abis/index.d.ts +5 -0
  19. package/lib/abis/index.js +5 -0
  20. package/lib/adapters/evm/getters.d.ts +17 -2
  21. package/lib/adapters/evm/getters.js +35 -3
  22. package/lib/adapters/evm/index.d.ts +262 -0
  23. package/lib/adapters/evm/index.js +268 -1
  24. package/lib/adapters/evm/utils.d.ts +6 -0
  25. package/lib/adapters/evm/utils.js +7 -0
  26. package/lib/adapters/solana/constants.js +4 -1
  27. package/lib/adapters/solana/getters.d.ts +8 -0
  28. package/lib/adapters/solana/getters.js +21 -0
  29. package/lib/adapters/solana/idl/vault-idl.js +9 -0
  30. package/lib/adapters/solana/index.d.ts +55 -0
  31. package/lib/adapters/solana/index.js +57 -0
  32. package/lib/adapters/solana/utils.d.ts +28 -0
  33. package/lib/adapters/solana/utils.js +79 -4
  34. package/lib/adapters/solana/vault.actions.d.ts +19 -0
  35. package/lib/adapters/solana/vault.actions.js +47 -3
  36. package/lib/adapters/stellar/actions.d.ts +25 -0
  37. package/lib/adapters/stellar/actions.js +33 -0
  38. package/lib/adapters/stellar/constants.d.ts +26 -0
  39. package/lib/adapters/stellar/constants.js +29 -0
  40. package/lib/adapters/stellar/getters.d.ts +56 -0
  41. package/lib/adapters/stellar/getters.js +81 -0
  42. package/lib/adapters/stellar/index.d.ts +48 -0
  43. package/lib/adapters/stellar/index.js +48 -0
  44. package/lib/adapters/stellar/soroban.d.ts +20 -0
  45. package/lib/adapters/stellar/soroban.js +46 -0
  46. package/lib/adapters/stellar/submit.d.ts +12 -0
  47. package/lib/adapters/stellar/submit.js +19 -0
  48. package/lib/adapters/stellar/types.d.ts +27 -0
  49. package/lib/adapters/stellar/types.js +3 -0
  50. package/lib/adapters/stellar/utils.d.ts +10 -0
  51. package/lib/adapters/stellar/utils.js +10 -0
  52. package/lib/adapters/sui/getters.d.ts +6 -0
  53. package/lib/adapters/sui/getters.js +6 -0
  54. package/lib/adapters/sui/index.d.ts +15 -0
  55. package/lib/adapters/sui/index.js +15 -0
  56. package/lib/adapters/sui/transformer.d.ts +6 -0
  57. package/lib/adapters/sui/transformer.js +7 -0
  58. package/lib/adapters/sui/utils.d.ts +6 -0
  59. package/lib/adapters/sui/utils.js +6 -0
  60. package/lib/core/analytics/chain-name.d.ts +8 -0
  61. package/lib/core/analytics/chain-name.js +8 -0
  62. package/lib/core/analytics/constants.d.ts +4 -0
  63. package/lib/core/analytics/constants.js +4 -0
  64. package/lib/core/analytics/env.d.ts +25 -0
  65. package/lib/core/analytics/env.js +26 -0
  66. package/lib/core/analytics/index.d.ts +26 -0
  67. package/lib/core/analytics/index.js +35 -0
  68. package/lib/core/analytics/instrumentation.d.ts +26 -0
  69. package/lib/core/analytics/instrumentation.js +66 -2
  70. package/lib/core/analytics/method-taxonomy.d.ts +16 -0
  71. package/lib/core/analytics/method-taxonomy.js +18 -0
  72. package/lib/core/analytics/metrics.d.ts +23 -0
  73. package/lib/core/analytics/metrics.js +40 -0
  74. package/lib/core/analytics/sanitize.d.ts +38 -0
  75. package/lib/core/analytics/sanitize.js +46 -0
  76. package/lib/core/analytics/sentry-runtime.d.ts +11 -0
  77. package/lib/core/analytics/sentry-runtime.js +19 -0
  78. package/lib/core/analytics/sentry.d.ts +45 -0
  79. package/lib/core/analytics/sentry.js +115 -2
  80. package/lib/core/analytics/types.d.ts +27 -0
  81. package/lib/core/analytics/user-identity.d.ts +34 -0
  82. package/lib/core/analytics/user-identity.js +42 -0
  83. package/lib/core/analytics/version.d.ts +6 -1
  84. package/lib/core/analytics/version.js +6 -1
  85. package/lib/core/auth/verify.js +5 -0
  86. package/lib/core/base.class.d.ts +75 -0
  87. package/lib/core/base.class.js +56 -0
  88. package/lib/core/cache.d.ts +5 -0
  89. package/lib/core/cache.js +6 -0
  90. package/lib/core/constants/adapters.d.ts +15 -0
  91. package/lib/core/constants/adapters.js +28 -8
  92. package/lib/core/constants/core.d.ts +12 -1
  93. package/lib/core/constants/core.js +12 -0
  94. package/lib/core/constants/swap-router.d.ts +46 -0
  95. package/lib/core/constants/swap-router.js +50 -0
  96. package/lib/core/constants/vaults.d.ts +56 -0
  97. package/lib/core/constants/vaults.js +66 -1
  98. package/lib/core/constants/web3.d.ts +3 -0
  99. package/lib/core/constants/web3.js +18 -5
  100. package/lib/core/errors/index.d.ts +36 -0
  101. package/lib/core/errors/index.js +29 -0
  102. package/lib/core/fetcher.d.ts +134 -0
  103. package/lib/core/fetcher.js +191 -5
  104. package/lib/core/helpers/adapters.d.ts +9 -0
  105. package/lib/core/helpers/adapters.js +11 -0
  106. package/lib/core/helpers/chain-address.d.ts +10 -0
  107. package/lib/core/helpers/chain-address.js +11 -0
  108. package/lib/core/helpers/core.d.ts +42 -0
  109. package/lib/core/helpers/core.js +66 -1
  110. package/lib/core/helpers/explorer-link.d.ts +14 -0
  111. package/lib/core/helpers/explorer-link.js +14 -0
  112. package/lib/core/helpers/signer.d.ts +26 -0
  113. package/lib/core/helpers/signer.js +39 -0
  114. package/lib/core/helpers/swap-router.d.ts +32 -0
  115. package/lib/core/helpers/swap-router.js +32 -0
  116. package/lib/core/helpers/vault-version.d.ts +1 -0
  117. package/lib/core/helpers/vault-version.js +2 -0
  118. package/lib/core/helpers/vaults.d.ts +8 -0
  119. package/lib/core/helpers/vaults.js +22 -8
  120. package/lib/core/helpers/web3.d.ts +152 -0
  121. package/lib/core/helpers/web3.js +183 -6
  122. package/lib/core/logger/index.d.ts +55 -0
  123. package/lib/core/logger/index.js +19 -0
  124. package/lib/core/logger/slack.d.ts +3 -0
  125. package/lib/core/logger/slack.js +3 -0
  126. package/lib/core/vault-metadata.d.ts +6 -0
  127. package/lib/core/vault-metadata.js +6 -0
  128. package/lib/core/version-check.d.ts +52 -0
  129. package/lib/core/version-check.js +81 -0
  130. package/lib/evm/methods/crossChainVault.d.ts +90 -0
  131. package/lib/evm/methods/crossChainVault.js +186 -1
  132. package/lib/evm/methods/crossChainVaultRegistry.d.ts +93 -0
  133. package/lib/evm/methods/crossChainVaultRegistry.js +240 -0
  134. package/lib/evm/methods/index.d.ts +1 -0
  135. package/lib/evm/methods/index.js +1 -0
  136. package/lib/evm/types/crossChain.d.ts +202 -0
  137. package/lib/evm/types/crossChain.js +11 -0
  138. package/lib/index.d.ts +16 -0
  139. package/lib/index.js +19 -0
  140. package/lib/main.d.ts +288 -5
  141. package/lib/main.js +305 -0
  142. package/lib/modules/api/index.d.ts +1 -0
  143. package/lib/modules/api/index.js +6 -0
  144. package/lib/modules/api/main.d.ts +52 -0
  145. package/lib/modules/api/main.js +130 -0
  146. package/lib/modules/sub-accounts/fetcher.d.ts +15 -0
  147. package/lib/modules/sub-accounts/fetcher.js +15 -0
  148. package/lib/modules/sub-accounts/main.d.ts +33 -0
  149. package/lib/modules/sub-accounts/main.js +38 -0
  150. package/lib/modules/sub-accounts/utils.d.ts +3 -0
  151. package/lib/modules/sub-accounts/utils.js +3 -0
  152. package/lib/modules/vaults/adapter.helpers.d.ts +18 -0
  153. package/lib/modules/vaults/adapter.helpers.js +34 -0
  154. package/lib/modules/vaults/fetcher.d.ts +20 -0
  155. package/lib/modules/vaults/fetcher.js +40 -3
  156. package/lib/modules/vaults/getters.d.ts +295 -0
  157. package/lib/modules/vaults/getters.js +552 -12
  158. package/lib/modules/vaults/index.d.ts +12 -0
  159. package/lib/modules/vaults/index.js +12 -0
  160. package/lib/modules/vaults/main.d.ts +292 -4
  161. package/lib/modules/vaults/main.js +379 -7
  162. package/lib/modules/vaults/read.actions.d.ts +168 -0
  163. package/lib/modules/vaults/read.actions.js +143 -0
  164. package/lib/modules/vaults/types.d.ts +34 -0
  165. package/lib/modules/vaults/utils/call-data-decoder.d.ts +47 -0
  166. package/lib/modules/vaults/utils/call-data-decoder.js +56 -0
  167. package/lib/modules/vaults/utils/date-utils.d.ts +39 -0
  168. package/lib/modules/vaults/utils/date-utils.js +47 -1
  169. package/lib/modules/vaults/utils.d.ts +70 -0
  170. package/lib/modules/vaults/utils.js +108 -5
  171. package/lib/modules/vaults/write.actions.d.ts +363 -3
  172. package/lib/modules/vaults/write.actions.js +364 -2
  173. package/lib/polyfills.js +2 -0
  174. package/lib/sdk.d.ts +23705 -0
  175. package/lib/services/coingecko/fetcher.d.ts +13 -0
  176. package/lib/services/coingecko/fetcher.js +17 -0
  177. package/lib/services/debank/fetcher.d.ts +14 -0
  178. package/lib/services/debank/fetcher.js +12 -0
  179. package/lib/services/debank/utils.js +17 -0
  180. package/lib/services/layerzero/deposits.d.ts +11 -0
  181. package/lib/services/layerzero/deposits.js +34 -11
  182. package/lib/services/layerzero/redeems.d.ts +10 -0
  183. package/lib/services/layerzero/redeems.js +13 -0
  184. package/lib/services/layerzero/utils.d.ts +8 -0
  185. package/lib/services/layerzero/utils.js +11 -0
  186. package/lib/services/octavfi/fetcher.d.ts +7 -0
  187. package/lib/services/octavfi/fetcher.js +25 -0
  188. package/lib/services/octavfi/utils.d.ts +12 -0
  189. package/lib/services/octavfi/utils.js +44 -10
  190. package/lib/services/subgraph/fetcher.js +4 -2
  191. package/lib/services/subgraph/vaults.d.ts +12 -0
  192. package/lib/services/subgraph/vaults.js +43 -2
  193. package/lib/services/swap-quotes/index.d.ts +71 -0
  194. package/lib/services/swap-quotes/index.js +25 -0
  195. package/lib/services/swap-quotes/paraswap.d.ts +17 -0
  196. package/lib/services/swap-quotes/paraswap.js +14 -0
  197. package/lib/types/pools.d.ts +3 -0
  198. package/lib/types/typed-contract.d.ts +64 -0
  199. package/lib/types/vaults.d.ts +139 -2
  200. package/lib/types/vaults.js +10 -0
  201. package/lib/types/web3.d.ts +8 -0
  202. package/lib/types/web3.js +1 -0
  203. package/lib/types/webserver.d.ts +45 -0
  204. package/package.json +6 -5
@@ -1,4 +1,12 @@
1
1
  "use strict";
2
+ /**
3
+ * Stellar Adapter for August SDK
4
+ *
5
+ * Provides Stellar vault operations: deposit, redeem, position queries,
6
+ * and on-chain data fetching via Soroban RPC.
7
+ *
8
+ * @module StellarAdapter
9
+ */
2
10
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
11
  if (k2 === undefined) k2 = k;
4
12
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -46,6 +54,20 @@ exports.Stellar = {
46
54
  submit: StellarSubmit,
47
55
  getters: StellarGetters,
48
56
  };
57
+ /**
58
+ * Stellar Adapter for August SDK
59
+ *
60
+ * @example
61
+ * ```
62
+ * const adapter = new StellarAdapter('testnet');
63
+ * const xdr = await adapter.vaultDeposit({
64
+ * contractId: 'CBGWW5...',
65
+ * amount: '1000000',
66
+ * senderAddress: 'GDLZ...',
67
+ * });
68
+ * // Sign xdr with wallet (e.g. Freighter), then submit via adapter.submitTransaction()
69
+ * ```
70
+ */
49
71
  class StellarAdapter {
50
72
  constructor(network = 'mainnet') {
51
73
  this._network = network;
@@ -59,24 +81,50 @@ class StellarAdapter {
59
81
  getExplorerLink(id, type) {
60
82
  return utils_1.StellarUtils.getExplorerLink({ id, type, network: this._network });
61
83
  }
84
+ /**
85
+ * Build an unsigned deposit transaction for a Stellar vault.
86
+ * @returns Base64-encoded XDR of the unsigned transaction.
87
+ */
62
88
  async vaultDeposit(params) {
63
89
  return StellarActions.handleStellarDeposit({
64
90
  ...params,
65
91
  network: this._network,
66
92
  });
67
93
  }
94
+ /**
95
+ * Build an unsigned redeem transaction for a Stellar vault.
96
+ * @returns Base64-encoded XDR of the unsigned transaction.
97
+ */
68
98
  async vaultRedeem(params) {
69
99
  return StellarActions.handleStellarRedeem({
70
100
  ...params,
71
101
  network: this._network,
72
102
  });
73
103
  }
104
+ /**
105
+ * Submit a signed Soroban transaction and poll until confirmed.
106
+ * @returns Transaction hash on success
107
+ */
74
108
  async submitTransaction(signedXdr) {
75
109
  return StellarSubmit.submitStellarTransaction(signedXdr, this._network);
76
110
  }
111
+ /**
112
+ * Get user's vault share balance.
113
+ *
114
+ * @returns The position `{ shares, decimals, decimalsFromFallback }`, or null
115
+ * if the balance read fails. When `decimalsFromFallback` is `true` the
116
+ * `decimals()` read failed and `decimals` is the fallback (7) — callers sizing
117
+ * a redeem MUST refuse rather than trust it (see AUGUST-6381).
118
+ */
77
119
  async getUserPosition(vaultAddress, walletAddress) {
78
120
  return StellarGetters.getStellarUserPosition(vaultAddress, walletAddress, this._network);
79
121
  }
122
+ /**
123
+ * Preview how many vault shares a deposit amount would yield.
124
+ * @param vaultAddress Stellar contract ID (C… address)
125
+ * @param rawAmount Deposit amount in the deposit token's smallest unit
126
+ * @returns Raw share amount as a string, or null if query fails.
127
+ */
80
128
  async convertToShares(vaultAddress, rawAmount) {
81
129
  return StellarGetters.convertToShares(vaultAddress, rawAmount, this._network);
82
130
  }
@@ -1,11 +1,31 @@
1
+ /**
2
+ * Shared Soroban RPC utilities
3
+ *
4
+ * Common transaction building and read-only query helpers used by
5
+ * actions, submit, and getters modules.
6
+ */
1
7
  import { xdr, rpc } from '@stellar/stellar-sdk';
2
8
  import type { IStellarNetwork } from './types';
9
+ /** Resolved network configuration for Soroban RPC calls. */
3
10
  export interface ISorobanNetworkConfig {
4
11
  rpcUrl: string;
5
12
  passphrase: string;
6
13
  }
7
14
  export declare function createServer(rpcUrl: string): rpc.Server;
15
+ /**
16
+ * Resolve RPC URL and network passphrase for a Stellar network.
17
+ */
8
18
  export declare function resolveNetworkConfig(network: IStellarNetwork): ISorobanNetworkConfig;
19
+ /**
20
+ * Validate and convert a string amount to a non-negative BigInt.
21
+ * Throws a descriptive error if the value is not a valid non-negative integer string.
22
+ */
9
23
  export declare function toBigIntAmount(value: string, label: string): bigint;
10
24
  export declare function queryContract(config: ISorobanNetworkConfig, contractId: string, method: string, args?: xdr.ScVal[]): Promise<xdr.ScVal | null>;
25
+ /**
26
+ * Build an unsigned Soroban contract invocation transaction.
27
+ * Fetches the real source account from the network (the account must exist and be funded).
28
+ * Simulates via Soroban RPC to attach resource footprint and auth entries,
29
+ * using MAX_FEE_STROOPS as the fee ceiling and incorporating the simulated resource fee.
30
+ */
11
31
  export declare function buildSorobanTx(config: ISorobanNetworkConfig, sourceAddress: string, contractId: string, method: string, args: xdr.ScVal[]): Promise<string>;
@@ -1,4 +1,10 @@
1
1
  "use strict";
2
+ /**
3
+ * Shared Soroban RPC utilities
4
+ *
5
+ * Common transaction building and read-only query helpers used by
6
+ * actions, submit, and getters modules.
7
+ */
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
9
  exports.createServer = createServer;
4
10
  exports.resolveNetworkConfig = resolveNetworkConfig;
@@ -13,12 +19,19 @@ function createServer(rpcUrl) {
13
19
  allowHttp: rpcUrl.startsWith('http://'),
14
20
  });
15
21
  }
22
+ /**
23
+ * Resolve RPC URL and network passphrase for a Stellar network.
24
+ */
16
25
  function resolveNetworkConfig(network) {
17
26
  return {
18
27
  rpcUrl: constants_1.SOROBAN_RPC_URLS[network],
19
28
  passphrase: constants_1.NETWORK_PASSPHRASES[network],
20
29
  };
21
30
  }
31
+ /**
32
+ * Validate and convert a string amount to a non-negative BigInt.
33
+ * Throws a descriptive error if the value is not a valid non-negative integer string.
34
+ */
22
35
  function toBigIntAmount(value, label) {
23
36
  if (value === '') {
24
37
  throw new core_1.AugustValidationError('INVALID_INPUT', `Invalid ${label}: value must not be empty`);
@@ -35,6 +48,11 @@ function toBigIntAmount(value, label) {
35
48
  }
36
49
  return result;
37
50
  }
51
+ /**
52
+ * Query a read-only Soroban contract function via simulation.
53
+ * Uses a throwaway source account — simulation is off-chain and has no on-chain side effects.
54
+ * Returns the ScVal result, or null if the call fails.
55
+ */
38
56
  function extractSimulationError(simulated) {
39
57
  return 'error' in simulated
40
58
  ? String(simulated.error)
@@ -46,6 +64,8 @@ async function queryContract(config, contractId, method, args = []) {
46
64
  const contract = new stellar_sdk_1.Contract(contractId);
47
65
  const sourceKeypair = stellar_sdk_1.Keypair.random();
48
66
  const account = new stellar_sdk_1.Account(sourceKeypair.publicKey(), '0');
67
+ // Minimal fee — simulation is off-chain; these values don't affect execution cost.
68
+ // Short timeout to avoid blocking vault listing if Soroban RPC is slow.
49
69
  const tx = new stellar_sdk_1.TransactionBuilder(account, {
50
70
  fee: '100',
51
71
  networkPassphrase: config.passphrase,
@@ -76,9 +96,22 @@ async function queryContract(config, contractId, method, args = []) {
76
96
  return null;
77
97
  }
78
98
  }
99
+ /**
100
+ * Read the network's wall-clock time (unix seconds) from the latest closed
101
+ * ledger, or null if the RPC can't report it.
102
+ *
103
+ * Soroban validators reject a transaction whose `maxTime` precedes the ledger
104
+ * close time (`txTOO_LATE`). Anchoring `maxTime` to the *network* clock instead
105
+ * of the signer's `Date.now()` immunises the deadline against a skewed device
106
+ * clock — a machine lagging behind real time was silently building
107
+ * already-expired transactions. Best-effort: on any RPC failure the caller
108
+ * falls back to the local clock, so this never regresses the prior behaviour.
109
+ */
79
110
  async function getNetworkCloseTime(server) {
80
111
  try {
81
112
  const { sequence } = await server.getLatestLedger();
113
+ // `latestLedgerCloseTime` on the response envelope is the freshest network
114
+ // time; the single-ledger page is just the cheapest valid request shape.
82
115
  const page = await server.getLedgers({
83
116
  startLedger: sequence,
84
117
  pagination: { limit: 1 },
@@ -92,14 +125,25 @@ async function getNetworkCloseTime(server) {
92
125
  return null;
93
126
  }
94
127
  }
128
+ /**
129
+ * Build an unsigned Soroban contract invocation transaction.
130
+ * Fetches the real source account from the network (the account must exist and be funded).
131
+ * Simulates via Soroban RPC to attach resource footprint and auth entries,
132
+ * using MAX_FEE_STROOPS as the fee ceiling and incorporating the simulated resource fee.
133
+ */
95
134
  async function buildSorobanTx(config, sourceAddress, contractId, method, args) {
96
135
  const server = createServer(config.rpcUrl);
136
+ // Read the network clock in parallel with the account fetch — it overlaps the
137
+ // account round-trip, so it adds no latency on the happy path.
97
138
  const networkCloseTimePromise = getNetworkCloseTime(server);
98
139
  let account;
99
140
  try {
100
141
  account = await server.getAccount(sourceAddress);
101
142
  }
102
143
  catch (err) {
144
+ // Soroban rpc currently throws plain `Error("Account not found: ...")`
145
+ // for unfunded accounts; check `NotFoundError` too so this survives an
146
+ // SDK refactor to typed errors.
103
147
  const msg = err instanceof Error ? err.message : String(err);
104
148
  const isAccountNotFound = err instanceof stellar_sdk_1.NotFoundError || /Account not found/.test(msg);
105
149
  if (isAccountNotFound) {
@@ -114,9 +158,11 @@ async function buildSorobanTx(config, sourceAddress, contractId, method, args) {
114
158
  }).addOperation(contract.call(method, ...args));
115
159
  const networkCloseTime = await networkCloseTimePromise;
116
160
  if (networkCloseTime !== null) {
161
+ // Absolute deadline anchored to the network clock — survives signer skew.
117
162
  builder.setTimebounds(0, networkCloseTime + constants_1.TX_TIMEOUT_SECONDS);
118
163
  }
119
164
  else {
165
+ // RPC couldn't report network time; fall back to the local-clock window.
120
166
  builder.setTimeout(constants_1.TX_TIMEOUT_SECONDS);
121
167
  }
122
168
  const tx = builder.build();
@@ -1,2 +1,14 @@
1
+ /**
2
+ * Stellar Transaction Submission
3
+ *
4
+ * Submits signed Soroban transactions and polls for confirmation.
5
+ */
1
6
  import type { IStellarNetwork } from './types';
7
+ /**
8
+ * Submit a signed Soroban transaction and poll until confirmed.
9
+ *
10
+ * @param signedXdr Base64-encoded XDR of the signed transaction
11
+ * @param network Stellar network name
12
+ * @returns Transaction hash on success
13
+ */
2
14
  export declare function submitStellarTransaction(signedXdr: string, network: IStellarNetwork): Promise<string>;
@@ -1,10 +1,22 @@
1
1
  "use strict";
2
+ /**
3
+ * Stellar Transaction Submission
4
+ *
5
+ * Submits signed Soroban transactions and polls for confirmation.
6
+ */
2
7
  Object.defineProperty(exports, "__esModule", { value: true });
3
8
  exports.submitStellarTransaction = submitStellarTransaction;
4
9
  const stellar_sdk_1 = require("@stellar/stellar-sdk");
5
10
  const core_1 = require("../../core");
6
11
  const soroban_1 = require("./soroban");
7
12
  const constants_1 = require("./constants");
13
+ /**
14
+ * Submit a signed Soroban transaction and poll until confirmed.
15
+ *
16
+ * @param signedXdr Base64-encoded XDR of the signed transaction
17
+ * @param network Stellar network name
18
+ * @returns Transaction hash on success
19
+ */
8
20
  async function submitStellarTransaction(signedXdr, network) {
9
21
  const { rpcUrl, passphrase } = (0, soroban_1.resolveNetworkConfig)(network);
10
22
  const server = (0, soroban_1.createServer)(rpcUrl);
@@ -18,6 +30,11 @@ async function submitStellarTransaction(signedXdr, network) {
18
30
  context: { network, status: sendResult.status },
19
31
  });
20
32
  }
33
+ // Only PENDING (and DUPLICATE) mean the tx was accepted by the RPC.
34
+ // DUPLICATE means this exact transaction was already submitted — it may
35
+ // already be confirmed or still pending from a prior submission.
36
+ // TRY_AGAIN_LATER and any other status should be surfaced immediately
37
+ // so callers can retry submission instead of waiting for a poll timeout.
21
38
  if (sendResult.status !== 'PENDING' && sendResult.status !== 'DUPLICATE') {
22
39
  const msg = `Transaction not accepted by RPC (status: ${sendResult.status}). ` +
23
40
  'This may be retryable — the RPC node could be overloaded.';
@@ -26,6 +43,8 @@ async function submitStellarTransaction(signedXdr, network) {
26
43
  context: { network, status: sendResult.status },
27
44
  });
28
45
  }
46
+ // Geometric backoff (start POLL_INTERVAL_MS, ×POLL_INTERVAL_BACKOFF up to
47
+ // POLL_INTERVAL_MAX_MS) — fast on the happy path, gentler on slow ledgers.
29
48
  let getResult = await server.getTransaction(sendResult.hash);
30
49
  let polls = 0;
31
50
  let nextDelay = constants_1.POLL_INTERVAL_MS;
@@ -1,19 +1,46 @@
1
+ /**
2
+ * Stellar Vault Types
3
+ */
1
4
  import type { IStellarNetwork } from '../../types/web3';
2
5
  export type { IStellarNetwork };
6
+ /** Parameters for building an unsigned Stellar vault deposit transaction. */
3
7
  export interface IStellarDepositParams {
4
8
  contractId: string;
5
9
  amount: string;
6
10
  senderAddress: string;
7
11
  network: IStellarNetwork;
8
12
  }
13
+ /** Parameters for building an unsigned Stellar vault redeem transaction. */
9
14
  export interface IStellarRedeemParams {
10
15
  contractId: string;
11
16
  shares: string;
12
17
  receiverAddress: string;
13
18
  network: IStellarNetwork;
14
19
  }
20
+ /**
21
+ * User vault position returned by on-chain balance queries.
22
+ *
23
+ * `decimals` carries the share-token scale used to interpret `shares`. When the
24
+ * on-chain `decimals()` read fails, it falls back to STELLAR_FALLBACK_DECIMALS
25
+ * (7) and `decimalsFromFallback` is set to `true`. Callers that size a redeem
26
+ * from this position MUST check `decimalsFromFallback` and refuse to settle
27
+ * when it is `true` — trusting a fabricated 7 against an ERC4626 offset vault
28
+ * (share decimals = asset + offset) under-redeems by `10^offset`. See
29
+ * AUGUST-6381.
30
+ */
15
31
  export interface IStellarUserPosition {
32
+ /** Raw share balance in smallest unit, as a non-negative integer string */
16
33
  shares: string;
34
+ /** Share-token decimals; may be the fallback — see `decimalsFromFallback`. */
17
35
  decimals: number;
36
+ /**
37
+ * `true` when `decimals` is the fallback (the on-chain `decimals()` read
38
+ * failed), `false` when it is the authoritative on-chain value. Treat `true`
39
+ * as a decimals read failure: do not trust `decimals` to scale or redeem.
40
+ *
41
+ * Optional for source back-compat (a consumer's existing object literal still
42
+ * compiles), but `getStellarUserPosition` always populates it — so a position
43
+ * obtained from the SDK never omits it.
44
+ */
18
45
  decimalsFromFallback?: boolean;
19
46
  }
@@ -1,3 +1,6 @@
1
1
  "use strict";
2
+ /**
3
+ * Stellar Vault Types
4
+ */
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  //# sourceMappingURL=types.js.map
@@ -1,11 +1,21 @@
1
+ /**
2
+ * Stellar Utilities
3
+ */
1
4
  import type { IStellarNetwork } from './types';
2
5
  import { isStellarAddress } from '../../core/helpers/chain-address';
3
6
  export { isStellarAddress };
7
+ /**
8
+ * Get the Stellar explorer URL for a given address or transaction.
9
+ */
4
10
  export declare function getExplorerLink({ id, type, network, }: {
5
11
  id: string;
6
12
  type?: 'contract' | 'account' | 'tx';
7
13
  network?: IStellarNetwork;
8
14
  }): string;
15
+ /**
16
+ * Throw if the given address is a Stellar address.
17
+ * Used as a guard in vault operations that don't yet support Stellar.
18
+ */
9
19
  export declare function assertNotStellar(address: string, operation: string): void;
10
20
  export declare const StellarUtils: {
11
21
  isStellarAddress: typeof isStellarAddress;
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ /**
3
+ * Stellar Utilities
4
+ */
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.StellarUtils = exports.isStellarAddress = void 0;
4
7
  exports.getExplorerLink = getExplorerLink;
@@ -6,11 +9,18 @@ exports.assertNotStellar = assertNotStellar;
6
9
  const core_1 = require("../../core");
7
10
  const chain_address_1 = require("../../core/helpers/chain-address");
8
11
  Object.defineProperty(exports, "isStellarAddress", { enumerable: true, get: function () { return chain_address_1.isStellarAddress; } });
12
+ /**
13
+ * Get the Stellar explorer URL for a given address or transaction.
14
+ */
9
15
  function getExplorerLink({ id, type = 'contract', network = 'mainnet', }) {
10
16
  const baseUrl = 'https://stellar.expert/explorer';
11
17
  const net = network === 'mainnet' ? 'public' : 'testnet';
12
18
  return `${baseUrl}/${net}/${type}/${id}`;
13
19
  }
20
+ /**
21
+ * Throw if the given address is a Stellar address.
22
+ * Used as a guard in vault operations that don't yet support Stellar.
23
+ */
14
24
  function assertNotStellar(address, operation) {
15
25
  if ((0, chain_address_1.isStellarAddress)(address)) {
16
26
  throw new core_1.AugustValidationError('INVALID_CHAIN', `${operation} is not yet supported for Stellar vaults: ${address}`);
@@ -1,3 +1,9 @@
1
1
  import { IEmberVault, IFetchEmberVaultsOptions } from './types';
2
+ /**
3
+ * Fetch Ember vaults from API
4
+ */
2
5
  export declare function getEmberVaults(options?: IFetchEmberVaultsOptions): Promise<IEmberVault[]>;
6
+ /**
7
+ * Fetch Ember TVL data
8
+ */
3
9
  export declare function getEmberTVL(limit?: number): Promise<number>;
@@ -5,6 +5,9 @@ exports.getEmberTVL = getEmberTVL;
5
5
  const constants_1 = require("./constants");
6
6
  const core_1 = require("../../core");
7
7
  const logger_1 = require("../../core/logger");
8
+ /**
9
+ * Fetch Ember vaults from API
10
+ */
8
11
  async function getEmberVaults(options) {
9
12
  try {
10
13
  const params = new URLSearchParams();
@@ -28,6 +31,9 @@ async function getEmberVaults(options) {
28
31
  return [];
29
32
  }
30
33
  }
34
+ /**
35
+ * Fetch Ember TVL data
36
+ */
31
37
  async function getEmberTVL(limit = 1) {
32
38
  try {
33
39
  const params = new URLSearchParams();
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Sui Adapter for August SDK
3
+ *
4
+ * @module SuiAdapter
5
+ */
1
6
  import * as SuiConstants from './constants';
2
7
  import * as SuiGetters from './getters';
3
8
  import * as SuiUtils from './utils';
@@ -12,6 +17,16 @@ export declare const Sui: {
12
17
  transformEmberVaultsToIVaults: typeof transformEmberVaultsToIVaults;
13
18
  };
14
19
  };
20
+ /**
21
+ * Sui Adapter for August SDK
22
+ *
23
+ * @example
24
+ * To access the Sui adapter instance
25
+ * ```
26
+ * const sdk = new AugustSDK()
27
+ * sdk.sui.getEmberVaults()
28
+ * ```
29
+ */
15
30
  declare class SuiAdapter {
16
31
  private _apiBaseUrl;
17
32
  private _chainId;
@@ -34,6 +34,11 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.Sui = void 0;
37
+ /**
38
+ * Sui Adapter for August SDK
39
+ *
40
+ * @module SuiAdapter
41
+ */
37
42
  const SuiConstants = __importStar(require("./constants"));
38
43
  const SuiGetters = __importStar(require("./getters"));
39
44
  const SuiUtils = __importStar(require("./utils"));
@@ -44,6 +49,16 @@ exports.Sui = {
44
49
  getters: SuiGetters,
45
50
  transformer: { transformEmberVaultToIVault: transformer_1.transformEmberVaultToIVault, transformEmberVaultsToIVaults: transformer_1.transformEmberVaultsToIVaults },
46
51
  };
52
+ /**
53
+ * Sui Adapter for August SDK
54
+ *
55
+ * @example
56
+ * To access the Sui adapter instance
57
+ * ```
58
+ * const sdk = new AugustSDK()
59
+ * sdk.sui.getEmberVaults()
60
+ * ```
61
+ */
47
62
  class SuiAdapter {
48
63
  constructor(apiBaseUrl = SuiConstants.EMBER_API_BASE_URL, chainId = SuiConstants.SUI_CHAIN_ID) {
49
64
  this._apiBaseUrl = apiBaseUrl;
@@ -1,4 +1,10 @@
1
1
  import { IVault } from '../../types';
2
2
  import { IEmberVault } from './types';
3
+ /**
4
+ * Transform Ember vault to IVault format
5
+ */
3
6
  export declare function transformEmberVaultToIVault(emberVault: IEmberVault): IVault;
7
+ /**
8
+ * Transform multiple Ember vaults
9
+ */
4
10
  export declare function transformEmberVaultsToIVaults(emberVaults: IEmberVault[]): IVault[];
@@ -5,6 +5,9 @@ exports.transformEmberVaultsToIVaults = transformEmberVaultsToIVaults;
5
5
  const core_1 = require("../../core");
6
6
  const constants_1 = require("./constants");
7
7
  const utils_1 = require("./utils");
8
+ /**
9
+ * Transform Ember vault to IVault format
10
+ */
8
11
  function transformEmberVaultToIVault(emberVault) {
9
12
  const depositTokenDecimals = emberVault.depositCoin?.decimals || constants_1.EMBER_DEFAULTS.DECIMALS;
10
13
  const receiptTokenDecimals = emberVault.receiptCoin?.decimals || constants_1.EMBER_DEFAULTS.DECIMALS;
@@ -38,6 +41,7 @@ function transformEmberVaultToIVault(emberVault) {
38
41
  ? 'Gamma Research'
39
42
  : manager?.name || 'Unknown',
40
43
  type: 'subaccount',
44
+ website_url: null,
41
45
  })),
42
46
  fees: {
43
47
  performance: (0, utils_1.convertFromE9)(emberVault.weeklyPerformanceFeeBpsE9 || 0) /
@@ -93,6 +97,9 @@ function transformEmberVaultToIVault(emberVault) {
93
97
  };
94
98
  return returnObj;
95
99
  }
100
+ /**
101
+ * Transform multiple Ember vaults
102
+ */
96
103
  function transformEmberVaultsToIVaults(emberVaults) {
97
104
  return emberVaults.map(transformEmberVaultToIVault);
98
105
  }
@@ -1,4 +1,10 @@
1
+ /**
2
+ * Convert E9 format to regular number
3
+ */
1
4
  export declare function convertFromE9(value: string | number): number;
5
+ /**
6
+ * Calculate capacity utilization percentage
7
+ */
2
8
  export declare function calculateUtilization(current: string | number, maximum: string | number): number;
3
9
  export { isSuiAddress } from '../../core/helpers/chain-address';
4
10
  export declare function isSuiVault(chainId: number): boolean;
@@ -5,9 +5,15 @@ exports.convertFromE9 = convertFromE9;
5
5
  exports.calculateUtilization = calculateUtilization;
6
6
  exports.isSuiVault = isSuiVault;
7
7
  const constants_1 = require("./constants");
8
+ /**
9
+ * Convert E9 format to regular number
10
+ */
8
11
  function convertFromE9(value) {
9
12
  return Number(value) / constants_1.EMBER_DEFAULTS.E9_DIVISOR;
10
13
  }
14
+ /**
15
+ * Calculate capacity utilization percentage
16
+ */
11
17
  function calculateUtilization(current, maximum) {
12
18
  const currentValue = Number(current) || 0;
13
19
  const maxValue = Number(maximum) || 0;
@@ -1 +1,9 @@
1
+ /**
2
+ * Map a numeric `chainId` to a stable lowercase slug for use as a Sentry tag
3
+ * value. Resolves both EVM chains ({@link NETWORKS}) and synthetic non-EVM
4
+ * chain IDs ({@link SPECIAL_CHAINS}); unknown IDs return `'unknown:<id>'`.
5
+ *
6
+ * @param chainId - Numeric chain ID, including negative IDs for non-EVM chains.
7
+ * @returns Slugified chain label (e.g. `'ethereum'`, `'arbitrum-one'`, `'solana'`).
8
+ */
1
9
  export declare function chainIdToTagValue(chainId: number | undefined): string;
@@ -2,6 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.chainIdToTagValue = chainIdToTagValue;
4
4
  const web3_1 = require("../constants/web3");
5
+ /**
6
+ * Map a numeric `chainId` to a stable lowercase slug for use as a Sentry tag
7
+ * value. Resolves both EVM chains ({@link NETWORKS}) and synthetic non-EVM
8
+ * chain IDs ({@link SPECIAL_CHAINS}); unknown IDs return `'unknown:<id>'`.
9
+ *
10
+ * @param chainId - Numeric chain ID, including negative IDs for non-EVM chains.
11
+ * @returns Slugified chain label (e.g. `'ethereum'`, `'arbitrum-one'`, `'solana'`).
12
+ */
5
13
  function chainIdToTagValue(chainId) {
6
14
  if (chainId === undefined || chainId === null || Number.isNaN(chainId)) {
7
15
  return 'unknown';
@@ -1 +1,5 @@
1
+ /**
2
+ * Sentry DSN for SDK analytics.
3
+ * This is an internal constant - not exposed to SDK users.
4
+ */
1
5
  export declare const SENTRY_DSN = "https://d73b6a85fe14960b8dac8ac61a743a94@o4507215496609792.ingest.de.sentry.io/4510699327389776";
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SENTRY_DSN = void 0;
4
+ /**
5
+ * Sentry DSN for SDK analytics.
6
+ * This is an internal constant - not exposed to SDK users.
7
+ */
4
8
  exports.SENTRY_DSN = 'https://d73b6a85fe14960b8dac8ac61a743a94@o4507215496609792.ingest.de.sentry.io/4510699327389776';
5
9
  //# sourceMappingURL=constants.js.map
@@ -1,4 +1,29 @@
1
+ /**
2
+ * Environment-variable gates for analytics. Pure functions — safe to import
3
+ * anywhere, no Sentry side effects. Tested directly in `analytics.test.js`.
4
+ */
5
+ /**
6
+ * Read a process env var without crashing in browsers or in bundles where
7
+ * `process.env` is a frozen / proxied object that throws on missing keys.
8
+ */
1
9
  export declare function readEnv(name: string): string | undefined;
10
+ /**
11
+ * `AUGUST_SDK_FORCE_ANALYTICS=1` bypasses the dev/test and localhost gates.
12
+ * Used by our own smoke-test script and by partners deliberately exercising
13
+ * telemetry in a non-prod environment.
14
+ */
2
15
  export declare function isAnalyticsForcedOnViaEnv(): boolean;
16
+ /**
17
+ * `AUGUST_SDK_DISABLE_ANALYTICS=1` is the env equivalent of passing
18
+ * `analytics: { enabled: false }`. Useful when partners can't easily plumb
19
+ * config through (CI runners, ops scripts).
20
+ */
3
21
  export declare function isAnalyticsDisabledViaEnv(): boolean;
22
+ /**
23
+ * True when `NODE_ENV` is `'development'` or `'test'`. The SDK auto-disables
24
+ * analytics in these environments so partners' local dev runs and Jest suites
25
+ * don't pollute the production Sentry project.
26
+ *
27
+ * `NODE_ENV` undefined / `'production'` / `'staging'` / anything else → false.
28
+ */
4
29
  export declare function isNodeDevOrTestEnv(): boolean;