@liquidium/client 0.4.0 → 0.4.1
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.
- package/README.md +12 -3
- package/dist/index.cjs +64 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -74
- package/dist/index.d.ts +22 -74
- package/dist/index.js +63 -59
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -106,16 +106,13 @@ interface CanisterContext {
|
|
|
106
106
|
|
|
107
107
|
/** Asset transfer path used for wallet-executed actions. */
|
|
108
108
|
declare const TransferMode: {
|
|
109
|
-
readonly ck: "ck";
|
|
110
109
|
readonly native: "native";
|
|
111
110
|
};
|
|
112
111
|
/** Asset transfer path used for wallet-executed actions. */
|
|
113
112
|
type TransferMode = (typeof TransferMode)[keyof typeof TransferMode];
|
|
114
113
|
/** Wallet capability required to execute a prepared SDK action. */
|
|
115
114
|
declare const WalletExecutionKind: {
|
|
116
|
-
readonly sendEthTransaction: "send-eth-transaction";
|
|
117
115
|
readonly signMessage: "sign-message";
|
|
118
|
-
readonly signPsbt: "sign-psbt";
|
|
119
116
|
};
|
|
120
117
|
/** Wallet capability required to execute a prepared SDK action. */
|
|
121
118
|
type WalletExecutionKind = (typeof WalletExecutionKind)[keyof typeof WalletExecutionKind];
|
|
@@ -151,19 +148,6 @@ interface SignMessageRequest {
|
|
|
151
148
|
/** Transfer path associated with the action. */
|
|
152
149
|
transferMode: TransferMode;
|
|
153
150
|
}
|
|
154
|
-
/** PSBT-signing request passed to BTC wallet adapters. */
|
|
155
|
-
interface SignPsbtRequest {
|
|
156
|
-
/** BTC chain discriminator. */
|
|
157
|
-
chain: Extract<Chain, "BTC">;
|
|
158
|
-
/** Base64-encoded unsigned PSBT. */
|
|
159
|
-
psbtBase64: string;
|
|
160
|
-
/** Optional BTC account override. */
|
|
161
|
-
account?: string;
|
|
162
|
-
/** SDK action type that produced this request. */
|
|
163
|
-
actionType: string;
|
|
164
|
-
/** Transfer path associated with the action. */
|
|
165
|
-
transferMode: TransferMode;
|
|
166
|
-
}
|
|
167
151
|
/** ETH transaction-sending request passed to wallet adapters. */
|
|
168
152
|
interface SendEthTransactionRequest {
|
|
169
153
|
/** ETH chain discriminator. */
|
|
@@ -198,13 +182,10 @@ interface SendBtcTransactionRequest {
|
|
|
198
182
|
* - `signMessage` - account creation, borrow, withdraw
|
|
199
183
|
* - `sendBtcTransaction` / `sendEthTransaction` - automated transfer-path supply
|
|
200
184
|
* - `sendEthTransaction` - contract-interaction supply and ETH native sends
|
|
201
|
-
* - `signPsbt` - reserved; no current SDK flow emits PSBT-signing actions
|
|
202
185
|
*/
|
|
203
186
|
interface WalletAdapter {
|
|
204
187
|
/** Signs an SDK plaintext message and returns the wallet signature. BTC adapters may return base64 BIP-322 or hex-encoded signature bytes. */
|
|
205
188
|
signMessage?: (request: SignMessageRequest) => Promise<string>;
|
|
206
|
-
/** Reserved for future PSBT-signing flows; no current SDK method calls this. */
|
|
207
|
-
signPsbt?: (request: SignPsbtRequest) => Promise<string>;
|
|
208
189
|
/** Sends an EVM transaction and returns its transaction hash. */
|
|
209
190
|
sendEthTransaction?: (request: SendEthTransactionRequest) => Promise<string>;
|
|
210
191
|
/** Sends a BTC transaction and returns its transaction id. */
|
|
@@ -219,16 +200,6 @@ interface SignatureInfo {
|
|
|
219
200
|
/** Account that produced the signature, when different from the action default. */
|
|
220
201
|
account?: string;
|
|
221
202
|
}
|
|
222
|
-
/** Request submitted after a BTC PSBT has been signed. */
|
|
223
|
-
interface SignPsbtSubmitRequest {
|
|
224
|
-
/** Base64-encoded signed PSBT. */
|
|
225
|
-
signedPsbtBase64: string;
|
|
226
|
-
}
|
|
227
|
-
/** Request submitted after an ETH transaction has been sent. */
|
|
228
|
-
interface SendEthTransactionSubmitRequest {
|
|
229
|
-
/** EVM transaction hash returned by the wallet. */
|
|
230
|
-
txHash: string;
|
|
231
|
-
}
|
|
232
203
|
/** Prepared action that requires message signing before submit. */
|
|
233
204
|
interface SignMessageWalletAction<TData, TResult> {
|
|
234
205
|
/** Protocol action kind. */
|
|
@@ -248,42 +219,8 @@ interface SignMessageWalletAction<TData, TResult> {
|
|
|
248
219
|
/** Submits the signature and resolves the protocol result. */
|
|
249
220
|
submit(signatureInfo: SignatureInfo): Promise<TResult>;
|
|
250
221
|
}
|
|
251
|
-
/** Reserved prepared action for future BTC PSBT-signing flows. */
|
|
252
|
-
interface SignPsbtWalletAction<TResult> {
|
|
253
|
-
/** Protocol action kind. */
|
|
254
|
-
kind: WalletActionKind;
|
|
255
|
-
/** Wallet capability required to execute the action. */
|
|
256
|
-
executionKind: typeof WalletExecutionKind.signPsbt;
|
|
257
|
-
/** Adapter-facing action type. */
|
|
258
|
-
actionType: string;
|
|
259
|
-
/** Transfer path associated with the action. */
|
|
260
|
-
transferMode: TransferMode;
|
|
261
|
-
/** Optional default account to pass to the wallet adapter. */
|
|
262
|
-
account?: string;
|
|
263
|
-
/** Base64-encoded unsigned PSBT. */
|
|
264
|
-
psbtBase64: string;
|
|
265
|
-
/** Submits the signed PSBT and resolves the protocol result. */
|
|
266
|
-
submit(request: SignPsbtSubmitRequest): Promise<TResult>;
|
|
267
|
-
}
|
|
268
|
-
/** Prepared action that requires sending an ETH transaction before submit. */
|
|
269
|
-
interface SendEthTransactionWalletAction<TResult> {
|
|
270
|
-
/** Protocol action kind. */
|
|
271
|
-
kind: WalletActionKind;
|
|
272
|
-
/** Wallet capability required to execute the action. */
|
|
273
|
-
executionKind: typeof WalletExecutionKind.sendEthTransaction;
|
|
274
|
-
/** Adapter-facing action type. */
|
|
275
|
-
actionType: string;
|
|
276
|
-
/** Transfer path associated with the action. */
|
|
277
|
-
transferMode: TransferMode;
|
|
278
|
-
/** Optional default account to pass to the wallet adapter. */
|
|
279
|
-
account?: string;
|
|
280
|
-
/** EVM transaction request to send. */
|
|
281
|
-
transaction: EthTransactionRequest;
|
|
282
|
-
/** Submits the transaction hash and resolves the protocol result. */
|
|
283
|
-
submit(request: SendEthTransactionSubmitRequest): Promise<TResult>;
|
|
284
|
-
}
|
|
285
222
|
/** Any prepared action returned by SDK methods and executable by {@link executeWith}. */
|
|
286
|
-
type WalletAction<TResult> = SignMessageWalletAction<unknown, TResult
|
|
223
|
+
type WalletAction<TResult> = SignMessageWalletAction<unknown, TResult>;
|
|
287
224
|
|
|
288
225
|
/** Options for preparing a profile-creation action. */
|
|
289
226
|
interface PrepareCreateProfileOptions {
|
|
@@ -756,15 +693,16 @@ interface BorrowAction extends SignMessageWalletAction<CreateBorrowData, BorrowO
|
|
|
756
693
|
/** Adapter-facing action type. */
|
|
757
694
|
actionType: typeof WalletActionKind.createBorrow;
|
|
758
695
|
}
|
|
759
|
-
/**
|
|
760
|
-
* Fields to build a withdraw request. `amount` is in the pool asset's base units.
|
|
761
|
-
*/
|
|
696
|
+
/** Fields to build a withdraw request. `amount` is in the pool asset's base units. */
|
|
762
697
|
interface CreateWithdrawRequest {
|
|
763
698
|
/** Liquidium profile principal text. */
|
|
764
699
|
profileId: string;
|
|
765
700
|
/** Pool principal text to withdraw from. */
|
|
766
701
|
poolId: string;
|
|
767
|
-
/**
|
|
702
|
+
/**
|
|
703
|
+
* Amount to withdraw in the pool asset's base units. BTC withdrawals require
|
|
704
|
+
* at least 5,000 sats. USDC and USDT withdrawals require at least 1 token.
|
|
705
|
+
*/
|
|
768
706
|
amount: bigint;
|
|
769
707
|
/** External-chain address that receives the withdrawn asset. Must match the pool chain. */
|
|
770
708
|
receiverAddress: string;
|
|
@@ -1104,7 +1042,6 @@ declare class LendingModule {
|
|
|
1104
1042
|
private requireApi;
|
|
1105
1043
|
private createSupplyFlowExecutor;
|
|
1106
1044
|
private getPoolById;
|
|
1107
|
-
private normalizeOutflowReceiverAddress;
|
|
1108
1045
|
}
|
|
1109
1046
|
|
|
1110
1047
|
/** Current protocol metadata and rate state for a lending pool. */
|
|
@@ -1188,8 +1125,7 @@ interface PoolRate {
|
|
|
1188
1125
|
/** Pool metadata, prices, and current rate helpers. */
|
|
1189
1126
|
declare class MarketModule {
|
|
1190
1127
|
private readonly canisterContext;
|
|
1191
|
-
|
|
1192
|
-
constructor(canisterContext: CanisterContext, apiClient: ApiClient | undefined);
|
|
1128
|
+
constructor(canisterContext: CanisterContext);
|
|
1193
1129
|
/**
|
|
1194
1130
|
* Lists SDK-supported pools with their current rates.
|
|
1195
1131
|
*
|
|
@@ -2204,6 +2140,20 @@ declare const RATE_SCALE = 1000000000000000000000000000n;
|
|
|
2204
2140
|
/** Number of decimal places represented by {@link RATE_SCALE}. */
|
|
2205
2141
|
declare const RATE_DECIMALS: bigint;
|
|
2206
2142
|
|
|
2143
|
+
/** Minimum withdraw amounts in each asset's base units. */
|
|
2144
|
+
declare const MIN_WITHDRAW_AMOUNTS_BY_ASSET: {
|
|
2145
|
+
readonly BTC: 5000n;
|
|
2146
|
+
readonly USDC: 1000000n;
|
|
2147
|
+
readonly USDT: 1000000n;
|
|
2148
|
+
};
|
|
2149
|
+
type MinimumWithdrawAsset = keyof typeof MIN_WITHDRAW_AMOUNTS_BY_ASSET;
|
|
2150
|
+
/**
|
|
2151
|
+
* Returns the minimum withdraw amount for an asset in base units.
|
|
2152
|
+
*
|
|
2153
|
+
* Assets without a configured product minimum return `0n`.
|
|
2154
|
+
*/
|
|
2155
|
+
declare function getMinimumWithdrawAmount(asset: string): bigint;
|
|
2156
|
+
|
|
2207
2157
|
/**
|
|
2208
2158
|
* Wallet wiring for {@link executeWith}.
|
|
2209
2159
|
*
|
|
@@ -2222,12 +2172,10 @@ interface ExecuteWithOptions {
|
|
|
2222
2172
|
* Returns an async function that runs a {@link WalletAction} end-to-end.
|
|
2223
2173
|
*
|
|
2224
2174
|
* - `sign-message`: needs `walletAdapter.signMessage` and `options.chain`.
|
|
2225
|
-
* - `sign-psbt`: reserved; no current SDK flow emits this action.
|
|
2226
|
-
* - `send-eth-transaction`: needs `walletAdapter.sendEthTransaction`.
|
|
2227
2175
|
*
|
|
2228
2176
|
* @param options - Adapter and optional chain/account overrides.
|
|
2229
2177
|
* @returns A function that accepts a `WalletAction` and resolves with its submit result.
|
|
2230
2178
|
*/
|
|
2231
2179
|
declare function executeWith(options: ExecuteWithOptions): <TResult>(action: WalletAction<TResult>) => Promise<TResult>;
|
|
2232
2180
|
|
|
2233
|
-
export { type AccountIdentifierAccount, type AccountIdentifierOutflowReceiver, AccountsModule, ActivitiesModule, type Activity, ActivityFilter, type ActivityStatusFoundResponse, type ActivityStatusNotFoundResponse, type ActivityTopUp, Asset, type AssetPrices, type BaseGetActivityStatusRequest, type BaseListActivitiesRequest, type BorrowAction, type BorrowOutflowDetails, type BorrowSubmitSignatureInfo, type BorrowingPower, CK_ETH_DEPOSIT_CONTRACT_ADDRESS, type CalculateLtvRequest, type CanisterIds, Chain, type ContractInteractionSupplyFlowRequest, type CreateAccountAction, type CreateAccountData, type CreateAccountRequest, type CreateBorrowData, type CreateBorrowRequest, type CreateInstantLoanRequest, type CreateProfileParams, type CreateTransferErc20TransactionParams, type CreateWithdrawData, type CreateWithdrawRequest, Environment, type EstimateInflowFeeRequest, type EthTransactionRequest, type EvmContractTransaction, type EvmReadClient, EvmSupplyApprovalStrategy, type EvmSupplyContext, type ExecuteWithOptions, type ExternalAccount, type ExternalOutflowReceiver, type FindPoolQuery, type FullWithdrawAmount, type GetActivityStatusByProfileRequest, type GetActivityStatusByShortRefRequest, type GetActivityStatusRequest, type GetActivityStatusResponse, type GetDepositAddressRequest, type GetEvmSupplyContextRequest, type HealthFactor, HistoryModule, type IcrcAccount, type IcrcAccountSupplyTarget, type IcrcOutflowReceiver, type InflowActivity, type InflowActivityOperation, type InflowActivityStatus, type InflowFeeEstimate, type InflowOperation, type InstantLoan, type InstantLoanAccount, type InstantLoanAsset, type InstantLoanAuthorization, type InstantLoanBorrow, type InstantLoanBorrowRequestedEventType, type InstantLoanCollateral, type InstantLoanConfig, type InstantLoanCreatedEventType, type InstantLoanDepositTimerExceededEventType, type InstantLoanDepositTimerStartedEventType, type InstantLoanEvent, type InstantLoanEventType, type InstantLoanFindBorrow, type InstantLoanFindCollateral, type InstantLoanFindResult, type InstantLoanFullLendWithdrawalRequestedEventType, type InstantLoanGetByIdRequest, type InstantLoanGetByRefRequest, type InstantLoanGetRequest, type InstantLoanInitialDeposit, type InstantLoanLeg, type InstantLoanListEventsRequest, type InstantLoanPositionSummary, type InstantLoanProfileWarmedEventType, type InstantLoanRepayCompleteEventType, type InstantLoanRepayment, type InstantLoanStuckFundsWithdrawalRequestedEventType, type InstantLoanTerms, type InstantLoanWarmedProfile, InstantLoansModule, LendingModule, LiquidiumClient, type LiquidiumClientConfig, LiquidiumError, LiquidiumErrorCode, type LiquidiumErrorContext, type LiquidiumOperation, type LiquidiumState, type LiquidiumStatus, type ListActivitiesByProfileRequest, type ListActivitiesByShortRefRequest, type ListActivitiesRequest, type LtvCalculation, MIN_BORROW_AMOUNTS_BY_ASSET, type ManualTransferSupplyFlowRequest, type MarketAsset, type MarketChain, MarketModule, type MaxRepayAmount, type MinimumBorrowAsset, type NativeAccount, type NativeAddressSupplyTarget, type NativeOutflowReceiver, type OutflowActivity, type OutflowActivityOperation, type OutflowActivityStatus, type OutflowDetails, type OutflowReceiver, OutflowType, type PaginatedResponse, type Pool, type PoolRate, type Position, PositionsModule, type PrepareCreateProfileOptions, QuoteModule, type QuoteRequest, type QuoteResult, type QuoteValidationError, QuoteValidationErrorCode, type QuoteWarning, QuoteWarningCode, RATE_DECIMALS, RATE_SCALE, type SendBtcTransactionRequest, type SendEthTransactionRequest, type
|
|
2181
|
+
export { type AccountIdentifierAccount, type AccountIdentifierOutflowReceiver, AccountsModule, ActivitiesModule, type Activity, ActivityFilter, type ActivityStatusFoundResponse, type ActivityStatusNotFoundResponse, type ActivityTopUp, Asset, type AssetPrices, type BaseGetActivityStatusRequest, type BaseListActivitiesRequest, type BorrowAction, type BorrowOutflowDetails, type BorrowSubmitSignatureInfo, type BorrowingPower, CK_ETH_DEPOSIT_CONTRACT_ADDRESS, type CalculateLtvRequest, type CanisterIds, Chain, type ContractInteractionSupplyFlowRequest, type CreateAccountAction, type CreateAccountData, type CreateAccountRequest, type CreateBorrowData, type CreateBorrowRequest, type CreateInstantLoanRequest, type CreateProfileParams, type CreateTransferErc20TransactionParams, type CreateWithdrawData, type CreateWithdrawRequest, Environment, type EstimateInflowFeeRequest, type EthTransactionRequest, type EvmContractTransaction, type EvmReadClient, EvmSupplyApprovalStrategy, type EvmSupplyContext, type ExecuteWithOptions, type ExternalAccount, type ExternalOutflowReceiver, type FindPoolQuery, type FullWithdrawAmount, type GetActivityStatusByProfileRequest, type GetActivityStatusByShortRefRequest, type GetActivityStatusRequest, type GetActivityStatusResponse, type GetDepositAddressRequest, type GetEvmSupplyContextRequest, type HealthFactor, HistoryModule, type IcrcAccount, type IcrcAccountSupplyTarget, type IcrcOutflowReceiver, type InflowActivity, type InflowActivityOperation, type InflowActivityStatus, type InflowFeeEstimate, type InflowOperation, type InstantLoan, type InstantLoanAccount, type InstantLoanAsset, type InstantLoanAuthorization, type InstantLoanBorrow, type InstantLoanBorrowRequestedEventType, type InstantLoanCollateral, type InstantLoanConfig, type InstantLoanCreatedEventType, type InstantLoanDepositTimerExceededEventType, type InstantLoanDepositTimerStartedEventType, type InstantLoanEvent, type InstantLoanEventType, type InstantLoanFindBorrow, type InstantLoanFindCollateral, type InstantLoanFindResult, type InstantLoanFullLendWithdrawalRequestedEventType, type InstantLoanGetByIdRequest, type InstantLoanGetByRefRequest, type InstantLoanGetRequest, type InstantLoanInitialDeposit, type InstantLoanLeg, type InstantLoanListEventsRequest, type InstantLoanPositionSummary, type InstantLoanProfileWarmedEventType, type InstantLoanRepayCompleteEventType, type InstantLoanRepayment, type InstantLoanStuckFundsWithdrawalRequestedEventType, type InstantLoanTerms, type InstantLoanWarmedProfile, InstantLoansModule, LendingModule, LiquidiumClient, type LiquidiumClientConfig, LiquidiumError, LiquidiumErrorCode, type LiquidiumErrorContext, type LiquidiumOperation, type LiquidiumState, type LiquidiumStatus, type ListActivitiesByProfileRequest, type ListActivitiesByShortRefRequest, type ListActivitiesRequest, type LtvCalculation, MIN_BORROW_AMOUNTS_BY_ASSET, MIN_WITHDRAW_AMOUNTS_BY_ASSET, type ManualTransferSupplyFlowRequest, type MarketAsset, type MarketChain, MarketModule, type MaxRepayAmount, type MinimumBorrowAsset, type MinimumWithdrawAsset, type NativeAccount, type NativeAddressSupplyTarget, type NativeOutflowReceiver, type OutflowActivity, type OutflowActivityOperation, type OutflowActivityStatus, type OutflowDetails, type OutflowReceiver, OutflowType, type PaginatedResponse, type Pool, type PoolRate, type Position, PositionsModule, type PrepareCreateProfileOptions, QuoteModule, type QuoteRequest, type QuoteResult, type QuoteValidationError, QuoteValidationErrorCode, type QuoteWarning, QuoteWarningCode, RATE_DECIMALS, RATE_SCALE, type SendBtcTransactionRequest, type SendEthTransactionRequest, type SignMessageRequest, type SignMessageWalletAction, type SignableAction, type SignatureInfo, type SubmitInflowRequest, type SubmitInflowResponse, type SubmitSupplyFlowInflowRequest, SupplyAction, type SupplyFlow, type SupplyFlowRequest, SupplyPlanType, type SupplyTarget, TransferMode, type TransferSupplyFlowRequest, USDC_CONTRACT_ADDRESS, USDT_CONTRACT_ADDRESS, type UserHistoryEntry, type UserHistoryEntryApiItem, type UserHistoryOperation, type UserHistoryResponse, type UserLiquidationHistoryEntry, type UserLiquidationHistoryFilters, type UserPositionSummary, type UserReserve, type UserStats, type UserTransactionHistoryEntry, type UserTransactionHistoryFilters, type UserTransactionHistoryOperation, type UserTransactionHistoryState, type Wallet, type WalletAction, WalletActionKind, type WalletAdapter, WalletExecutionKind, type WalletExecutionParams, type WalletTransferSupplyFlowRequest, type WithdrawAction, type WithdrawOutflowDetails, type WithdrawSubmitSignatureInfo, createTransferErc20Transaction, executeWith, getMinimumBorrowAmount, getMinimumWithdrawAmount, intFromPublicId, publicIdFromInt };
|
package/dist/index.d.ts
CHANGED
|
@@ -106,16 +106,13 @@ interface CanisterContext {
|
|
|
106
106
|
|
|
107
107
|
/** Asset transfer path used for wallet-executed actions. */
|
|
108
108
|
declare const TransferMode: {
|
|
109
|
-
readonly ck: "ck";
|
|
110
109
|
readonly native: "native";
|
|
111
110
|
};
|
|
112
111
|
/** Asset transfer path used for wallet-executed actions. */
|
|
113
112
|
type TransferMode = (typeof TransferMode)[keyof typeof TransferMode];
|
|
114
113
|
/** Wallet capability required to execute a prepared SDK action. */
|
|
115
114
|
declare const WalletExecutionKind: {
|
|
116
|
-
readonly sendEthTransaction: "send-eth-transaction";
|
|
117
115
|
readonly signMessage: "sign-message";
|
|
118
|
-
readonly signPsbt: "sign-psbt";
|
|
119
116
|
};
|
|
120
117
|
/** Wallet capability required to execute a prepared SDK action. */
|
|
121
118
|
type WalletExecutionKind = (typeof WalletExecutionKind)[keyof typeof WalletExecutionKind];
|
|
@@ -151,19 +148,6 @@ interface SignMessageRequest {
|
|
|
151
148
|
/** Transfer path associated with the action. */
|
|
152
149
|
transferMode: TransferMode;
|
|
153
150
|
}
|
|
154
|
-
/** PSBT-signing request passed to BTC wallet adapters. */
|
|
155
|
-
interface SignPsbtRequest {
|
|
156
|
-
/** BTC chain discriminator. */
|
|
157
|
-
chain: Extract<Chain, "BTC">;
|
|
158
|
-
/** Base64-encoded unsigned PSBT. */
|
|
159
|
-
psbtBase64: string;
|
|
160
|
-
/** Optional BTC account override. */
|
|
161
|
-
account?: string;
|
|
162
|
-
/** SDK action type that produced this request. */
|
|
163
|
-
actionType: string;
|
|
164
|
-
/** Transfer path associated with the action. */
|
|
165
|
-
transferMode: TransferMode;
|
|
166
|
-
}
|
|
167
151
|
/** ETH transaction-sending request passed to wallet adapters. */
|
|
168
152
|
interface SendEthTransactionRequest {
|
|
169
153
|
/** ETH chain discriminator. */
|
|
@@ -198,13 +182,10 @@ interface SendBtcTransactionRequest {
|
|
|
198
182
|
* - `signMessage` - account creation, borrow, withdraw
|
|
199
183
|
* - `sendBtcTransaction` / `sendEthTransaction` - automated transfer-path supply
|
|
200
184
|
* - `sendEthTransaction` - contract-interaction supply and ETH native sends
|
|
201
|
-
* - `signPsbt` - reserved; no current SDK flow emits PSBT-signing actions
|
|
202
185
|
*/
|
|
203
186
|
interface WalletAdapter {
|
|
204
187
|
/** Signs an SDK plaintext message and returns the wallet signature. BTC adapters may return base64 BIP-322 or hex-encoded signature bytes. */
|
|
205
188
|
signMessage?: (request: SignMessageRequest) => Promise<string>;
|
|
206
|
-
/** Reserved for future PSBT-signing flows; no current SDK method calls this. */
|
|
207
|
-
signPsbt?: (request: SignPsbtRequest) => Promise<string>;
|
|
208
189
|
/** Sends an EVM transaction and returns its transaction hash. */
|
|
209
190
|
sendEthTransaction?: (request: SendEthTransactionRequest) => Promise<string>;
|
|
210
191
|
/** Sends a BTC transaction and returns its transaction id. */
|
|
@@ -219,16 +200,6 @@ interface SignatureInfo {
|
|
|
219
200
|
/** Account that produced the signature, when different from the action default. */
|
|
220
201
|
account?: string;
|
|
221
202
|
}
|
|
222
|
-
/** Request submitted after a BTC PSBT has been signed. */
|
|
223
|
-
interface SignPsbtSubmitRequest {
|
|
224
|
-
/** Base64-encoded signed PSBT. */
|
|
225
|
-
signedPsbtBase64: string;
|
|
226
|
-
}
|
|
227
|
-
/** Request submitted after an ETH transaction has been sent. */
|
|
228
|
-
interface SendEthTransactionSubmitRequest {
|
|
229
|
-
/** EVM transaction hash returned by the wallet. */
|
|
230
|
-
txHash: string;
|
|
231
|
-
}
|
|
232
203
|
/** Prepared action that requires message signing before submit. */
|
|
233
204
|
interface SignMessageWalletAction<TData, TResult> {
|
|
234
205
|
/** Protocol action kind. */
|
|
@@ -248,42 +219,8 @@ interface SignMessageWalletAction<TData, TResult> {
|
|
|
248
219
|
/** Submits the signature and resolves the protocol result. */
|
|
249
220
|
submit(signatureInfo: SignatureInfo): Promise<TResult>;
|
|
250
221
|
}
|
|
251
|
-
/** Reserved prepared action for future BTC PSBT-signing flows. */
|
|
252
|
-
interface SignPsbtWalletAction<TResult> {
|
|
253
|
-
/** Protocol action kind. */
|
|
254
|
-
kind: WalletActionKind;
|
|
255
|
-
/** Wallet capability required to execute the action. */
|
|
256
|
-
executionKind: typeof WalletExecutionKind.signPsbt;
|
|
257
|
-
/** Adapter-facing action type. */
|
|
258
|
-
actionType: string;
|
|
259
|
-
/** Transfer path associated with the action. */
|
|
260
|
-
transferMode: TransferMode;
|
|
261
|
-
/** Optional default account to pass to the wallet adapter. */
|
|
262
|
-
account?: string;
|
|
263
|
-
/** Base64-encoded unsigned PSBT. */
|
|
264
|
-
psbtBase64: string;
|
|
265
|
-
/** Submits the signed PSBT and resolves the protocol result. */
|
|
266
|
-
submit(request: SignPsbtSubmitRequest): Promise<TResult>;
|
|
267
|
-
}
|
|
268
|
-
/** Prepared action that requires sending an ETH transaction before submit. */
|
|
269
|
-
interface SendEthTransactionWalletAction<TResult> {
|
|
270
|
-
/** Protocol action kind. */
|
|
271
|
-
kind: WalletActionKind;
|
|
272
|
-
/** Wallet capability required to execute the action. */
|
|
273
|
-
executionKind: typeof WalletExecutionKind.sendEthTransaction;
|
|
274
|
-
/** Adapter-facing action type. */
|
|
275
|
-
actionType: string;
|
|
276
|
-
/** Transfer path associated with the action. */
|
|
277
|
-
transferMode: TransferMode;
|
|
278
|
-
/** Optional default account to pass to the wallet adapter. */
|
|
279
|
-
account?: string;
|
|
280
|
-
/** EVM transaction request to send. */
|
|
281
|
-
transaction: EthTransactionRequest;
|
|
282
|
-
/** Submits the transaction hash and resolves the protocol result. */
|
|
283
|
-
submit(request: SendEthTransactionSubmitRequest): Promise<TResult>;
|
|
284
|
-
}
|
|
285
222
|
/** Any prepared action returned by SDK methods and executable by {@link executeWith}. */
|
|
286
|
-
type WalletAction<TResult> = SignMessageWalletAction<unknown, TResult
|
|
223
|
+
type WalletAction<TResult> = SignMessageWalletAction<unknown, TResult>;
|
|
287
224
|
|
|
288
225
|
/** Options for preparing a profile-creation action. */
|
|
289
226
|
interface PrepareCreateProfileOptions {
|
|
@@ -756,15 +693,16 @@ interface BorrowAction extends SignMessageWalletAction<CreateBorrowData, BorrowO
|
|
|
756
693
|
/** Adapter-facing action type. */
|
|
757
694
|
actionType: typeof WalletActionKind.createBorrow;
|
|
758
695
|
}
|
|
759
|
-
/**
|
|
760
|
-
* Fields to build a withdraw request. `amount` is in the pool asset's base units.
|
|
761
|
-
*/
|
|
696
|
+
/** Fields to build a withdraw request. `amount` is in the pool asset's base units. */
|
|
762
697
|
interface CreateWithdrawRequest {
|
|
763
698
|
/** Liquidium profile principal text. */
|
|
764
699
|
profileId: string;
|
|
765
700
|
/** Pool principal text to withdraw from. */
|
|
766
701
|
poolId: string;
|
|
767
|
-
/**
|
|
702
|
+
/**
|
|
703
|
+
* Amount to withdraw in the pool asset's base units. BTC withdrawals require
|
|
704
|
+
* at least 5,000 sats. USDC and USDT withdrawals require at least 1 token.
|
|
705
|
+
*/
|
|
768
706
|
amount: bigint;
|
|
769
707
|
/** External-chain address that receives the withdrawn asset. Must match the pool chain. */
|
|
770
708
|
receiverAddress: string;
|
|
@@ -1104,7 +1042,6 @@ declare class LendingModule {
|
|
|
1104
1042
|
private requireApi;
|
|
1105
1043
|
private createSupplyFlowExecutor;
|
|
1106
1044
|
private getPoolById;
|
|
1107
|
-
private normalizeOutflowReceiverAddress;
|
|
1108
1045
|
}
|
|
1109
1046
|
|
|
1110
1047
|
/** Current protocol metadata and rate state for a lending pool. */
|
|
@@ -1188,8 +1125,7 @@ interface PoolRate {
|
|
|
1188
1125
|
/** Pool metadata, prices, and current rate helpers. */
|
|
1189
1126
|
declare class MarketModule {
|
|
1190
1127
|
private readonly canisterContext;
|
|
1191
|
-
|
|
1192
|
-
constructor(canisterContext: CanisterContext, apiClient: ApiClient | undefined);
|
|
1128
|
+
constructor(canisterContext: CanisterContext);
|
|
1193
1129
|
/**
|
|
1194
1130
|
* Lists SDK-supported pools with their current rates.
|
|
1195
1131
|
*
|
|
@@ -2204,6 +2140,20 @@ declare const RATE_SCALE = 1000000000000000000000000000n;
|
|
|
2204
2140
|
/** Number of decimal places represented by {@link RATE_SCALE}. */
|
|
2205
2141
|
declare const RATE_DECIMALS: bigint;
|
|
2206
2142
|
|
|
2143
|
+
/** Minimum withdraw amounts in each asset's base units. */
|
|
2144
|
+
declare const MIN_WITHDRAW_AMOUNTS_BY_ASSET: {
|
|
2145
|
+
readonly BTC: 5000n;
|
|
2146
|
+
readonly USDC: 1000000n;
|
|
2147
|
+
readonly USDT: 1000000n;
|
|
2148
|
+
};
|
|
2149
|
+
type MinimumWithdrawAsset = keyof typeof MIN_WITHDRAW_AMOUNTS_BY_ASSET;
|
|
2150
|
+
/**
|
|
2151
|
+
* Returns the minimum withdraw amount for an asset in base units.
|
|
2152
|
+
*
|
|
2153
|
+
* Assets without a configured product minimum return `0n`.
|
|
2154
|
+
*/
|
|
2155
|
+
declare function getMinimumWithdrawAmount(asset: string): bigint;
|
|
2156
|
+
|
|
2207
2157
|
/**
|
|
2208
2158
|
* Wallet wiring for {@link executeWith}.
|
|
2209
2159
|
*
|
|
@@ -2222,12 +2172,10 @@ interface ExecuteWithOptions {
|
|
|
2222
2172
|
* Returns an async function that runs a {@link WalletAction} end-to-end.
|
|
2223
2173
|
*
|
|
2224
2174
|
* - `sign-message`: needs `walletAdapter.signMessage` and `options.chain`.
|
|
2225
|
-
* - `sign-psbt`: reserved; no current SDK flow emits this action.
|
|
2226
|
-
* - `send-eth-transaction`: needs `walletAdapter.sendEthTransaction`.
|
|
2227
2175
|
*
|
|
2228
2176
|
* @param options - Adapter and optional chain/account overrides.
|
|
2229
2177
|
* @returns A function that accepts a `WalletAction` and resolves with its submit result.
|
|
2230
2178
|
*/
|
|
2231
2179
|
declare function executeWith(options: ExecuteWithOptions): <TResult>(action: WalletAction<TResult>) => Promise<TResult>;
|
|
2232
2180
|
|
|
2233
|
-
export { type AccountIdentifierAccount, type AccountIdentifierOutflowReceiver, AccountsModule, ActivitiesModule, type Activity, ActivityFilter, type ActivityStatusFoundResponse, type ActivityStatusNotFoundResponse, type ActivityTopUp, Asset, type AssetPrices, type BaseGetActivityStatusRequest, type BaseListActivitiesRequest, type BorrowAction, type BorrowOutflowDetails, type BorrowSubmitSignatureInfo, type BorrowingPower, CK_ETH_DEPOSIT_CONTRACT_ADDRESS, type CalculateLtvRequest, type CanisterIds, Chain, type ContractInteractionSupplyFlowRequest, type CreateAccountAction, type CreateAccountData, type CreateAccountRequest, type CreateBorrowData, type CreateBorrowRequest, type CreateInstantLoanRequest, type CreateProfileParams, type CreateTransferErc20TransactionParams, type CreateWithdrawData, type CreateWithdrawRequest, Environment, type EstimateInflowFeeRequest, type EthTransactionRequest, type EvmContractTransaction, type EvmReadClient, EvmSupplyApprovalStrategy, type EvmSupplyContext, type ExecuteWithOptions, type ExternalAccount, type ExternalOutflowReceiver, type FindPoolQuery, type FullWithdrawAmount, type GetActivityStatusByProfileRequest, type GetActivityStatusByShortRefRequest, type GetActivityStatusRequest, type GetActivityStatusResponse, type GetDepositAddressRequest, type GetEvmSupplyContextRequest, type HealthFactor, HistoryModule, type IcrcAccount, type IcrcAccountSupplyTarget, type IcrcOutflowReceiver, type InflowActivity, type InflowActivityOperation, type InflowActivityStatus, type InflowFeeEstimate, type InflowOperation, type InstantLoan, type InstantLoanAccount, type InstantLoanAsset, type InstantLoanAuthorization, type InstantLoanBorrow, type InstantLoanBorrowRequestedEventType, type InstantLoanCollateral, type InstantLoanConfig, type InstantLoanCreatedEventType, type InstantLoanDepositTimerExceededEventType, type InstantLoanDepositTimerStartedEventType, type InstantLoanEvent, type InstantLoanEventType, type InstantLoanFindBorrow, type InstantLoanFindCollateral, type InstantLoanFindResult, type InstantLoanFullLendWithdrawalRequestedEventType, type InstantLoanGetByIdRequest, type InstantLoanGetByRefRequest, type InstantLoanGetRequest, type InstantLoanInitialDeposit, type InstantLoanLeg, type InstantLoanListEventsRequest, type InstantLoanPositionSummary, type InstantLoanProfileWarmedEventType, type InstantLoanRepayCompleteEventType, type InstantLoanRepayment, type InstantLoanStuckFundsWithdrawalRequestedEventType, type InstantLoanTerms, type InstantLoanWarmedProfile, InstantLoansModule, LendingModule, LiquidiumClient, type LiquidiumClientConfig, LiquidiumError, LiquidiumErrorCode, type LiquidiumErrorContext, type LiquidiumOperation, type LiquidiumState, type LiquidiumStatus, type ListActivitiesByProfileRequest, type ListActivitiesByShortRefRequest, type ListActivitiesRequest, type LtvCalculation, MIN_BORROW_AMOUNTS_BY_ASSET, type ManualTransferSupplyFlowRequest, type MarketAsset, type MarketChain, MarketModule, type MaxRepayAmount, type MinimumBorrowAsset, type NativeAccount, type NativeAddressSupplyTarget, type NativeOutflowReceiver, type OutflowActivity, type OutflowActivityOperation, type OutflowActivityStatus, type OutflowDetails, type OutflowReceiver, OutflowType, type PaginatedResponse, type Pool, type PoolRate, type Position, PositionsModule, type PrepareCreateProfileOptions, QuoteModule, type QuoteRequest, type QuoteResult, type QuoteValidationError, QuoteValidationErrorCode, type QuoteWarning, QuoteWarningCode, RATE_DECIMALS, RATE_SCALE, type SendBtcTransactionRequest, type SendEthTransactionRequest, type
|
|
2181
|
+
export { type AccountIdentifierAccount, type AccountIdentifierOutflowReceiver, AccountsModule, ActivitiesModule, type Activity, ActivityFilter, type ActivityStatusFoundResponse, type ActivityStatusNotFoundResponse, type ActivityTopUp, Asset, type AssetPrices, type BaseGetActivityStatusRequest, type BaseListActivitiesRequest, type BorrowAction, type BorrowOutflowDetails, type BorrowSubmitSignatureInfo, type BorrowingPower, CK_ETH_DEPOSIT_CONTRACT_ADDRESS, type CalculateLtvRequest, type CanisterIds, Chain, type ContractInteractionSupplyFlowRequest, type CreateAccountAction, type CreateAccountData, type CreateAccountRequest, type CreateBorrowData, type CreateBorrowRequest, type CreateInstantLoanRequest, type CreateProfileParams, type CreateTransferErc20TransactionParams, type CreateWithdrawData, type CreateWithdrawRequest, Environment, type EstimateInflowFeeRequest, type EthTransactionRequest, type EvmContractTransaction, type EvmReadClient, EvmSupplyApprovalStrategy, type EvmSupplyContext, type ExecuteWithOptions, type ExternalAccount, type ExternalOutflowReceiver, type FindPoolQuery, type FullWithdrawAmount, type GetActivityStatusByProfileRequest, type GetActivityStatusByShortRefRequest, type GetActivityStatusRequest, type GetActivityStatusResponse, type GetDepositAddressRequest, type GetEvmSupplyContextRequest, type HealthFactor, HistoryModule, type IcrcAccount, type IcrcAccountSupplyTarget, type IcrcOutflowReceiver, type InflowActivity, type InflowActivityOperation, type InflowActivityStatus, type InflowFeeEstimate, type InflowOperation, type InstantLoan, type InstantLoanAccount, type InstantLoanAsset, type InstantLoanAuthorization, type InstantLoanBorrow, type InstantLoanBorrowRequestedEventType, type InstantLoanCollateral, type InstantLoanConfig, type InstantLoanCreatedEventType, type InstantLoanDepositTimerExceededEventType, type InstantLoanDepositTimerStartedEventType, type InstantLoanEvent, type InstantLoanEventType, type InstantLoanFindBorrow, type InstantLoanFindCollateral, type InstantLoanFindResult, type InstantLoanFullLendWithdrawalRequestedEventType, type InstantLoanGetByIdRequest, type InstantLoanGetByRefRequest, type InstantLoanGetRequest, type InstantLoanInitialDeposit, type InstantLoanLeg, type InstantLoanListEventsRequest, type InstantLoanPositionSummary, type InstantLoanProfileWarmedEventType, type InstantLoanRepayCompleteEventType, type InstantLoanRepayment, type InstantLoanStuckFundsWithdrawalRequestedEventType, type InstantLoanTerms, type InstantLoanWarmedProfile, InstantLoansModule, LendingModule, LiquidiumClient, type LiquidiumClientConfig, LiquidiumError, LiquidiumErrorCode, type LiquidiumErrorContext, type LiquidiumOperation, type LiquidiumState, type LiquidiumStatus, type ListActivitiesByProfileRequest, type ListActivitiesByShortRefRequest, type ListActivitiesRequest, type LtvCalculation, MIN_BORROW_AMOUNTS_BY_ASSET, MIN_WITHDRAW_AMOUNTS_BY_ASSET, type ManualTransferSupplyFlowRequest, type MarketAsset, type MarketChain, MarketModule, type MaxRepayAmount, type MinimumBorrowAsset, type MinimumWithdrawAsset, type NativeAccount, type NativeAddressSupplyTarget, type NativeOutflowReceiver, type OutflowActivity, type OutflowActivityOperation, type OutflowActivityStatus, type OutflowDetails, type OutflowReceiver, OutflowType, type PaginatedResponse, type Pool, type PoolRate, type Position, PositionsModule, type PrepareCreateProfileOptions, QuoteModule, type QuoteRequest, type QuoteResult, type QuoteValidationError, QuoteValidationErrorCode, type QuoteWarning, QuoteWarningCode, RATE_DECIMALS, RATE_SCALE, type SendBtcTransactionRequest, type SendEthTransactionRequest, type SignMessageRequest, type SignMessageWalletAction, type SignableAction, type SignatureInfo, type SubmitInflowRequest, type SubmitInflowResponse, type SubmitSupplyFlowInflowRequest, SupplyAction, type SupplyFlow, type SupplyFlowRequest, SupplyPlanType, type SupplyTarget, TransferMode, type TransferSupplyFlowRequest, USDC_CONTRACT_ADDRESS, USDT_CONTRACT_ADDRESS, type UserHistoryEntry, type UserHistoryEntryApiItem, type UserHistoryOperation, type UserHistoryResponse, type UserLiquidationHistoryEntry, type UserLiquidationHistoryFilters, type UserPositionSummary, type UserReserve, type UserStats, type UserTransactionHistoryEntry, type UserTransactionHistoryFilters, type UserTransactionHistoryOperation, type UserTransactionHistoryState, type Wallet, type WalletAction, WalletActionKind, type WalletAdapter, WalletExecutionKind, type WalletExecutionParams, type WalletTransferSupplyFlowRequest, type WithdrawAction, type WithdrawOutflowDetails, type WithdrawSubmitSignatureInfo, createTransferErc20Transaction, executeWith, getMinimumBorrowAmount, getMinimumWithdrawAmount, intFromPublicId, publicIdFromInt };
|
package/dist/index.js
CHANGED
|
@@ -982,13 +982,10 @@ function getVariantKey(variant) {
|
|
|
982
982
|
|
|
983
983
|
// src/core/wallet-actions.ts
|
|
984
984
|
var TransferMode = {
|
|
985
|
-
ck: "ck",
|
|
986
985
|
native: "native"
|
|
987
986
|
};
|
|
988
987
|
var WalletExecutionKind = {
|
|
989
|
-
|
|
990
|
-
signMessage: "sign-message",
|
|
991
|
-
signPsbt: "sign-psbt"
|
|
988
|
+
signMessage: "sign-message"
|
|
992
989
|
};
|
|
993
990
|
var WalletActionKind = {
|
|
994
991
|
createAccount: "create-account",
|
|
@@ -1026,38 +1023,6 @@ function executeWith(options) {
|
|
|
1026
1023
|
account: options.account ?? action.account
|
|
1027
1024
|
});
|
|
1028
1025
|
}
|
|
1029
|
-
case WalletExecutionKind.signPsbt: {
|
|
1030
|
-
if (!options.walletAdapter.signPsbt) {
|
|
1031
|
-
throw new LiquidiumError(
|
|
1032
|
-
LiquidiumErrorCode.VALIDATION_ERROR,
|
|
1033
|
-
"Wallet adapter does not support PSBT signing"
|
|
1034
|
-
);
|
|
1035
|
-
}
|
|
1036
|
-
const signedPsbtBase64 = await options.walletAdapter.signPsbt({
|
|
1037
|
-
chain: Chain.BTC,
|
|
1038
|
-
psbtBase64: action.psbtBase64,
|
|
1039
|
-
account: options.account ?? action.account,
|
|
1040
|
-
actionType: action.actionType,
|
|
1041
|
-
transferMode: action.transferMode
|
|
1042
|
-
});
|
|
1043
|
-
return action.submit({ signedPsbtBase64 });
|
|
1044
|
-
}
|
|
1045
|
-
case WalletExecutionKind.sendEthTransaction: {
|
|
1046
|
-
if (!options.walletAdapter.sendEthTransaction) {
|
|
1047
|
-
throw new LiquidiumError(
|
|
1048
|
-
LiquidiumErrorCode.VALIDATION_ERROR,
|
|
1049
|
-
"Wallet adapter does not support ETH transaction sending"
|
|
1050
|
-
);
|
|
1051
|
-
}
|
|
1052
|
-
const txHash = await options.walletAdapter.sendEthTransaction({
|
|
1053
|
-
chain: Chain.ETH,
|
|
1054
|
-
transaction: action.transaction,
|
|
1055
|
-
account: options.account ?? action.account,
|
|
1056
|
-
actionType: action.actionType,
|
|
1057
|
-
transferMode: action.transferMode
|
|
1058
|
-
});
|
|
1059
|
-
return action.submit({ txHash });
|
|
1060
|
-
}
|
|
1061
1026
|
default:
|
|
1062
1027
|
throw new LiquidiumError(
|
|
1063
1028
|
LiquidiumErrorCode.VALIDATION_ERROR,
|
|
@@ -3257,13 +3222,12 @@ function assertSupportsIcrcAccountInflowTarget(asset) {
|
|
|
3257
3222
|
}
|
|
3258
3223
|
|
|
3259
3224
|
// src/core/borrow-minimums.ts
|
|
3225
|
+
var MINIMUM_BTC_BORROW_AMOUNT_SATS = 5100n;
|
|
3226
|
+
var MINIMUM_STABLECOIN_BORROW_AMOUNT_BASE_UNITS = 1000000n;
|
|
3260
3227
|
var MIN_BORROW_AMOUNTS_BY_ASSET = {
|
|
3261
|
-
BTC:
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
// 1 USDC
|
|
3265
|
-
USDT: 1000000n
|
|
3266
|
-
// 1 USDT
|
|
3228
|
+
[Asset.BTC]: MINIMUM_BTC_BORROW_AMOUNT_SATS,
|
|
3229
|
+
[Asset.USDC]: MINIMUM_STABLECOIN_BORROW_AMOUNT_BASE_UNITS,
|
|
3230
|
+
[Asset.USDT]: MINIMUM_STABLECOIN_BORROW_AMOUNT_BASE_UNITS
|
|
3267
3231
|
};
|
|
3268
3232
|
function getMinimumBorrowAmount(asset) {
|
|
3269
3233
|
if (!isMinimumBorrowAsset(asset)) {
|
|
@@ -4761,6 +4725,38 @@ function accountTypeToString(accountType) {
|
|
|
4761
4725
|
}
|
|
4762
4726
|
}
|
|
4763
4727
|
|
|
4728
|
+
// src/core/withdraw-minimums.ts
|
|
4729
|
+
var MINIMUM_BTC_WITHDRAW_AMOUNT_SATS = 5000n;
|
|
4730
|
+
var MINIMUM_STABLECOIN_WITHDRAW_AMOUNT_BASE_UNITS = 1000000n;
|
|
4731
|
+
var MIN_WITHDRAW_AMOUNTS_BY_ASSET = {
|
|
4732
|
+
[Asset.BTC]: MINIMUM_BTC_WITHDRAW_AMOUNT_SATS,
|
|
4733
|
+
[Asset.USDC]: MINIMUM_STABLECOIN_WITHDRAW_AMOUNT_BASE_UNITS,
|
|
4734
|
+
[Asset.USDT]: MINIMUM_STABLECOIN_WITHDRAW_AMOUNT_BASE_UNITS
|
|
4735
|
+
};
|
|
4736
|
+
function getMinimumWithdrawAmount(asset) {
|
|
4737
|
+
if (!isMinimumWithdrawAsset(asset)) {
|
|
4738
|
+
return 0n;
|
|
4739
|
+
}
|
|
4740
|
+
return MIN_WITHDRAW_AMOUNTS_BY_ASSET[asset];
|
|
4741
|
+
}
|
|
4742
|
+
function getWithdrawAmountMinimumValidationError(params) {
|
|
4743
|
+
const minimumAmount = getMinimumWithdrawAmount(params.asset);
|
|
4744
|
+
if (minimumAmount <= 0n || params.amount >= minimumAmount) {
|
|
4745
|
+
return null;
|
|
4746
|
+
}
|
|
4747
|
+
return {
|
|
4748
|
+
asset: params.asset,
|
|
4749
|
+
minimumAmount,
|
|
4750
|
+
message: formatMinimumWithdrawAmountMessage(params.asset, minimumAmount)
|
|
4751
|
+
};
|
|
4752
|
+
}
|
|
4753
|
+
function formatMinimumWithdrawAmountMessage(asset, minimumAmount) {
|
|
4754
|
+
return `Withdraw amount must be at least ${minimumAmount} base units for ${asset}`;
|
|
4755
|
+
}
|
|
4756
|
+
function isMinimumWithdrawAsset(asset) {
|
|
4757
|
+
return Object.hasOwn(MIN_WITHDRAW_AMOUNTS_BY_ASSET, asset);
|
|
4758
|
+
}
|
|
4759
|
+
|
|
4764
4760
|
// src/modules/lending/_internal/inflow-fee-rounding.ts
|
|
4765
4761
|
var ETH_STABLECOIN_INFLOW_FEE_ROUND_UP_TO_NEAREST_10_CENTS = 100000n;
|
|
4766
4762
|
var BTC_INFLOW_FEE_ROUND_UP_TO_NEAREST_SATS = 500n;
|
|
@@ -5437,9 +5433,28 @@ var LendingModule = class {
|
|
|
5437
5433
|
"Withdraw requires a signer account"
|
|
5438
5434
|
);
|
|
5439
5435
|
}
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
|
|
5436
|
+
if (request.amount <= 0n) {
|
|
5437
|
+
throw new LiquidiumError(
|
|
5438
|
+
LiquidiumErrorCode.VALIDATION_ERROR,
|
|
5439
|
+
"Withdraw amount must be greater than 0"
|
|
5440
|
+
);
|
|
5441
|
+
}
|
|
5442
|
+
const selectedPool = await this.getPoolById(request.poolId);
|
|
5443
|
+
const selectedAsset = selectedPool.asset;
|
|
5444
|
+
const minimumWithdrawAmountError = getWithdrawAmountMinimumValidationError({
|
|
5445
|
+
amount: request.amount,
|
|
5446
|
+
asset: selectedAsset
|
|
5447
|
+
});
|
|
5448
|
+
if (minimumWithdrawAmountError) {
|
|
5449
|
+
throw new LiquidiumError(
|
|
5450
|
+
LiquidiumErrorCode.VALIDATION_ERROR,
|
|
5451
|
+
minimumWithdrawAmountError.message
|
|
5452
|
+
);
|
|
5453
|
+
}
|
|
5454
|
+
const receiverAddress = normalizeExternalAddress({
|
|
5455
|
+
address: destinationAccount,
|
|
5456
|
+
asset: selectedAsset,
|
|
5457
|
+
chain: selectedPool.chain
|
|
5443
5458
|
});
|
|
5444
5459
|
const lendingActor = createLendingActor(this.canisterContext);
|
|
5445
5460
|
try {
|
|
@@ -5851,14 +5866,6 @@ var LendingModule = class {
|
|
|
5851
5866
|
}
|
|
5852
5867
|
return decodedPool;
|
|
5853
5868
|
}
|
|
5854
|
-
async normalizeOutflowReceiverAddress(params) {
|
|
5855
|
-
const selectedPool = await this.getPoolById(params.poolId);
|
|
5856
|
-
return normalizeExternalAddress({
|
|
5857
|
-
address: params.receiverAddress,
|
|
5858
|
-
asset: selectedPool.asset,
|
|
5859
|
-
chain: selectedPool.chain
|
|
5860
|
-
});
|
|
5861
|
-
}
|
|
5862
5869
|
};
|
|
5863
5870
|
function mapExpectedOutflowDetails(details, expectedOutflowType, operation) {
|
|
5864
5871
|
if (details.outflowType !== expectedOutflowType) {
|
|
@@ -5954,12 +5961,10 @@ function formatPrice(price, decimals) {
|
|
|
5954
5961
|
// src/modules/market/market.ts
|
|
5955
5962
|
var ZERO_POOL_RATE = [0n, 0n, 0n];
|
|
5956
5963
|
var MarketModule = class {
|
|
5957
|
-
constructor(canisterContext
|
|
5964
|
+
constructor(canisterContext) {
|
|
5958
5965
|
this.canisterContext = canisterContext;
|
|
5959
|
-
this.apiClient = apiClient;
|
|
5960
5966
|
}
|
|
5961
5967
|
canisterContext;
|
|
5962
|
-
apiClient;
|
|
5963
5968
|
/**
|
|
5964
5969
|
* Lists SDK-supported pools with their current rates.
|
|
5965
5970
|
*
|
|
@@ -5968,7 +5973,6 @@ var MarketModule = class {
|
|
|
5968
5973
|
* @returns Supported lending pools enriched with their current rate data.
|
|
5969
5974
|
*/
|
|
5970
5975
|
async listPools() {
|
|
5971
|
-
void this.apiClient;
|
|
5972
5976
|
try {
|
|
5973
5977
|
const flexibleActor = createFlexibleLendingActor(this.canisterContext);
|
|
5974
5978
|
const rawPools = await flexibleActor.list_pools();
|
|
@@ -6410,7 +6414,7 @@ var LiquidiumClient = class {
|
|
|
6410
6414
|
this.apiClient,
|
|
6411
6415
|
this.evmReadClient
|
|
6412
6416
|
);
|
|
6413
|
-
this.market = new MarketModule(this.canisterContext
|
|
6417
|
+
this.market = new MarketModule(this.canisterContext);
|
|
6414
6418
|
this.positions = new PositionsModule(this.canisterContext, this.market);
|
|
6415
6419
|
this.activities = new ActivitiesModule(
|
|
6416
6420
|
this.apiClient,
|
|
@@ -6442,6 +6446,6 @@ function resolveEvmReadClient(config) {
|
|
|
6442
6446
|
});
|
|
6443
6447
|
}
|
|
6444
6448
|
|
|
6445
|
-
export { AccountsModule, ActivitiesModule, ActivityFilter, Asset, CK_ETH_DEPOSIT_CONTRACT_ADDRESS, Chain, Environment, EvmSupplyApprovalStrategy, HistoryModule, InstantLoansModule, LendingModule, LiquidiumClient, LiquidiumError, LiquidiumErrorCode, MIN_BORROW_AMOUNTS_BY_ASSET, MarketModule, OutflowType, PositionsModule, QuoteModule, QuoteValidationErrorCode, QuoteWarningCode, RATE_DECIMALS, RATE_SCALE2 as RATE_SCALE, SupplyAction, SupplyPlanType, TransferMode, USDC_CONTRACT_ADDRESS, USDT_CONTRACT_ADDRESS, WalletActionKind, WalletExecutionKind, createTransferErc20Transaction, executeWith, getMinimumBorrowAmount, intFromPublicId, publicIdFromInt };
|
|
6449
|
+
export { AccountsModule, ActivitiesModule, ActivityFilter, Asset, CK_ETH_DEPOSIT_CONTRACT_ADDRESS, Chain, Environment, EvmSupplyApprovalStrategy, HistoryModule, InstantLoansModule, LendingModule, LiquidiumClient, LiquidiumError, LiquidiumErrorCode, MIN_BORROW_AMOUNTS_BY_ASSET, MIN_WITHDRAW_AMOUNTS_BY_ASSET, MarketModule, OutflowType, PositionsModule, QuoteModule, QuoteValidationErrorCode, QuoteWarningCode, RATE_DECIMALS, RATE_SCALE2 as RATE_SCALE, SupplyAction, SupplyPlanType, TransferMode, USDC_CONTRACT_ADDRESS, USDT_CONTRACT_ADDRESS, WalletActionKind, WalletExecutionKind, createTransferErc20Transaction, executeWith, getMinimumBorrowAmount, getMinimumWithdrawAmount, intFromPublicId, publicIdFromInt };
|
|
6446
6450
|
//# sourceMappingURL=index.js.map
|
|
6447
6451
|
//# sourceMappingURL=index.js.map
|