@upshiftfinance/sdk 0.2.0 → 0.4.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 (55) hide show
  1. package/README.md +1 -1
  2. package/lib/abis/KycRegistry.d.ts +109 -0
  3. package/lib/abis/KycRegistry.js +73 -0
  4. package/lib/abis/index.d.ts +1 -0
  5. package/lib/abis/index.js +1 -0
  6. package/lib/adapters/sui/actions.d.ts +174 -0
  7. package/lib/adapters/sui/actions.js +382 -0
  8. package/lib/adapters/sui/getters.d.ts +166 -0
  9. package/lib/adapters/sui/getters.js +391 -0
  10. package/lib/adapters/sui/index.d.ts +95 -2
  11. package/lib/adapters/sui/index.js +92 -2
  12. package/lib/adapters/sui/targets.d.ts +35 -0
  13. package/lib/adapters/sui/targets.js +35 -0
  14. package/lib/core/analytics/method-taxonomy.d.ts +1 -1
  15. package/lib/core/analytics/method-taxonomy.js +7 -0
  16. package/lib/core/analytics/version.d.ts +1 -1
  17. package/lib/core/analytics/version.js +1 -1
  18. package/lib/core/constants/core.d.ts +5 -0
  19. package/lib/core/constants/core.js +5 -0
  20. package/lib/core/constants/kyc.d.ts +9 -0
  21. package/lib/core/constants/kyc.js +12 -0
  22. package/lib/core/constants/swap-router.js +24 -0
  23. package/lib/core/constants/web3.d.ts +2 -2
  24. package/lib/core/constants/web3.js +9 -2
  25. package/lib/core/errors/index.d.ts +77 -1
  26. package/lib/core/errors/index.js +94 -1
  27. package/lib/core/fetcher.d.ts +5 -0
  28. package/lib/core/fetcher.js +1 -1
  29. package/lib/core/helpers/chain-support.d.ts +2 -2
  30. package/lib/core/helpers/chain-support.js +3 -3
  31. package/lib/core/helpers/kyc.d.ts +47 -0
  32. package/lib/core/helpers/kyc.js +111 -0
  33. package/lib/core/helpers/revert-decode.js +3 -2
  34. package/lib/core/index.d.ts +2 -0
  35. package/lib/core/index.js +2 -0
  36. package/lib/main.d.ts +31 -3
  37. package/lib/main.js +32 -0
  38. package/lib/modules/api/kyc.d.ts +4 -0
  39. package/lib/modules/api/kyc.js +148 -0
  40. package/lib/modules/api/main.d.ts +63 -1
  41. package/lib/modules/api/main.js +64 -0
  42. package/lib/modules/vaults/getters.d.ts +3 -1
  43. package/lib/modules/vaults/getters.js +53 -9
  44. package/lib/modules/vaults/main.d.ts +39 -3
  45. package/lib/modules/vaults/main.js +79 -5
  46. package/lib/modules/vaults/types.d.ts +7 -1
  47. package/lib/modules/vaults/utils.js +4 -1
  48. package/lib/sdk.d.ts +15131 -14393
  49. package/lib/types/index.d.ts +1 -0
  50. package/lib/types/index.js +1 -0
  51. package/lib/types/kyc.d.ts +61 -0
  52. package/lib/types/kyc.js +3 -0
  53. package/lib/types/vaults.d.ts +2 -0
  54. package/lib/types/webserver.d.ts +5 -0
  55. package/package.json +1 -1
@@ -88,6 +88,8 @@ const SolanaConstants = __importStar(require("../../adapters/solana/constants"))
88
88
  const withdrawal_queue_1 = require("../../adapters/solana/withdrawal-queue");
89
89
  const web3_js_1 = require("@solana/web3.js");
90
90
  const StellarGetters = __importStar(require("../../adapters/stellar/getters"));
91
+ const SuiGetters = __importStar(require("../../adapters/sui/getters"));
92
+ const chain_address_1 = require("../../core/helpers/chain-address");
91
93
  const utils_3 = require("../../adapters/stellar/utils");
92
94
  const constants_1 = require("../../adapters/stellar/constants");
93
95
  const EVM = __importStar(require("../../adapters/evm"));
