@kasufinance/kasu-sdk 2.6.0 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +128 -3
  2. package/dist/bundle.cjs.js +1119 -254
  3. package/dist/bundle.esm.js +1109 -255
  4. package/dist/domain/index.d.ts +3 -2
  5. package/dist/domain/index.js +2 -2
  6. package/dist/domain/index.js.map +1 -1
  7. package/dist/domain/requests.d.ts +42 -4
  8. package/dist/domain/requests.js +20 -4
  9. package/dist/domain/requests.js.map +1 -1
  10. package/dist/domain/wallet-errors.d.ts +63 -8
  11. package/dist/domain/wallet-errors.js +115 -16
  12. package/dist/domain/wallet-errors.js.map +1 -1
  13. package/dist/facade/deposits.js +2 -1
  14. package/dist/facade/deposits.js.map +1 -1
  15. package/dist/facade/flows.d.ts +95 -0
  16. package/dist/facade/flows.js +116 -0
  17. package/dist/facade/flows.js.map +1 -0
  18. package/dist/facade/index.d.ts +3 -0
  19. package/dist/facade/index.js +3 -0
  20. package/dist/facade/index.js.map +1 -1
  21. package/dist/facade/kasu.d.ts +6 -2
  22. package/dist/facade/kasu.js +28 -3
  23. package/dist/facade/kasu.js.map +1 -1
  24. package/dist/facade/read-only.d.ts +12 -0
  25. package/dist/facade/read-only.js +13 -0
  26. package/dist/facade/read-only.js.map +1 -0
  27. package/dist/flows/deposit-flow.d.ts +301 -0
  28. package/dist/flows/deposit-flow.js +358 -0
  29. package/dist/flows/deposit-flow.js.map +1 -0
  30. package/dist/flows/flow.d.ts +72 -0
  31. package/dist/flows/flow.js +110 -0
  32. package/dist/flows/flow.js.map +1 -0
  33. package/dist/flows/index.d.ts +19 -0
  34. package/dist/flows/index.js +17 -0
  35. package/dist/flows/index.js.map +1 -0
  36. package/dist/flows/observable.d.ts +59 -0
  37. package/dist/flows/observable.js +81 -0
  38. package/dist/flows/observable.js.map +1 -0
  39. package/dist/flows/withdraw-flow.d.ts +99 -0
  40. package/dist/flows/withdraw-flow.js +83 -0
  41. package/dist/flows/withdraw-flow.js.map +1 -0
  42. package/dist/index.d.ts +1 -0
  43. package/dist/index.js +6 -0
  44. package/dist/index.js.map +1 -1
  45. package/dist/services/DataService/data-service.js +0 -1
  46. package/dist/services/DataService/data-service.js.map +1 -1
  47. package/package.json +8 -2
  48. package/src/domain/index.ts +7 -1
  49. package/src/domain/requests.ts +57 -4
  50. package/src/domain/wallet-errors.ts +135 -18
  51. package/src/facade/deposits.ts +2 -3
  52. package/src/facade/flows.ts +172 -0
  53. package/src/facade/index.ts +8 -0
  54. package/src/facade/kasu.ts +43 -3
  55. package/src/facade/read-only.ts +13 -0
  56. package/src/flows/deposit-flow.ts +775 -0
  57. package/src/flows/flow.ts +108 -0
  58. package/src/flows/index.ts +45 -0
  59. package/src/flows/observable.ts +97 -0
  60. package/src/flows/withdraw-flow.ts +210 -0
  61. package/src/index.ts +7 -0
  62. package/src/services/DataService/data-service.ts +0 -1
  63. package/dist/domain/au-minimum.test.d.ts +0 -1
  64. package/dist/domain/au-minimum.test.js +0 -202
  65. package/dist/domain/au-minimum.test.js.map +0 -1
  66. package/dist/domain/deposit-bounds.test.d.ts +0 -1
  67. package/dist/domain/deposit-bounds.test.js +0 -135
  68. package/dist/domain/deposit-bounds.test.js.map +0 -1
  69. package/dist/domain/loan-contract.test.d.ts +0 -1
  70. package/dist/domain/loan-contract.test.js +0 -255
  71. package/dist/domain/loan-contract.test.js.map +0 -1
  72. package/dist/domain/partners.test.d.ts +0 -1
  73. package/dist/domain/partners.test.js +0 -53
  74. package/dist/domain/partners.test.js.map +0 -1
  75. package/dist/domain/pools.test.d.ts +0 -1
  76. package/dist/domain/pools.test.js +0 -184
  77. package/dist/domain/pools.test.js.map +0 -1
  78. package/dist/domain/rates.test.d.ts +0 -1
  79. package/dist/domain/rates.test.js +0 -181
  80. package/dist/domain/rates.test.js.map +0 -1
  81. package/dist/domain/requests.test.d.ts +0 -1
  82. package/dist/domain/requests.test.js +0 -470
  83. package/dist/domain/requests.test.js.map +0 -1
  84. package/dist/domain/settlement.test.d.ts +0 -1
  85. package/dist/domain/settlement.test.js +0 -152
  86. package/dist/domain/settlement.test.js.map +0 -1
  87. package/dist/domain/tranche-display-name.test.d.ts +0 -1
  88. package/dist/domain/tranche-display-name.test.js +0 -58
  89. package/dist/domain/tranche-display-name.test.js.map +0 -1
  90. package/dist/domain/tranches.test.d.ts +0 -1
  91. package/dist/domain/tranches.test.js +0 -206
  92. package/dist/domain/tranches.test.js.map +0 -1
  93. package/dist/domain/wallet-errors.test.d.ts +0 -1
  94. package/dist/domain/wallet-errors.test.js +0 -71
  95. package/dist/domain/wallet-errors.test.js.map +0 -1
  96. package/dist/facade/config.test.d.ts +0 -1
  97. package/dist/facade/config.test.js +0 -216
  98. package/dist/facade/config.test.js.map +0 -1
  99. package/dist/facade/facade.test.d.ts +0 -1
  100. package/dist/facade/facade.test.js +0 -278
  101. package/dist/facade/facade.test.js.map +0 -1
  102. package/dist/services/Locking/calculate-apy.test.d.ts +0 -1
  103. package/dist/services/Locking/calculate-apy.test.js +0 -41
  104. package/dist/services/Locking/calculate-apy.test.js.map +0 -1
  105. package/dist/tests/sample.test.d.ts +0 -1
  106. package/dist/tests/sample.test.js +0 -59
  107. package/dist/tests/sample.test.js.map +0 -1
  108. package/src/domain/au-minimum.test.ts +0 -371
  109. package/src/domain/deposit-bounds.test.ts +0 -200
  110. package/src/domain/loan-contract.test.ts +0 -343
  111. package/src/domain/partners.test.ts +0 -83
  112. package/src/domain/pools.test.ts +0 -260
  113. package/src/domain/rates.test.ts +0 -254
  114. package/src/domain/requests.test.ts +0 -653
  115. package/src/domain/settlement.test.ts +0 -198
  116. package/src/domain/tranche-display-name.test.ts +0 -96
  117. package/src/domain/tranches.test.ts +0 -300
  118. package/src/domain/wallet-errors.test.ts +0 -100
  119. package/src/facade/config.test.ts +0 -265
  120. package/src/facade/facade.test.ts +0 -374
  121. package/src/services/Locking/calculate-apy.test.ts +0 -52
  122. package/src/tests/sample.test.ts +0 -63
