@kasufinance/kasu-sdk 2.8.0 → 2.10.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.
Files changed (91) hide show
  1. package/README.md +120 -9
  2. package/dist/bundle.cjs.js +2077 -476
  3. package/dist/bundle.esm.js +2039 -478
  4. package/dist/domain/batch-proof.d.ts +210 -0
  5. package/dist/domain/batch-proof.js +384 -0
  6. package/dist/domain/batch-proof.js.map +1 -0
  7. package/dist/domain/explorer-urls.d.ts +33 -0
  8. package/dist/domain/explorer-urls.js +38 -0
  9. package/dist/domain/explorer-urls.js.map +1 -0
  10. package/dist/domain/fixed-term.d.ts +74 -0
  11. package/dist/domain/fixed-term.js +86 -0
  12. package/dist/domain/fixed-term.js.map +1 -0
  13. package/dist/domain/index.d.ts +12 -2
  14. package/dist/domain/index.js +7 -2
  15. package/dist/domain/index.js.map +1 -1
  16. package/dist/domain/partners.d.ts +29 -0
  17. package/dist/domain/partners.js +20 -0
  18. package/dist/domain/partners.js.map +1 -1
  19. package/dist/domain/requests.d.ts +24 -0
  20. package/dist/domain/requests.js +33 -0
  21. package/dist/domain/requests.js.map +1 -1
  22. package/dist/domain/sponsored-calls.d.ts +74 -0
  23. package/dist/domain/sponsored-calls.js +156 -0
  24. package/dist/domain/sponsored-calls.js.map +1 -0
  25. package/dist/domain/yields.d.ts +121 -0
  26. package/dist/domain/yields.js +151 -0
  27. package/dist/domain/yields.js.map +1 -0
  28. package/dist/facade/calls.d.ts +59 -0
  29. package/dist/facade/calls.js +89 -0
  30. package/dist/facade/calls.js.map +1 -0
  31. package/dist/facade/chain-configs.js +5 -0
  32. package/dist/facade/chain-configs.js.map +1 -1
  33. package/dist/facade/flows.d.ts +24 -3
  34. package/dist/facade/flows.js +22 -2
  35. package/dist/facade/flows.js.map +1 -1
  36. package/dist/facade/index.d.ts +3 -1
  37. package/dist/facade/index.js +1 -0
  38. package/dist/facade/index.js.map +1 -1
  39. package/dist/facade/kasu.d.ts +8 -2
  40. package/dist/facade/kasu.js +17 -5
  41. package/dist/facade/kasu.js.map +1 -1
  42. package/dist/facade/strategies.d.ts +43 -2
  43. package/dist/facade/strategies.js +80 -4
  44. package/dist/facade/strategies.js.map +1 -1
  45. package/dist/facade/types.d.ts +18 -0
  46. package/dist/flows/batch-errors.d.ts +74 -0
  47. package/dist/flows/batch-errors.js +83 -0
  48. package/dist/flows/batch-errors.js.map +1 -0
  49. package/dist/flows/batch-submission.d.ts +223 -0
  50. package/dist/flows/batch-submission.js +321 -0
  51. package/dist/flows/batch-submission.js.map +1 -0
  52. package/dist/flows/deposit-flow.d.ts +13 -20
  53. package/dist/flows/deposit-flow.js +14 -25
  54. package/dist/flows/deposit-flow.js.map +1 -1
  55. package/dist/flows/index.d.ts +6 -2
  56. package/dist/flows/index.js +4 -2
  57. package/dist/flows/index.js.map +1 -1
  58. package/dist/flows/withdraw-flow.d.ts +95 -4
  59. package/dist/flows/withdraw-flow.js +107 -2
  60. package/dist/flows/withdraw-flow.js.map +1 -1
  61. package/dist/services/DataService/queries.js +1 -0
  62. package/dist/services/DataService/queries.js.map +1 -1
  63. package/dist/services/Portfolio/portfolio.js +11 -0
  64. package/dist/services/Portfolio/portfolio.js.map +1 -1
  65. package/dist/services/UserLending/user-lending.d.ts +13 -0
  66. package/dist/services/UserLending/user-lending.js +25 -4
  67. package/dist/services/UserLending/user-lending.js.map +1 -1
  68. package/package.json +1 -1
  69. package/src/domain/batch-proof.ts +576 -0
  70. package/src/domain/explorer-urls.ts +74 -0
  71. package/src/domain/fixed-term.ts +115 -0
  72. package/src/domain/index.ts +56 -0
  73. package/src/domain/partners.ts +35 -0
  74. package/src/domain/requests.ts +37 -0
  75. package/src/domain/sponsored-calls.ts +213 -0
  76. package/src/domain/yields.ts +189 -0
  77. package/src/facade/calls.ts +135 -0
  78. package/src/facade/chain-configs.ts +5 -0
  79. package/src/facade/flows.ts +23 -2
  80. package/src/facade/index.ts +3 -0
  81. package/src/facade/kasu.ts +31 -2
  82. package/src/facade/strategies.ts +98 -7
  83. package/src/facade/types.ts +19 -0
  84. package/src/flows/batch-errors.ts +118 -0
  85. package/src/flows/batch-submission.ts +511 -0
  86. package/src/flows/deposit-flow.ts +27 -33
  87. package/src/flows/index.ts +33 -2
  88. package/src/flows/withdraw-flow.ts +219 -10
  89. package/src/services/DataService/queries.ts +1 -0
  90. package/src/services/Portfolio/portfolio.ts +14 -0
  91. package/src/services/UserLending/user-lending.ts +38 -10
