@scallop-io/sui-scallop-sdk 3.0.2 → 4.1.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 (283) hide show
  1. package/dist/Logger-Cg2iFdpH.d.ts +8 -0
  2. package/dist/builder.cjs +22 -0
  3. package/dist/builder.d.cts +28 -0
  4. package/dist/builder.d.ts +28 -0
  5. package/dist/builder.js +4 -0
  6. package/dist/chunk-33AK5RWM.js +15 -0
  7. package/dist/chunk-6UQ4NWEU.js +3 -0
  8. package/dist/chunk-DIC6P5HB.js +11 -0
  9. package/dist/chunk-S34VOEZN.js +3 -0
  10. package/dist/chunk-VTGQACWU.js +6 -0
  11. package/dist/client.cjs +21 -0
  12. package/dist/client.d.cts +401 -0
  13. package/dist/client.d.ts +401 -0
  14. package/dist/client.js +5 -0
  15. package/dist/errors.cjs +10 -0
  16. package/dist/errors.d.cts +32 -0
  17. package/dist/errors.d.ts +32 -0
  18. package/dist/errors.js +1 -0
  19. package/dist/index.cjs +51 -34
  20. package/dist/index.d.cts +130 -3145
  21. package/dist/index.d.ts +130 -3145
  22. package/dist/index.js +8 -12
  23. package/dist/logger.cjs +6 -0
  24. package/dist/logger.d.cts +7 -0
  25. package/dist/logger.d.ts +7 -0
  26. package/dist/logger.js +1 -0
  27. package/dist/query-DkitepDi.d.ts +3305 -0
  28. package/dist/query.cjs +19 -0
  29. package/dist/query.d.cts +9 -0
  30. package/dist/query.d.ts +9 -0
  31. package/dist/query.js +3 -0
  32. package/dist/types.cjs +2 -0
  33. package/dist/types.d.cts +90 -0
  34. package/dist/types.d.ts +90 -0
  35. package/dist/types.js +1 -0
  36. package/package.json +98 -56
  37. package/src/constants/api.ts +2 -0
  38. package/src/constants/coinType.ts +2 -0
  39. package/src/constants/common.ts +0 -7
  40. package/src/constants/index.ts +2 -0
  41. package/src/constants/queryKeys.ts +14 -7
  42. package/src/constants/testAddress.ts +1 -0
  43. package/src/datasources/api.ts +34 -0
  44. package/src/datasources/indexer.ts +8 -0
  45. package/src/datasources/onchain.ts +121 -0
  46. package/src/entries/builder.ts +5 -0
  47. package/src/entries/client.ts +3 -0
  48. package/src/entries/errors.ts +2 -0
  49. package/src/entries/index.ts +17 -0
  50. package/src/entries/logger.ts +2 -0
  51. package/src/entries/query.ts +6 -0
  52. package/src/entries/types.ts +2 -0
  53. package/src/errors/ScallopConfigError.ts +8 -0
  54. package/src/errors/ScallopError.ts +30 -0
  55. package/src/errors/ScallopIndexerError.ts +8 -0
  56. package/src/errors/ScallopParseError.ts +8 -0
  57. package/src/errors/ScallopRpcError.ts +8 -0
  58. package/src/errors/ScallopTransactionBuildError.ts +8 -0
  59. package/src/errors/index.ts +6 -0
  60. package/src/logger/Logger.ts +6 -0
  61. package/src/logger/consoleLogger.ts +13 -0
  62. package/src/logger/index.ts +3 -0
  63. package/src/logger/noopLogger.ts +8 -0
  64. package/src/mappers/index.ts +1 -0
  65. package/src/mappers/moveTypeMapper.ts +48 -0
  66. package/src/models/index.ts +8 -10
  67. package/src/models/interface.ts +9 -9
  68. package/src/models/scallop.ts +9 -16
  69. package/src/models/scallopAddress/const.ts +416 -0
  70. package/src/models/scallopAddress/index.ts +188 -0
  71. package/src/models/scallopAddress/types.ts +212 -0
  72. package/src/models/{scallopBuilder.ts → scallopBuilder/index.ts} +65 -29
  73. package/src/models/scallopBuilder/types.ts +37 -0
  74. package/src/models/{scallopClient.ts → scallopClient/index.ts} +157 -598
  75. package/src/models/scallopClient/types.ts +25 -0
  76. package/src/models/scallopConstants/config/AddressConfigSource.ts +13 -0
  77. package/src/models/scallopConstants/config/ConfigValidator.ts +70 -0
  78. package/src/models/scallopConstants/config/PoolAddressConfigSource.ts +12 -0
  79. package/src/models/scallopConstants/config/ScallopConfig.ts +80 -0
  80. package/src/models/scallopConstants/config/ScallopConfigSnapshot.ts +46 -0
  81. package/src/models/scallopConstants/config/WhitelistConfigSource.ts +16 -0
  82. package/src/models/scallopConstants/config/index.ts +6 -0
  83. package/src/models/scallopConstants/const.ts +19 -0
  84. package/src/models/scallopConstants/constantsSource.ts +98 -0
  85. package/src/models/scallopConstants/deriveConstants.ts +150 -0
  86. package/src/models/scallopConstants/index.ts +257 -0
  87. package/src/models/scallopConstants/loadConstantsState.ts +135 -0
  88. package/src/models/scallopConstants/types.ts +77 -0
  89. package/src/models/scallopConstants/utils.ts +69 -0
  90. package/src/models/scallopQuery/index.ts +1279 -0
  91. package/src/models/scallopQuery/types.ts +9 -0
  92. package/src/models/scallopQuery/utils.ts +13 -0
  93. package/src/models/scallopUtils/index.ts +505 -0
  94. package/src/models/scallopUtils/types.ts +30 -0
  95. package/src/models/transactionExecutor.ts +122 -0
  96. package/src/repositories/addressApi/helpers.ts +14 -0
  97. package/src/repositories/addressApi/index.ts +24 -0
  98. package/src/repositories/addressApi/schema.ts +0 -0
  99. package/src/repositories/addressApi/types.ts +177 -0
  100. package/src/repositories/base.ts +38 -0
  101. package/src/repositories/borrowIncentive/bcs.ts +11 -0
  102. package/src/repositories/borrowIncentive/helpers.ts +396 -0
  103. package/src/repositories/borrowIncentive/index.ts +52 -0
  104. package/src/{types/query/borrowIncentive.ts → repositories/borrowIncentive/types.ts} +69 -23
  105. package/src/repositories/borrowIncentive/utils.ts +234 -0
  106. package/src/repositories/cache.ts +4 -0
  107. package/src/repositories/coinBalance/helpers.ts +394 -0
  108. package/src/repositories/coinBalance/index.ts +69 -0
  109. package/src/repositories/coinBalance/types.ts +33 -0
  110. package/src/repositories/flashloan/const.ts +3 -0
  111. package/src/repositories/flashloan/helpers.ts +107 -0
  112. package/src/repositories/flashloan/index.ts +34 -0
  113. package/src/repositories/flashloan/types.ts +16 -0
  114. package/src/repositories/isolatedAssets/bcs.ts +4 -0
  115. package/src/repositories/isolatedAssets/const.ts +2 -0
  116. package/src/repositories/isolatedAssets/helpers.ts +91 -0
  117. package/src/repositories/isolatedAssets/index.ts +42 -0
  118. package/src/repositories/isolatedAssets/types.ts +35 -0
  119. package/src/repositories/loyaltyProgram/bcs.ts +7 -0
  120. package/src/repositories/loyaltyProgram/helpers.ts +117 -0
  121. package/src/repositories/loyaltyProgram/index.ts +28 -0
  122. package/src/repositories/loyaltyProgram/schema.ts +18 -0
  123. package/src/repositories/loyaltyProgram/types.ts +37 -0
  124. package/src/repositories/market/const.ts +6 -0
  125. package/src/repositories/market/helpers.ts +740 -0
  126. package/src/repositories/market/index.ts +137 -0
  127. package/src/repositories/market/mapper.ts +30 -0
  128. package/src/repositories/market/types.ts +443 -0
  129. package/src/repositories/market/utils.ts +285 -0
  130. package/src/repositories/obligation/helpers.ts +228 -0
  131. package/src/repositories/obligation/index.ts +51 -0
  132. package/src/repositories/obligation/types.ts +71 -0
  133. package/src/repositories/obligation/utils.ts +57 -0
  134. package/src/repositories/poolAddresses/const.ts +5 -0
  135. package/src/repositories/poolAddresses/helpers.ts +422 -0
  136. package/src/repositories/poolAddresses/index.ts +56 -0
  137. package/src/repositories/poolAddresses/schema.ts +34 -0
  138. package/src/repositories/poolAddresses/types.ts +69 -0
  139. package/src/repositories/price/const.ts +1 -0
  140. package/src/repositories/price/helpers.ts +237 -0
  141. package/src/repositories/price/index.ts +91 -0
  142. package/src/repositories/price/schema.ts +24 -0
  143. package/src/repositories/price/types.ts +56 -0
  144. package/src/repositories/price/utils.ts +21 -0
  145. package/src/repositories/referral/bcs.ts +3 -0
  146. package/src/repositories/referral/helper.ts +24 -0
  147. package/src/repositories/referral/index.ts +31 -0
  148. package/src/repositories/referral/types.ts +33 -0
  149. package/src/repositories/spool/const.ts +1 -0
  150. package/src/repositories/spool/helpers.ts +471 -0
  151. package/src/repositories/spool/index.ts +135 -0
  152. package/src/{types/query/spool.ts → repositories/spool/types.ts} +67 -2
  153. package/src/repositories/spool/utils.ts +215 -0
  154. package/src/repositories/types.ts +39 -0
  155. package/src/repositories/utils.ts +137 -0
  156. package/src/repositories/veSca/bcs.ts +6 -0
  157. package/src/repositories/veSca/helpers.ts +341 -0
  158. package/src/repositories/veSca/index.ts +57 -0
  159. package/src/repositories/veSca/types.ts +79 -0
  160. package/src/repositories/veScaLoyaltyProgram/bcs.ts +3 -0
  161. package/src/repositories/veScaLoyaltyProgram/helpers.ts +135 -0
  162. package/src/repositories/veScaLoyaltyProgram/index.ts +28 -0
  163. package/src/repositories/veScaLoyaltyProgram/schema.ts +15 -0
  164. package/src/repositories/veScaLoyaltyProgram/types.ts +47 -0
  165. package/src/repositories/wiring/datasources.ts +42 -0
  166. package/src/repositories/wiring/metadata.ts +292 -0
  167. package/src/repositories/wiring/registry.ts +194 -0
  168. package/src/repositories/wiring/source.ts +63 -0
  169. package/src/repositories/xOracle/bcs.ts +7 -0
  170. package/src/repositories/xOracle/const.ts +1 -0
  171. package/src/repositories/xOracle/helpers.ts +304 -0
  172. package/src/repositories/xOracle/index.ts +45 -0
  173. package/src/repositories/xOracle/types.ts +96 -0
  174. package/src/repositories/xOracle/utils.ts +3 -0
  175. package/src/services/client/BorrowService.ts +229 -0
  176. package/src/services/client/CollateralService.ts +76 -0
  177. package/src/services/client/LendingService.ts +75 -0
  178. package/src/services/client/ReferralService.ts +71 -0
  179. package/src/services/client/SpoolService.ts +170 -0
  180. package/src/services/client/VeScaService.ts +142 -0
  181. package/src/services/client/types.ts +44 -0
  182. package/src/services/index.ts +8 -0
  183. package/src/services/query/portfolioCalculations.ts +1171 -0
  184. package/src/txBuilders/borrowIncentive/index.ts +80 -0
  185. package/src/txBuilders/borrowIncentive/moveCalls.ts +124 -0
  186. package/src/txBuilders/borrowIncentive/quick.ts +207 -0
  187. package/src/txBuilders/context.ts +62 -0
  188. package/src/txBuilders/core/index.ts +95 -0
  189. package/src/txBuilders/core/moveCalls.ts +241 -0
  190. package/src/txBuilders/core/quick.ts +306 -0
  191. package/src/{builders → txBuilders}/index.ts +35 -9
  192. package/src/txBuilders/loyaltyProgram/index.ts +78 -0
  193. package/src/txBuilders/loyaltyProgram/moveCalls.ts +44 -0
  194. package/src/txBuilders/loyaltyProgram/quick.ts +58 -0
  195. package/src/txBuilders/manifest.ts +160 -0
  196. package/src/txBuilders/modules.ts +70 -0
  197. package/src/{builders → txBuilders}/oracles/index.ts +3 -2
  198. package/src/{builders → txBuilders}/oracles/pyth.ts +4 -3
  199. package/src/txBuilders/referral/index.ts +72 -0
  200. package/src/txBuilders/referral/moveCalls.ts +93 -0
  201. package/src/txBuilders/referral/quick.ts +57 -0
  202. package/src/txBuilders/sCoin/index.ts +72 -0
  203. package/src/txBuilders/sCoin/moveCalls.ts +36 -0
  204. package/src/txBuilders/sCoin/quick.ts +34 -0
  205. package/src/txBuilders/spool/index.ts +82 -0
  206. package/src/txBuilders/spool/moveCalls.ts +79 -0
  207. package/src/{builders/spoolBuilder.ts → txBuilders/spool/quick.ts} +22 -162
  208. package/src/txBuilders/utils.ts +36 -0
  209. package/src/txBuilders/verify.ts +45 -0
  210. package/src/txBuilders/vesca/index.ts +75 -0
  211. package/src/txBuilders/vesca/moveCalls.ts +147 -0
  212. package/src/{builders/vescaBuilder.ts → txBuilders/vesca/quick.ts} +85 -274
  213. package/src/types/address.ts +4 -178
  214. package/src/types/builder/borrowIncentive.ts +4 -3
  215. package/src/types/builder/core.ts +6 -33
  216. package/src/types/builder/index.ts +5 -1
  217. package/src/types/builder/loyaltyProgram.ts +4 -3
  218. package/src/types/builder/modules.ts +49 -0
  219. package/src/types/builder/referral.ts +5 -4
  220. package/src/types/builder/sCoin.ts +20 -2
  221. package/src/types/builder/spool.ts +22 -2
  222. package/src/types/builder/vesca.ts +4 -12
  223. package/src/types/constant/index.ts +3 -1
  224. package/src/types/constant/queryKeys.ts +15 -8
  225. package/src/types/index.ts +5 -6
  226. package/src/types/internal/dto.ts +46 -0
  227. package/src/types/internal/index.ts +2 -0
  228. package/src/types/internal/move.ts +13 -0
  229. package/src/types/public/index.ts +21 -0
  230. package/src/types/query/core.ts +0 -317
  231. package/src/types/query/index.ts +3 -4
  232. package/src/types/query/portfolio.ts +2 -15
  233. package/src/types/repositories/borrowIncentive.ts +12 -0
  234. package/src/types/repositories/index.ts +9 -0
  235. package/src/types/repositories/loyaltyProgram.ts +2 -0
  236. package/src/types/repositories/market.ts +13 -0
  237. package/src/types/repositories/spool.ts +21 -0
  238. package/src/types/repositories/veSca.ts +5 -0
  239. package/src/types/repositories/veScaLoyaltyProgram.ts +2 -0
  240. package/src/types/sui.ts +0 -1
  241. package/src/utils/array.ts +7 -0
  242. package/src/utils/cache.ts +17 -0
  243. package/src/utils/object.ts +30 -12
  244. package/src/utils/query.ts +9 -190
  245. package/src/utils/vesca.ts +0 -8
  246. package/src/builders/borrowIncentiveBuilder.ts +0 -372
  247. package/src/builders/coreBuilder.ts +0 -636
  248. package/src/builders/loyaltyProgramBuilder.ts +0 -142
  249. package/src/builders/referralBuilder.ts +0 -192
  250. package/src/builders/sCoinBuilder.ts +0 -124
  251. package/src/index.ts +0 -13
  252. package/src/models/scallopAddress.ts +0 -841
  253. package/src/models/scallopAxios.ts +0 -185
  254. package/src/models/scallopConstants.ts +0 -380
  255. package/src/models/scallopIndexer.ts +0 -226
  256. package/src/models/scallopQuery.ts +0 -974
  257. package/src/models/scallopQueryClient.ts +0 -29
  258. package/src/models/scallopSuiKit.ts +0 -480
  259. package/src/models/scallopUtils.ts +0 -734
  260. package/src/queries/borrowIncentiveQuery.ts +0 -361
  261. package/src/queries/borrowLimitQuery.ts +0 -33
  262. package/src/queries/coreQuery.ts +0 -1173
  263. package/src/queries/flashloanFeeQuery.ts +0 -92
  264. package/src/queries/index.ts +0 -15
  265. package/src/queries/isolatedAssetQuery.ts +0 -103
  266. package/src/queries/loyaltyProgramQuery.ts +0 -178
  267. package/src/queries/ownerQuery.ts +0 -32
  268. package/src/queries/poolAddressesQuery.ts +0 -340
  269. package/src/queries/portfolioQuery.ts +0 -1149
  270. package/src/queries/priceQuery.ts +0 -37
  271. package/src/queries/referralQuery.ts +0 -42
  272. package/src/queries/sCoinQuery.ts +0 -195
  273. package/src/queries/spoolQuery.ts +0 -542
  274. package/src/queries/supplyLimitQuery.ts +0 -32
  275. package/src/queries/switchboardQuery.ts +0 -65
  276. package/src/queries/vescaQuery.ts +0 -312
  277. package/src/queries/xOracleQuery.ts +0 -149
  278. package/src/types/constant/common.ts +0 -55
  279. package/src/types/query/loyaltyProgram.ts +0 -12
  280. package/src/types/query/vesca.ts +0 -27
  281. package/src/utils/index.ts +0 -7
  282. package/src/utils/indexer.ts +0 -47
  283. /package/src/{models → datasources}/rateLimiter.ts +0 -0