@@ -30,11 +30,12 @@ export { asContractType, buildContractVersionType, buildFullNameRequestMessage,
30
30
  export type { ContractListItem, ContractSection, ContractType, ExemptLoanContract, GenerateContractResponse, LoanContractFormatted, ResolvedContractResponse, RetailLoanContract, } from './loan-contract';
31
31
  export { maxNetRateCeiling, pickHighestYieldTranche, poolMaxApy, selectVisiblePools, } from './pools';
32
32
  export type { BestTranche } from './pools';
33
- export { countSubmissions, deriveRequestState, firstSubmissionTimestamp, isCycleClosed, submissionEvents, } from './requests';
33
+ export { countSubmissions, deriveRequestState, firstSubmissionTimestamp, isCycleClosed, lastEventTimestamp, submissionEvents, } from './requests';
34
34
  export type { RequestKind, RequestState, RequestStatusCode, } from './requests';
35
35
  export { CLEARING_WINDOW_SECONDS, computeSettlementWindow, deriveCycleDates, nextCycleBoundary, } from './settlement';
36
36
  export type { CycleDates, SettlementWindowInput, SettlementWindowState, } from './settlement';
37
37
  export { getTrancheDisplayName, UPPER_MEZZANINE } from './tranche-display-name';
38
38
  export { compareTrancheSeniority, derivePoolStatus, MIN_TRANCHE_CAPACITY, netTrancheApyBounds, pickDefaultTrancheId, poolAllTranchesFull, trancheApyBounds, trancheHasCapacity, trancheRiskRank, } from './tranches';
39
39
  export type { ApyBounds, PoolStatus, TrancheCapacitySignal, } from './tranches';
40
- export { isUnpredictableGas, isUserRejected } from './wallet-errors';
40
+ export { classifyWalletFailure, isUnpredictableGas, isUserRejected, } from './wallet-errors';
41
+ export type { WalletFailure } from './wallet-errors';
@@ -25,9 +25,9 @@ export { ceilToCents, floorToCents, isBelowMinimumCapacity, MAX_LENDING_AMOUNT_F
25
25
  export { APXIUM, getCreditOriginator, getInstitutionalLender, INVOICEMATE, RIXON_CAPITAL, } from './partners';
26
26
  export { asContractType, buildContractVersionType, buildFullNameRequestMessage, buildLegacyContractRequestMessage, buildLoanAgreementSignMessage, encodeDepositData, formatSignTimestampUtc, parseFormattedMessage, } from './loan-contract';
27
27
  export { maxNetRateCeiling, pickHighestYieldTranche, poolMaxApy, selectVisiblePools, } from './pools';
28
- export { countSubmissions, deriveRequestState, firstSubmissionTimestamp, isCycleClosed, submissionEvents, } from './requests';
28
+ export { countSubmissions, deriveRequestState, firstSubmissionTimestamp, isCycleClosed, lastEventTimestamp, submissionEvents, } from './requests';
29
29
  export { CLEARING_WINDOW_SECONDS, computeSettlementWindow, deriveCycleDates, nextCycleBoundary, } from './settlement';
30
30
  export { getTrancheDisplayName, UPPER_MEZZANINE } from './tranche-display-name';
31
31
  export { compareTrancheSeniority, derivePoolStatus, MIN_TRANCHE_CAPACITY, netTrancheApyBounds, pickDefaultTrancheId, poolAllTranchesFull, trancheApyBounds, trancheHasCapacity, trancheRiskRank, } from './tranches';
32
- export { isUnpredictableGas, isUserRejected } from './wallet-errors';
32
+ export { classifyWalletFailure, isUnpredictableGas, isUserRejected, } from './wallet-errors';
33
33
  //# 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,gBAAgB,GACnB,MAAM,YAAY,CAAC;AAOpB,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,EAAE,kBAAkB,EAAE,cAAc,EAAE,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,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,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"}
@@ -87,6 +87,36 @@ export interface RequestState {
87
87
  * here.
88
88
  */
89
89
  initiatedAmount: number | null;
90
+ /**
91
+ * The rejected figure the subgraph reported, parsed with the same `num`
92
+ * rule as the rest: an absent or unparseable value is 0. Unlike
93
+ * `acceptedAmount` this is NOT nullable — it feeds the partial-vs-complete
94
+ * branch, where "no figure" and "nothing rejected" mean the same thing.
95
+ */
96
+ rejectedAmount: number;
97
+ /**
98
+ * `assetAmount` of the reallocation event, or 0 when the request was not
99
+ * reallocated. The amount that LEFT the requested tranche — which is not
100
+ * necessarily `acceptedAmount`, because a partly-filled request can be
101
+ * reallocated for only part of itself.
102
+ */
103
+ reallocatedOutAmount: number;
104
+ /**
105
+ * RAW name of the tranche a reallocated deposit was accepted into, or
106
+ * `null` when there was no reallocation. RAW for the same reason
107
+ * `trancheName` is: the app calls `getTrancheDisplayName` on it at the
108
+ * view boundary, and a renamed value must never reach matching code.
109
+ */
110
+ reallocationTargetTrancheName: string | null;
111
+ /**
112
+ * The row's highest-resolution timestamp: the LATEST event, or
113
+ * `request.timestamp` when the timeline is empty or older. Unix seconds.
114
+ *
115
+ * `firstSubmissionTimestamp` says when the lender asked; this says when
116
+ * anything last happened to the request, which is what a "last updated"
117
+ * column and a recency sort need.
118
+ */
119
+ lastTimestamp: number;
90
120
  /**
91
121
  * The signed figure the row shows, chosen by the same branch logic
92
122
  * kasu-ui uses: positive for an inflow, negative for an outflow, 0 for a
@@ -123,6 +153,14 @@ export declare function countSubmissions(events: Pick<UserRequestEvent, 'request
123
153
  * that is (kasu-ui passes the request's own timestamp).
124
154
  */
125
155
  export declare function firstSubmissionTimestamp(events: Pick<UserRequestEvent, 'requestType' | 'timestamp'>[], fallback: number): number;
156
+ /**
157
+ * The LATEST event timestamp, or `fallback` when the timeline is empty — or
158
+ * when every event predates it, because `fallback` seeds the reduction. That
159
+ * seeding is deliberate and is kasu-ui's behaviour: `request.timestamp` is a
160
+ * fact about the request, and an event indexed with an earlier clock must not
161
+ * make the row look older than the request itself.
162
+ */
163
+ export declare function lastEventTimestamp(events: Pick<UserRequestEvent, 'timestamp'>[], fallback: number): number;
126
164
  /**
127
165
  * Has THIS request's cycle closed? — the single open/closed signal behind the
128
166
  * status vocabulary and behind Cancel.
@@ -170,10 +208,10 @@ export declare function isCycleClosed(request: Pick<UserRequest, 'canCancel'>):
170
208
  * status would strand it.
171
209
  *
172
210
  * WHAT THE APPLICATION STILL OWNS: the status word and the detail line beneath
173
- * it; the tranche display rename (`getTrancheDisplayName` on `trancheName`,
174
- * and on the reallocation destination read off `request.events`); the pool-name
175
- * split; the amount format. The "view loan agreement" affordance is a fact, and
176
- * it follows from two fields already here —
211
+ * it; the tranche display rename (`getTrancheDisplayName` on `trancheName`
212
+ * and on `reallocationTargetTrancheName`, both of which are RAW here); the
213
+ * pool-name split; the amount format. The "view loan agreement" affordance is
214
+ * a fact, and it follows from two fields already here —
177
215
  * `requestType === 'Deposit' && statusCode !== 'cancelled' && statusCode !== 'rejected'`
178
216
  * — because neither a cancelled nor a fully-rejected deposit ever issued one,
179
217
  * and withdrawals sign no agreement at all.
@@ -29,6 +29,16 @@ export function firstSubmissionTimestamp(events, fallback) {
29
29
  return fallback;
30
30
  return submissions.reduce((min, e) => (e.timestamp < min ? e.timestamp : min), Infinity);
31
31
  }
32
+ /**
33
+ * The LATEST event timestamp, or `fallback` when the timeline is empty — or
34
+ * when every event predates it, because `fallback` seeds the reduction. That
35
+ * seeding is deliberate and is kasu-ui's behaviour: `request.timestamp` is a
36
+ * fact about the request, and an event indexed with an earlier clock must not
37
+ * make the row look older than the request itself.
38
+ */
39
+ export function lastEventTimestamp(events, fallback) {
40
+ return events.reduce((max, e) => (e.timestamp > max ? e.timestamp : max), fallback);
41
+ }
32
42
  /**
33
43
  * Has THIS request's cycle closed? — the single open/closed signal behind the
34
44
  * status vocabulary and behind Cancel.
@@ -112,10 +122,10 @@ const numOrNull = (str) => {
112
122
  * status would strand it.
113
123
  *
114
124
  * WHAT THE APPLICATION STILL OWNS: the status word and the detail line beneath
115
- * it; the tranche display rename (`getTrancheDisplayName` on `trancheName`,
116
- * and on the reallocation destination read off `request.events`); the pool-name
117
- * split; the amount format. The "view loan agreement" affordance is a fact, and
118
- * it follows from two fields already here —
125
+ * it; the tranche display rename (`getTrancheDisplayName` on `trancheName`
126
+ * and on `reallocationTargetTrancheName`, both of which are RAW here); the
127
+ * pool-name split; the amount format. The "view loan agreement" affordance is
128
+ * a fact, and it follows from two fields already here —
119
129
  * `requestType === 'Deposit' && statusCode !== 'cancelled' && statusCode !== 'rejected'`
120
130
  * — because neither a cancelled nor a fully-rejected deposit ever issued one,
121
131
  * and withdrawals sign no agreement at all.
@@ -150,6 +160,12 @@ export function deriveRequestState(request) {
150
160
  initiatedAmount: initiated
151
161
  ? initiatedAmountOf(request.events)
152
162
  : null,
163
+ rejectedAmount: rejected,
164
+ reallocatedOutAmount: reallocation ? num(reallocation.assetAmount) : 0,
165
+ reallocationTargetTrancheName: reallocation
166
+ ? reallocation.trancheName
167
+ : null,
168
+ lastTimestamp: lastEventTimestamp(request.events, request.timestamp),
153
169
  submissionCount: countSubmissions(request.events),
154
170
  // `firstSubmissionTimestamp` needs a fallback it will never use here:
155
171
  // the bundle is non-empty on every path that reaches the call.
@@ -1 +1 @@
1
- {"version":3,"file":"requests.js","sourceRoot":"","sources":["../../src/domain/requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAgI3E;;;;;;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,MAAM,WAAW,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC7C,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC9C,OAAO,WAAW,CAAC,MAAM,CACrB,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EACnD,QAAQ,CACX,CAAC;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/web3/is-user-rejected.ts` and kasu-mobile's
11
- * `src/features/lending/lib/errors.ts`.
11
+ * `src/features/lending/lib/errors.ts` — and now the UNION of the two, so
12
+ * neither app has to keep a wrapper on top of this one.
12
13
  */
13
14
  /**
14
15
  * Did the lender reject the request in their wallet?
15
16
  *
16
- * Providers surface a rejection in different shapes:
17
+ * Providers surface a rejection in different shapes, and the union of them is
18
+ * the point of this function existing once:
17
19
  * - MetaMask and most EIP-1193 wallets: `code: 4001`
20
+ * - Coinbase Wallet and ethers v5: `code: 'ACTION_REJECTED'`
21
+ * - viem: a `UserRejectedRequestError` name
18
22
  * - WalletConnect and some Privy paths: `Error('User rejected the request')`
19
- * - ethers v5 wraps it as `ACTION_REJECTED`
20
- * - Coinbase Wallet sometimes: `code: 'ACTION_REJECTED'` as a string
23
+ * - a provider error WRAPPED by another layer, carrying the real code and
24
+ * message on a nested `error` — the shape Privy's embedded wallet
25
+ * surfaces on Expo, where the outer object says nothing useful
26
+ * - ethers' own `reason` field, which is often the only place the text lands
27
+ * - a PLAIN OBJECT carrying `message`, which `String(err)` would read as
28
+ * `"[object Object]"`
21
29
  *
22
- * This is kasu-ui's implementation verbatim. kasu-mobile's copy additionally
23
- * reads a nested `error.code` / `error.message`, an ethers `reason`, and the
24
- * words "request rejected" / "declined"; a consumer that needs those shapes
25
- * should keep its own check on top rather than assume they are covered here.
30
+ * Previously kasu-ui's implementation verbatim, with kasu-mobile keeping its
31
+ * own superset on top. That is precisely the drift this layer exists to stop —
32
+ * a rejection kasu-mobile recognised and kasu-ui did not was reported to the
33
+ * same lender as a failure on one app and a cancellation on the other. The
34
+ * union lives here; the mobile wrapper goes.
35
+ *
36
+ * ## The text is read for a SUBJECT, not for a keyword
37
+ *
38
+ * The words alone are not the signal. "Declined" and "request rejected" are
39
+ * also what a rate limiter, a risk engine and a KYC decision say, and those
40
+ * arrive wrapped in exactly the same envelope a wallet error does — ethers'
41
+ * `SERVER_ERROR` around `-32603` carries the upstream body on a nested
42
+ * `error.message`, so `{ error: { message: 'request rejected: rate limit
43
+ * exceeded' } }` is an RPC refusing to serve us, not a lender refusing to
44
+ * sign. Reporting one as the other tells a lender they cancelled something
45
+ * they never saw, and DROPS the real error on the floor.
46
+ *
47
+ * So a rejection is a machine-readable wallet code, or a sentence that names
48
+ * the party who did it: "user rejected", "declined by the user", "cancelled by
49
+ * the wallet". A bare "declined" is not a rejection, whatever else is on the
50
+ * envelope.
51
+ *
52
+ * Within that rule, being generous is the safe direction: calling a genuine
53
+ * fault a cancellation costs a lender one retry, while calling a deliberate
54
+ * rejection a failure sends them to support to report a bug that does not
55
+ * exist.
26
56
  */
27
57
  export declare function isUserRejected(err: unknown): boolean;
28
58
  /**
@@ -35,3 +65,28 @@ export declare function isUserRejected(err: unknown): boolean;
35
65
  * re-check its preconditions rather than invite a retry.
36
66
  */
37
67
  export declare function isUnpredictableGas(err: unknown): boolean;
68
+ /** A step that failed, as a code plus whether the lender chose it. */
69
+ export type WalletFailure<Step> = {
70
+ step: Step;
71
+ reason: 'cancelled';
72
+ } | {
73
+ step: Step;
74
+ reason: 'failed';
75
+ error: unknown;
76
+ };
77
+ /**
78
+ * The `cancelled` / `failed` split, for a WALLET call on any step of any flow.
79
+ *
80
+ * A lender who pressed Reject is not a fault. Reporting one as the other is
81
+ * how a support queue fills with people who did exactly what they meant to.
82
+ *
83
+ * Generic in the step so both flows share one implementation — it was
84
+ * duplicated byte-for-byte in each of them, which is the same drift this
85
+ * layer exists to stop, one level up.
86
+ *
87
+ * Only pass it an error a WALLET produced. An HTTP port's throw is always a
88
+ * `failed`: the lender's wallet was not involved in it, so a backend that
89
+ * happens to word a refusal "declined" must never be shown to them as
90
+ * something they did.
91
+ */
92
+ export declare function classifyWalletFailure<Step>(step: Step, err: unknown): WalletFailure<Step>;
@@ -8,36 +8,115 @@
8
8
  * enumerated once here.
9
9
  *
10
10
  * Lifted from kasu-ui's `src/lib/web3/is-user-rejected.ts` and kasu-mobile's
11
- * `src/features/lending/lib/errors.ts`.
11
+ * `src/features/lending/lib/errors.ts` — and now the UNION of the two, so
12
+ * neither app has to keep a wrapper on top of this one.
12
13
  */
13
14
  /**
14
15
  * Did the lender reject the request in their wallet?
15
16
  *
16
- * Providers surface a rejection in different shapes:
17
+ * Providers surface a rejection in different shapes, and the union of them is
18
+ * the point of this function existing once:
17
19
  * - MetaMask and most EIP-1193 wallets: `code: 4001`
20
+ * - Coinbase Wallet and ethers v5: `code: 'ACTION_REJECTED'`
21
+ * - viem: a `UserRejectedRequestError` name
18
22
  * - WalletConnect and some Privy paths: `Error('User rejected the request')`
19
- * - ethers v5 wraps it as `ACTION_REJECTED`
20
- * - Coinbase Wallet sometimes: `code: 'ACTION_REJECTED'` as a string
23
+ * - a provider error WRAPPED by another layer, carrying the real code and
24
+ * message on a nested `error` — the shape Privy's embedded wallet
25
+ * surfaces on Expo, where the outer object says nothing useful
26
+ * - ethers' own `reason` field, which is often the only place the text lands
27
+ * - a PLAIN OBJECT carrying `message`, which `String(err)` would read as
28
+ * `"[object Object]"`
21
29
  *
22
- * This is kasu-ui's implementation verbatim. kasu-mobile's copy additionally
23
- * reads a nested `error.code` / `error.message`, an ethers `reason`, and the
24
- * words "request rejected" / "declined"; a consumer that needs those shapes
25
- * should keep its own check on top rather than assume they are covered here.
30
+ * Previously kasu-ui's implementation verbatim, with kasu-mobile keeping its
31
+ * own superset on top. That is precisely the drift this layer exists to stop —
32
+ * a rejection kasu-mobile recognised and kasu-ui did not was reported to the
33
+ * same lender as a failure on one app and a cancellation on the other. The
34
+ * union lives here; the mobile wrapper goes.
35
+ *
36
+ * ## The text is read for a SUBJECT, not for a keyword
37
+ *
38
+ * The words alone are not the signal. "Declined" and "request rejected" are
39
+ * also what a rate limiter, a risk engine and a KYC decision say, and those
40
+ * arrive wrapped in exactly the same envelope a wallet error does — ethers'
41
+ * `SERVER_ERROR` around `-32603` carries the upstream body on a nested
42
+ * `error.message`, so `{ error: { message: 'request rejected: rate limit
43
+ * exceeded' } }` is an RPC refusing to serve us, not a lender refusing to
44
+ * sign. Reporting one as the other tells a lender they cancelled something
45
+ * they never saw, and DROPS the real error on the floor.
46
+ *
47
+ * So a rejection is a machine-readable wallet code, or a sentence that names
48
+ * the party who did it: "user rejected", "declined by the user", "cancelled by
49
+ * the wallet". A bare "declined" is not a rejection, whatever else is on the
50
+ * envelope.
51
+ *
52
+ * Within that rule, being generous is the safe direction: calling a genuine
53
+ * fault a cancellation costs a lender one retry, while calling a deliberate
54
+ * rejection a failure sends them to support to report a bug that does not
55
+ * exist.
26
56
  */
27
57
  export function isUserRejected(err) {
58
+ var _a;
28
59
  if (!err)
29
60
  return false;
30
61
  if (typeof err === 'object') {
31
- const code = err.code;
32
- if (code === 4001 || code === 'ACTION_REJECTED')
62
+ const e = err;
63
+ if (isRejectionCode(e.code))
64
+ return true;
65
+ // A wrapped provider error: the outer layer's code is its own, the
66
+ // inner one is the wallet's.
67
+ if (isRejectionCode((_a = e.error) === null || _a === void 0 ? void 0 : _a.code))
33
68
  return true;
34
69
  }
35
- const msg = err instanceof Error ? err.message : String(err);
36
- const lower = msg.toLowerCase();
37
- return (lower.includes('user rejected') ||
38
- lower.includes('user denied') ||
39
- lower.includes('rejected the request') ||
40
- lower.includes('action_rejected'));
70
+ const lower = rejectionText(err).toLowerCase();
71
+ return USER_REJECTION_PATTERNS.some((pattern) => pattern.test(lower));
72
+ }
73
+ function isRejectionCode(code) {
74
+ return code === 4001 || code === 'ACTION_REJECTED';
75
+ }
76
+ /**
77
+ * The wordings that name the wallet or the person at it.
78
+ *
79
+ * Each one carries a SUBJECT — the identifier a wallet library uses, or the
80
+ * verb with the party who performed it. That is what separates a lender
81
+ * pressing Reject from a server declining to answer, and it is why none of
82
+ * these is a bare "declined" or "rejected".
83
+ */
84
+ const USER_REJECTION_PATTERNS = [
85
+ // Machine-readable markers that only a wallet layer emits, arriving as
86
+ // text because something in between stringified the error.
87
+ /action_rejected/,
88
+ /user_rejected/,
89
+ /userrejectedrequest/,
90
+ // "the user did it", in the orders the wallets write it.
91
+ /user\s+(?:has\s+)?(?:rejected|denied|declined|refused|cancell?ed)/,
92
+ /(?:rejected|denied|declined|refused|cancell?ed)\s+by\s+(?:the\s+)?(?:user|wallet|signer|owner)/,
93
+ // The wallet as the subject, which is how some embedded wallets word it.
94
+ /(?:wallet|signer)\s+(?:rejected|denied|declined|refused)/,
95
+ ];
96
+ /**
97
+ * Every place a wallet might have put the words: the message, ethers' `reason`,
98
+ * the error's `name` (viem puts the whole signal there), and a wrapped error's
99
+ * own three. Joined rather than picked, because which one carries the text
100
+ * depends on how many layers wrapped it.
101
+ *
102
+ * A separator is used rather than a bare space: two fields must not be able to
103
+ * form a phrase across the join that neither of them said.
104
+ */
105
+ function rejectionText(err) {
106
+ var _a, _b, _c;
107
+ if (typeof err !== 'object' || err === null)
108
+ return String(err);
109
+ const e = err;
110
+ return [
111
+ e.message,
112
+ e.reason,
113
+ e.name,
114
+ (_a = e.error) === null || _a === void 0 ? void 0 : _a.message,
115
+ (_b = e.error) === null || _b === void 0 ? void 0 : _b.reason,
116
+ (_c = e.error) === null || _c === void 0 ? void 0 : _c.name,
117
+ ]
118
+ .filter((part) => typeof part === 'string')
119
+ .join(' | ');
41
120
  }
42
121
  /**
43
122
  * Did the wallet or RPC signal that the on-chain call would revert?
@@ -53,4 +132,24 @@ export function isUnpredictableGas(err) {
53
132
  return false;
54
133
  return err.code === 'UNPREDICTABLE_GAS_LIMIT';
55
134
  }
135
+ /**
136
+ * The `cancelled` / `failed` split, for a WALLET call on any step of any flow.
137
+ *
138
+ * A lender who pressed Reject is not a fault. Reporting one as the other is
139
+ * how a support queue fills with people who did exactly what they meant to.
140
+ *
141
+ * Generic in the step so both flows share one implementation — it was
142
+ * duplicated byte-for-byte in each of them, which is the same drift this
143
+ * layer exists to stop, one level up.
144
+ *
145
+ * Only pass it an error a WALLET produced. An HTTP port's throw is always a
146
+ * `failed`: the lender's wallet was not involved in it, so a backend that
147
+ * happens to word a refusal "declined" must never be shown to them as
148
+ * something they did.
149
+ */
150
+ export function classifyWalletFailure(step, err) {
151
+ return isUserRejected(err)
152
+ ? { step, reason: 'cancelled' }
153
+ : { step, reason: 'failed', error: err };
154
+ }
56
155
  //# sourceMappingURL=wallet-errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wallet-errors.js","sourceRoot":"","sources":["../../src/domain/wallet-errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,cAAc,CAAC,GAAY;IACvC,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IACvB,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC1B,MAAM,IAAI,GAAI,GAA0B,CAAC,IAAI,CAAC;QAC9C,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,iBAAiB;YAAE,OAAO,IAAI,CAAC;IACjE,CAAC;IACD,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7D,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IAChC,OAAO,CACH,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC;QAC/B,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC;QAC7B,KAAK,CAAC,QAAQ,CAAC,sBAAsB,CAAC;QACtC,KAAK,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CACpC,CAAC;AACN,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAY;IAC3C,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAClD,OAAQ,GAA0B,CAAC,IAAI,KAAK,yBAAyB,CAAC;AAC1E,CAAC"}
1
+ {"version":3,"file":"wallet-errors.js","sourceRoot":"","sources":["../../src/domain/wallet-errors.ts"],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R,CAAC,CAAC,IAAI;QACN,MAAA,CAAC,CAAC,KAAK,0CAAE,OAAO;QAChB,MAAA,CAAC,CAAC,KAAK,0CAAE,MAAM;QACf,MAAA,CAAC,CAAC,KAAK,0CAAE,IAAI;KAChB;SACI,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC;SAC1D,IAAI,CAAC,KAAK,CAAC,CAAC;AACrB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAY;IAC3C,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAClD,OAAQ,GAA0B,CAAC,IAAI,KAAK,yBAAyB,CAAC;AAC1E,CAAC;AAOD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,qBAAqB,CACjC,IAAU,EACV,GAAY;IAEZ,OAAO,cAAc,CAAC,GAAG,CAAC;QACtB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE;QAC/B,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;AACjD,CAAC"}
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ import { READ_ONLY_MESSAGE } from './read-only';
10
11
  /**
11
12
  * High-level facade for deposit and withdrawal operations.
12
13
  *
@@ -35,7 +36,7 @@ export class DepositsFacade {
35
36
  */
36
37
  assertWritable() {
37
38
  if (this._isReadOnly) {
38
- throw new Error('Kasu: this instance is read-only; call kasu.connect(signer) first');
39
+ throw new Error(READ_ONLY_MESSAGE);
39
40
  }
40
41
  }
41
42
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"deposits.js","sourceRoot":"","sources":["../../src/facade/deposits.ts"],"names":[],"mappings":";;;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AC,WAAW,mCAAI,IAAI,EAC1B,MAAM,CAAC,YAAY,EACnB,MAAA,MAAM,CAAC,QAAQ,mCAAI,GAAG,CACzB,CAAC;QACN,CAAC;KAAA;IAED;;OAEG;IACG,QAAQ,CAAC,MAAsB;;YACjC,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,wBAAwB,CACnD,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,SAAS,EAChB,MAAM,CAAC,MAAM,CAChB,CAAC;QACN,CAAC;KAAA;IAED;;OAEG;IACG,WAAW,CACb,MAAc,EACd,SAAiB,EACjB,WAAmB;;YAEnB,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,oBAAoB,CAC/C,MAAM,EACN,SAAS,EACT,WAAW,CACd,CAAC;QACN,CAAC;KAAA;IAED;;;;;OAKG;IACH,cAAc,CAAC,WAA0B;QACrC,OAAO,IAAI,CAAC,YAAY,CAAC,uBAAuB,CAC5C,WAAW,EACX,IAAI,CAAC,QAAQ,CAChB,CAAC;IACN,CAAC;IAED;;;OAGG;IACG,iBAAiB,CAAC,MAAc;;YAClC,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC7D,CAAC;KAAA;IAED;;OAEG;IACG,eAAe;;YACjB,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,CAAC;QACrD,CAAC;KAAA;CACJ"}
@@ -0,0 +1,95 @@
1
+ import type { IERC20MetadataAbi } from '../contracts';
2
+ import { DepositFlow, DepositFlowOptions, DepositPorts, WithdrawFlow, WithdrawPorts } from '../flows';
3
+ import { DepositsFacade } from './deposits';
4
+ /**
5
+ * The ports a consumer MUST supply for a deposit, plus optional overrides for
6
+ * the ones the SDK can serve itself.
7
+ *
8
+ * The three required ones all reach the application's own backend or wallet:
9
+ * the SDK has no opinion on how a lender signs, which proxy the agreements
10
+ * service sits behind, or where the KYC signature is fetched — and it must not
11
+ * learn any of them, because it is a public package.
12
+ */
13
+ export type DepositFlowPortOverrides = Pick<DepositPorts, 'signMessage' | 'generateContract' | 'getKycSignature'> & Partial<DepositPorts>;
14
+ /**
15
+ * Every withdraw port has an SDK default except `getKycSignature`, which has
16
+ * no default at all and which turns the KYC pre-check on by being supplied.
17
+ */
18
+ export type WithdrawFlowPortOverrides = Partial<WithdrawPorts>;
19
+ /**
20
+ * Builds `DepositFlow` / `WithdrawFlow` instances wired to THIS Kasu instance:
21
+ * its chain's stable token, its `LendingPoolManager`, its signer.
22
+ *
23
+ * ```ts
24
+ * const flow = kasu.connect(signer).flows.deposit({
25
+ * signMessage: (m) => signer.signMessage(m),
26
+ * generateContract: (req) => postToMyProxy(req),
27
+ * getKycSignature: (p) => postToMyBackend(p),
28
+ * });
29
+ * ```
30
+ *
31
+ * A flow built from a read-only instance constructs fine and reads fine — the
32
+ * write ports throw `READ_ONLY_MESSAGE` when the run reaches them, exactly as
33
+ * `kasu.deposits.deposit` does. Constructing is not the mistake; submitting is.
34
+ *
35
+ * It holds the `DepositsFacade` and NOTHING the facade already owns: no
36
+ * `UserLending`, no chain id, no signer. Two paths to one behaviour is how the
37
+ * KYC params a flow built came to differ from the ones `kasu.deposits`
38
+ * built — the same class of drift the flows themselves exist to end.
39
+ */
40
+ export declare class FlowsFacade {
41
+ private readonly _deposits;
42
+ /**
43
+ * The chain's stable token, bound to whatever the Kasu instance holds.
44
+ * A factory rather than a contract: it is one `new Contract`, and a
45
+ * cached binding would outlive the config it was built from.
46
+ */
47
+ private readonly _erc20;
48
+ /** The read-only flag `Kasu` already computed — never re-derived here. */
49
+ private readonly _isReadOnly;
50
+ /**
51
+ * The ERC-20 spender every deposit run approves: this chain's
52
+ * `LendingPoolManager`, which is the only contract the default deposit
53
+ * port calls. Passed to the flow so a consumer never has to hand-wire
54
+ * an address whose only wrong value grants an approval to the wrong
55
+ * contract.
56
+ */
57
+ private readonly _spender;
58
+ constructor(_deposits: DepositsFacade,
59
+ /**
60
+ * The chain's stable token, bound to whatever the Kasu instance holds.
61
+ * A factory rather than a contract: it is one `new Contract`, and a
62
+ * cached binding would outlive the config it was built from.
63
+ */
64
+ _erc20: () => IERC20MetadataAbi,
65
+ /** The read-only flag `Kasu` already computed — never re-derived here. */
66
+ _isReadOnly: boolean,
67
+ /**
68
+ * The ERC-20 spender every deposit run approves: this chain's
69
+ * `LendingPoolManager`, which is the only contract the default deposit
70
+ * port calls. Passed to the flow so a consumer never has to hand-wire
71
+ * an address whose only wrong value grants an approval to the wrong
72
+ * contract.
73
+ */
74
+ _spender: string);
75
+ /**
76
+ * A deposit pipeline. `readAllowance`, `approve`, `deposit` and
77
+ * `buildKycParams` default to the SDK's own implementations; pass any of
78
+ * them to override (kasu-ui approves through its sponsored-gas path, for
79
+ * one).
80
+ *
81
+ * Each default is applied per key with `??`, not by spreading `ports` over
82
+ * them: `{ ...defaults, ...ports }` lets an EXPLICITLY undefined value
83
+ * delete the default it was meant to keep, and
84
+ * `approve: sponsoredGas ? sponsoredApprove : undefined` is exactly how a
85
+ * consumer writes a conditional override.
86
+ */
87
+ deposit(ports: DepositFlowPortOverrides, opts?: DepositFlowOptions): DepositFlow;
88
+ /**
89
+ * A withdrawal pipeline. Both write ports and `buildKycParams` default to
90
+ * this instance; supplying `getKycSignature` turns the KYC pre-check on.
91
+ * Defaults are applied per key, for the reason `deposit()` gives.
92
+ */
93
+ withdraw(ports?: WithdrawFlowPortOverrides): WithdrawFlow;
94
+ private _assertWritable;
95
+ }