@@ -0,0 +1,38 @@
1
+ import { utils } from 'ethers';
2
+ const TX_HASH = /^0x[0-9a-fA-F]{64}$/;
3
+ const ADDRESS = /^0x[0-9a-fA-F]{40}$/;
4
+ /** `https://host[:port][/path]`, no query, fragment, credentials or space. */
5
+ const HTTPS_BASE = /^https:\/\/[A-Za-z0-9.-]+(:[0-9]{1,5})?(\/[A-Za-z0-9._~\-/]*)?$/;
6
+ function explorerBase(config) {
7
+ // Read defensively: a custom config written before 2.10.0 has no field,
8
+ // and TypeScript only tells its author once they bump.
9
+ const base = config === null || config === void 0 ? void 0 : config.blockExplorerUrl;
10
+ if (typeof base !== 'string' || !HTTPS_BASE.test(base)) {
11
+ throw new Error('explorer url: the chain config has no valid https blockExplorerUrl');
12
+ }
13
+ return base.replace(/\/+$/, '');
14
+ }
15
+ /**
16
+ * `<blockExplorerUrl>/tx/<txHash>`. Throws unless `txHash` is exactly `0x`
17
+ * followed by 64 hex digits.
18
+ */
19
+ export function explorerTxUrl(config, txHash) {
20
+ if (typeof txHash !== 'string' || !TX_HASH.test(txHash)) {
21
+ throw new Error('explorerTxUrl: not a 32-byte 0x-prefixed hex hash');
22
+ }
23
+ return `${explorerBase(config)}/tx/${txHash}`;
24
+ }
25
+ /**
26
+ * `<blockExplorerUrl>/address/<address>`, the address as given. Throws unless
27
+ * `address` is `0x` followed by 40 hex digits with a valid checksum when it
28
+ * is mixed-case (all-lower and all-upper carry no checksum and are accepted).
29
+ */
30
+ export function explorerAddressUrl(config, address) {
31
+ if (typeof address !== 'string' ||
32
+ !ADDRESS.test(address) ||
33
+ !utils.isAddress(address)) {
34
+ throw new Error('explorerAddressUrl: not a valid 0x-prefixed address');
35
+ }
36
+ return `${explorerBase(config)}/address/${address}`;
37
+ }
38
+ //# sourceMappingURL=explorer-urls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"explorer-urls.js","sourceRoot":"","sources":["../../src/domain/explorer-urls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AA0B/B,MAAM,OAAO,GAAG,qBAAqB,CAAC;AACtC,MAAM,OAAO,GAAG,qBAAqB,CAAC;AACtC,8EAA8E;AAC9E,MAAM,UAAU,GACZ,iEAAiE,CAAC;AAEtE,SAAS,YAAY,CAAC,MAAsB;IACxC,wEAAwE;IACxE,uDAAuD;IACvD,MAAM,IAAI,GAAI,MAAqD,aAArD,MAAM,uBAAN,MAAM,CACd,gBAAgB,CAAC;IACvB,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CACX,oEAAoE,CACvE,CAAC;IACN,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,MAAsB,EAAE,MAAc;IAChE,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,OAAO,MAAM,EAAE,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAC9B,MAAsB,EACtB,OAAe;IAEf,IACI,OAAO,OAAO,KAAK,QAAQ;QAC3B,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,EAC3B,CAAC;QACC,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,YAAY,OAAO,EAAE,CAAC;AACxD,CAAC"}
@@ -0,0 +1,74 @@
1
+ import { TrancheData } from '../services/DataService/types';
2
+ /**
3
+ * Fixed-term deposits. A fixed-term config locks a deposit for N epochs in
4
+ * exchange for a fixed rate. The configs ride on `TrancheData.fixedTermConfig`;
5
+ * `'0'` is the variable-rate sentinel (no lock) that `requestDepositWithKyc`
6
+ * takes as `fixedTermConfigId`.
7
+ *
8
+ * Numbers only. Turning a lock into "12 months" or "3 weeks" is copy, and
9
+ * stays in each application — what lives here is the arithmetic both of those
10
+ * strings have to agree on, so a selector and a details table can never state
11
+ * one term two ways.
12
+ */
13
+ /** One fixed-term config, exactly as `TrancheData` carries it. */
14
+ export type FixedTermConfig = TrancheData['fixedTermConfig'][number];
15
+ /**
16
+ * One epoch's nominal length in days. A lock is counted in epochs, and the
17
+ * loan-agreement text states its term from the same 7-day epoch.
18
+ */
19
+ export declare const DAYS_PER_EPOCH = 7;
20
+ /**
21
+ * The average calendar month, 365.25 / 12. A lock is counted in epochs, so a
22
+ * "12-month" term is 52 epochs = 364 days, and only the average-month divisor
23
+ * lands that on 12 (364 / 30.4375 = 11.96 → 12).
24
+ */
25
+ export declare const DAYS_PER_MONTH = 30.4375;
26
+ /**
27
+ * The shortest lock stated in months. Below it a term reads in weeks or days,
28
+ * so nothing may claim a month count for it — a 3-epoch lock is 21 days, which
29
+ * the average-month divisor would otherwise round UP to one month.
30
+ */
31
+ export declare const MIN_DAYS_FOR_MONTHS = 30;
32
+ /**
33
+ * `'0'`, empty or absent is the variable-rate sentinel, not a fixed term.
34
+ * Every surface that tags a rate "variable" or "fixed" must derive the tag
35
+ * through this, so no screen can hardcode a tag that contradicts the rate
36
+ * beside it.
37
+ */
38
+ export declare function isFixedTermConfigId(configId: string | null | undefined): boolean;
39
+ /**
40
+ * The fixed-term configs this wallet may actually select on a tranche: a
41
+ * config open to `Everyone`, or an `AllowlistedOnly` config whose allowlist
42
+ * names the wallet. Anything else is dropped (hide-ineligible): the contract
43
+ * refuses a deposit into an allowlisted config from a wallet that is not on
44
+ * it, so offering one is offering a transaction that reverts.
45
+ *
46
+ * Address matching is case-insensitive. An allowlist entry whose
47
+ * `isAllowlisted` is `false` is a wallet that was REMOVED — the subgraph keeps
48
+ * the entity and flips the flag — so it does not count. An entry that carries
49
+ * no flag at all counts by its presence, which is how every entry read before
50
+ * 2.9.0 arrived (the query did not select the field).
51
+ *
52
+ * `address` `null` / `undefined` — no wallet yet — sees only the `Everyone`
53
+ * configs. Order is the tranche's own.
54
+ */
55
+ export declare function availableFixedTermConfigs(tranche: Pick<TrancheData, 'fixedTermConfig'> | null | undefined, address: string | null | undefined): FixedTermConfig[];
56
+ /**
57
+ * A lock's length in days: `epochLockDuration × 7`.
58
+ *
59
+ * FAILS CLOSED: an unparseable, non-finite, zero or negative epoch count
60
+ * returns `NaN`, never `0` — a zero-day lock is not a term, and a consumer
61
+ * that rendered it would state one.
62
+ *
63
+ * @param epochLockDuration the config's `epochLockDuration`, a decimal string.
64
+ */
65
+ export declare function lockDurationDays(epochLockDuration: string): number;
66
+ /**
67
+ * A lock in WHOLE months, or `null` when the epoch count is not a positive
68
+ * number or the lock is shorter than `MIN_DAYS_FOR_MONTHS`.
69
+ *
70
+ * Unlike a year-rounding formatter it never rolls up into years: a 104-epoch
71
+ * lock is 24 months. A consumer that states years does that conversion in its
72
+ * own words.
73
+ */
74
+ export declare function lockDurationMonths(epochLockDuration: string): number | null;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * One epoch's nominal length in days. A lock is counted in epochs, and the
3
+ * loan-agreement text states its term from the same 7-day epoch.
4
+ */
5
+ export const DAYS_PER_EPOCH = 7;
6
+ /**
7
+ * The average calendar month, 365.25 / 12. A lock is counted in epochs, so a
8
+ * "12-month" term is 52 epochs = 364 days, and only the average-month divisor
9
+ * lands that on 12 (364 / 30.4375 = 11.96 → 12).
10
+ */
11
+ export const DAYS_PER_MONTH = 30.4375;
12
+ /**
13
+ * The shortest lock stated in months. Below it a term reads in weeks or days,
14
+ * so nothing may claim a month count for it — a 3-epoch lock is 21 days, which
15
+ * the average-month divisor would otherwise round UP to one month.
16
+ */
17
+ export const MIN_DAYS_FOR_MONTHS = 30;
18
+ /**
19
+ * `'0'`, empty or absent is the variable-rate sentinel, not a fixed term.
20
+ * Every surface that tags a rate "variable" or "fixed" must derive the tag
21
+ * through this, so no screen can hardcode a tag that contradicts the rate
22
+ * beside it.
23
+ */
24
+ export function isFixedTermConfigId(configId) {
25
+ if (configId == null)
26
+ return false;
27
+ const trimmed = configId.trim();
28
+ return trimmed !== '' && trimmed !== '0';
29
+ }
30
+ /**
31
+ * The fixed-term configs this wallet may actually select on a tranche: a
32
+ * config open to `Everyone`, or an `AllowlistedOnly` config whose allowlist
33
+ * names the wallet. Anything else is dropped (hide-ineligible): the contract
34
+ * refuses a deposit into an allowlisted config from a wallet that is not on
35
+ * it, so offering one is offering a transaction that reverts.
36
+ *
37
+ * Address matching is case-insensitive. An allowlist entry whose
38
+ * `isAllowlisted` is `false` is a wallet that was REMOVED — the subgraph keeps
39
+ * the entity and flips the flag — so it does not count. An entry that carries
40
+ * no flag at all counts by its presence, which is how every entry read before
41
+ * 2.9.0 arrived (the query did not select the field).
42
+ *
43
+ * `address` `null` / `undefined` — no wallet yet — sees only the `Everyone`
44
+ * configs. Order is the tranche's own.
45
+ */
46
+ export function availableFixedTermConfigs(tranche, address) {
47
+ if (!tranche)
48
+ return [];
49
+ const lower = address === null || address === void 0 ? void 0 : address.toLowerCase();
50
+ return tranche.fixedTermConfig.filter((config) => config.fixedTermDepositStatus === 'Everyone' ||
51
+ (lower != null &&
52
+ lower !== '' &&
53
+ config.fixedTermDepositAllowlist.some((entry) => entry.isAllowlisted !==
54
+ false && entry.userId.toLowerCase() === lower)));
55
+ }
56
+ /**
57
+ * A lock's length in days: `epochLockDuration × 7`.
58
+ *
59
+ * FAILS CLOSED: an unparseable, non-finite, zero or negative epoch count
60
+ * returns `NaN`, never `0` — a zero-day lock is not a term, and a consumer
61
+ * that rendered it would state one.
62
+ *
63
+ * @param epochLockDuration the config's `epochLockDuration`, a decimal string.
64
+ */
65
+ export function lockDurationDays(epochLockDuration) {
66
+ const epochs = parseFloat(epochLockDuration);
67
+ if (!Number.isFinite(epochs) || epochs <= 0)
68
+ return NaN;
69
+ return epochs * DAYS_PER_EPOCH;
70
+ }
71
+ /**
72
+ * A lock in WHOLE months, or `null` when the epoch count is not a positive
73
+ * number or the lock is shorter than `MIN_DAYS_FOR_MONTHS`.
74
+ *
75
+ * Unlike a year-rounding formatter it never rolls up into years: a 104-epoch
76
+ * lock is 24 months. A consumer that states years does that conversion in its
77
+ * own words.
78
+ */
79
+ export function lockDurationMonths(epochLockDuration) {
80
+ const days = lockDurationDays(epochLockDuration);
81
+ if (Number.isNaN(days) || days < MIN_DAYS_FOR_MONTHS)
82
+ return null;
83
+ const months = Math.round(days / DAYS_PER_MONTH);
84
+ return months > 0 ? months : null;
85
+ }
86
+ //# sourceMappingURL=fixed-term.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-term.js","sourceRoot":"","sources":["../../src/domain/fixed-term.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAEhC;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAEtC;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAC/B,QAAmC;IAEnC,IAAI,QAAQ,IAAI,IAAI;QAAE,OAAO,KAAK,CAAC;IACnC,MAAM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CAAC,CAAC;IACjD,OAAO,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACtC,CAAC"}
@@ -22,22 +22,32 @@
22
22
  export { apyToEpochRate, epochRateToApy, EPOCHS_IN_YEAR, netEffectiveApy, } from './rates';