@@ -0,0 +1,401 @@
1
+ import { S as ScallopBuilder, f as ScallopQuery, g as ScallopUtils, h as ScallopConstants, be as TransactionExecutor, bf as DefaultTxInclude, a as ScallopTxBlock, e as SuiObjectData, b as ScallopBuilderConstructorParams, bg as ScallopClientInterface, bh as OnChainDataSource, aw as ScallopAddress } from './query-DkitepDi.js';
2
+ import * as _scallop_io_sui_kit from '@scallop-io/sui-kit';
3
+ import { SuiObjectArg, SuiTransactionBlockResponse, NetworkType } from '@scallop-io/sui-kit';
4
+ import { Transaction, TransactionObjectArgument, TransactionResult } from '@mysten/sui/transactions';
5
+ import { SuiClientTypes } from '@mysten/sui/client';
6
+ import '@tanstack/query-core';
7
+ import './Logger-Cg2iFdpH.js';
8
+ import 'axios';
9
+ import '@mysten/sui/cryptography';
10
+ import '@pythnetwork/pyth-sui-js';
11
+
12
+ type ClientTxResult<S extends boolean, Include extends DefaultTxInclude = DefaultTxInclude> = S extends true ? SuiClientTypes.TransactionResult<Include> : Transaction;
13
+ /**
14
+ * The exact surface that client-side application services consume. Derived
15
+ * structurally from the concrete model classes so the types stay in sync.
16
+ *
17
+ * `ScallopClient` is structurally assignable to this interface (it already
18
+ * exposes every member via fields/getters), which lets services accept either
19
+ * a `ScallopClient` or a hand-built fake without depending on the concrete
20
+ * class.
21
+ */
22
+ interface ClientServiceContext {
23
+ readonly walletAddress: string;
24
+ readonly builder: Pick<ScallopBuilder, 'createTxBlock'>;
25
+ readonly query: Pick<ScallopQuery, 'getObligations' | 'getObligationAccount' | 'getStakeAccounts' | 'getVeScas'>;
26
+ readonly utils: Pick<ScallopUtils, 'logger' | 'mergeSimilarCoins' | 'parseCoinName' | 'parseCoinType' | 'parseMarketCoinName' | 'parseSCoinType'>;
27
+ readonly constants: Pick<ScallopConstants, 'whitelist'>;
28
+ readonly executor: TransactionExecutor;
29
+ }
30
+
31
+ declare class CollateralService {
32
+ private readonly ctx;
33
+ constructor(ctx: ClientServiceContext);
34
+ depositCollateral<S extends boolean>(collateralCoinName: string, amount: number, sign?: S, obligationId?: string, walletAddress?: string, isSponsoredTx?: boolean): Promise<ClientTxResult<S>>;
35
+ withdrawCollateral<S extends boolean>(collateralCoinName: string, amount: number, sign?: S, obligationId?: string, obligationKey?: string, walletAddress?: string, isSponsoredTx?: boolean): Promise<ClientTxResult<S>>;
36
+ }
37
+
38
+ declare class LendingService {
39
+ private readonly ctx;
40
+ constructor(ctx: ClientServiceContext);
41
+ supply<S extends boolean>(poolCoinName: string, amount: number, sign?: S, walletAddress?: string): Promise<ClientTxResult<S>>;
42
+ withdraw<S extends boolean>(poolCoinName: string, amount: number, sign?: S, walletAddress?: string): Promise<ClientTxResult<S>>;
43
+ flashLoan<S extends boolean>(poolCoinName: string, amount: number, callback: (txBlock: ScallopTxBlock, coin: TransactionObjectArgument | string) => SuiObjectArg | Promise<SuiObjectArg>, sign?: S, walletAddress?: string): Promise<ClientTxResult<S>>;
44
+ }
45
+
46
+ /**
47
+ * Application service for borrow-side lifecycle operations:
48
+ * - obligation creation
49
+ * - borrow / repay
50
+ * - supply + auto-stake convenience
51
+ * - borrow-incentive stake / unstake / claim
52
+ *
53
+ * Each method preserves the public ScallopClient signature one-to-one.
54
+ */
55
+ declare class BorrowService {
56
+ private readonly ctx;
57
+ constructor(ctx: ClientServiceContext);
58
+ openObligation<S extends boolean>(sign?: S): Promise<ClientTxResult<S>>;
59
+ borrow<S extends boolean>(poolCoinName: string, amount: number, sign: S | undefined, obligationId: string, obligationKey: string, walletAddress?: string, isSponsoredTx?: boolean): Promise<ClientTxResult<S>>;
60
+ repay<S extends boolean>(poolCoinName: string, amount: number, sign: S | undefined, obligationId: string, obligationKey: string, walletAddress?: string, isSponsoredTx?: boolean): Promise<ClientTxResult<S>>;
61
+ supplyAndStake<S extends boolean>(stakeCoinName: string, amount: number, sign?: S, stakeAccountId?: string, walletAddress?: string): Promise<ClientTxResult<S>>;
62
+ stakeObligation<S extends boolean>(obligationId: string, obligationKeyId: string, sign?: S, walletAddress?: string): Promise<ClientTxResult<S>>;
63
+ unstakeObligation<S extends boolean>(obligationId: string, obligationKeyId: string, sign?: S, walletAddress?: string): Promise<ClientTxResult<S>>;
64
+ claimBorrowIncentive<S extends boolean>(obligationId: string, obligationKeyId: string, sign?: S, walletAddress?: string): Promise<ClientTxResult<S>>;
65
+ }
66
+
67
+ /**
68
+ * Application service for spool lifecycle:
69
+ * - createStakeAccount
70
+ * - stake / unstake
71
+ * - unstake + auto-withdraw convenience
72
+ * - claim spool rewards
73
+ */
74
+ declare class SpoolService {
75
+ private readonly ctx;
76
+ constructor(ctx: ClientServiceContext);
77
+ createStakeAccount<S extends boolean>(marketCoinName: string, sign?: S, walletAddress?: string): Promise<ClientTxResult<S>>;
78
+ stake<S extends boolean>(stakeMarketCoinName: string, amount: number, sign?: S, stakeAccountId?: string, walletAddress?: string): Promise<ClientTxResult<S>>;
79
+ unstake<S extends boolean>(stakeMarketCoinName: string, amount: number, sign?: S, stakeAccountId?: string, walletAddress?: string): Promise<ClientTxResult<S>>;
80
+ unstakeAndWithdraw<S extends boolean>(stakeMarketCoinName: string, amount: number, sign?: S, stakeAccountId?: string, walletAddress?: string): Promise<ClientTxResult<S>>;
81
+ claim<S extends boolean>(stakeMarketCoinName: string, sign?: S, stakeAccountId?: string, walletAddress?: string): Promise<ClientTxResult<S>>;
82
+ }
83
+
84
+ type VeScaClaimResult<S extends boolean> = S extends true ? SuiTransactionBlockResponse : {
85
+ tx: Transaction;
86
+ scaCoin: TransactionResult;
87
+ };
88
+ type SignedOrTx<S extends boolean> = S extends true ? SuiTransactionBlockResponse : Transaction;
89
+ /**
90
+ * Application service for veSCA operations:
91
+ * - lock / extend / claim helpers (thin wrappers over the tx-block quick
92
+ * methods, so callers can stay on the service object instead of touching
93
+ * `tx` directly).
94
+ * - claim-all-unlocked-SCA aggregation across every veSCA owned by the
95
+ * wallet (parity with the legacy ScallopClient method).
96
+ */
97
+ declare class VeScaService {
98
+ private readonly ctx;
99
+ constructor(ctx: ClientServiceContext);
100
+ lockSca<S extends boolean>(params: {
101
+ amountOrCoin?: SuiObjectArg | number;
102
+ lockPeriodInDays?: number;
103
+ autoCheck?: boolean;
104
+ veScaKey?: SuiObjectData | string;
105
+ }, sign?: S, walletAddress?: string): Promise<SignedOrTx<S>>;
106
+ extendLockPeriod<S extends boolean>(params: {
107
+ lockPeriodInDays: number;
108
+ autoCheck?: boolean;
109
+ veScaKey?: SuiObjectData | string;
110
+ }, sign?: S, walletAddress?: string): Promise<SignedOrTx<S>>;
111
+ extendLockAmount<S extends boolean>(params: {
112
+ scaAmount: number;
113
+ autoCheck?: boolean;
114
+ veScaKey?: SuiObjectData | string;
115
+ }, sign?: S, walletAddress?: string): Promise<SignedOrTx<S>>;
116
+ claimAllUnlockedSca<S extends boolean>(sign?: S, walletAddress?: string): Promise<VeScaClaimResult<S>>;
117
+ }
118
+
119
+ /**
120
+ * Application service for referral lifecycle:
121
+ * - bindToReferral
122
+ * - claimReferralRevenue
123
+ * - burnReferralTicket
124
+ *
125
+ * Thin wrappers around the tx-block referral methods so callers can stay on
126
+ * the service object instead of touching `tx` directly.
127
+ */
128
+ declare class ReferralService {
129
+ private readonly ctx;
130
+ constructor(ctx: ClientServiceContext);
131
+ bindToReferral<S extends boolean>(veScaKeyId: string, sign?: S, walletAddress?: string): Promise<ClientTxResult<S>>;
132
+ claimReferralRevenue<S extends boolean>(veScaKey: SuiObjectArg, coinNames?: string[], sign?: S, walletAddress?: string): Promise<ClientTxResult<S>>;
133
+ burnReferralTicket<S extends boolean>(ticket: SuiObjectArg, poolCoinName: string, sign?: S, walletAddress?: string): Promise<ClientTxResult<S>>;
134
+ }
135
+
136
+ type ScallopClientConstructorParams = {
137
+ networkType?: SuiClientTypes.Network;
138
+ builder?: ScallopBuilder;
139
+ } & ScallopBuilderConstructorParams;
140
+ type ScallopClientFnReturnType<T extends boolean, Include extends DefaultTxInclude = DefaultTxInclude> = T extends true ? SuiClientTypes.TransactionResult<Include> : Transaction;
141
+ type ScallopClientVeScaReturnType<T extends boolean, Include extends DefaultTxInclude = DefaultTxInclude> = T extends true ? SuiClientTypes.TransactionResult<Include> : {
142
+ tx: Transaction;
143
+ scaCoin: TransactionResult;
144
+ };
145
+
146
+ /**
147
+ * @description
148
+ * It provides contract interaction operations for general users.
149
+ *
150
+ * @example
151
+ * ```typescript
152
+ * const scallopClient = new ScallopClient(<parameters>);
153
+ * await scallopClient.init();
154
+ * scallopClient.<client functions>();
155
+ * await scallopClient.<client async functions>();
156
+ * ```
157
+ */
158
+ declare class ScallopClient implements ScallopClientInterface {
159
+ readonly builder: ScallopBuilder;
160
+ readonly collateralService: CollateralService;
161
+ readonly lendingService: LendingService;
162
+ readonly borrowService: BorrowService;
163
+ readonly spoolService: SpoolService;
164
+ readonly veScaService: VeScaService;
165
+ readonly referralService: ReferralService;
166
+ networkType: NetworkType;
167
+ constructor({ builder, networkType, ...scallopBuilderArgs }: ScallopClientConstructorParams);
168
+ get query(): ScallopQuery;
169
+ get utils(): ScallopUtils;
170
+ get constants(): ScallopConstants;
171
+ get walletAddress(): string;
172
+ get suiKit(): _scallop_io_sui_kit.SuiKit;
173
+ get onchain(): OnChainDataSource;
174
+ get executor(): TransactionExecutor;
175
+ get address(): ScallopAddress;
176
+ /**
177
+ * Request the scallop API to initialize data.
178
+ *
179
+ * @param force - Whether to force initialization.
180
+ */
181
+ init(force?: boolean): Promise<void>;
182
+ /**
183
+ * Open obligation.
184
+ *
185
+ * @param sign - Decide to directly sign the transaction or return the transaction block.
186
+ * @return Transaction block response or transaction block.
187
+ */
188
+ openObligation(): Promise<SuiTransactionBlockResponse>;
189
+ openObligation<S extends boolean>(sign?: S): Promise<ScallopClientFnReturnType<S>>;
190
+ /**
191
+ * Deposit collateral into the specific pool.
192
+ *
193
+ * @param collateralCoinName - Types of collateral coin.
194
+ * @param amount - The amount of coins would deposit.
195
+ * @param sign - Decide to directly sign the transaction or return the transaction block.
196
+ * @param obligationId - The obligation object.
197
+ * @param walletAddress - The wallet address of the owner.
198
+ * @param isSponsoredTx - Whether the transaction is sponsored.
199
+ * @return Transaction block response or transaction block.
200
+ */
201
+ depositCollateral(collateralCoinName: string, amount: number): Promise<SuiTransactionBlockResponse>;
202
+ depositCollateral<S extends boolean>(collateralCoinName: string, amount: number, sign?: S, obligationId?: string, walletAddress?: string, isSponsoredTx?: boolean): Promise<ScallopClientFnReturnType<S>>;
203
+ /**
204
+ * Withdraw collateral from the specific pool.
205
+ *
206
+ * @param collateralCoinName - Types of collateral coin.
207
+ * @param amount - The amount of coins would deposit.
208
+ * @param sign - Decide to directly sign the transaction or return the transaction block.
209
+ * @param obligationId - The obligation object.
210
+ * @param obligationKey - The obligation key object to verifying obligation authority.
211
+ * @param walletAddress - The wallet address of the owner.
212
+ * @param isSponsoredTx - Whether the transaction is sponsored.
213
+ * @return Transaction block response or transaction block.
214
+ */
215
+ withdrawCollateral(collateralCoinName: string, amount: number): Promise<SuiTransactionBlockResponse>;
216
+ withdrawCollateral<S extends boolean>(collateralCoinName: string, amount: number, sign?: S, obligationId?: string, obligationKey?: string, walletAddress?: string, isSponsoredTx?: boolean): Promise<ScallopClientFnReturnType<S>>;
217
+ /**
218
+ * Supply asset into the specific lending pool.
219
+ *
220
+ * @param poolCoinName - Types of pool coin.
221
+ * @param amount - The amount of coins would deposit.
222
+ * @param sign - Decide to directly sign the transaction or return the transaction block.
223
+ * @param walletAddress - The wallet address of the owner.
224
+ * @return Transaction block response or transaction block.
225
+ */
226
+ supply(poolCoinName: string, amount: number): Promise<SuiTransactionBlockResponse>;
227
+ supply<S extends boolean>(poolCoinName: string, amount: number, sign?: S, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
228
+ /**
229
+ * Supply asset into the specific lending pool and stake market coin into the corresponding staking pool (spool).
230
+ *
231
+ * @param stakeCoinName - Types of stake coin.
232
+ * @param amount - The amount of coins would supply.
233
+ * @param sign - Decide to directly sign the transaction or return the transaction block.
234
+ * @param stakeAccountId - The stake account object.
235
+ * @param walletAddress - The wallet address of the owner.
236
+ * @return Transaction block response or transaction block.
237
+ */
238
+ supplyAndStake(stakeCoinName: string, amount: number): Promise<SuiTransactionBlockResponse>;
239
+ supplyAndStake<S extends boolean>(stakeCoinName: string, amount: number, sign?: S, stakeAccountId?: string, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
240
+ /**
241
+ * Withdraw asset from the specific lending pool, must return market coin.
242
+ *
243
+ * @param poolCoinName - Specific support pool coin name.
244
+ * @param amount - The amount of coins would withdraw.
245
+ * @param sign - Decide to directly sign the transaction or return the transaction block.
246
+ * @param walletAddress - The wallet address of the owner.
247
+ * @return Transaction block response or transaction block.
248
+ */
249
+ withdraw(poolCoinName: string, amount: number): Promise<SuiTransactionBlockResponse>;
250
+ withdraw<S extends boolean>(poolCoinName: string, amount: number, sign?: S, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
251
+ /**
252
+ * Borrow asset from the specific pool.
253
+ *
254
+ * @param poolCoinName - Specific support pool coin name.
255
+ * @param amount - The amount of coins would borrow.
256
+ * @param sign - Decide to directly sign the transaction or return the transaction block.
257
+ * @param obligationId - The obligation object.
258
+ * @param obligationKey - The obligation key object to verifying obligation authority.
259
+ * @param walletAddress - The wallet address of the owner.
260
+ * @param isSponsoredTx - Whether the transaction is sponsored.
261
+ * @return Transaction block response or transaction block.
262
+ */
263
+ borrow<S extends boolean>(poolCoinName: string, amount: number, sign: S | undefined, obligationId: string, obligationKey: string, walletAddress?: string, isSponsoredTx?: boolean): Promise<ScallopClientFnReturnType<S>>;
264
+ /**
265
+ * Repay asset into the specific pool.
266
+ *
267
+ * @param poolCoinName - Specific support pool coin name.
268
+ * @param amount - The amount of coins would repay.
269
+ * @param sign - Decide to directly sign the transaction or return the transaction block.
270
+ * @param obligationId - The obligation object.
271
+ * @param walletAddress - The wallet address of the owner.
272
+ * @param isSponsoredTx - Whether the transaction is sponsored.
273
+ * @return Transaction block response or transaction block.
274
+ */
275
+ repay<S extends boolean>(poolCoinName: string, amount: number, sign: S | undefined, obligationId: string, obligationKey: string, walletAddress?: string, isSponsoredTx?: boolean): Promise<ScallopClientFnReturnType<S>>;
276
+ /**
277
+ * FlashLoan asset from the specific pool.
278
+ *
279
+ * @param poolCoinName - Specific support pool coin name..
280
+ * @param amount - The amount of coins would repay.
281
+ * @param callback - The callback function to build transaction block and return coin argument.
282
+ * @param sign - Decide to directly sign the transaction or return the transaction block.
283
+ * @return Transaction block response or transaction block.
284
+ */
285
+ flashLoan(poolCoinName: string, amount: number, callback: (txBlock: ScallopTxBlock, coin: TransactionObjectArgument | string) => SuiObjectArg): Promise<SuiTransactionBlockResponse>;
286
+ flashLoan<S extends boolean>(poolCoinName: string, amount: number, callback: (txBlock: ScallopTxBlock, coin: TransactionObjectArgument | string) => SuiObjectArg, sign?: S, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
287
+ /**
288
+ * Create stake account.
289
+ *
290
+ * @param sign - Decide to directly sign the transaction or return the transaction block.
291
+ * @param walletAddress - The wallet address of the owner.
292
+ * @return Transaction block response or transaction block.
293
+ */
294
+ createStakeAccount(marketCoinName: string): Promise<SuiTransactionBlockResponse>;
295
+ createStakeAccount<S extends boolean>(marketCoinName: string, sign?: S, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
296
+ /**
297
+ * Stake market coin into the specific spool.
298
+ *
299
+ * @param marketCoinName - Types of market coin.
300
+ * @param amount - The amount of coins would deposit.
301
+ * @param sign - Decide to directly sign the transaction or return the transaction block.
302
+ * @param stakeAccountId - The stake account object.
303
+ * @param walletAddress - The wallet address of the owner.
304
+ * @return Transaction block response or transaction block.
305
+ */
306
+ stake(stakeMarketCoinName: string, amount: number): Promise<SuiTransactionBlockResponse>;
307
+ stake<S extends boolean>(stakeMarketCoinName: string, amount: number, sign?: S, stakeAccountId?: string, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
308
+ /**
309
+ * Unstake market coin from the specific spool.
310
+ *
311
+ * @param stakeMarketCoinName - Types of mak coin.
312
+ * @param amount - The amount of coins would deposit.
313
+ * @param sign - Decide to directly sign the transaction or return the transaction block.
314
+ * @param accountId - The stake account object.
315
+ * @param walletAddress - The wallet address of the owner.
316
+ * @return Transaction block response or transaction block.
317
+ */
318
+ unstake(stakeMarketCoinName: string, amount: number): Promise<SuiTransactionBlockResponse>;
319
+ unstake<S extends boolean>(stakeMarketCoinName: string, amount: number, sign?: S, stakeAccountId?: string, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
320
+ /**
321
+ * Unstake market coin from the specific spool and withdraw asset from the corresponding pool.
322
+ *
323
+ * @param marketCoinName - Types of mak coin.
324
+ * @param amount - The amount of coins would deposit.
325
+ * @param sign - Decide to directly sign the transaction or return the transaction block.
326
+ * @param accountId - The stake account object.
327
+ * @param walletAddress - The wallet address of the owner.
328
+ * @return Transaction block response or transaction block.
329
+ */
330
+ unstakeAndWithdraw(stakeMarketCoinName: string, amount: number): Promise<SuiTransactionBlockResponse>;
331
+ unstakeAndWithdraw<S extends boolean>(stakeMarketCoinName: string, amount: number, sign?: S, stakeAccountId?: string, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
332
+ /**
333
+ * Claim reward coin from the specific spool.
334
+ *
335
+ * @param stakeMarketCoinName - Types of mak coin.
336
+ * @param amount - The amount of coins would deposit.
337
+ * @param sign - Decide to directly sign the transaction or return the transaction block.
338
+ * @param accountId - The stake account object.
339
+ * @param walletAddress - The wallet address of the owner.
340
+ * @return Transaction block response or transaction block.
341
+ */
342
+ claim(stakeMarketCoinName: string): Promise<SuiTransactionBlockResponse>;
343
+ claim<S extends boolean>(stakeMarketCoinName: string, sign?: S, stakeAccountId?: string, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
344
+ /**
345
+ * stake obligaion.
346
+ *
347
+ * @param obligationId - The obligation account object.
348
+ * @param obligationKeyId - The obligation key account object.
349
+ * @param sign - Decide to directly sign the transaction or return the transaction block.
350
+ * @param walletAddress - The wallet address of the owner.
351
+ * @return Transaction block response or transaction block
352
+ */
353
+ stakeObligation<S extends boolean>(obligationId: string, obligationKeyId: string, sign?: S, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
354
+ /**
355
+ * unstake obligaion.
356
+ *
357
+ * @param obligationId - The obligation account object.
358
+ * @param obligationKeyId - The obligation key account object.
359
+ * @param sign - Decide to directly sign the transaction or return the transaction block.
360
+ * @param walletAddress - The wallet address of the owner.
361
+ * @return Transaction block response or transaction block
362
+ */
363
+ unstakeObligation<S extends boolean>(obligationId: string, obligationKeyId: string, sign?: S, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
364
+ /**
365
+ * Claim borrow incentive reward.
366
+ *
367
+ * @param poolName
368
+ * @param amount - The amount of coins would deposit.
369
+ * @param sign - Decide to directly sign the transaction or return the transaction block.
370
+ * @param accountId - The stake account object.
371
+ * @param walletAddress - The wallet address of the owner.
372
+ * @return Transaction block response or transaction block
373
+ */
374
+ claimBorrowIncentive<S extends boolean>(obligationId: string, obligationKeyId: string, sign?: S, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
375
+ /**
376
+ * Function to migrate all market coin in user wallet into sCoin
377
+ * @returns Transaction response
378
+ */
379
+ migrateAllMarketCoin<S extends boolean>(includeStakePool?: boolean, sign?: S, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
380
+ /**
381
+ * Claim unlocked SCA from all veSCA accounts.
382
+ */
383
+ claimAllUnlockedSca(): Promise<SuiTransactionBlockResponse>;
384
+ claimAllUnlockedSca<S extends boolean>(sign?: S, walletAddress?: string): Promise<ScallopClientVeScaReturnType<S>>;
385
+ /**
386
+ * Mint and get test coin.
387
+ *
388
+ * @remarks
389
+ * Only be used on the test network.
390
+ *
391
+ * @param assetCoinName - Specific asset coin name.
392
+ * @param amount - The amount of coins minted and received.
393
+ * @param receiveAddress - The wallet address that receives the coins.
394
+ * @param sign - Decide to directly sign the transaction or return the transaction block.
395
+ * @return Transaction block response or transaction block.
396
+ */
397
+ mintTestCoin(assetCoinName: Exclude<string, 'sui'>, amount: number): Promise<SuiTransactionBlockResponse>;
398
+ mintTestCoin<S extends boolean>(assetCoinName: Exclude<string, 'sui'>, amount: number, sign?: S, receiveAddress?: string): Promise<ScallopClientFnReturnType<S>>;
399
+ }
400
+
401
+ export { ScallopClient, type ScallopClientConstructorParams };