@@ -160,6 +162,10 @@ async function getVault({ vault, loans = false, allocations = false, options, lo
160
162
  returnedVault = await StellarGetters.getStellarVault(tokenizedVault, options);
161
163
  break;
162
164
  }
165
+ case 'sui-0': {
166
+ returnedVault = await SuiGetters.getSuiVault(tokenizedVault, options);
167
+ break;
168
+ }
163
169
  case 'evm-2': {
164
170
  returnedVault = await EVM.getEvmVaultV2(tokenizedVault, options);
165
171
  break;
@@ -968,9 +974,9 @@ async function readSolanaRedemptions(input) {
968
974
  }
969
975
  async function getVaultAvailableRedemptions({ vault, wallet, options, prefetchedReads, }) {
970
976
  try {
971
- // Stellar vaults don't support on-chain redemptions yet
972
- if ((0, utils_3.isStellarAddress)(vault)) {
973
- core_1.Logger.log.warn('getVaultAvailableRedemptions', `Available redemptions is not yet supported for Stellar vaults: ${vault}`);
977
+ // Stellar and Sui vaults don't support on-chain redemptions yet
978
+ if ((0, utils_3.isStellarAddress)(vault) || (0, chain_address_1.isSuiAddress)(vault)) {
979
+ core_1.Logger.log.warn('getVaultAvailableRedemptions', `Available redemptions is not yet supported for this vault: ${vault}`);
974
980
  return {
975
981
  availableRedemptions: [],
976
982
  pendingRedemptions: [],
@@ -1305,9 +1311,9 @@ async function getVaultAvailableRedemptions({ vault, wallet, options, prefetched
1305
1311
  }
1306
1312
  async function getVaultRedemptionHistory({ vault, wallet, lookbackBlocks, options, }) {
1307
1313
  try {
1308
- // Stellar vaults: no on-chain redemption history yet
1309
- if ((0, utils_3.isStellarAddress)(vault)) {
1310
- core_1.Logger.log.warn('getVaultRedemptionHistory', `Redemption history is not yet supported for Stellar vaults: ${vault}`);
1314
+ // Stellar and Sui vaults: no on-chain redemption history yet
1315
+ if ((0, utils_3.isStellarAddress)(vault) || (0, chain_address_1.isSuiAddress)(vault)) {
1316
+ core_1.Logger.log.warn('getVaultRedemptionHistory', `Redemption history is not yet supported for this vault: ${vault}`);
1311
1317
  return [];
1312
1318
  }
1313
1319
  // setup
@@ -1481,7 +1487,7 @@ Object.defineProperty(exports, "getSwapRouterDepositResult", { enumerable: true,
1481
1487
  /**
1482
1488
  * Vault Positions
1483
1489
  */
1484
- async function getVaultPositions({ vault, wallet, solanaWallet, stellarWallet, options, prefetchedReads, }) {
1490
+ async function getVaultPositions({ vault, wallet, solanaWallet, stellarWallet, suiWallet, options, prefetchedReads, }) {
1485
1491
  try {
1486
1492
  const tokenizedVaults = await (0, core_1.fetchTokenizedVault)(vault ? vault : undefined, options?.headers, false, false);
1487
1493
  if (!tokenizedVaults || tokenizedVaults.length === 0) {
@@ -1594,6 +1600,32 @@ async function getVaultPositions({ vault, wallet, solanaWallet, stellarWallet, o
1594
1600
  walletBalance: balance,
1595
1601
  };
1596
1602
  }
1603
+ if ((0, chain_address_1.isSuiAddress)(v.address)) {
1604
+ // The contract gives shares the deposit coin's decimals.
1605
+ const decimals = v.sui_vault_metadata?.deposit_token_decimals;
1606
+ const shareCoinType = v.sui_vault_metadata?.share_coin_type;
1607
+ const network = v.sui_vault_metadata?.network_name;
1608
+ let balance = (0, core_1.toNormalizedBn)(0, decimals ?? 0);
1609
+ // No metadata at all: a legacy Ember/Gamma vault, nothing to read.
1610
+ if (suiWallet && (0, chain_address_1.isSuiAddress)(suiWallet) && v.sui_vault_metadata) {
1611
+ if (decimals == null || !shareCoinType || !network) {
1612
+ // Without the share type or its decimals there is nothing to
1613
+ // read or no way to scale it: fail the row, don't show zero.
1614
+ throw new errors_1.UpshiftValidationError('INVALID_INPUT', 'getVaultPositions: Sui vault is missing sui_vault_metadata share type, decimals or network', { context: { vault: v.address } });
1615
+ }
1616
+ const shares = await SuiGetters.getSuiShareBalance(suiWallet, shareCoinType, network, options.sui);
1617
+ balance = (0, core_1.toNormalizedBn)(shares, decimals);
1618
+ }
1619
+ // Sui vaults have no redemption reads in v1.
1620
+ return {
1621
+ vault: v.address,
1622
+ status: renderStatus([], balance),
1623
+ availableRedemptions: [],
1624
+ pendingRedemptions: [],
1625
+ redeemable: (0, core_1.toNormalizedBn)(0),
1626
+ walletBalance: balance,
1627
+ };
1628
+ }
1597
1629
  // create provider
1598
1630
  const provider = (0, core_1.createProvider)(options.rpcUrl);
1599
1631
  // version split logic
@@ -1709,6 +1741,7 @@ async function getVaultPositions({ vault, wallet, solanaWallet, stellarWallet, o
1709
1741
  wallet,
1710
1742
  solanaWallet,
1711
1743
  stellarWallet,
1744
+ suiWallet,
1712
1745
  });
1713
1746
  throw new Error(`#getVaultPositions::${vault}:${e?.message}`);
1714
1747
  }
@@ -1897,6 +1930,14 @@ async function getVaultTvl({ vault, options, historical, }) {
1897
1930
  },
1898
1931
  ];
1899
1932
  }
1933
+ if (version === 'sui-0') {
1934
+ return [
1935
+ {
1936
+ value: (0, utils_1.backendTvlToNormalizedBn)(_vaultExists?.latest_reported_tvl, _vaultExists?.sui_vault_metadata?.deposit_token_decimals ?? 0),
1937
+ timestamp: new Date().toISOString(),
1938
+ },
1939
+ ];
1940
+ }
1900
1941
  if (version === 'stellar-0') {
1901
1942
  const stellarDecimals = _vaultExists?.stellar_vault_metadata?.deposit_token_decimals ??
1902
1943
  constants_1.STELLAR_FALLBACK_DECIMALS;
@@ -1957,7 +1998,9 @@ async function getVaultTvl({ vault, options, historical, }) {
1957
1998
  // historical tvl
1958
1999
  // check vault version early to guard non-EVM chains
1959
2000
  const version = (0, core_1.getVaultVersionV2)(_vaultExists);
1960
- if (version === 'stellar-0' || version === 'sol-0') {
2001
+ if (version === 'stellar-0' ||
2002
+ version === 'sol-0' ||
2003
+ version === 'sui-0') {
1961
2004
  core_1.Logger.log.warn('getVaultTvl:historical', 'Historical TVL not supported for non-EVM vaults', { vault, version });
1962
2005
  return [];
1963
2006
  }
@@ -2349,7 +2392,8 @@ async function getYieldLastRealizedOn({ vault, options, }) {
2349
2392
  break;
2350
2393
  }
2351
2394
  case 'sol-0':
2352
- case 'stellar-0': {
2395
+ case 'stellar-0':
2396
+ case 'sui-0': {
2353
2397
  return 0;
2354
2398
  }
2355
2399
  default: {
@@ -7,7 +7,7 @@
7
7
  * Export getters
8
8
  */
9
9
  export * from './getters';
10
- import type { IAddress, IChainId, IGetOriginInfoOptions, INormalizedNumber, IOriginInfo, IVaultHistoricalParams, IVaultPosition, IVaultUserHistoryItem } from '../../types';
10
+ import type { IAddress, IChainId, IGetOriginInfoOptions, IKycRecord, IKycStatus, IKycWalletOptions, INormalizedNumber, IOriginInfo, IVaultHistoricalParams, IVaultPosition, IVaultUserHistoryItem } from '../../types';
11
11
  import type SolanaAdapter from '../../adapters/solana';
12
12
  import { UpshiftBase, type IUpshiftBase } from '../../core';
13
13
  import { type IContractWriteOptions, type INativeDepositOptions } from './write.actions';
@@ -27,6 +27,8 @@ export declare class UpshiftVaults extends UpshiftBase {
27
27
  * vaults (see `IVaultBaseOptions.stellarRpc`).
28
28
  */
29
29
  private _stellarRpc?;
30
+ /** The SDK's `sui` config, for Sui vault reads (see `IVaultBaseOptions.sui`). */
31
+ private _sui?;
30
32
  constructor(baseConfig: IUpshiftBase, solana: SolanaAdapter);
31
33
  /**
32
34
  * @description deposit underlying token into the specified pool with adapter support. This is for when we cannot pass in a signer in sdk and need to do so as an arg
@@ -240,8 +242,8 @@ export declare class UpshiftVaults extends UpshiftBase {
240
242
  solanaWallet?: string;
241
243
  stellarWallet?: string;
242
244
  /**
243
- * Sui wallet address (`0x` + 64 hex chars). Validated now; Sui positions
244
- * are not read yet, so passing it does not add Sui vaults to the result.
245
+ * Sui wallet address (`0x` + 64 hex chars). Its share balance is read for
246
+ * each Sui vault; Sui positions have no redemptions in v1.
245
247
  */
246
248
  suiWallet?: string;
247
249
  options?: IVaultBaseOptions;
@@ -408,6 +410,40 @@ export declare class UpshiftVaults extends UpshiftBase {
408
410
  * ```
409
411
  */
410
412
  getOriginInfo(options: Omit<IGetOriginInfoOptions, 'rpcUrl'>): Promise<IOriginInfo>;
413
+ /**
414
+ * Read a wallet's KYC status through this instance's provider for
415
+ * `chainId`. See {@link getKycStatus}.
416
+ *
417
+ * @param options - `chainId` and `wallet`.
418
+ * @returns The wallet's {@link IKycStatus}.
419
+ * @throws UpshiftValidationError (`INVALID_CHAIN`) when no provider is
420
+ * configured or no registry is deployed for `chainId`;
421
+ * (`INVALID_ADDRESS`) for a malformed wallet.
422
+ * @throws UpshiftSDKError when the `statusOf` read fails.
423
+ * @worstCaseRpcCalls 1
424
+ * @example
425
+ * ```ts
426
+ * const status = await upshiftSdk.getKycStatus({ chainId: 1, wallet });
427
+ * ```
428
+ */
429
+ getKycStatus(options: Omit<IKycWalletOptions, 'rpcUrl'>): Promise<IKycStatus>;
430
+ /**
431
+ * Read a wallet's raw KYC record through this instance's provider for
432
+ * `chainId`. See {@link getKycRecord}.
433
+ *
434
+ * @param options - `chainId` and `wallet`.
435
+ * @returns The wallet's {@link IKycRecord}.
436
+ * @throws UpshiftValidationError (`INVALID_CHAIN`) when no provider is
437
+ * configured or no registry is deployed for `chainId`;
438
+ * (`INVALID_ADDRESS`) for a malformed wallet.
439
+ * @throws UpshiftSDKError when the `getRecord` read fails.
440
+ * @worstCaseRpcCalls 1
441
+ * @example
442
+ * ```ts
443
+ * const record = await upshiftSdk.getKycRecord({ chainId: 1, wallet });
444
+ * ```
445
+ */
446
+ getKycRecord(options: Omit<IKycWalletOptions, 'rpcUrl'>): Promise<IKycRecord>;
411
447
  /**
412
448
  * @function getStakingPositions gets all available reward staking positions
413
449
  * @param wallet optionally passed user wallet address
@@ -77,6 +77,8 @@ class UpshiftVaults extends core_1.UpshiftBase {
77
77
  * vaults (see `IVaultBaseOptions.stellarRpc`).
78
78
  */
79
79
  _stellarRpc;
80
+ /** The SDK's `sui` config, for Sui vault reads (see `IVaultBaseOptions.sui`). */
81
+ _sui;
80
82
  constructor(baseConfig, solana) {
81
83
  super(baseConfig);
82
84
  this.solanaService = solana;
@@ -87,6 +89,7 @@ class UpshiftVaults extends core_1.UpshiftBase {
87
89
  network: baseConfig.stellar.network ?? 'mainnet',
88
90
  }
89
91
  : undefined;
92
+ this._sui = baseConfig.sui;
90
93
  this.headers = {
91
94
  'x-environment': this.monitoring?.['x-environment'],
92
95
  'x-user-id': this.monitoring?.['x-user-id'],
@@ -134,8 +137,10 @@ class UpshiftVaults extends core_1.UpshiftBase {
134
137
  // if (!(this.authorized && this.upshiftKey)) // @todo: commented out for integrators
135
138
  const allVaults = await (0, core_1.fetchTokenizedVaults)(undefined, this.headers, options?.loadSubaccounts, options?.loadSnapshots);
136
139
  const vaultsPerAvailableProviders = allVaults.filter((v) =>
137
- // Stellar vaults are backend-only (no RPC provider required)
140
+ // Stellar and Sui vaults use their own endpoints, not this.providers.
141
+ // Sui rows without sui_vault_metadata are legacy Ember/Gamma vaults.
138
142
  v?.chain_type === 'stellar' ||
143
+ (v?.chain_type === 'sui' && !!v.sui_vault_metadata) ||
139
144
  // Solana vaults use this.solanaService (not this.providers). Without
140
145
  // an explicit pass-through here they get silently dropped on any
141
146
  // instance whose ACTIVE_RPC_URLS() doesn't register chainId -1.
@@ -202,6 +207,7 @@ class UpshiftVaults extends core_1.UpshiftBase {
202
207
  rpcUrl,
203
208
  solanaService: this.solanaService,
204
209
  stellarRpc: this._stellarRpc,
210
+ sui: this._sui,
205
211
  env: this.monitoring?.env,
206
212
  upshiftKey: this.keys?.upshift,
207
213
  subgraphKey: this.keys?.graph,
@@ -294,6 +300,7 @@ class UpshiftVaults extends core_1.UpshiftBase {
294
300
  rpcUrl: this.providers?.[v.chain],
295
301
  solanaService: this.solanaService,
296
302
  stellarRpc: this._stellarRpc,
303
+ sui: this._sui,
297
304
  env: this.monitoring?.env,
298
305
  upshiftKey: this.keys?.upshift,
299
306
  subgraphKey: this.keys?.graph,
@@ -361,7 +368,6 @@ class UpshiftVaults extends core_1.UpshiftBase {
361
368
  // `Vault input parameter is not an address: ${String(vault)}`,
362
369
  // );
363
370
  (0, core_1.assertKnownChainId)(chainId, this.providers, 'getVault');
364
- (0, core_1.assertSuiReadsSupported)(chainId, vault, 'getVault');
365
371
  (0, core_1.assertEvmProviderConfigured)(chainId, this.providers, 'getVault');
366
372
  // get vault data
367
373
  const vaultResponse = await (0, getters_1.getVault)({
@@ -376,6 +382,7 @@ class UpshiftVaults extends core_1.UpshiftBase {
376
382
  : this.activeNetwork?.rpcUrl,
377
383
  solanaService: this.solanaService,
378
384
  stellarRpc: this._stellarRpc,
385
+ sui: this._sui,
379
386
  env: this.monitoring?.env,
380
387
  upshiftKey: this.keys?.upshift,
381
388
  subgraphKey: this.keys?.graph,
@@ -404,6 +411,7 @@ class UpshiftVaults extends core_1.UpshiftBase {
404
411
  : this.activeNetwork?.rpcUrl,
405
412
  solanaService: this.solanaService,
406
413
  stellarRpc: this._stellarRpc,
414
+ sui: this._sui,
407
415
  env: this.monitoring?.env,
408
416
  upshiftKey: this.keys?.upshift,
409
417
  subgraphKey: this.keys?.graph,
@@ -453,6 +461,7 @@ class UpshiftVaults extends core_1.UpshiftBase {
453
461
  chainId: chainId,
454
462
  solanaService: this.solanaService,
455
463
  stellarRpc: this._stellarRpc,
464
+ sui: this._sui,
456
465
  headers: this.headers,
457
466
  });
458
467
  return vaultResponse;
@@ -486,6 +495,7 @@ class UpshiftVaults extends core_1.UpshiftBase {
486
495
  chainId: chainId,
487
496
  solanaService: this.solanaService,
488
497
  stellarRpc: this._stellarRpc,
498
+ sui: this._sui,
489
499
  headers: this.headers,
490
500
  });
491
501
  return vaultResponse;
@@ -519,6 +529,7 @@ class UpshiftVaults extends core_1.UpshiftBase {
519
529
  : this.activeNetwork?.rpcUrl,
520
530
  solanaService: this.solanaService,
521
531
  stellarRpc: this._stellarRpc,
532
+ sui: this._sui,
522
533
  env: this.monitoring?.env,
523
534
  upshiftKey: this.keys?.upshift,
524
535
  subgraphKey: this.keys?.graph,
@@ -601,6 +612,7 @@ class UpshiftVaults extends core_1.UpshiftBase {
601
612
  throw new Error('Vault input parameter is undefined.');
602
613
  if (!(0, ethers_1.isAddress)(vault) &&
603
614
  !(0, utils_2.isStellarAddress)(vault) &&
615
+ !(0, chain_address_1.isSuiAddress)(vault) &&
604
616
  !utils_1.SolanaUtils.isSolanaAddress(vault))
605
617
  throw new Error(`Vault input parameter is not an address: ${String(vault)}`);
606
618
  return await (0, getters_1.getVaultAvailableRedemptions)({
@@ -612,6 +624,7 @@ class UpshiftVaults extends core_1.UpshiftBase {
612
624
  : this.activeNetwork?.rpcUrl,
613
625
  solanaService: this.solanaService,
614
626
  stellarRpc: this._stellarRpc,
627
+ sui: this._sui,
615
628
  env: this.monitoring?.env,
616
629
  upshiftKey: this.keys?.upshift,
617
630
  subgraphKey: this.keys?.graph,
@@ -654,7 +667,7 @@ class UpshiftVaults extends core_1.UpshiftBase {
654
667
  throw new Error('Not authorized.');
655
668
  if (!vault)
656
669
  throw new Error('Vault input parameter is undefined.');
657
- if (!(0, ethers_1.isAddress)(vault) && !(0, utils_2.isStellarAddress)(vault)) {
670
+ if (!(0, ethers_1.isAddress)(vault) && !(0, utils_2.isStellarAddress)(vault) && !(0, chain_address_1.isSuiAddress)(vault)) {
658
671
  throw new Error(`Vault input parameter is not an address: ${String(vault)}`);
659
672
  }
660
673
  return await (0, getters_1.getVaultRedemptionHistory)({
@@ -705,12 +718,14 @@ class UpshiftVaults extends core_1.UpshiftBase {
705
718
  wallet,
706
719
  solanaWallet,
707
720
  stellarWallet,
721
+ suiWallet,
708
722
  options: {
709
723
  rpcUrl: chainId
710
724
  ? this.providers?.[chainId]
711
725
  : this.activeNetwork?.rpcUrl,
712
726
  solanaService: this.solanaService,
713
727
  stellarRpc: this._stellarRpc,
728
+ sui: this._sui,
714
729
  env: this.monitoring?.env,
715
730
  upshiftKey: this.keys?.upshift,
716
731
  subgraphKey: this.keys?.graph,
@@ -735,11 +750,13 @@ class UpshiftVaults extends core_1.UpshiftBase {
735
750
  vault: v.address,
736
751
  solanaWallet,
737
752
  stellarWallet,
753
+ suiWallet,
738
754
  wallet,
739
755
  options: {
740
756
  rpcUrl: this.providers?.[v.chain],
741
757
  solanaService: this.solanaService,
742
758
  stellarRpc: this._stellarRpc,
759
+ sui: this._sui,
743
760
  env: this.monitoring?.env,
744
761
  upshiftKey: this.keys?.upshift,
745
762
  subgraphKey: this.keys?.graph,
@@ -757,8 +774,10 @@ class UpshiftVaults extends core_1.UpshiftBase {
757
774
  return final;
758
775
  }
759
776
  const vaultsPerAvailableProviders = allVaults.filter((v) =>
760
- // Stellar vaults are backend-only (no RPC provider required)
777
+ // Stellar and Sui vaults use their own endpoints, not this.providers.
778
+ // Sui rows without sui_vault_metadata are legacy Ember/Gamma vaults.
761
779
  v?.chain_type === 'stellar' ||
780
+ (v?.chain_type === 'sui' && !!v.sui_vault_metadata) ||
762
781
  // Solana vaults use this.solanaService (not this.providers). Without
763
782
  // this clause every Solana position is dropped on any instance where
764
783
  // ACTIVE_RPC_URLS() doesn't register chainId -1 — which is exactly
@@ -779,11 +798,13 @@ class UpshiftVaults extends core_1.UpshiftBase {
779
798
  vault: v.address,
780
799
  solanaWallet,
781
800
  stellarWallet,
801
+ suiWallet,
782
802
  wallet,
783
803
  options: {
784
804
  rpcUrl: this.providers?.[v.chain],
785
805
  solanaService: this.solanaService,
786
806
  stellarRpc: this._stellarRpc,
807
+ sui: this._sui,
787
808
  env: this.monitoring?.env,
788
809
  upshiftKey: this.keys?.upshift,
789
810
  subgraphKey: this.keys?.graph,
@@ -963,6 +984,7 @@ class UpshiftVaults extends core_1.UpshiftBase {
963
984
  : this.requireActiveNetwork().rpcUrl,
964
985
  solanaService: this.solanaService,
965
986
  stellarRpc: this._stellarRpc,
987
+ sui: this._sui,
966
988
  env: this.monitoring?.env,
967
989
  upshiftKey: this.keys?.upshift,
968
990
  subgraphKey: this.keys?.graph,
@@ -989,6 +1011,7 @@ class UpshiftVaults extends core_1.UpshiftBase {
989
1011
  : this.requireActiveNetwork().rpcUrl,
990
1012
  solanaService: this.solanaService,
991
1013
  stellarRpc: this._stellarRpc,
1014
+ sui: this._sui,
992
1015
  env: this.monitoring?.env,
993
1016
  upshiftKey: this.keys?.upshift,
994
1017
  subgraphKey: this.keys?.graph,
@@ -1208,6 +1231,52 @@ class UpshiftVaults extends core_1.UpshiftBase {
1208
1231
  rpcUrl: this.providers[options.chainId],
1209
1232
  });
1210
1233
  }
1234
+ /**
1235
+ * Read a wallet's KYC status through this instance's provider for
1236
+ * `chainId`. See {@link getKycStatus}.
1237
+ *
1238
+ * @param options - `chainId` and `wallet`.
1239
+ * @returns The wallet's {@link IKycStatus}.
1240
+ * @throws UpshiftValidationError (`INVALID_CHAIN`) when no provider is
1241
+ * configured or no registry is deployed for `chainId`;
1242
+ * (`INVALID_ADDRESS`) for a malformed wallet.
1243
+ * @throws UpshiftSDKError when the `statusOf` read fails.
1244
+ * @worstCaseRpcCalls 1
1245
+ * @example
1246
+ * ```ts
1247
+ * const status = await upshiftSdk.getKycStatus({ chainId: 1, wallet });
1248
+ * ```
1249
+ */
1250
+ async getKycStatus(options) {
1251
+ (0, core_1.assertEvmProviderConfigured)(options.chainId, this.providers, 'getKycStatus');
1252
+ return (0, core_1.getKycStatus)({
1253
+ ...options,
1254
+ rpcUrl: this.providers[options.chainId],
1255
+ });
1256
+ }
1257
+ /**
1258
+ * Read a wallet's raw KYC record through this instance's provider for
1259
+ * `chainId`. See {@link getKycRecord}.
1260
+ *
1261
+ * @param options - `chainId` and `wallet`.
1262
+ * @returns The wallet's {@link IKycRecord}.
1263
+ * @throws UpshiftValidationError (`INVALID_CHAIN`) when no provider is
1264
+ * configured or no registry is deployed for `chainId`;
1265
+ * (`INVALID_ADDRESS`) for a malformed wallet.
1266
+ * @throws UpshiftSDKError when the `getRecord` read fails.
1267
+ * @worstCaseRpcCalls 1
1268
+ * @example
1269
+ * ```ts
1270
+ * const record = await upshiftSdk.getKycRecord({ chainId: 1, wallet });
1271
+ * ```
1272
+ */
1273
+ async getKycRecord(options) {
1274
+ (0, core_1.assertEvmProviderConfigured)(options.chainId, this.providers, 'getKycRecord');
1275
+ return (0, core_1.getKycRecord)({
1276
+ ...options,
1277
+ rpcUrl: this.providers[options.chainId],
1278
+ });
1279
+ }
1211
1280
  /**
1212
1281
  * @function getStakingPositions gets all available reward staking positions
1213
1282
  * @param wallet optionally passed user wallet address
@@ -1243,7 +1312,7 @@ class UpshiftVaults extends core_1.UpshiftBase {
1243
1312
  throw new Error('Not authorized.');
1244
1313
  if (!vault)
1245
1314
  throw new Error('Pool input parameter is undefined.');
1246
- if (!(0, ethers_1.isAddress)(vault) && !(0, utils_2.isStellarAddress)(vault))
1315
+ if (!(0, ethers_1.isAddress)(vault) && !(0, utils_2.isStellarAddress)(vault) && !(0, chain_address_1.isSuiAddress)(vault))
1247
1316
  throw new Error(`Pool input parameter is not an address: ${String(vault)}`);
1248
1317
  const resolvedChainId = chainId ?? this.activeNetwork?.chainId;
1249
1318
  const rpcUrl = chainId
@@ -1256,6 +1325,7 @@ class UpshiftVaults extends core_1.UpshiftBase {
1256
1325
  chainId: resolvedChainId,
1257
1326
  solanaService: this.solanaService,
1258
1327
  stellarRpc: this._stellarRpc,
1328
+ sui: this._sui,
1259
1329
  env: this.monitoring?.env,
1260
1330
  upshiftKey: this.keys?.upshift,
1261
1331
  subgraphKey: this.keys?.graph,
@@ -1280,6 +1350,7 @@ class UpshiftVaults extends core_1.UpshiftBase {
1280
1350
  rpcUrl: rpcUrl,
1281
1351
  solanaService: this.solanaService,
1282
1352
  stellarRpc: this._stellarRpc,
1353
+ sui: this._sui,
1283
1354
  env: this.monitoring?.env,
1284
1355
  upshiftKey: this.keys?.upshift,
1285
1356
  subgraphKey: this.keys?.graph,
@@ -1328,6 +1399,7 @@ class UpshiftVaults extends core_1.UpshiftBase {
1328
1399
  : rpcUrl || this.requireActiveNetwork().rpcUrl,
1329
1400
  solanaService: this.solanaService,
1330
1401
  stellarRpc: this._stellarRpc,
1402
+ sui: this._sui,
1331
1403
  env: this.monitoring?.env,
1332
1404
  upshiftKey: this.keys?.upshift,
1333
1405
  subgraphKey: this.keys?.graph,
@@ -1602,6 +1674,7 @@ class UpshiftVaults extends core_1.UpshiftBase {
1602
1674
  rpcUrl: chainId ? this.providers?.[chainId] : this.activeNetwork.rpcUrl,
1603
1675
  solanaService: this.solanaService,
1604
1676
  stellarRpc: this._stellarRpc,
1677
+ sui: this._sui,
1605
1678
  env: this.monitoring?.env,
1606
1679
  upshiftKey: this.keys?.upshift,
1607
1680
  subgraphKey: this.keys?.graph,
@@ -1655,6 +1728,7 @@ class UpshiftVaults extends core_1.UpshiftBase {
1655
1728
  rpcUrl,
1656
1729
  solanaService: this.solanaService,
1657
1730
  stellarRpc: this._stellarRpc,
1731
+ sui: this._sui,
1658
1732
  env: this.monitoring?.env,
1659
1733
  upshiftKey: this.keys?.upshift,
1660
1734
  subgraphKey: this.keys?.graph,
@@ -1,5 +1,5 @@
1
1
  import type { Connection } from '@solana/web3.js';
2
- import type { IAddress, IEnv, ISolanaNetwork, IStellarNetwork, IWSMonitorHeaders } from '../../types';
2
+ import type { IAddress, IEnv, ISolanaNetwork, IStellarNetwork, ISuiConfig, IWSMonitorHeaders } from '../../types';
3
3
  /**
4
4
  * Structural interface for the Solana adapter surface used by vault operations.
5
5
  * Avoids importing the concrete SolanaAdapter class to prevent circular dependencies.
@@ -63,6 +63,12 @@ export interface IVaultBaseOptions {
63
63
  rpcUrl: string;
64
64
  network: IStellarNetwork;
65
65
  };
66
+ /**
67
+ * The SDK's `sui` config for Sui vault reads: endpoint override and contract
68
+ * IDs. Applied only to vaults on its `network`; other Sui vaults use the
69
+ * built-in endpoint and contract IDs.
70
+ */
71
+ sui?: ISuiConfig;
66
72
  headers?: IWSMonitorHeaders;
67
73
  /**
68
74
  * Portfolio mode: when true, the per-vault EVM getter does NOT null out a
@@ -209,7 +209,8 @@ async function getYieldLastRealizedOn(provider, vaultAddress) {
209
209
  break;
210
210
  }
211
211
  case 'sol-0':
212
- case 'stellar-0': {
212
+ case 'stellar-0':
213
+ case 'sui-0': {
213
214
  return 0;
214
215
  }
215
216
  default: {
@@ -392,6 +393,7 @@ function buildBackendVault(tokenizedVault, overrides) {
392
393
  isFeatured: tokenizedVault.is_featured || false,
393
394
  isSpotlighted: tokenizedVault.is_spotlighted ?? false,
394
395
  withdrawalOnly: tokenizedVault.withdrawal_only ?? false,
396
+ requiresKyc: tokenizedVault.requires_kyc ?? false,
395
397
  isVisible: tokenizedVault.is_visible || false,
396
398
  reserveTarget: tokenizedVault.reserve_target || 0,
397
399
  reserveTolerance: tokenizedVault.reserve_tolerance || 0,
@@ -527,6 +529,7 @@ async function buildFormattedVault(provider, tokenizedVault, contractCalls) {
527
529
  isFeatured: tokenizedVault.is_featured,
528
530
  withdrawalOnly: tokenizedVault.withdrawal_only ?? false,
529
531
  isSpotlighted: tokenizedVault.is_spotlighted ?? false,
532
+ requiresKyc: tokenizedVault.requires_kyc ?? false,
530
533
  isVisible: tokenizedVault.is_visible,
531
534
  reserveTarget: tokenizedVault.reserve_target,
532
535
  reserveTolerance: tokenizedVault.reserve_tolerance,