23
23
  export { AU_ALPHA3, AU_MIN_CUMULATIVE_BY_STABLE, auMinimumRemaining, auThresholdFor, isAuMinimumExempt, isAustralianKyc, parseMinorUnits, } from './au-minimum';
24
24
  export type { AuMinimumInput } from './au-minimum';
25
+ export { DepositBatchMismatchError, ENTRY_POINT_V07, proveDepositInReceipt, proveUserOperationInReceipt, validateDepositBatchCalls, } from './batch-proof';
26
+ export type { DepositBatchCall, DepositBatchExpectation, DepositProof, DepositProofExpectation, ReceiptLike, ReceiptLog, UserOperationProof, UserOperationProofExpectation, ValidatedDepositBatch, } from './batch-proof';
25
27
  export { ceilToCents, floorToCents, isBelowMinimumCapacity, MAX_LENDING_AMOUNT_FALLBACK, MIN_LENDING_AMOUNT_FALLBACK, parseTrancheBound, resolveBoundShortcuts, resolveDepositBounds, } from './deposit-bounds';
26
28
  export type { BoundShortcuts, DepositBounds } from './deposit-bounds';
27
- export { APXIUM, getCreditOriginator, getInstitutionalLender, INVOICEMATE, RIXON_CAPITAL, } from './partners';
29
+ export { explorerAddressUrl, explorerTxUrl } from './explorer-urls';
30
+ export type { ExplorerConfig } from './explorer-urls';
31
+ export { availableFixedTermConfigs, DAYS_PER_EPOCH, DAYS_PER_MONTH, isFixedTermConfigId, lockDurationDays, lockDurationMonths, MIN_DAYS_FOR_MONTHS, } from './fixed-term';
32
+ export type { FixedTermConfig } from './fixed-term';
33
+ export { APXIUM, getCreditOriginator, getInstitutionalLender, getStrategyRegion, INVOICEMATE, RIXON_CAPITAL, } from './partners';
28
34
  export type { PoolNameSignal, StrategyPartner } from './partners';
