@liquidium/client 0.5.0-rc.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -345
- package/dist/index.cjs +3607 -3497
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +294 -288
- package/dist/index.d.ts +294 -288
- package/dist/index.js +3605 -3495
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -56,8 +56,8 @@ interface CanisterIds {
|
|
|
56
56
|
pools: PoolCanisterIds;
|
|
57
57
|
/** ckETH minter deposit helper canister principal. */
|
|
58
58
|
ethDeposit: string;
|
|
59
|
-
/** Accountless
|
|
60
|
-
|
|
59
|
+
/** Accountless Simple Loans canister principal. */
|
|
60
|
+
simpleLoans: string;
|
|
61
61
|
}
|
|
62
62
|
/** Custom canister principal overrides accepted by client configuration. */
|
|
63
63
|
type CanisterIdOverrides = Omit<Partial<CanisterIds>, "pools"> & {
|
|
@@ -175,7 +175,7 @@ interface IcpAccountIdentifierAccount {
|
|
|
175
175
|
/** ICP ledger account identifier text. */
|
|
176
176
|
address: string;
|
|
177
177
|
}
|
|
178
|
-
/** ICRC account display shape shared by lending and
|
|
178
|
+
/** ICRC account display shape shared by lending and Simple Loans responses. */
|
|
179
179
|
interface IcrcAccount {
|
|
180
180
|
/** Account type. */
|
|
181
181
|
type: "IcrcAccount";
|
|
@@ -502,12 +502,12 @@ interface ListActivitiesByProfileRequest extends BaseListActivitiesRequest {
|
|
|
502
502
|
/** Profile principal text to list activities for. */
|
|
503
503
|
profileId: string;
|
|
504
504
|
}
|
|
505
|
-
/** Activity list request scoped to
|
|
505
|
+
/** Activity list request scoped to a simple loan short reference. */
|
|
506
506
|
interface ListActivitiesByShortRefRequest extends BaseListActivitiesRequest {
|
|
507
|
-
/**
|
|
507
|
+
/** Simple loan short reference to list activities for. */
|
|
508
508
|
shortRef: string;
|
|
509
509
|
}
|
|
510
|
-
/** Request for listing activities by profile id or
|
|
510
|
+
/** Request for listing activities by profile id or simple loan short reference. */
|
|
511
511
|
type ListActivitiesRequest = ListActivitiesByProfileRequest | ListActivitiesByShortRefRequest;
|
|
512
512
|
/** Shared request fields for an activity status lookup. */
|
|
513
513
|
interface BaseGetActivityStatusRequest {
|
|
@@ -519,9 +519,9 @@ interface GetActivityStatusByProfileRequest extends BaseGetActivityStatusRequest
|
|
|
519
519
|
/** Profile principal text that owns the activity. */
|
|
520
520
|
profileId: string;
|
|
521
521
|
}
|
|
522
|
-
/** Activity status lookup scoped to
|
|
522
|
+
/** Activity status lookup scoped to a simple loan short reference. */
|
|
523
523
|
interface GetActivityStatusByShortRefRequest extends BaseGetActivityStatusRequest {
|
|
524
|
-
/**
|
|
524
|
+
/** Simple loan short reference that owns the activity. */
|
|
525
525
|
shortRef: string;
|
|
526
526
|
}
|
|
527
527
|
/** Request for fetching one activity by id and owner identifier. */
|
|
@@ -553,7 +553,7 @@ declare class ActivitiesModule {
|
|
|
553
553
|
*
|
|
554
554
|
* Uses the Liquidium SDK API.
|
|
555
555
|
*
|
|
556
|
-
* @param request - Profile id or
|
|
556
|
+
* @param request - Profile id or simple loan short reference plus optional lifecycle filter.
|
|
557
557
|
* @returns Activities owned by the resolved profile.
|
|
558
558
|
*/
|
|
559
559
|
list(request: ListActivitiesRequest): Promise<Activity[]>;
|
|
@@ -562,7 +562,7 @@ declare class ActivitiesModule {
|
|
|
562
562
|
*
|
|
563
563
|
* Uses the Liquidium SDK API.
|
|
564
564
|
*
|
|
565
|
-
* @param request - Activity id plus profile id or
|
|
565
|
+
* @param request - Activity id plus profile id or simple loan short reference.
|
|
566
566
|
* @returns The activity when found, otherwise `{ found: false }` with the requested id.
|
|
567
567
|
*/
|
|
568
568
|
getStatus(request: GetActivityStatusRequest): Promise<GetActivityStatusResponse>;
|
|
@@ -975,6 +975,9 @@ interface EvmSupplyContext {
|
|
|
975
975
|
approvalStrategy: EvmSupplyApprovalStrategy;
|
|
976
976
|
}
|
|
977
977
|
|
|
978
|
+
/** Builds calldata for an ERC-20 `transfer(recipient, amount)` transaction. */
|
|
979
|
+
declare function createTransferErc20Transaction(params: CreateTransferErc20TransactionParams): EvmContractTransaction;
|
|
980
|
+
|
|
978
981
|
/** Borrow, withdraw, supply, inflow reporting, and fee-estimation helpers. */
|
|
979
982
|
declare class LendingModule {
|
|
980
983
|
private readonly canisterContext;
|
|
@@ -985,7 +988,6 @@ declare class LendingModule {
|
|
|
985
988
|
* Prepares a withdraw action that can be signed and submitted later.
|
|
986
989
|
*
|
|
987
990
|
* Use this when you need explicit control over signing and submission.
|
|
988
|
-
*
|
|
989
991
|
* @param request - Profile, pool, amount (pool asset base units), outflow address, and signer wallet.
|
|
990
992
|
* @returns A signable {@link WithdrawAction} with `submit` wired to the canister.
|
|
991
993
|
*/
|
|
@@ -1004,6 +1006,8 @@ declare class LendingModule {
|
|
|
1004
1006
|
* Prepares a borrow action that can be signed and submitted later.
|
|
1005
1007
|
*
|
|
1006
1008
|
* Use this when you need explicit control over signing and submission.
|
|
1009
|
+
* When the selected pool disables same-asset borrowing, preparation rejects
|
|
1010
|
+
* profiles whose supplied balance in that pool is at or above its dust threshold.
|
|
1007
1011
|
*
|
|
1008
1012
|
* @param request - Profile, pool, amount (borrow asset base units), outflow address, and signer wallet.
|
|
1009
1013
|
* @returns A signable {@link BorrowAction} with `submit` wired to the canister.
|
|
@@ -1014,6 +1018,7 @@ declare class LendingModule {
|
|
|
1014
1018
|
* Creates a borrow outflow using the provided wallet adapter.
|
|
1015
1019
|
*
|
|
1016
1020
|
* This is the convenience form of `prepareBorrow(...)` plus execution.
|
|
1021
|
+
* Same-asset policy validation runs before the wallet is asked to sign.
|
|
1017
1022
|
*
|
|
1018
1023
|
* @param params - Borrow request fields plus `signerChain` and `signerWalletAdapter`.
|
|
1019
1024
|
* @returns The lending canister receipt as {@link OutflowDetails}.
|
|
@@ -1087,6 +1092,7 @@ declare class LendingModule {
|
|
|
1087
1092
|
isBorrowingDisabled(): Promise<boolean>;
|
|
1088
1093
|
private requireApi;
|
|
1089
1094
|
private createSupplyFlowExecutor;
|
|
1095
|
+
private guardBorrowSameAssetPolicy;
|
|
1090
1096
|
}
|
|
1091
1097
|
|
|
1092
1098
|
/** Current protocol metadata and rate state for a lending pool. */
|
|
@@ -1143,6 +1149,8 @@ interface Pool {
|
|
|
1143
1149
|
borrowIndex: bigint;
|
|
1144
1150
|
/** Whether borrowing the same asset as collateral is allowed. */
|
|
1145
1151
|
sameAssetBorrowing: boolean;
|
|
1152
|
+
/** Same-asset collateral below this base-unit amount is treated as dust. */
|
|
1153
|
+
sameAssetBorrowingDustThreshold: bigint;
|
|
1146
1154
|
/** Unix timestamp in seconds of the last pool update when available. */
|
|
1147
1155
|
lastUpdated?: bigint;
|
|
1148
1156
|
}
|
|
@@ -1392,13 +1400,157 @@ declare class PositionsModule {
|
|
|
1392
1400
|
getFullWithdrawAmount(profileId: string, poolId: string): Promise<FullWithdrawAmount>;
|
|
1393
1401
|
}
|
|
1394
1402
|
|
|
1395
|
-
/**
|
|
1396
|
-
|
|
1403
|
+
/** Input for calculating required collateral from a target LTV. */
|
|
1404
|
+
interface QuoteRequest {
|
|
1405
|
+
/** Requested borrow amount in borrow asset base units. */
|
|
1406
|
+
borrowAmount: bigint;
|
|
1407
|
+
/** Pool principal text for the borrow side. */
|
|
1408
|
+
borrowPoolId: string;
|
|
1409
|
+
/** Pool principal text for the collateral side. */
|
|
1410
|
+
collateralPoolId: string;
|
|
1411
|
+
/** Target loan-to-value ratio in basis points. */
|
|
1412
|
+
targetLtvBps: bigint;
|
|
1413
|
+
}
|
|
1414
|
+
/** Input for calculating LTV from explicit borrow and collateral amounts. */
|
|
1415
|
+
interface CalculateLtvRequest {
|
|
1416
|
+
/** Requested borrow amount in borrow asset base units. */
|
|
1417
|
+
borrowAmount: bigint;
|
|
1418
|
+
/** Pool principal text for the borrow side. */
|
|
1419
|
+
borrowPoolId: string;
|
|
1420
|
+
/** Collateral amount in collateral asset base units. */
|
|
1421
|
+
collateralAmount: bigint;
|
|
1422
|
+
/** Pool principal text for the collateral side. */
|
|
1423
|
+
collateralPoolId: string;
|
|
1424
|
+
}
|
|
1425
|
+
/** Validation error produced by quote helpers. */
|
|
1426
|
+
interface QuoteValidationError {
|
|
1427
|
+
/** Stable machine-readable validation code. */
|
|
1428
|
+
code: QuoteValidationErrorCode;
|
|
1429
|
+
/** Human-readable validation message. */
|
|
1430
|
+
message: string;
|
|
1431
|
+
}
|
|
1432
|
+
/** Stable validation codes produced by quote helpers. */
|
|
1433
|
+
declare enum QuoteValidationErrorCode {
|
|
1434
|
+
INVALID_LTV = "INVALID_LTV",
|
|
1435
|
+
LTV_EXCEEDS_MAX = "LTV_EXCEEDS_MAX",
|
|
1436
|
+
SAME_ASSET_NOT_ALLOWED = "SAME_ASSET_NOT_ALLOWED",
|
|
1437
|
+
BORROW_AMOUNT_TOO_LOW = "BORROW_AMOUNT_TOO_LOW",
|
|
1438
|
+
PRICE_NOT_AVAILABLE = "PRICE_NOT_AVAILABLE",
|
|
1439
|
+
POOL_NOT_FOUND = "POOL_NOT_FOUND",
|
|
1440
|
+
UNKNOWN = "UNKNOWN"
|
|
1441
|
+
}
|
|
1442
|
+
/** Non-blocking warning produced by quote helpers. */
|
|
1443
|
+
interface QuoteWarning {
|
|
1444
|
+
/** Stable machine-readable warning code. */
|
|
1445
|
+
code: QuoteWarningCode;
|
|
1446
|
+
/** Human-readable warning message. */
|
|
1447
|
+
message: string;
|
|
1448
|
+
}
|
|
1449
|
+
/** Stable warning codes produced by quote helpers. */
|
|
1450
|
+
declare enum QuoteWarningCode {
|
|
1451
|
+
HIGH_LTV = "HIGH_LTV",
|
|
1452
|
+
SAME_ASSET_BORROWING = "SAME_ASSET_BORROWING"
|
|
1453
|
+
}
|
|
1454
|
+
/** Quote result for a requested borrow amount and target LTV. */
|
|
1455
|
+
interface QuoteResult {
|
|
1456
|
+
/** Requested borrow amount in borrow asset base units. */
|
|
1457
|
+
borrowAmount: bigint;
|
|
1458
|
+
/** Borrow value in internal USD units. */
|
|
1459
|
+
borrowUsd: bigint;
|
|
1460
|
+
/** Required collateral amount in collateral asset base units. */
|
|
1461
|
+
requiredCollateralAmount: bigint;
|
|
1462
|
+
/** Required collateral value in internal USD units. */
|
|
1463
|
+
requiredCollateralUsd: bigint;
|
|
1464
|
+
/** Maximum allowed LTV in basis points for the collateral pool. */
|
|
1465
|
+
maxAllowedLtvBps: bigint;
|
|
1466
|
+
/** Requested target LTV in basis points. */
|
|
1467
|
+
targetLtvBps: bigint;
|
|
1468
|
+
/** Pool principal text for the borrow side. */
|
|
1469
|
+
borrowPoolId: string;
|
|
1470
|
+
/** Pool principal text for the collateral side. */
|
|
1471
|
+
collateralPoolId: string;
|
|
1472
|
+
/** Borrow asset symbol. */
|
|
1473
|
+
borrowAsset: string;
|
|
1474
|
+
/** Collateral asset symbol. */
|
|
1475
|
+
collateralAsset: string;
|
|
1476
|
+
/** Blocking validation errors. Empty when the quote is usable. */
|
|
1477
|
+
validationErrors: QuoteValidationError[];
|
|
1478
|
+
/** Non-blocking quote warnings. */
|
|
1479
|
+
warnings: QuoteWarning[];
|
|
1480
|
+
}
|
|
1481
|
+
/** LTV calculation result for explicit borrow and collateral amounts. */
|
|
1482
|
+
interface LtvCalculation {
|
|
1483
|
+
/** Requested borrow amount in borrow asset base units. */
|
|
1484
|
+
borrowAmount: bigint;
|
|
1485
|
+
/** Collateral amount in collateral asset base units. */
|
|
1486
|
+
collateralAmount: bigint;
|
|
1487
|
+
/** Borrow value in internal USD units. */
|
|
1488
|
+
borrowUsd: bigint;
|
|
1489
|
+
/** Collateral value in internal USD units. */
|
|
1490
|
+
collateralUsd: bigint;
|
|
1491
|
+
/** Computed LTV in basis points. */
|
|
1492
|
+
ltvBps: bigint;
|
|
1493
|
+
/** Maximum allowed LTV in basis points for the collateral pool. */
|
|
1494
|
+
maxAllowedLtvBps: bigint;
|
|
1495
|
+
/** Pool principal text for the borrow side. */
|
|
1496
|
+
borrowPoolId: string;
|
|
1497
|
+
/** Pool principal text for the collateral side. */
|
|
1498
|
+
collateralPoolId: string;
|
|
1499
|
+
/** Borrow asset symbol. */
|
|
1500
|
+
borrowAsset: string;
|
|
1501
|
+
/** Collateral asset symbol. */
|
|
1502
|
+
collateralAsset: string;
|
|
1503
|
+
/** Blocking validation errors. Empty when the calculation is usable. */
|
|
1504
|
+
validationErrors: QuoteValidationError[];
|
|
1505
|
+
}
|
|
1397
1506
|
|
|
1398
|
-
/**
|
|
1399
|
-
|
|
1400
|
-
/**
|
|
1401
|
-
|
|
1507
|
+
/** Pure quote helpers for LTV and required-collateral calculations. */
|
|
1508
|
+
declare class QuoteModule {
|
|
1509
|
+
/**
|
|
1510
|
+
* Calculates current LTV from caller-supplied borrow and collateral amounts.
|
|
1511
|
+
*
|
|
1512
|
+
* Amount fields are base units. USD fields are scaled to 8 decimal places.
|
|
1513
|
+
*
|
|
1514
|
+
* @param request - Borrow and collateral pool ids plus base-unit amounts.
|
|
1515
|
+
* @param pools - Available pools, usually from `client.market.listPools()`.
|
|
1516
|
+
* @param prices - USD price map, usually from `client.market.getAssetPrices()`.
|
|
1517
|
+
* @returns LTV calculation plus validation errors when inputs are unusable.
|
|
1518
|
+
*/
|
|
1519
|
+
calculateLtv(request: CalculateLtvRequest, pools: Pool[], prices: AssetPrices): LtvCalculation;
|
|
1520
|
+
/**
|
|
1521
|
+
* Calculates a loan quote based on borrow amount, LTV, and pool selections.
|
|
1522
|
+
*
|
|
1523
|
+
* All arithmetic is performed in bigint. `requiredCollateralAmount` and
|
|
1524
|
+
* `requiredCollateralUsd` are rounded UP so the caller never under-collateralizes
|
|
1525
|
+
* due to integer truncation. `borrowUsd` is floored for display.
|
|
1526
|
+
*
|
|
1527
|
+
* @param request - Quote request parameters.
|
|
1528
|
+
* @param pools - All available pools (use MarketModule.listPools() to fetch).
|
|
1529
|
+
* @param prices - Asset prices in USD (use MarketModule.getAssetPrices() to fetch).
|
|
1530
|
+
* @returns Quote result with required collateral and validation state.
|
|
1531
|
+
*/
|
|
1532
|
+
getQuote(request: QuoteRequest, pools: Pool[], prices: AssetPrices): QuoteResult;
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
/**
|
|
1536
|
+
* Converts a canister loan id into a short user-facing reference.
|
|
1537
|
+
*
|
|
1538
|
+
* @param id - Canister loan id in the supported public-reference range.
|
|
1539
|
+
* @returns Fixed-length public reference string.
|
|
1540
|
+
*/
|
|
1541
|
+
declare function publicIdFromInt(id: bigint): string;
|
|
1542
|
+
/**
|
|
1543
|
+
* Decodes a short user-facing reference back into the canister loan id.
|
|
1544
|
+
*
|
|
1545
|
+
* @param ref - Fixed-length public reference string.
|
|
1546
|
+
* @returns Canister loan id represented by the reference.
|
|
1547
|
+
*/
|
|
1548
|
+
declare function intFromPublicId(ref: string): bigint;
|
|
1549
|
+
|
|
1550
|
+
/** Asset symbols supported by the Simple Loans canister. */
|
|
1551
|
+
type SimpleLoanAsset = AssetIdentifier["asset"];
|
|
1552
|
+
/** Collateral leg used when creating a simple loan. */
|
|
1553
|
+
interface CreateSimpleLoanCollateral {
|
|
1402
1554
|
/**
|
|
1403
1555
|
* Principal text of the pool that receives the user's collateral deposit.
|
|
1404
1556
|
*
|
|
@@ -1412,7 +1564,7 @@ interface CreateInstantLoanCollateral {
|
|
|
1412
1564
|
* Must match the asset for `poolId`; for example, use `"BTC"` with a BTC
|
|
1413
1565
|
* collateral pool.
|
|
1414
1566
|
*/
|
|
1415
|
-
asset:
|
|
1567
|
+
asset: SimpleLoanAsset;
|
|
1416
1568
|
/**
|
|
1417
1569
|
* Intended credited collateral amount, in base units.
|
|
1418
1570
|
*
|
|
@@ -1425,12 +1577,12 @@ interface CreateInstantLoanCollateral {
|
|
|
1425
1577
|
amount: bigint;
|
|
1426
1578
|
}
|
|
1427
1579
|
/**
|
|
1428
|
-
* Borrow leg used when creating
|
|
1580
|
+
* Borrow leg used when creating a simple loan.
|
|
1429
1581
|
*
|
|
1430
1582
|
* `chain` and `asset` form the canonical asset identifier. For example,
|
|
1431
1583
|
* `{ chain: "ICP", asset: "USDT" }` means ckUSDT.
|
|
1432
1584
|
*/
|
|
1433
|
-
type
|
|
1585
|
+
type CreateSimpleLoanBorrow = AssetIdentifier & {
|
|
1434
1586
|
/**
|
|
1435
1587
|
* Principal text of the pool that funds the borrow.
|
|
1436
1588
|
*
|
|
@@ -1453,10 +1605,10 @@ type CreateInstantLoanBorrow = AssetIdentifier & {
|
|
|
1453
1605
|
* require an `IcPrincipal`; native ICP also accepts `IcpAccountIdentifier`
|
|
1454
1606
|
* and `IcrcAccount` destinations.
|
|
1455
1607
|
*/
|
|
1456
|
-
destination:
|
|
1608
|
+
destination: SimpleLoanDestination;
|
|
1457
1609
|
};
|
|
1458
|
-
/** Refund leg used when creating
|
|
1459
|
-
interface
|
|
1610
|
+
/** Refund leg used when creating a simple loan. */
|
|
1611
|
+
interface CreateSimpleLoanRefund {
|
|
1460
1612
|
/** Delivery chain used for collateral refunds and withdrawals. Use ICP for ck-ledger delivery. */
|
|
1461
1613
|
chain: Chain;
|
|
1462
1614
|
/**
|
|
@@ -1467,40 +1619,40 @@ interface CreateInstantLoanRefund {
|
|
|
1467
1619
|
* require an `IcPrincipal`; native ICP also accepts `IcpAccountIdentifier`
|
|
1468
1620
|
* and `IcrcAccount` destinations.
|
|
1469
1621
|
*/
|
|
1470
|
-
destination:
|
|
1622
|
+
destination: SimpleLoanDestination;
|
|
1471
1623
|
}
|
|
1472
1624
|
/**
|
|
1473
|
-
* Borrow destination or refund account associated with
|
|
1625
|
+
* Borrow destination or refund account associated with a simple loan.
|
|
1474
1626
|
*
|
|
1475
1627
|
* @example
|
|
1476
1628
|
* ```ts
|
|
1477
|
-
* const icPrincipalAccount:
|
|
1629
|
+
* const icPrincipalAccount: SimpleLoanAccount = {
|
|
1478
1630
|
* type: "IcPrincipal",
|
|
1479
1631
|
* address: "aaaaa-aa",
|
|
1480
1632
|
* };
|
|
1481
1633
|
*
|
|
1482
|
-
* const chainAddressAccount:
|
|
1634
|
+
* const chainAddressAccount: SimpleLoanAccount = {
|
|
1483
1635
|
* type: "ChainAddress",
|
|
1484
1636
|
* address: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
|
|
1485
1637
|
* };
|
|
1486
1638
|
*
|
|
1487
|
-
* const accountIdentifierAccount:
|
|
1639
|
+
* const accountIdentifierAccount: SimpleLoanAccount = {
|
|
1488
1640
|
* type: "IcpAccountIdentifier",
|
|
1489
1641
|
* address: "e2134f3f176b1429df3f92807b8f0f26a520debc313b2d6ad86a4a2e7f3d8f8d",
|
|
1490
1642
|
* };
|
|
1491
1643
|
*
|
|
1492
|
-
* const icrcAccount:
|
|
1644
|
+
* const icrcAccount: SimpleLoanAccount = {
|
|
1493
1645
|
* type: "IcrcAccount",
|
|
1494
1646
|
* owner: "aaaaa-aa",
|
|
1495
1647
|
* address: "aaaaa-aa",
|
|
1496
1648
|
* };
|
|
1497
1649
|
* ```
|
|
1498
1650
|
*/
|
|
1499
|
-
type
|
|
1500
|
-
/** Destination accepted when creating
|
|
1501
|
-
type
|
|
1651
|
+
type SimpleLoanAccount = LiquidiumAccount;
|
|
1652
|
+
/** Destination accepted when creating a simple loan. */
|
|
1653
|
+
type SimpleLoanDestination = LiquidiumAccountInput;
|
|
1502
1654
|
/**
|
|
1503
|
-
* Parameters for creating an accountless
|
|
1655
|
+
* Parameters for creating an accountless simple loan.
|
|
1504
1656
|
*
|
|
1505
1657
|
* Use market data from `client.market.listPools()` to choose the two pool ids,
|
|
1506
1658
|
* and use `client.quote.calculateLtv(...)` before creation to validate the
|
|
@@ -1510,13 +1662,13 @@ type InstantLoanDestination = LiquidiumAccountInput;
|
|
|
1510
1662
|
* satoshis and ERC-20 assets use token base units according to the selected
|
|
1511
1663
|
* pool decimals.
|
|
1512
1664
|
*/
|
|
1513
|
-
interface
|
|
1665
|
+
interface CreateSimpleLoanRequest {
|
|
1514
1666
|
/** Collateral leg: pool, asset, and amount the user deposits. */
|
|
1515
|
-
collateral:
|
|
1667
|
+
collateral: CreateSimpleLoanCollateral;
|
|
1516
1668
|
/** Borrow leg: pool, asset, amount, delivery chain, and destination. */
|
|
1517
|
-
borrow:
|
|
1669
|
+
borrow: CreateSimpleLoanBorrow;
|
|
1518
1670
|
/** Refund leg: chain and destination for returned collateral. */
|
|
1519
|
-
refund:
|
|
1671
|
+
refund: CreateSimpleLoanRefund;
|
|
1520
1672
|
/**
|
|
1521
1673
|
* Maximum allowed loan-to-value ratio in basis points.
|
|
1522
1674
|
*
|
|
@@ -1530,137 +1682,137 @@ interface CreateInstantLoanRequest {
|
|
|
1530
1682
|
* Seconds allowed for the user to send collateral after loan creation.
|
|
1531
1683
|
*
|
|
1532
1684
|
* If the collateral deposit is not detected before this window expires, the
|
|
1533
|
-
*
|
|
1685
|
+
* simple loan flow can time out. Internally this is sent to the canister as
|
|
1534
1686
|
* `ltv_timer_s`.
|
|
1535
1687
|
*/
|
|
1536
1688
|
depositWindowSeconds: bigint;
|
|
1537
1689
|
}
|
|
1538
|
-
/** Lookup request for loading
|
|
1539
|
-
interface
|
|
1690
|
+
/** Lookup request for loading a simple loan by numeric canister id. */
|
|
1691
|
+
interface SimpleLoanGetByIdRequest {
|
|
1540
1692
|
/** Canister-assigned loan id. */
|
|
1541
1693
|
loanId: bigint;
|
|
1542
1694
|
}
|
|
1543
|
-
/** Lookup request for loading
|
|
1544
|
-
interface
|
|
1695
|
+
/** Lookup request for loading a simple loan by short user-facing reference. */
|
|
1696
|
+
interface SimpleLoanGetByRefRequest {
|
|
1545
1697
|
/** Short user-facing reference derived from `loanId`. */
|
|
1546
1698
|
ref: string;
|
|
1547
1699
|
}
|
|
1548
|
-
/** Lookup request for loading canonical
|
|
1549
|
-
type
|
|
1550
|
-
/** Collateral leg returned by
|
|
1551
|
-
interface
|
|
1700
|
+
/** Lookup request for loading canonical simple loan state. */
|
|
1701
|
+
type SimpleLoanGetRequest = SimpleLoanGetByIdRequest | SimpleLoanGetByRefRequest;
|
|
1702
|
+
/** Collateral leg returned by Simple Loans search. */
|
|
1703
|
+
interface SimpleLoanFindCollateral {
|
|
1552
1704
|
/** Principal text of the collateral pool. */
|
|
1553
1705
|
poolId: string;
|
|
1554
1706
|
/** Asset the user deposits as collateral. */
|
|
1555
|
-
asset:
|
|
1707
|
+
asset: SimpleLoanAsset;
|
|
1556
1708
|
/** Intended credited collateral amount in base units, before inflow fees. */
|
|
1557
1709
|
amount: bigint;
|
|
1558
1710
|
}
|
|
1559
|
-
/** Borrow leg returned by
|
|
1560
|
-
interface
|
|
1711
|
+
/** Borrow leg returned by Simple Loans search. */
|
|
1712
|
+
interface SimpleLoanFindBorrow {
|
|
1561
1713
|
/** Principal text of the borrow pool. */
|
|
1562
1714
|
poolId: string;
|
|
1563
1715
|
/** Asset the user borrows. */
|
|
1564
|
-
asset:
|
|
1716
|
+
asset: SimpleLoanAsset;
|
|
1565
1717
|
}
|
|
1566
|
-
/** Lightweight search result for
|
|
1567
|
-
interface
|
|
1568
|
-
/** Canister-assigned loan id. Use this with `client.
|
|
1718
|
+
/** Lightweight search result for a simple loan match. */
|
|
1719
|
+
interface SimpleLoanFindResult {
|
|
1720
|
+
/** Canister-assigned loan id. Use this with `client.simpleLoans.get({ loanId })` to load full loan state. */
|
|
1569
1721
|
loanId: bigint;
|
|
1570
1722
|
/** Short user-facing reference derived from `loanId`. */
|
|
1571
1723
|
ref: string;
|
|
1572
1724
|
/** Unix creation timestamp in seconds. */
|
|
1573
1725
|
createdAt: bigint;
|
|
1574
1726
|
/** Collateral-side pool, asset, and requested credited amount. */
|
|
1575
|
-
collateral:
|
|
1727
|
+
collateral: SimpleLoanFindCollateral;
|
|
1576
1728
|
/** Borrow-side pool and asset. */
|
|
1577
|
-
borrow:
|
|
1729
|
+
borrow: SimpleLoanFindBorrow;
|
|
1578
1730
|
/** Generated profile principal from the search index. */
|
|
1579
1731
|
profileId: string;
|
|
1580
1732
|
}
|
|
1581
|
-
/** Page request for direct
|
|
1582
|
-
interface
|
|
1733
|
+
/** Page request for direct Simple Loans canister event queries. */
|
|
1734
|
+
interface SimpleLoanListEventsRequest {
|
|
1583
1735
|
/** Event id to start from. */
|
|
1584
1736
|
start: bigint;
|
|
1585
1737
|
/** Maximum number of events to return. */
|
|
1586
1738
|
limit: bigint;
|
|
1587
1739
|
}
|
|
1588
|
-
/** Active
|
|
1589
|
-
interface
|
|
1590
|
-
/** Principal text of the lending canister used by
|
|
1740
|
+
/** Active Simple Loans canister config. */
|
|
1741
|
+
interface SimpleLoanConfig {
|
|
1742
|
+
/** Principal text of the lending canister used by Simple Loans. */
|
|
1591
1743
|
lendingCanisterId: string;
|
|
1592
1744
|
}
|
|
1593
|
-
/** Authentication metadata for warmed
|
|
1594
|
-
interface
|
|
1745
|
+
/** Authentication metadata for warmed Simple Loans profiles. */
|
|
1746
|
+
interface SimpleLoanAuthorization {
|
|
1595
1747
|
type: "EthSignature";
|
|
1596
1748
|
derivationIndex: Uint8Array;
|
|
1597
1749
|
publicKey: Uint8Array;
|
|
1598
1750
|
address: string;
|
|
1599
1751
|
}
|
|
1600
|
-
/** Warmed profile available for a future
|
|
1601
|
-
interface
|
|
1752
|
+
/** Warmed profile available for a future simple loan. */
|
|
1753
|
+
interface SimpleLoanWarmedProfile {
|
|
1602
1754
|
id: bigint;
|
|
1603
|
-
authorization:
|
|
1755
|
+
authorization: SimpleLoanAuthorization;
|
|
1604
1756
|
/** Unix creation timestamp in seconds. */
|
|
1605
1757
|
createdAt: bigint;
|
|
1606
1758
|
profileId: string;
|
|
1607
1759
|
}
|
|
1608
|
-
/** Direct canister event returned by the
|
|
1609
|
-
interface
|
|
1760
|
+
/** Direct canister event returned by the Simple Loans query API. */
|
|
1761
|
+
interface SimpleLoanEvent {
|
|
1610
1762
|
id: bigint;
|
|
1611
1763
|
schemaVersion: number;
|
|
1612
1764
|
/** Unix event timestamp in seconds. */
|
|
1613
1765
|
timestamp: bigint;
|
|
1614
|
-
eventType:
|
|
1766
|
+
eventType: SimpleLoanEventType;
|
|
1615
1767
|
}
|
|
1616
|
-
/**
|
|
1617
|
-
type
|
|
1618
|
-
/**
|
|
1619
|
-
interface
|
|
1768
|
+
/** Simple loan leg used when stuck funds are withdrawn. */
|
|
1769
|
+
type SimpleLoanLeg = "Lend" | "Borrow";
|
|
1770
|
+
/** Simple-loan-created event payload. */
|
|
1771
|
+
interface SimpleLoanCreatedEventType {
|
|
1620
1772
|
type: "LoanCreated";
|
|
1621
1773
|
loanId: bigint;
|
|
1622
|
-
borrowDestination:
|
|
1623
|
-
collateralAsset:
|
|
1774
|
+
borrowDestination: SimpleLoanAccount;
|
|
1775
|
+
collateralAsset: SimpleLoanAsset;
|
|
1624
1776
|
borrowAmount: bigint;
|
|
1625
1777
|
collateralPoolId: string;
|
|
1626
|
-
refundDestination:
|
|
1778
|
+
refundDestination: SimpleLoanAccount;
|
|
1627
1779
|
ltvMaxBps: bigint;
|
|
1628
1780
|
depositWindowSeconds: bigint;
|
|
1629
1781
|
profileId: string;
|
|
1630
1782
|
borrowPoolId: string;
|
|
1631
|
-
borrowAsset:
|
|
1783
|
+
borrowAsset: SimpleLoanAsset;
|
|
1632
1784
|
}
|
|
1633
1785
|
/** Full collateral withdrawal request event payload. */
|
|
1634
|
-
interface
|
|
1786
|
+
interface SimpleLoanFullLendWithdrawalRequestedEventType {
|
|
1635
1787
|
type: "FullLendWithdrawalRequested";
|
|
1636
1788
|
loanId: bigint;
|
|
1637
|
-
account:
|
|
1789
|
+
account: SimpleLoanAccount;
|
|
1638
1790
|
poolId: string;
|
|
1639
1791
|
}
|
|
1640
1792
|
/** Borrow request event payload. */
|
|
1641
|
-
interface
|
|
1793
|
+
interface SimpleLoanBorrowRequestedEventType {
|
|
1642
1794
|
type: "BorrowRequested";
|
|
1643
1795
|
loanId: bigint;
|
|
1644
|
-
account:
|
|
1796
|
+
account: SimpleLoanAccount;
|
|
1645
1797
|
poolId: string;
|
|
1646
1798
|
amount: bigint;
|
|
1647
1799
|
}
|
|
1648
1800
|
/** Deposit timer exceeded event payload. */
|
|
1649
|
-
interface
|
|
1801
|
+
interface SimpleLoanDepositTimerExceededEventType {
|
|
1650
1802
|
type: "DepositTimerExceeded";
|
|
1651
1803
|
loanId: bigint;
|
|
1652
1804
|
}
|
|
1653
1805
|
/** Stuck funds withdrawal request event payload. */
|
|
1654
|
-
interface
|
|
1806
|
+
interface SimpleLoanStuckFundsWithdrawalRequestedEventType {
|
|
1655
1807
|
type: "StuckFundsWithdrawalRequested";
|
|
1656
|
-
leg:
|
|
1808
|
+
leg: SimpleLoanLeg;
|
|
1657
1809
|
loanId: bigint;
|
|
1658
|
-
account:
|
|
1810
|
+
account: SimpleLoanAccount;
|
|
1659
1811
|
poolId: string;
|
|
1660
1812
|
amount: bigint;
|
|
1661
1813
|
}
|
|
1662
1814
|
/** Profile-warmed event payload. */
|
|
1663
|
-
interface
|
|
1815
|
+
interface SimpleLoanProfileWarmedEventType {
|
|
1664
1816
|
type: "ProfileWarmed";
|
|
1665
1817
|
derivationIndex: Uint8Array;
|
|
1666
1818
|
warmedProfileId: bigint;
|
|
@@ -1668,22 +1820,22 @@ interface InstantLoanProfileWarmedEventType {
|
|
|
1668
1820
|
profileId: string;
|
|
1669
1821
|
}
|
|
1670
1822
|
/** Repay-complete event payload. */
|
|
1671
|
-
interface
|
|
1823
|
+
interface SimpleLoanRepayCompleteEventType {
|
|
1672
1824
|
type: "RepayComplete";
|
|
1673
1825
|
loanId: bigint;
|
|
1674
1826
|
profileId: string;
|
|
1675
1827
|
}
|
|
1676
1828
|
/** Deposit timer started event payload. */
|
|
1677
|
-
interface
|
|
1829
|
+
interface SimpleLoanDepositTimerStartedEventType {
|
|
1678
1830
|
type: "DepositTimerStarted";
|
|
1679
1831
|
loanId: bigint;
|
|
1680
1832
|
/** Unix timestamp in seconds when the deposit timer started. */
|
|
1681
1833
|
timestamp: bigint;
|
|
1682
1834
|
}
|
|
1683
|
-
/** Direct canister event payload returned by
|
|
1684
|
-
type
|
|
1835
|
+
/** Direct canister event payload returned by Simple Loans event queries. */
|
|
1836
|
+
type SimpleLoanEventType = SimpleLoanCreatedEventType | SimpleLoanFullLendWithdrawalRequestedEventType | SimpleLoanBorrowRequestedEventType | SimpleLoanDepositTimerExceededEventType | SimpleLoanStuckFundsWithdrawalRequestedEventType | SimpleLoanProfileWarmedEventType | SimpleLoanRepayCompleteEventType | SimpleLoanDepositTimerStartedEventType;
|
|
1685
1837
|
/** Fee-inclusive collateral deposit quote for one transfer target. */
|
|
1686
|
-
interface
|
|
1838
|
+
interface SimpleLoanInitialDepositTargetQuote {
|
|
1687
1839
|
/** Full amount to send to the collateral deposit target, including fee. */
|
|
1688
1840
|
amount: bigint;
|
|
1689
1841
|
/** Inflow fee amount in base units added to the transfer amount. */
|
|
@@ -1692,7 +1844,7 @@ interface InstantLoanInitialDepositTargetQuote {
|
|
|
1692
1844
|
target: SupplyTarget;
|
|
1693
1845
|
}
|
|
1694
1846
|
/** Fee-inclusive repayment quote for one transfer target. */
|
|
1695
|
-
interface
|
|
1847
|
+
interface SimpleLoanRepaymentTargetQuote {
|
|
1696
1848
|
/** Full amount to send to the repayment target, including fee and interest buffer. */
|
|
1697
1849
|
amount: bigint;
|
|
1698
1850
|
/** Inflow fee amount in base units added to the repayment transfer. Falls back to the protocol minimum when live estimation is unavailable. */
|
|
@@ -1703,7 +1855,7 @@ interface InstantLoanRepaymentTargetQuote {
|
|
|
1703
1855
|
target: SupplyTarget;
|
|
1704
1856
|
}
|
|
1705
1857
|
/** Current amount to send to a repayment target to close the debt. */
|
|
1706
|
-
interface
|
|
1858
|
+
interface SimpleLoanRepayment {
|
|
1707
1859
|
/** Decimal scale for `amount`. */
|
|
1708
1860
|
decimals: bigint;
|
|
1709
1861
|
/** Current debt in base units, before fee and interest buffer. */
|
|
@@ -1713,27 +1865,27 @@ interface InstantLoanRepayment {
|
|
|
1713
1865
|
/** Seconds of interest accrual included in `interestBufferAmount`. */
|
|
1714
1866
|
interestBufferSeconds: bigint;
|
|
1715
1867
|
/** Asset to repay. */
|
|
1716
|
-
asset:
|
|
1868
|
+
asset: SimpleLoanAsset;
|
|
1717
1869
|
/** Available repayment targets keyed by the actual transfer chain. */
|
|
1718
|
-
targets: Partial<Record<Chain,
|
|
1870
|
+
targets: Partial<Record<Chain, SimpleLoanRepaymentTargetQuote>>;
|
|
1719
1871
|
}
|
|
1720
|
-
/** Initial collateral deposit quote returned when
|
|
1721
|
-
interface
|
|
1872
|
+
/** Initial collateral deposit quote returned when a simple loan is created. */
|
|
1873
|
+
interface SimpleLoanInitialDeposit {
|
|
1722
1874
|
/** Decimal scale for `amount`, `collateralAmount`, and `inflowFeeAmount`. */
|
|
1723
1875
|
decimals: bigint;
|
|
1724
1876
|
/** Intended credited collateral amount in base units, before inflow fees. */
|
|
1725
1877
|
collateralAmount: bigint;
|
|
1726
1878
|
/** Collateral asset to deposit. */
|
|
1727
|
-
asset:
|
|
1879
|
+
asset: SimpleLoanAsset;
|
|
1728
1880
|
/** Available collateral deposit targets keyed by the actual transfer chain. */
|
|
1729
|
-
targets: Partial<Record<Chain,
|
|
1881
|
+
targets: Partial<Record<Chain, SimpleLoanInitialDepositTargetQuote>>;
|
|
1730
1882
|
/** Unix timestamp in seconds when the collateral deposit was detected, or null before detection. */
|
|
1731
1883
|
detectedTimestamp: bigint | null;
|
|
1732
1884
|
/** Unix timestamp in seconds when the collateral deposit window expires, or null before detection when unavailable. */
|
|
1733
1885
|
expiryTimestamp: bigint | null;
|
|
1734
1886
|
}
|
|
1735
|
-
/** Current lending position backing the
|
|
1736
|
-
interface
|
|
1887
|
+
/** Current lending position backing the simple loan. */
|
|
1888
|
+
interface SimpleLoanPositionSummary {
|
|
1737
1889
|
/** Current collateral amount in the collateral asset's base units. */
|
|
1738
1890
|
collateralAmount: bigint;
|
|
1739
1891
|
/** Decimal scale for `collateralAmount`. */
|
|
@@ -1749,26 +1901,26 @@ interface InstantLoanPositionSummary {
|
|
|
1749
1901
|
/** Borrowed principal plus accrued interest in base units, before repayment buffer. */
|
|
1750
1902
|
totalDebtAmount: bigint;
|
|
1751
1903
|
}
|
|
1752
|
-
/** Immutable terms selected for
|
|
1753
|
-
interface
|
|
1904
|
+
/** Immutable terms selected for a simple loan. */
|
|
1905
|
+
interface SimpleLoanTerms {
|
|
1754
1906
|
/** Maximum loan-to-value ratio in basis points. */
|
|
1755
1907
|
ltvMaxBps: bigint;
|
|
1756
1908
|
/** Seconds allowed for the collateral deposit before timeout. */
|
|
1757
1909
|
depositWindowSeconds: bigint;
|
|
1758
1910
|
}
|
|
1759
|
-
/** Collateral leg selected for
|
|
1760
|
-
interface
|
|
1911
|
+
/** Collateral leg selected for a simple loan. */
|
|
1912
|
+
interface SimpleLoanCollateral {
|
|
1761
1913
|
/** Principal text of the collateral pool. */
|
|
1762
1914
|
poolId: string;
|
|
1763
1915
|
/** Asset deposited as collateral. Transfer rails are exposed by `initialDeposit.targets`. */
|
|
1764
|
-
asset:
|
|
1916
|
+
asset: SimpleLoanAsset;
|
|
1765
1917
|
/** Decimal scale for collateral amounts. */
|
|
1766
1918
|
decimals: bigint;
|
|
1767
1919
|
/** Intended credited collateral amount in base units, before inflow fees. */
|
|
1768
1920
|
amount: bigint;
|
|
1769
1921
|
}
|
|
1770
|
-
/** Borrow leg selected for
|
|
1771
|
-
type
|
|
1922
|
+
/** Borrow leg selected for a simple loan. */
|
|
1923
|
+
type SimpleLoanBorrow = AssetIdentifier & {
|
|
1772
1924
|
/** Principal text of the borrow pool. */
|
|
1773
1925
|
poolId: string;
|
|
1774
1926
|
/** Decimal scale for borrow and debt amounts. */
|
|
@@ -1776,47 +1928,47 @@ type InstantLoanBorrow = AssetIdentifier & {
|
|
|
1776
1928
|
/** Requested borrow amount in base units. */
|
|
1777
1929
|
amount: bigint;
|
|
1778
1930
|
/** Destination that receives the borrowed asset. */
|
|
1779
|
-
destination:
|
|
1931
|
+
destination: SimpleLoanAccount;
|
|
1780
1932
|
};
|
|
1781
|
-
/** Hydrated
|
|
1782
|
-
interface
|
|
1933
|
+
/** Hydrated simple loan state plus generated quote targets. */
|
|
1934
|
+
interface SimpleLoan {
|
|
1783
1935
|
/** Canister-assigned loan id. */
|
|
1784
1936
|
loanId: bigint;
|
|
1785
1937
|
/** Short user-facing reference derived from `loanId`. */
|
|
1786
1938
|
ref: string;
|
|
1787
1939
|
/** Shared lifecycle status for display and flow control. */
|
|
1788
1940
|
status: LiquidiumStatus;
|
|
1789
|
-
/** Generated profile principal used by the
|
|
1941
|
+
/** Generated profile principal used by the simple loan. */
|
|
1790
1942
|
profileId: string;
|
|
1791
1943
|
/** Immutable loan terms. */
|
|
1792
|
-
terms:
|
|
1944
|
+
terms: SimpleLoanTerms;
|
|
1793
1945
|
/** Collateral-side pool, asset, decimals, and requested credited amount. */
|
|
1794
|
-
collateral:
|
|
1946
|
+
collateral: SimpleLoanCollateral;
|
|
1795
1947
|
/** Borrow-side pool, asset, chain, decimals, requested amount, and destination. */
|
|
1796
|
-
borrow:
|
|
1948
|
+
borrow: SimpleLoanBorrow;
|
|
1797
1949
|
/** Destination used for collateral refunds or withdrawals. */
|
|
1798
|
-
refundDestination:
|
|
1950
|
+
refundDestination: SimpleLoanAccount;
|
|
1799
1951
|
/** Current actionable initial collateral deposit quote. */
|
|
1800
|
-
initialDeposit:
|
|
1952
|
+
initialDeposit: SimpleLoanInitialDeposit;
|
|
1801
1953
|
/** Current repayment quote. Amount fields are zero when the loan has no debt. */
|
|
1802
|
-
repayment:
|
|
1954
|
+
repayment: SimpleLoanRepayment;
|
|
1803
1955
|
/** Current lending position state for the generated profile. */
|
|
1804
|
-
position:
|
|
1956
|
+
position: SimpleLoanPositionSummary;
|
|
1805
1957
|
}
|
|
1806
1958
|
|
|
1807
1959
|
/**
|
|
1808
1960
|
* A loan was created remotely, but the SDK could not load its enriched state.
|
|
1809
|
-
* Retry with `
|
|
1961
|
+
* Retry with `simpleLoans.get({ loanId })`; do not create the loan again.
|
|
1810
1962
|
*/
|
|
1811
|
-
declare class
|
|
1812
|
-
readonly code: "
|
|
1963
|
+
declare class SimpleLoanCreatedError extends Error {
|
|
1964
|
+
readonly code: "SIMPLE_LOAN_HYDRATION_FAILED";
|
|
1813
1965
|
readonly loanId: bigint;
|
|
1814
1966
|
readonly ref: string;
|
|
1815
1967
|
readonly cause: unknown;
|
|
1816
1968
|
constructor(loanId: bigint, cause: unknown);
|
|
1817
1969
|
}
|
|
1818
|
-
/** Accountless
|
|
1819
|
-
declare class
|
|
1970
|
+
/** Accountless Simple Loans creation, lookup, recovery, and canister query helpers. */
|
|
1971
|
+
declare class SimpleLoansModule {
|
|
1820
1972
|
private readonly canisterContext;
|
|
1821
1973
|
private readonly apiClient;
|
|
1822
1974
|
private readonly activities;
|
|
@@ -1824,7 +1976,7 @@ declare class InstantLoansModule {
|
|
|
1824
1976
|
private readonly positions;
|
|
1825
1977
|
constructor(canisterContext: CanisterContext, apiClient: ApiClient | undefined, activities: ActivitiesModule, lending: LendingModule, positions: PositionsModule);
|
|
1826
1978
|
/**
|
|
1827
|
-
* Creates a profileless
|
|
1979
|
+
* Creates a profileless simple loan and returns canonical canister state plus
|
|
1828
1980
|
* generated initial-deposit and repayment quote targets.
|
|
1829
1981
|
*
|
|
1830
1982
|
* Choose `collateralPoolId` and `borrowPoolId` from
|
|
@@ -1836,23 +1988,24 @@ declare class InstantLoansModule {
|
|
|
1836
1988
|
* `refund.destination` receives collateral refunds or withdrawals. Use
|
|
1837
1989
|
* `depositWindowSeconds` for the user-facing collateral deposit timeout; the
|
|
1838
1990
|
* SDK maps it to the canister's internal `ltv_timer_s` field.
|
|
1991
|
+
* Pool assets and same-asset borrowing policy are validated before creation.
|
|
1839
1992
|
*
|
|
1840
1993
|
* @param request - Collateral, borrow, refund, LTV limit, timeout, and inflow options.
|
|
1841
1994
|
* @returns Hydrated loan state plus generated initial-deposit and repayment quote targets.
|
|
1842
1995
|
*/
|
|
1843
|
-
create(request:
|
|
1996
|
+
create(request: CreateSimpleLoanRequest): Promise<SimpleLoan>;
|
|
1844
1997
|
/**
|
|
1845
1998
|
* Resolves canonical canister state by loan id or short reference.
|
|
1846
1999
|
*
|
|
1847
2000
|
* References are decoded locally, then the corresponding loan id is loaded
|
|
1848
|
-
* from the
|
|
2001
|
+
* from the Simple Loans canister.
|
|
1849
2002
|
*
|
|
1850
2003
|
* @param request - Canister loan id or short public reference.
|
|
1851
2004
|
* @returns Hydrated loan state plus generated initial-deposit and repayment quote targets.
|
|
1852
2005
|
*/
|
|
1853
|
-
get(request:
|
|
2006
|
+
get(request: SimpleLoanGetRequest): Promise<SimpleLoan>;
|
|
1854
2007
|
/**
|
|
1855
|
-
* Finds
|
|
2008
|
+
* Finds simple loans by short reference, numeric loan id string, address, or transaction id.
|
|
1856
2009
|
*
|
|
1857
2010
|
* Search returns lightweight matches. Call `get({ loanId })` or `get({ ref })`
|
|
1858
2011
|
* when the user selects a match and you need hydrated loan state.
|
|
@@ -1860,27 +2013,27 @@ declare class InstantLoansModule {
|
|
|
1860
2013
|
* @param query - Short reference, address, transaction id/hash, or numeric loan id string.
|
|
1861
2014
|
* @returns Matching loan ids and references from the search index.
|
|
1862
2015
|
*/
|
|
1863
|
-
find(query: string): Promise<
|
|
2016
|
+
find(query: string): Promise<SimpleLoanFindResult[]>;
|
|
1864
2017
|
/**
|
|
1865
|
-
* Returns the active
|
|
2018
|
+
* Returns the active Simple Loans canister config via direct query.
|
|
1866
2019
|
*
|
|
1867
2020
|
* @returns Active canister configuration.
|
|
1868
2021
|
*/
|
|
1869
|
-
getConfig(): Promise<
|
|
2022
|
+
getConfig(): Promise<SimpleLoanConfig>;
|
|
1870
2023
|
/**
|
|
1871
2024
|
* Returns a single canister event by id via direct query.
|
|
1872
2025
|
*
|
|
1873
2026
|
* @param eventId - Event id to load.
|
|
1874
2027
|
* @returns The event when found, otherwise `null`.
|
|
1875
2028
|
*/
|
|
1876
|
-
getEvent(eventId: bigint): Promise<
|
|
2029
|
+
getEvent(eventId: bigint): Promise<SimpleLoanEvent | null>;
|
|
1877
2030
|
/**
|
|
1878
2031
|
* Returns a page of canister events via direct query.
|
|
1879
2032
|
*
|
|
1880
2033
|
* @param request - Start event id and maximum number of events to return.
|
|
1881
2034
|
* @returns Canister events in ascending id order.
|
|
1882
2035
|
*/
|
|
1883
|
-
listEvents(request:
|
|
2036
|
+
listEvents(request: SimpleLoanListEventsRequest): Promise<SimpleLoanEvent[]>;
|
|
1884
2037
|
/**
|
|
1885
2038
|
* Returns principals authorized for protected update callbacks.
|
|
1886
2039
|
*
|
|
@@ -1894,170 +2047,23 @@ declare class InstantLoansModule {
|
|
|
1894
2047
|
*/
|
|
1895
2048
|
countWarmedProfiles(): Promise<bigint>;
|
|
1896
2049
|
/**
|
|
1897
|
-
* Returns warmed profiles currently available for future
|
|
2050
|
+
* Returns warmed profiles currently available for future simple loans.
|
|
1898
2051
|
*
|
|
1899
2052
|
* @returns Warmed profile records available for assignment.
|
|
1900
2053
|
*/
|
|
1901
|
-
listWarmedProfiles(): Promise<
|
|
2054
|
+
listWarmedProfiles(): Promise<SimpleLoanWarmedProfile[]>;
|
|
1902
2055
|
private findCandidateLoansByQuery;
|
|
1903
2056
|
private getLoanRecord;
|
|
1904
2057
|
private mapLoanRecord;
|
|
1905
2058
|
private getCollateralAmountHint;
|
|
1906
2059
|
private hydrateLoan;
|
|
1907
2060
|
private createInitialDepositQuote;
|
|
1908
|
-
private
|
|
2061
|
+
private resolveSimpleLoanInflowTargets;
|
|
1909
2062
|
private createRepaymentTargetQuotes;
|
|
1910
2063
|
private estimateRepaymentInflowFee;
|
|
1911
2064
|
private requireApi;
|
|
1912
|
-
private
|
|
1913
|
-
private
|
|
1914
|
-
}
|
|
1915
|
-
|
|
1916
|
-
/**
|
|
1917
|
-
* Converts a canister loan id into a short user-facing reference.
|
|
1918
|
-
*
|
|
1919
|
-
* @param id - Canister loan id in the supported public-reference range.
|
|
1920
|
-
* @returns Fixed-length public reference string.
|
|
1921
|
-
*/
|
|
1922
|
-
declare function publicIdFromInt(id: bigint): string;
|
|
1923
|
-
/**
|
|
1924
|
-
* Decodes a short user-facing reference back into the canister loan id.
|
|
1925
|
-
*
|
|
1926
|
-
* @param ref - Fixed-length public reference string.
|
|
1927
|
-
* @returns Canister loan id represented by the reference.
|
|
1928
|
-
*/
|
|
1929
|
-
declare function intFromPublicId(ref: string): bigint;
|
|
1930
|
-
|
|
1931
|
-
/** Input for calculating required collateral from a target LTV. */
|
|
1932
|
-
interface QuoteRequest {
|
|
1933
|
-
/** Requested borrow amount in borrow asset base units. */
|
|
1934
|
-
borrowAmount: bigint;
|
|
1935
|
-
/** Pool principal text for the borrow side. */
|
|
1936
|
-
borrowPoolId: string;
|
|
1937
|
-
/** Pool principal text for the collateral side. */
|
|
1938
|
-
collateralPoolId: string;
|
|
1939
|
-
/** Target loan-to-value ratio in basis points. */
|
|
1940
|
-
targetLtvBps: bigint;
|
|
1941
|
-
}
|
|
1942
|
-
/** Input for calculating LTV from explicit borrow and collateral amounts. */
|
|
1943
|
-
interface CalculateLtvRequest {
|
|
1944
|
-
/** Requested borrow amount in borrow asset base units. */
|
|
1945
|
-
borrowAmount: bigint;
|
|
1946
|
-
/** Pool principal text for the borrow side. */
|
|
1947
|
-
borrowPoolId: string;
|
|
1948
|
-
/** Collateral amount in collateral asset base units. */
|
|
1949
|
-
collateralAmount: bigint;
|
|
1950
|
-
/** Pool principal text for the collateral side. */
|
|
1951
|
-
collateralPoolId: string;
|
|
1952
|
-
}
|
|
1953
|
-
/** Validation error produced by quote helpers. */
|
|
1954
|
-
interface QuoteValidationError {
|
|
1955
|
-
/** Stable machine-readable validation code. */
|
|
1956
|
-
code: QuoteValidationErrorCode;
|
|
1957
|
-
/** Human-readable validation message. */
|
|
1958
|
-
message: string;
|
|
1959
|
-
}
|
|
1960
|
-
/** Stable validation codes produced by quote helpers. */
|
|
1961
|
-
declare enum QuoteValidationErrorCode {
|
|
1962
|
-
INVALID_LTV = "INVALID_LTV",
|
|
1963
|
-
LTV_EXCEEDS_MAX = "LTV_EXCEEDS_MAX",
|
|
1964
|
-
SAME_ASSET_NOT_ALLOWED = "SAME_ASSET_NOT_ALLOWED",
|
|
1965
|
-
BORROW_AMOUNT_TOO_LOW = "BORROW_AMOUNT_TOO_LOW",
|
|
1966
|
-
PRICE_NOT_AVAILABLE = "PRICE_NOT_AVAILABLE",
|
|
1967
|
-
POOL_NOT_FOUND = "POOL_NOT_FOUND",
|
|
1968
|
-
UNKNOWN = "UNKNOWN"
|
|
1969
|
-
}
|
|
1970
|
-
/** Non-blocking warning produced by quote helpers. */
|
|
1971
|
-
interface QuoteWarning {
|
|
1972
|
-
/** Stable machine-readable warning code. */
|
|
1973
|
-
code: QuoteWarningCode;
|
|
1974
|
-
/** Human-readable warning message. */
|
|
1975
|
-
message: string;
|
|
1976
|
-
}
|
|
1977
|
-
/** Stable warning codes produced by quote helpers. */
|
|
1978
|
-
declare enum QuoteWarningCode {
|
|
1979
|
-
HIGH_LTV = "HIGH_LTV",
|
|
1980
|
-
SAME_ASSET_BORROWING = "SAME_ASSET_BORROWING"
|
|
1981
|
-
}
|
|
1982
|
-
/** Quote result for a requested borrow amount and target LTV. */
|
|
1983
|
-
interface QuoteResult {
|
|
1984
|
-
/** Requested borrow amount in borrow asset base units. */
|
|
1985
|
-
borrowAmount: bigint;
|
|
1986
|
-
/** Borrow value in internal USD units. */
|
|
1987
|
-
borrowUsd: bigint;
|
|
1988
|
-
/** Required collateral amount in collateral asset base units. */
|
|
1989
|
-
requiredCollateralAmount: bigint;
|
|
1990
|
-
/** Required collateral value in internal USD units. */
|
|
1991
|
-
requiredCollateralUsd: bigint;
|
|
1992
|
-
/** Maximum allowed LTV in basis points for the collateral pool. */
|
|
1993
|
-
maxAllowedLtvBps: bigint;
|
|
1994
|
-
/** Requested target LTV in basis points. */
|
|
1995
|
-
targetLtvBps: bigint;
|
|
1996
|
-
/** Pool principal text for the borrow side. */
|
|
1997
|
-
borrowPoolId: string;
|
|
1998
|
-
/** Pool principal text for the collateral side. */
|
|
1999
|
-
collateralPoolId: string;
|
|
2000
|
-
/** Borrow asset symbol. */
|
|
2001
|
-
borrowAsset: string;
|
|
2002
|
-
/** Collateral asset symbol. */
|
|
2003
|
-
collateralAsset: string;
|
|
2004
|
-
/** Blocking validation errors. Empty when the quote is usable. */
|
|
2005
|
-
validationErrors: QuoteValidationError[];
|
|
2006
|
-
/** Non-blocking quote warnings. */
|
|
2007
|
-
warnings: QuoteWarning[];
|
|
2008
|
-
}
|
|
2009
|
-
/** LTV calculation result for explicit borrow and collateral amounts. */
|
|
2010
|
-
interface LtvCalculation {
|
|
2011
|
-
/** Requested borrow amount in borrow asset base units. */
|
|
2012
|
-
borrowAmount: bigint;
|
|
2013
|
-
/** Collateral amount in collateral asset base units. */
|
|
2014
|
-
collateralAmount: bigint;
|
|
2015
|
-
/** Borrow value in internal USD units. */
|
|
2016
|
-
borrowUsd: bigint;
|
|
2017
|
-
/** Collateral value in internal USD units. */
|
|
2018
|
-
collateralUsd: bigint;
|
|
2019
|
-
/** Computed LTV in basis points. */
|
|
2020
|
-
ltvBps: bigint;
|
|
2021
|
-
/** Maximum allowed LTV in basis points for the collateral pool. */
|
|
2022
|
-
maxAllowedLtvBps: bigint;
|
|
2023
|
-
/** Pool principal text for the borrow side. */
|
|
2024
|
-
borrowPoolId: string;
|
|
2025
|
-
/** Pool principal text for the collateral side. */
|
|
2026
|
-
collateralPoolId: string;
|
|
2027
|
-
/** Borrow asset symbol. */
|
|
2028
|
-
borrowAsset: string;
|
|
2029
|
-
/** Collateral asset symbol. */
|
|
2030
|
-
collateralAsset: string;
|
|
2031
|
-
/** Blocking validation errors. Empty when the calculation is usable. */
|
|
2032
|
-
validationErrors: QuoteValidationError[];
|
|
2033
|
-
}
|
|
2034
|
-
|
|
2035
|
-
/** Pure quote helpers for LTV and required-collateral calculations. */
|
|
2036
|
-
declare class QuoteModule {
|
|
2037
|
-
/**
|
|
2038
|
-
* Calculates current LTV from caller-supplied borrow and collateral amounts.
|
|
2039
|
-
*
|
|
2040
|
-
* Amount fields are base units. USD fields are scaled to 8 decimal places.
|
|
2041
|
-
*
|
|
2042
|
-
* @param request - Borrow and collateral pool ids plus base-unit amounts.
|
|
2043
|
-
* @param pools - Available pools, usually from `client.market.listPools()`.
|
|
2044
|
-
* @param prices - USD price map, usually from `client.market.getAssetPrices()`.
|
|
2045
|
-
* @returns LTV calculation plus validation errors when inputs are unusable.
|
|
2046
|
-
*/
|
|
2047
|
-
calculateLtv(request: CalculateLtvRequest, pools: Pool[], prices: AssetPrices): LtvCalculation;
|
|
2048
|
-
/**
|
|
2049
|
-
* Calculates a loan quote based on borrow amount, LTV, and pool selections.
|
|
2050
|
-
*
|
|
2051
|
-
* All arithmetic is performed in bigint. `requiredCollateralAmount` and
|
|
2052
|
-
* `requiredCollateralUsd` are rounded UP so the caller never under-collateralizes
|
|
2053
|
-
* due to integer truncation. `borrowUsd` is floored for display.
|
|
2054
|
-
*
|
|
2055
|
-
* @param request - Quote request parameters.
|
|
2056
|
-
* @param pools - All available pools (use MarketModule.listPools() to fetch).
|
|
2057
|
-
* @param prices - Asset prices in USD (use MarketModule.getAssetPrices() to fetch).
|
|
2058
|
-
* @returns Quote result with required collateral and validation state.
|
|
2059
|
-
*/
|
|
2060
|
-
getQuote(request: QuoteRequest, pools: Pool[], prices: AssetPrices): QuoteResult;
|
|
2065
|
+
private validateSimpleLoanLtvPolicy;
|
|
2066
|
+
private calculateSimpleLoanLtv;
|
|
2061
2067
|
}
|
|
2062
2068
|
|
|
2063
2069
|
/**
|
|
@@ -2078,8 +2084,8 @@ declare class LiquidiumClient {
|
|
|
2078
2084
|
readonly activities: ActivitiesModule;
|
|
2079
2085
|
/** Pool and user history through the Liquidium SDK API. */
|
|
2080
2086
|
readonly history: HistoryModule;
|
|
2081
|
-
/** Accountless
|
|
2082
|
-
readonly
|
|
2087
|
+
/** Accountless Simple Loans backed by generated deposit/repay targets. */
|
|
2088
|
+
readonly simpleLoans: SimpleLoansModule;
|
|
2083
2089
|
/** Pure quote helpers from market inputs. */
|
|
2084
2090
|
readonly quote: QuoteModule;
|
|
2085
2091
|
private readonly canisterContext;
|
|
@@ -2230,4 +2236,4 @@ interface ExecuteWithOptions {
|
|
|
2230
2236
|
*/
|
|
2231
2237
|
declare function executeWith(options: ExecuteWithOptions): <TResult>(action: WalletAction<TResult>) => Promise<TResult>;
|
|
2232
2238
|
|
|
2233
|
-
export { AccountsModule, ActivitiesModule, type Activity, ActivityFilter, type ActivityStatusFoundResponse, type ActivityStatusNotFoundResponse, type ActivityTopUp, Asset, type AssetIdentifier, type AssetPrices, type BaseGetActivityStatusRequest, type BaseListActivitiesRequest, type BorrowAction, type BorrowOutflowDetails, type BorrowingPower, CK_ETH_DEPOSIT_CONTRACT_ADDRESS, type CalculateLtvRequest, type CanisterIdOverrides, type CanisterIds, Chain, type ChainAddressAccount, type ContractInteractionSupplyFlowRequest, type CreateAccountAction, type CreateAccountData, type CreateAccountRequest, type CreateBorrowData, type CreateBorrowRequest, type
|
|
2239
|
+
export { AccountsModule, ActivitiesModule, type Activity, ActivityFilter, type ActivityStatusFoundResponse, type ActivityStatusNotFoundResponse, type ActivityTopUp, Asset, type AssetIdentifier, type AssetPrices, type BaseGetActivityStatusRequest, type BaseListActivitiesRequest, type BorrowAction, type BorrowOutflowDetails, type BorrowingPower, CK_ETH_DEPOSIT_CONTRACT_ADDRESS, type CalculateLtvRequest, type CanisterIdOverrides, type CanisterIds, Chain, type ChainAddressAccount, type ContractInteractionSupplyFlowRequest, type CreateAccountAction, type CreateAccountData, type CreateAccountRequest, type CreateBorrowData, type CreateBorrowRequest, type CreateProfileParams, type CreateSimpleLoanBorrow, type CreateSimpleLoanCollateral, type CreateSimpleLoanRefund, type CreateSimpleLoanRequest, type CreateTransferErc20TransactionParams, type CreateWithdrawData, type CreateWithdrawRequest, Environment, type EstimateInflowFeeRequest, type EthTransactionRequest, type EvmContractTransaction, type EvmReadClient, EvmSupplyApprovalStrategy, type EvmSupplyContext, type ExecuteWithOptions, type FindPoolQuery, type FullWithdrawAmount, type GetActivityStatusByProfileRequest, type GetActivityStatusByShortRefRequest, type GetActivityStatusRequest, type GetActivityStatusResponse, type GetDepositAddressRequest, type GetEvmSupplyContextRequest, type HealthFactor, HistoryModule, type IcPrincipalAccount, type IcpAccountIdentifierAccount, type IcrcAccount, type IcrcTransferDetails, type InflowActivity, type InflowActivityOperation, type InflowActivityStatus, type InflowFeeEstimate, type InflowOperation, LendingModule, type LiquidiumAccount, type LiquidiumAccountInput, type LiquidiumAccountReference, LiquidiumAccountType, 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, MarketModule, type MaxRepayAmount, type MinimumBorrowAsset, type MinimumWithdrawAsset, type OutflowActivity, type OutflowActivityOperation, type OutflowActivityStatus, type OutflowDetails, OutflowType, type PaginatedResponse, type Pool, type PoolCanisterIds, 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 SendIcrcTransferRequest, type SignMessageRequest, type SignMessageWalletAction, type SignatureInfo, type SigningChain, type SimpleLoan, type SimpleLoanAccount, type SimpleLoanAsset, type SimpleLoanAuthorization, type SimpleLoanBorrow, type SimpleLoanBorrowRequestedEventType, type SimpleLoanCollateral, type SimpleLoanConfig, SimpleLoanCreatedError, type SimpleLoanCreatedEventType, type SimpleLoanDepositTimerExceededEventType, type SimpleLoanDepositTimerStartedEventType, type SimpleLoanDestination, type SimpleLoanEvent, type SimpleLoanEventType, type SimpleLoanFindBorrow, type SimpleLoanFindCollateral, type SimpleLoanFindResult, type SimpleLoanFullLendWithdrawalRequestedEventType, type SimpleLoanGetByIdRequest, type SimpleLoanGetByRefRequest, type SimpleLoanGetRequest, type SimpleLoanInitialDeposit, type SimpleLoanInitialDepositTargetQuote, type SimpleLoanLeg, type SimpleLoanListEventsRequest, type SimpleLoanPositionSummary, type SimpleLoanProfileWarmedEventType, type SimpleLoanRepayCompleteEventType, type SimpleLoanRepayment, type SimpleLoanRepaymentTargetQuote, type SimpleLoanStuckFundsWithdrawalRequestedEventType, type SimpleLoanTerms, type SimpleLoanWarmedProfile, SimpleLoansModule, type SubmitInflowRequest, type SubmitInflowResponse, type SubmitSupplyFlowInflowRequest, SupplyAction, type SupplyFlow, type SupplyFlowRequest, SupplyPlanType, type SupplyTarget, 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, createTransferErc20Transaction, executeWith, getMinimumBorrowAmount, getMinimumWithdrawAmount, intFromPublicId, isAssetIdentifier, publicIdFromInt };
|