29
35
  export { asContractType, buildContractVersionType, buildFullNameRequestMessage, buildLegacyContractRequestMessage, buildLoanAgreementSignMessage, encodeDepositData, formatSignTimestampUtc, parseFormattedMessage, } from './loan-contract';
30
36
  export type { ContractListItem, ContractSection, ContractType, ExemptLoanContract, GenerateContractResponse, LoanContractFormatted, ResolvedContractResponse, RetailLoanContract, } from './loan-contract';
31
37
  export { maxNetRateCeiling, pickHighestYieldTranche, poolMaxApy, selectVisiblePools, } from './pools';
32
38
  export type { BestTranche } from './pools';
33
- export { countSubmissions, deriveRequestState, firstSubmissionTimestamp, isCycleClosed, lastEventTimestamp, submissionEvents, } from './requests';
39
+ export { cancelDeadline, countSubmissions, deriveRequestState, firstSubmissionTimestamp, isCycleClosed, lastEventTimestamp, submissionEvents, } from './requests';
34
40
  export type { RequestKind, RequestState, RequestStatusCode, } from './requests';
35
41
  export { decodeRevert, extractRevertData } from './revert-errors';
36
42
  export type { DecodedRevert, RevertFamily } from './revert-errors';
37
43
  export { CLEARING_WINDOW_SECONDS, computeSettlementWindow, deriveCycleDates, nextCycleBoundary, } from './settlement';
38
44
  export type { CycleDates, SettlementWindowInput, SettlementWindowState, } from './settlement';
45
+ export { encodeCancelDepositCall, encodeCancelWithdrawalCall, encodeRequestWithdrawalCall, encodeWithdrawAtExpiryCall, SPONSORED_CALL_KINDS, SPONSORED_CALL_SELECTORS, SponsoredCallInputError, } from './sponsored-calls';
46
+ export type { SponsoredCall, SponsoredCallKind } from './sponsored-calls';
39
47
  export { getTrancheDisplayName, UPPER_MEZZANINE } from './tranche-display-name';
40
48
  export { compareTrancheSeniority, derivePoolStatus, MIN_TRANCHE_CAPACITY, netTrancheApyBounds, pickDefaultTrancheId, poolAllTranchesFull, trancheApyBounds, trancheHasCapacity, trancheRiskRank, } from './tranches';
41
49
  export type { ApyBounds, PoolStatus, TrancheCapacitySignal, } from './tranches';
42
50
  export { classifyWalletFailure, isUnpredictableGas, isUserRejected, } from './wallet-errors';
43
51
  export type { WalletFailure } from './wallet-errors';
52
+ export { accruedInterest, dailyInterest, projectedAnnualEarnings, SECONDS_PER_WEEK, weeklyInterest, weightedAverageApy, } from './yields';
53
+ export type { InterestSlice, PoolAccrual } from './yields';
@@ -21,14 +21,19 @@
21
21
  */
22
22
  export { apyToEpochRate, epochRateToApy, EPOCHS_IN_YEAR, netEffectiveApy, } from './rates';
23
23
  export { AU_ALPHA3, AU_MIN_CUMULATIVE_BY_STABLE, auMinimumRemaining, auThresholdFor, isAuMinimumExempt, isAustralianKyc, parseMinorUnits, } from './au-minimum';
24
+ export { DepositBatchMismatchError, ENTRY_POINT_V07, proveDepositInReceipt, proveUserOperationInReceipt, validateDepositBatchCalls, } from './batch-proof';
24
25
  export { ceilToCents, floorToCents, isBelowMinimumCapacity, MAX_LENDING_AMOUNT_FALLBACK, MIN_LENDING_AMOUNT_FALLBACK, parseTrancheBound, resolveBoundShortcuts, resolveDepositBounds, } from './deposit-bounds';
25
- export { APXIUM, getCreditOriginator, getInstitutionalLender, INVOICEMATE, RIXON_CAPITAL, } from './partners';
26
+ export { explorerAddressUrl, explorerTxUrl } from './explorer-urls';
27
+ export { availableFixedTermConfigs, DAYS_PER_EPOCH, DAYS_PER_MONTH, isFixedTermConfigId, lockDurationDays, lockDurationMonths, MIN_DAYS_FOR_MONTHS, } from './fixed-term';
28
+ export { APXIUM, getCreditOriginator, getInstitutionalLender, getStrategyRegion, INVOICEMATE, RIXON_CAPITAL, } from './partners';
26
29
  export { asContractType, buildContractVersionType, buildFullNameRequestMessage, buildLegacyContractRequestMessage, buildLoanAgreementSignMessage, encodeDepositData, formatSignTimestampUtc, parseFormattedMessage, } from './loan-contract';
27
30
  export { maxNetRateCeiling, pickHighestYieldTranche, poolMaxApy, selectVisiblePools, } from './pools';
28
- export { countSubmissions, deriveRequestState, firstSubmissionTimestamp, isCycleClosed, lastEventTimestamp, submissionEvents, } from './requests';
31
+ export { cancelDeadline, countSubmissions, deriveRequestState, firstSubmissionTimestamp, isCycleClosed, lastEventTimestamp, submissionEvents, } from './requests';
29
32
  export { decodeRevert, extractRevertData } from './revert-errors';
30
33
  export { CLEARING_WINDOW_SECONDS, computeSettlementWindow, deriveCycleDates, nextCycleBoundary, } from './settlement';
34
+ export { encodeCancelDepositCall, encodeCancelWithdrawalCall, encodeRequestWithdrawalCall, encodeWithdrawAtExpiryCall, SPONSORED_CALL_KINDS, SPONSORED_CALL_SELECTORS, SponsoredCallInputError, } from './sponsored-calls';
31
35
  export { getTrancheDisplayName, UPPER_MEZZANINE } from './tranche-display-name';
32
36
  export { compareTrancheSeniority, derivePoolStatus, MIN_TRANCHE_CAPACITY, netTrancheApyBounds, pickDefaultTrancheId, poolAllTranchesFull, trancheApyBounds, trancheHasCapacity, trancheRiskRank, } from './tranches';
33
37
  export { classifyWalletFailure, isUnpredictableGas, isUserRejected, } from './wallet-errors';
38
+ export { accruedInterest, dailyInterest, projectedAnnualEarnings, SECONDS_PER_WEEK, weeklyInterest, weightedAverageApy, } from './yields';
34
39
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/domain/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EACH,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,GAClB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACH,SAAS,EACT,2BAA2B,EAC3B,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,eAAe,GAClB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACH,WAAW,EACX,YAAY,EACZ,sBAAsB,EACtB,2BAA2B,EAC3B,2BAA2B,EAC3B,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,GACvB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACH,MAAM,EACN,mBAAmB,EACnB,sBAAsB,EACtB,WAAW,EACX,aAAa,GAChB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACH,cAAc,EACd,wBAAwB,EACxB,2BAA2B,EAC3B,iCAAiC,EACjC,6BAA6B,EAC7B,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,GACxB,MAAM,iBAAiB,CAAC;AAYzB,OAAO,EACH,iBAAiB,EACjB,uBAAuB,EACvB,UAAU,EACV,kBAAkB,GACrB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACH,gBAAgB,EAChB,kBAAkB,EAClB,wBAAwB,EACxB,aAAa,EACb,kBAAkB,EAClB,gBAAgB,GACnB,MAAM,YAAY,CAAC;AAOpB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGlE,OAAO,EACH,uBAAuB,EACvB,uBAAuB,EACvB,gBAAgB,EAChB,iBAAiB,GACpB,MAAM,cAAc,CAAC;AAOtB,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEhF,OAAO,EACH,uBAAuB,EACvB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,GAClB,MAAM,YAAY,CAAC;AAOpB,OAAO,EACH,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,GACjB,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/domain/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EACH,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,GAClB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACH,SAAS,EACT,2BAA2B,EAC3B,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,eAAe,GAClB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACH,yBAAyB,EACzB,eAAe,EACf,qBAAqB,EACrB,2BAA2B,EAC3B,yBAAyB,GAC5B,MAAM,eAAe,CAAC;AAavB,OAAO,EACH,WAAW,EACX,YAAY,EACZ,sBAAsB,EACtB,2BAA2B,EAC3B,2BAA2B,EAC3B,iBA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kBAAkB,EAClB,eAAe,GAClB,MAAM,YAAY,CAAC;AAOpB,OAAO,EACH,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,GACjB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACH,eAAe,EACf,aAAa,EACb,uBAAuB,EACvB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,GACrB,MAAM,UAAU,CAAC"}
@@ -1,6 +1,20 @@
1
1
  export interface StrategyPartner {
2
2
  name: string;
3
3
  url: string;
4
+ /**
5
+ * The region of the strategies this partner takes part in, as every Kasu
6
+ * surface names it. For a credit originator it is THE strategy's region —
7
+ * `getStrategyRegion` reads it from here — and it is the word that goes
8
+ * into the wallet-signed loan-agreement message, so it must never be
9
+ * stated from anywhere else.
10
+ *
11
+ * Apxium originates in Australia. InvoiceMate (PayFi) funds cross-border
12
+ * payment corridors no single jurisdiction names, so its region is a
13
+ * SCOPE — `'Global'` — rather than a country: naming one would be a claim
14
+ * about where its End Borrowers sit. Rixon Capital is the senior lender in
15
+ * Apxium's Australian strategies.
16
+ */
17
+ region: string;
4
18
  }
5
19
  export declare const APXIUM: StrategyPartner;
6
20
  export declare const INVOICEMATE: StrategyPartner;
@@ -32,3 +46,18 @@ export declare function getCreditOriginator(pool: PoolNameSignal): StrategyPartn
32
46
  * InvoiceMate pools have none.
33
47
  */
34
48
  export declare function getInstitutionalLender(originator: StrategyPartner): StrategyPartner | null;
49
+ /**
50
+ * The strategy's region — `'Australia'` for the Apxium family, `'Global'` for
51
+ * PayFi — derived from its credit originator, exactly as every surface that
52
+ * states a region must derive it.
53
+ *
54
+ * LOAD-BEARING ON THE MONEY PATH: this is the `region` a lender's wallet signs
55
+ * in the loan-agreement message (`buildLoanAgreementSignMessage`). The backend
56
+ * rebuilds that message from whatever region the client sends and treats it
57
+ * as display-only, so nothing but this function keeps the signed word equal to
58
+ * the word on screen. Never state a region from a constant — that is how a
59
+ * PayFi lender came to pick "Global · Junior" and sign "Australia".
60
+ *
61
+ * Replace the inference with a per-pool field (in the SDK) when one ships.
62
+ */
63
+ export declare function getStrategyRegion(pool: PoolNameSignal): string;
@@ -1,14 +1,17 @@
1
1
  export const APXIUM = {
2
2
  name: 'Apxium',
3
3
  url: 'https://www.apxium.com/',
4
+ region: 'Australia',
4
5
  };
5
6
  export const INVOICEMATE = {
6
7
  name: 'InvoiceMate',
7
8
  url: 'https://invoicemate.net/',
9
+ region: 'Global',
8
10
  };
9
11
  export const RIXON_CAPITAL = {
10
12
  name: 'Rixon Capital',
11
13
  url: 'https://rixon.capital/',
14
+ region: 'Australia',
12
15
  };
13
16
  function poolNameOf(pool) {
14
17
  var _a, _b;
@@ -40,4 +43,21 @@ export function getCreditOriginator(pool) {
40
43
  export function getInstitutionalLender(originator) {
41
44
  return originator.name === APXIUM.name ? RIXON_CAPITAL : null;
42
45
  }
46
+ /**
47
+ * The strategy's region — `'Australia'` for the Apxium family, `'Global'` for
48
+ * PayFi — derived from its credit originator, exactly as every surface that
49
+ * states a region must derive it.
50
+ *
51
+ * LOAD-BEARING ON THE MONEY PATH: this is the `region` a lender's wallet signs
52
+ * in the loan-agreement message (`buildLoanAgreementSignMessage`). The backend
53
+ * rebuilds that message from whatever region the client sends and treats it
54
+ * as display-only, so nothing but this function keeps the signed word equal to
55
+ * the word on screen. Never state a region from a constant — that is how a
56
+ * PayFi lender came to pick "Global · Junior" and sign "Australia".
57
+ *
58
+ * Replace the inference with a per-pool field (in the SDK) when one ships.
59
+ */
60
+ export function getStrategyRegion(pool) {
61
+ return getCreditOriginator(pool).region;
62
+ }
43
63
  //# sourceMappingURL=partners.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"partners.js","sourceRoot":"","sources":["../../src/domain/partners.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,MAAM,GAAoB;IACnC,IAAI,EAAE,QAAQ;IACd,GAAG,EAAE,yBAAyB;CACjC,CAAC;AACF,MAAM,CAAC,MAAM,WAAW,GAAoB;IACxC,IAAI,EAAE,aAAa;IACnB,GA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SAAS,UAAU,CAAC,IAAoB;;IACpC,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC1C,MAAM,MAAM,GAAuD,IAAI,CAAC;IACxE,OAAO,MAAA,MAAA,MAAM,CAAC,QAAQ,mCAAI,MAAM,CAAC,IAAI,mCAAI,EAAE,CAAC;AAChD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAoB;IACpD,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAC5C,IAAI,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,WAAW,CAAC;IAC3D,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAClC,UAA2B;IAE3B,OAAO,UAAU,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC;AAClE,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAoB;IAClD,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;AAC5C,CAAC"}
@@ -179,6 +179,30 @@ export declare function lastEventTimestamp(events: Pick<UserRequestEvent, 'times
179
179
  * request's pool is already clearing.
180
180
  */
181
181
  export declare function isCycleClosed(request: Pick<UserRequest, 'canCancel'>): boolean;
182
+ /**
183
+ * Until when can THIS request still be cancelled? — unix seconds, or `null`
184
+ * when it cannot be cancelled at all, or when no epoch boundary is loaded.
185
+ *
186
+ * The answer is the next cycle close (`deriveCycleDates(...).close`): the
187
+ * clearing window opens there, and the contract refuses a cancel while the
188
+ * pool's clearing is pending (`CannotCancelRequestIfClearingIsPending`).
189
+ * Inside a window whose clearing already ENDED, a still-cancellable request is
190
+ * queued for the next cycle, so its deadline is next week's close — which is
191
+ * exactly what `deriveCycleDates` rolls forward to.
192
+ *
193
+ * `null` unless the request is BOTH:
194
+ *
195
+ * - `canCancel` — the SDK's per-pool signal (see `isCycleClosed`);
196
+ * - live: `statusCode` `pending`, or `partial` (a partly-filled withdrawal
197
+ * whose remainder is back in the queue — a resolved partial has
198
+ * `canCancel: false`). A cancelled, forced, reallocated, rejected or complete
199
+ * request has nothing left to cancel, whatever `canCancel` says.
200
+ *
201
+ * `canCancel` is read ONCE, when the request was fetched. A request held
202
+ * across a cycle boundary (`nextCycleBoundary`) must be refetched before this
203
+ * is shown again — the deadline is a hint, the contract is the gate.
204
+ */
205
+ export declare function cancelDeadline(request: Pick<RequestState, 'canCancel' | 'statusCode'>, nextEpochStart: number | undefined, nowSeconds: number): number | null;
182
206
  /**
183
207
  * Convert a `UserRequest` into a `RequestState`. Pure — no clock, no network,
184
208
  * no copy.
@@ -1,4 +1,5 @@
1
1
  import { UserRequestStatus } from '../services/UserLending/subgraph-types';
2
+ import { deriveCycleDates } from './settlement';
2
3
  /**
3
4
  * Events that represent a lender SUBMISSION into the bundle. A dNFT position
4
5
  * aggregates every submission the lender made into the same pool/tranche this
@@ -59,6 +60,38 @@ export function lastEventTimestamp(events, fallback) {
59
60
  export function isCycleClosed(request) {
60
61
  return !request.canCancel;
61
62
  }
63
+ /**
64
+ * Until when can THIS request still be cancelled? — unix seconds, or `null`
65
+ * when it cannot be cancelled at all, or when no epoch boundary is loaded.
66
+ *
67
+ * The answer is the next cycle close (`deriveCycleDates(...).close`): the
68
+ * clearing window opens there, and the contract refuses a cancel while the
69
+ * pool's clearing is pending (`CannotCancelRequestIfClearingIsPending`).
70
+ * Inside a window whose clearing already ENDED, a still-cancellable request is
71
+ * queued for the next cycle, so its deadline is next week's close — which is
72
+ * exactly what `deriveCycleDates` rolls forward to.
73
+ *
74
+ * `null` unless the request is BOTH:
75
+ *
76
+ * - `canCancel` — the SDK's per-pool signal (see `isCycleClosed`);
77
+ * - live: `statusCode` `pending`, or `partial` (a partly-filled withdrawal
78
+ * whose remainder is back in the queue — a resolved partial has
79
+ * `canCancel: false`). A cancelled, forced, reallocated, rejected or complete
80
+ * request has nothing left to cancel, whatever `canCancel` says.
81
+ *
82
+ * `canCancel` is read ONCE, when the request was fetched. A request held
83
+ * across a cycle boundary (`nextCycleBoundary`) must be refetched before this
84
+ * is shown again — the deadline is a hint, the contract is the gate.
85
+ */
86
+ export function cancelDeadline(request, nextEpochStart, nowSeconds) {
87
+ var _a, _b;
88
+ if (!request.canCancel)
89
+ return null;
90
+ if (request.statusCode !== 'pending' && request.statusCode !== 'partial') {
91
+ return null;
92
+ }
93
+ return (_b = (_a = deriveCycleDates(nextEpochStart, nowSeconds)) === null || _a === void 0 ? void 0 : _a.close) !== null && _b !== void 0 ? _b : null;
94
+ }
62
95
  const isCancelled = (events) => events.some((e) => e.requestType === 'Cancelled');
63
96
  const isForced = (events) => events.some((e) => e.requestType === 'Forced');
64
97
  const initiatedEvent = (events) => events.find((e) => e.requestType === 'Initiated');
@@ -1 +1 @@
1
- {"version":3,"file":"requests.js","sourceRoot":"","sources":["../../src/domain/requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AA8J3E;;;;;;GAMG;AACH,MAAM,iBAAiB,GAAiD,IAAI,GAAG,CAC3E,CAAC,WAAW,EAAE,WAAW,CAAC,CAC7B,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAE9B,MAAW;IACT,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;AACtE,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,gBAAgB,CAC5B,MAA+C;IAE/C,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;AAC3C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACpC,MAA6D,EAC7D,QAAgB;IAEhB,MA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AAS,EAC7C,UAAU,EAAE,SAAS,IACvB;AACN,CAAC"}
@@ -0,0 +1,74 @@
1
+ import { BigNumberish } from 'ethers';
2
+ /**
3
+ * The single-call `LendingPoolManager` requests a sponsored relay may carry,
4
+ * encoded by the SDK so no application hand-builds calldata or hand-maps the
5
+ * relay's `kind` for them.
6
+ *
7
+ * Every function here is PURE: addresses and ids in, `{ kind, call }` out.
8
+ * Reading the chain (the shares a withdrawal is for) is the facade's job —
9
+ * `kasu.calls` — and sending is the application's.
10
+ *
11
+ * Each call is `{ to, data }` and nothing else: no `value` (none of these
12
+ * functions is payable), no `from` (the manager acts for `msg.sender`, the
13
+ * lender's own account, which is why none of them takes a user argument).
14
+ * `data` is ethers' ABI encoding, which is canonical by construction — the
15
+ * relay re-encodes what it decodes and refuses anything that differs, so a
16
+ * hand-tweaked blob never gets through, and an SDK-built one always matches.
17
+ */
18
+ /**
19
+ * The relay's name for each shape. Carried beside the call so the app posts
20
+ * `kind` from the SDK, never from a table of its own — a request declaring the
21
+ * wrong kind is refused (`invalid_calls`), so a hand-mapped table that drifts
22
+ * turns into a lender who cannot withdraw.
23
+ */
24
+ export declare const SPONSORED_CALL_KINDS: readonly ["withdrawal", "cancel_deposit", "cancel_withdrawal", "withdraw_at_expiry"];
25
+ export type SponsoredCallKind = (typeof SPONSORED_CALL_KINDS)[number];
26
+ /** One encoded call and the relay `kind` that names its shape. */
27
+ export interface SponsoredCall {
28
+ kind: SponsoredCallKind;
29
+ /**
30
+ * Exactly `{ to, data }` — structurally the flows' `BatchCall`. Post it as
31
+ * the relay's single call; do not add keys to it.
32
+ */
33
+ call: {
34
+ to: string;
35
+ data: string;
36
+ };
37
+ }
38
+ /**
39
+ * The 4-byte selector of each kind's function, DERIVED from the generated
40
+ * `ILendingPoolManager` ABI — never typed in by hand, so an ABI change moves
41
+ * it and the cross-check spec against the relay's own pins goes red.
42
+ */
43
+ export declare const SPONSORED_CALL_SELECTORS: Readonly<Record<SponsoredCallKind, string>>;
44
+ /**
45
+ * What an encoder throws for an input it will not encode. `code` names the
46
+ * argument; the message names no party, so a wallet-rejection classifier can
47
+ * never read it as something the lender did. Nothing has been sent when this
48
+ * is thrown.
49
+ */
50
+ export declare class SponsoredCallInputError extends Error {
51
+ readonly code: string;
52
+ constructor(code: string);
53
+ }
54
+ /**
55
+ * `requestWithdrawal(poolId, trancheId, shares)` — `withdrawal`.
56
+ *
57
+ * `shares` are tranche SHARES, not assets: `kasu.calls.requestWithdrawal`
58
+ * converts an asset amount (or `'max'`) into them exactly as
59
+ * `UserLending.requestWithdrawalInAsset` / `requestWithdrawalMax` do. Zero
60
+ * shares is refused here: the contract reverts on it
61
+ * (`RequestWithdrawSharesAreZero`) and the relay refuses it before that.
62
+ */
63
+ export declare function encodeRequestWithdrawalCall(lendingPoolManager: string, poolId: string, trancheId: string, shares: BigNumberish): SponsoredCall;
64
+ /** `cancelDepositRequest(poolId, dNftId)` — `cancel_deposit`. */
65
+ export declare function encodeCancelDepositCall(lendingPoolManager: string, poolId: string, dNftId: BigNumberish): SponsoredCall;
66
+ /** `cancelWithdrawalRequest(poolId, wNftId)` — `cancel_withdrawal`. */
67
+ export declare function encodeCancelWithdrawalCall(lendingPoolManager: string, poolId: string, wNftId: BigNumberish): SponsoredCall;
68
+ /**
69
+ * `requestFixedTermDepositWithdrawal(poolId, fixedTermDepositId)` —
70
+ * `withdraw_at_expiry`. The contract function takes the pool and the LOCK id
71
+ * only (no tranche): the manager forwards to the fixed-term contract on the
72
+ * lender's behalf, which knows the lock's tranche.
73
+ */
74
+ export declare function encodeWithdrawAtExpiryCall(lendingPoolManager: string, poolId: string, fixedTermDepositId: BigNumberish): SponsoredCall;