@kasufinance/kasu-sdk 2.10.2 → 2.11.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 +17 -0
- package/dist/bundle.cjs.js +214 -11
- package/dist/bundle.esm.js +212 -12
- package/dist/domain/index.d.ts +7 -1
- package/dist/domain/index.js +6 -1
- package/dist/domain/index.js.map +1 -1
- package/dist/domain/sponsored-calls.d.ts +34 -6
- package/dist/domain/sponsored-calls.js +65 -7
- package/dist/domain/sponsored-calls.js.map +1 -1
- package/dist/domain/strategy-summary.d.ts +47 -0
- package/dist/domain/strategy-summary.js +76 -0
- package/dist/domain/strategy-summary.js.map +1 -0
- package/dist/facade/strategies.js +14 -0
- package/dist/facade/strategies.js.map +1 -1
- package/dist/facade/types.d.ts +23 -0
- package/dist/flows/batch-submission.d.ts +21 -4
- package/dist/flows/batch-submission.js +59 -5
- package/dist/flows/batch-submission.js.map +1 -1
- package/dist/flows/index.d.ts +1 -1
- package/dist/flows/index.js +1 -1
- package/dist/flows/index.js.map +1 -1
- package/package.json +2 -1
- package/src/domain/index.ts +8 -0
- package/src/domain/sponsored-calls.ts +79 -13
- package/src/domain/strategy-summary.ts +88 -0
- package/src/facade/strategies.ts +15 -0
- package/src/facade/types.ts +28 -1
- package/src/flows/batch-submission.ts +63 -6
- package/src/flows/index.ts +1 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A strategy's SHORT blurb, as plain text: the CMS `liteDescription` first,
|
|
3
|
+
* else the first paragraph of the long `description`, else nothing.
|
|
4
|
+
*
|
|
5
|
+
* Lifted from kasu-ui (`pickShortDescription`, its deposit dialog and landing
|
|
6
|
+
* strategy card) so every app shows the same line, and pinned to its output
|
|
7
|
+
* for every live CMS row. The rules are facts about how the CMS is authored,
|
|
8
|
+
* not formatting preferences:
|
|
9
|
+
*
|
|
10
|
+
* - `liteDescription` IS THE SHORT ONE. `description` is the credit
|
|
11
|
+
* originator's several-paragraph profile; on a card it is a wall.
|
|
12
|
+
* - `"Not Available"` IS A PLACEHOLDER, not editorial. Several rows carry it
|
|
13
|
+
* verbatim, and it must read as missing, not print. Matched on the whole
|
|
14
|
+
* trimmed value, case-insensitively. It applies to `liteDescription` only.
|
|
15
|
+
* - EMPTY OR BLANK IS MISSING. The service maps a pool with no CMS record to
|
|
16
|
+
* `''`.
|
|
17
|
+
* - THE FIELDS HOLD MARKDOWN. `liteDescription` can open with a `**bold**`
|
|
18
|
+
* lead, and the surfaces this feeds render plain text, so the markers are
|
|
19
|
+
* stripped (bold, then italic, then inline code).
|
|
20
|
+
* - AND HARD NEWLINES. Every run of whitespace becomes one space, so a
|
|
21
|
+
* paragraph break inside the value is not a gap in a one-line slot.
|
|
22
|
+
* - NOT SANITISED. "Plain text" means text to render AS text. HTML tags,
|
|
23
|
+
* entities and link syntax (`<script>`, `<`, `[a](javascript:…)`) pass
|
|
24
|
+
* through unchanged, and removing markers can join fragments into a tag
|
|
25
|
+
* (`<scr**i**pt>` becomes `<script>`). Render it as a text node, never as
|
|
26
|
+
* HTML or markdown.
|
|
27
|
+
*
|
|
28
|
+
* Two refinements over the kasu-ui original, neither reachable by any live
|
|
29
|
+
* row: the cleaned text is trimmed (a CRLF value no longer ends in a space),
|
|
30
|
+
* and a `liteDescription` that cleans to nothing (`** **`) counts as missing,
|
|
31
|
+
* so the result is never a blank string.
|
|
32
|
+
*
|
|
33
|
+
* This authors no string of its own. It selects and cleans editorial the CMS
|
|
34
|
+
* already holds, and an absent blurb is `undefined`, never a fallback sentence:
|
|
35
|
+
* what "no blurb" means is the render site's decision.
|
|
36
|
+
*
|
|
37
|
+
* Pure. A value that is not a string reads as missing.
|
|
38
|
+
*/
|
|
39
|
+
export function pickShortDescription(source) {
|
|
40
|
+
var _a;
|
|
41
|
+
const lite = asTrimmed(source.liteDescription);
|
|
42
|
+
if (lite && !NOT_AVAILABLE.test(lite)) {
|
|
43
|
+
const summary = toOneLine(lite);
|
|
44
|
+
if (summary)
|
|
45
|
+
return summary;
|
|
46
|
+
}
|
|
47
|
+
const long = asTrimmed(source.description);
|
|
48
|
+
if (long) {
|
|
49
|
+
const firstParagraph = (_a = long.split(PARAGRAPH_BREAK, 1)[0]) !== null && _a !== void 0 ? _a : long;
|
|
50
|
+
return toOneLine(firstParagraph) || undefined;
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
const NOT_AVAILABLE = /^not available$/i;
|
|
55
|
+
const PARAGRAPH_BREAK = /\n\s*\n/;
|
|
56
|
+
function asTrimmed(value) {
|
|
57
|
+
return typeof value === 'string' ? value.trim() : '';
|
|
58
|
+
}
|
|
59
|
+
/** Markers off, whitespace runs to one space, ends trimmed. `''` when nothing is left. */
|
|
60
|
+
function toOneLine(text) {
|
|
61
|
+
return stripInlineMarkdown(text).replace(/\s+/gu, ' ').trim();
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Inline markdown markers off, in the order bold → italic → code. The bold
|
|
65
|
+
* passes consume every `**` / `__` pair first, so the italic patterns can match
|
|
66
|
+
* a lone `*` / `_` without lookarounds.
|
|
67
|
+
*/
|
|
68
|
+
function stripInlineMarkdown(input) {
|
|
69
|
+
return input
|
|
70
|
+
.replace(/\*\*(.+?)\*\*/g, '$1')
|
|
71
|
+
.replace(/__(.+?)__/g, '$1')
|
|
72
|
+
.replace(/\*(.+?)\*/g, '$1')
|
|
73
|
+
.replace(/_(.+?)_/g, '$1')
|
|
74
|
+
.replace(/`([^`]+)`/g, '$1');
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=strategy-summary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy-summary.js","sourceRoot":"","sources":["../../src/domain/strategy-summary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,UAAU,oBAAoB,CAChC,MAA8B;;IAE9B,MAAM,IAA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AAC"}
|
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { selectVisiblePools } from '../domain/pools';
|
|
11
|
+
import { pickShortDescription } from '../domain/strategy-summary';
|
|
11
12
|
/**
|
|
12
13
|
* High-level facade for browsing Kasu lending strategies (pools).
|
|
13
14
|
*
|
|
@@ -191,7 +192,10 @@ export class StrategiesFacade {
|
|
|
191
192
|
return {
|
|
192
193
|
id: pool.id,
|
|
193
194
|
name: pool.poolName,
|
|
195
|
+
subheading: nonEmptyOrUndefined(pool.subheading),
|
|
194
196
|
description: pool.description,
|
|
197
|
+
liteDescription: nonEmptyOrUndefined(pool.liteDescription),
|
|
198
|
+
summary: pickShortDescription(pool),
|
|
195
199
|
isActive: pool.isActive,
|
|
196
200
|
apy: pool.apy,
|
|
197
201
|
tvl: pool.totalValueLocked,
|
|
@@ -206,6 +210,16 @@ export class StrategiesFacade {
|
|
|
206
210
|
};
|
|
207
211
|
}
|
|
208
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* A CMS text field as a string, or `undefined` when it is absent, not a
|
|
215
|
+
* string, or empty (blank included) — the CMS stores an emptied field as `''`, and an empty
|
|
216
|
+
* subheading must read as "none", not render an empty line.
|
|
217
|
+
*/
|
|
218
|
+
function nonEmptyOrUndefined(value) {
|
|
219
|
+
return typeof value === 'string' && value.trim().length > 0
|
|
220
|
+
? value
|
|
221
|
+
: undefined;
|
|
222
|
+
}
|
|
209
223
|
/**
|
|
210
224
|
* A CMS "numeric" field as a finite number, or `null`. An empty or blank
|
|
211
225
|
* string is UNAUTHORED, not zero.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strategies.js","sourceRoot":"","sources":["../../src/facade/strategies.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"strategies.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,IAAI,CAAC,UAAU;YAC3B,YAAY,EAAE,IAAI,CAAC,gBAAgB;YACnC,YAAY,EAAE,IAAI,CAAC,iBAAiB;YACpC,SAAS,EAAE,IAAI,CAAC,cAAc;YAC9B,IAAI,EAAE,IAAI;SACb,CAAC;IACN,CAAC;CACJ;AAED;;;;GAIG;AACH,SAAS,mBAAmB,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QACvD,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,SAAS,CAAC;AACpB,CAAC;AAED;;;GAGG;AACH,SAAS,YAAY,CAAC,KAAc;IAChC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5E,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,OAAO,IAAI,CAAC;QACrC,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC9B,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IACrD,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
package/dist/facade/types.d.ts
CHANGED
|
@@ -87,7 +87,30 @@ export interface KasuOptions {
|
|
|
87
87
|
export interface Strategy {
|
|
88
88
|
id: string;
|
|
89
89
|
name: string;
|
|
90
|
+
/**
|
|
91
|
+
* The CMS subheading (the borrower type shown under the name). Absent when
|
|
92
|
+
* the record has none, or an empty one.
|
|
93
|
+
*/
|
|
94
|
+
subheading?: string;
|
|
90
95
|
description: string;
|
|
96
|
+
/**
|
|
97
|
+
* The CMS short description (`liteDescription`) for compact surfaces.
|
|
98
|
+
* Absent when the record has none, or an empty one.
|
|
99
|
+
*/
|
|
100
|
+
liteDescription?: string;
|
|
101
|
+
/**
|
|
102
|
+
* The strategy's short blurb as ONE line of plain text, for cards and
|
|
103
|
+
* compact surfaces: `liteDescription` when it is usable, else the first
|
|
104
|
+
* paragraph of `description`, with inline markdown markers stripped and
|
|
105
|
+
* every run of whitespace collapsed to one space. The `"Not Available"`
|
|
106
|
+
* placeholder, an empty or blank value, and a missing one all count as
|
|
107
|
+
* absent. `undefined` when neither field yields a blurb; the SDK never
|
|
108
|
+
* substitutes a sentence of its own. See `pickShortDescription`.
|
|
109
|
+
*
|
|
110
|
+
* Not sanitised: HTML tags and link syntax pass through unchanged. Render
|
|
111
|
+
* it as text, never as HTML or markdown.
|
|
112
|
+
*/
|
|
113
|
+
summary?: string;
|
|
91
114
|
isActive: boolean;
|
|
92
115
|
/** Weighted-average APY across tranches (decimal, e.g. 0.08 = 8 %). */
|
|
93
116
|
apy: number;
|
|
@@ -157,6 +157,22 @@ export declare function submitBatch<R extends ReceiptLike = ReceiptLike>(input:
|
|
|
157
157
|
* means the lender is told the earlier one landed (`already-submitted`).
|
|
158
158
|
*/
|
|
159
159
|
export declare function checkBatchOutcome<R extends ReceiptLike = ReceiptLike>(transactionId: string, expect: Omit<DepositProofExpectation, 'userOperationHash'>, ports: Pick<BatchSubmissionPorts<R>, 'getStatus' | 'getReceipt'>): Promise<'deposited' | 'not-deposited' | 'unknown'>;
|
|
160
|
+
/**
|
|
161
|
+
* `checkBatchOutcome` for ONE sponsored call — ONE status read, no polling —
|
|
162
|
+
* for an app's guard against sending the same request twice (a P2P transfer
|
|
163
|
+
* whose earlier submission ended PENDING, say):
|
|
164
|
+
*
|
|
165
|
+
* - `executed` — mined, and the receipt proves the sender's operation
|
|
166
|
+
* succeeded (`proveUserOperationInReceipt`);
|
|
167
|
+
* - `not-executed` — definitively reverted (vendor status or the operation's
|
|
168
|
+
* own flag);
|
|
169
|
+
* - `unknown` — anything else, including a read or receipt that failed, or a
|
|
170
|
+
* receipt that does not show the sender's operation.
|
|
171
|
+
*
|
|
172
|
+
* Only `not-executed` may let a new attempt proceed unprompted; `executed`
|
|
173
|
+
* means the earlier one landed and the user should be told.
|
|
174
|
+
*/
|
|
175
|
+
export declare function checkSponsoredCallOutcome<R extends ReceiptLike = ReceiptLike>(transactionId: string, expect: Omit<UserOperationProofExpectation, 'userOperationHash'>, ports: Pick<BatchSubmissionPorts<R>, 'getStatus' | 'getReceipt'>): Promise<'executed' | 'not-executed' | 'unknown'>;
|
|
160
176
|
/**
|
|
161
177
|
* `BatchSubmissionPorts` for ONE sponsored call: the same status, receipt and
|
|
162
178
|
* clock ports — a relay client written for the deposit batch serves both —
|
|
@@ -194,9 +210,9 @@ export interface SponsoredCallSubmission<R extends ReceiptLike = ReceiptLike> ex
|
|
|
194
210
|
wait(): Promise<ExecutedCall<R>>;
|
|
195
211
|
}
|
|
196
212
|
/**
|
|
197
|
-
* `submitBatch` for ONE sponsored
|
|
198
|
-
* `
|
|
199
|
-
*
|
|
213
|
+
* `submitBatch` for ONE sponsored call — the body of a `WithdrawFlow`
|
|
214
|
+
* `submitCall` port, of an app's cancel or withdraw-at-expiry action, and of
|
|
215
|
+
* a P2P transfer (`encodeStableTransfer`). Same post, same polling policy, same outcome
|
|
200
216
|
* table; the proof is `proveUserOperationInReceipt` (the sender's operation
|
|
201
217
|
* succeeded) instead of the deposit proof, and an unproven receipt is
|
|
202
218
|
* `call_unproven:<reason>`.
|
|
@@ -212,7 +228,8 @@ export interface SponsoredCallSubmission<R extends ReceiptLike = ReceiptLike> ex
|
|
|
212
228
|
* The call is checked against its kind before anything is posted — a known
|
|
213
229
|
* kind, exactly `{ to, data }`, and `data` opening with that kind's selector —
|
|
214
230
|
* and a mismatch is `BatchSubmissionError('call_mismatch', 'failed')`: nothing
|
|
215
|
-
* was sent. Build calls with `kasu.calls
|
|
231
|
+
* was sent. Build calls with `kasu.calls` (or `encodeStableTransfer`), and
|
|
232
|
+
* this never fires.
|
|
216
233
|
*
|
|
217
234
|
* As on the deposit path, nothing after the post ever produces `failed`.
|
|
218
235
|
*/
|
|
@@ -222,7 +222,10 @@ export function checkBatchOutcome(transactionId, expect, ports) {
|
|
|
222
222
|
}
|
|
223
223
|
if (read.kind === 'reverted')
|
|
224
224
|
return 'not-deposited';
|
|
225
|
-
|
|
225
|
+
// An empty hash is not an answer — `waitForMined` reads it the same way.
|
|
226
|
+
if (read.kind !== 'mined' ||
|
|
227
|
+
typeof read.txHash !== 'string' ||
|
|
228
|
+
read.txHash === '') {
|
|
226
229
|
return 'unknown';
|
|
227
230
|
}
|
|
228
231
|
try {
|
|
@@ -239,10 +242,60 @@ export function checkBatchOutcome(transactionId, expect, ports) {
|
|
|
239
242
|
}
|
|
240
243
|
});
|
|
241
244
|
}
|
|
245
|
+
// ---------------------------------------------------------------------------
|
|
246
|
+
// One sponsored call — withdraw, cancel, withdraw at expiry, transfer
|
|
247
|
+
// ---------------------------------------------------------------------------
|
|
242
248
|
/**
|
|
243
|
-
* `
|
|
244
|
-
*
|
|
245
|
-
*
|
|
249
|
+
* `checkBatchOutcome` for ONE sponsored call — ONE status read, no polling —
|
|
250
|
+
* for an app's guard against sending the same request twice (a P2P transfer
|
|
251
|
+
* whose earlier submission ended PENDING, say):
|
|
252
|
+
*
|
|
253
|
+
* - `executed` — mined, and the receipt proves the sender's operation
|
|
254
|
+
* succeeded (`proveUserOperationInReceipt`);
|
|
255
|
+
* - `not-executed` — definitively reverted (vendor status or the operation's
|
|
256
|
+
* own flag);
|
|
257
|
+
* - `unknown` — anything else, including a read or receipt that failed, or a
|
|
258
|
+
* receipt that does not show the sender's operation.
|
|
259
|
+
*
|
|
260
|
+
* Only `not-executed` may let a new attempt proceed unprompted; `executed`
|
|
261
|
+
* means the earlier one landed and the user should be told.
|
|
262
|
+
*/
|
|
263
|
+
export function checkSponsoredCallOutcome(transactionId, expect, ports) {
|
|
264
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
265
|
+
var _a;
|
|
266
|
+
let read;
|
|
267
|
+
try {
|
|
268
|
+
read = yield ports.getStatus(transactionId);
|
|
269
|
+
}
|
|
270
|
+
catch (_b) {
|
|
271
|
+
return 'unknown';
|
|
272
|
+
}
|
|
273
|
+
if (read.kind === 'reverted')
|
|
274
|
+
return 'not-executed';
|
|
275
|
+
// An empty hash is not an answer — `waitForMined` reads it the same way.
|
|
276
|
+
if (read.kind !== 'mined' ||
|
|
277
|
+
typeof read.txHash !== 'string' ||
|
|
278
|
+
read.txHash === '') {
|
|
279
|
+
return 'unknown';
|
|
280
|
+
}
|
|
281
|
+
try {
|
|
282
|
+
const receipt = yield ports.getReceipt(read.txHash);
|
|
283
|
+
const proof = proveUserOperationInReceipt(receipt, Object.assign(Object.assign({}, expect), { userOperationHash: (_a = read.userOperationHash) !== null && _a !== void 0 ? _a : null }));
|
|
284
|
+
if (proof.kind === 'executed')
|
|
285
|
+
return 'executed';
|
|
286
|
+
if (proof.kind === 'reverted')
|
|
287
|
+
return 'not-executed';
|
|
288
|
+
return 'unknown';
|
|
289
|
+
}
|
|
290
|
+
catch (_c) {
|
|
291
|
+
return 'unknown';
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* `submitBatch` for ONE sponsored call — the body of a `WithdrawFlow`
|
|
297
|
+
* `submitCall` port, of an app's cancel or withdraw-at-expiry action, and of
|
|
298
|
+
* a P2P transfer (`encodeStableTransfer`). Same post, same polling policy, same outcome
|
|
246
299
|
* table; the proof is `proveUserOperationInReceipt` (the sender's operation
|
|
247
300
|
* succeeded) instead of the deposit proof, and an unproven receipt is
|
|
248
301
|
* `call_unproven:<reason>`.
|
|
@@ -258,7 +311,8 @@ export function checkBatchOutcome(transactionId, expect, ports) {
|
|
|
258
311
|
* The call is checked against its kind before anything is posted — a known
|
|
259
312
|
* kind, exactly `{ to, data }`, and `data` opening with that kind's selector —
|
|
260
313
|
* and a mismatch is `BatchSubmissionError('call_mismatch', 'failed')`: nothing
|
|
261
|
-
* was sent. Build calls with `kasu.calls
|
|
314
|
+
* was sent. Build calls with `kasu.calls` (or `encodeStableTransfer`), and
|
|
315
|
+
* this never fires.
|
|
262
316
|
*
|
|
263
317
|
* As on the deposit path, nothing after the post ever produces `failed`.
|
|
264
318
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch-submission.js","sourceRoot":"","sources":["../../src/flows/batch-submission.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAGH,qBAAqB,EACrB,2BAA2B,GAI9B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACH,oBAAoB,EACpB,wBAAwB,GAE3B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACH,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,GACvB,MAAM,gBAAgB,CAAC;AA0ExB;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GACrC,MAAM,CAAC,MAAM,CAAC;IACV,SAAS,EAAE,IAAK;IAChB,KAAK,EAAE,KAAM;IACb,OAAO,EAAE,GAAG;IACZ,SAAS,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;CAC5B,CAAC,CAAC;AAqBP,SAAS,aAAa,CAClB,MAA+C;;IAE/C,MAAM,QAAQ,GAAuB;QACjC,SAAS,EAAE,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,mCAAI,4BAA4B,CAAC,SAAS;QACtE,KAAK,EAAE,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,mCAAI,4BAA4B,CAAC,KAAK;QAC1D,OAAO,EAAE,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,mCAAI,4BAA4B,CAAC,OAAO;QAChE,SAAS,EAAE,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,mCAAI,4BAA4B,CAAC,SAAS;KACzE,CAAC;IACF,MAAM,EAAE,SAAS,EAAE,KAAK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C,MAAM,KACT,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,IAC5C,CAAC;QACP,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,IAAI,iBAAiB,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC5B,MAAM,IAAI,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACpD,CAAC;QACD,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC5B,MAAM,IAAI,iBAAiB,CAAC,iBAAiB,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;IACnE,CAAC;CAAA"}
|
package/dist/flows/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
export { BatchPendingError, BatchRevertedError, batchOutcomeOf, BatchSubmissionError, isDefinitivelyNotSubmitted, } from './batch-errors';
|
|
14
14
|
export type { BatchSubmissionOutcome } from './batch-errors';
|
|
15
|
-
export { checkBatchOutcome, DEFAULT_BATCH_POLLING_POLICY, submitBatch, submitSponsoredCall, } from './batch-submission';
|
|
15
|
+
export { checkBatchOutcome, checkSponsoredCallOutcome, DEFAULT_BATCH_POLLING_POLICY, submitBatch, submitSponsoredCall, } from './batch-submission';
|
|
16
16
|
export type { BatchPollingPolicy, BatchStatusRead, BatchSubmission, BatchSubmissionPorts, ExecutedCall, ProvenBatch, SponsoredCallSubmission, SponsoredCallSubmissionPorts, SubmitBatchCall, } from './batch-submission';
|
|
17
17
|
export { Flow } from './flow';
|
|
18
18
|
export { FlowStore } from './observable';
|
package/dist/flows/index.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* the copies had already started to differ.
|
|
12
12
|
*/
|
|
13
13
|
export { BatchPendingError, BatchRevertedError, batchOutcomeOf, BatchSubmissionError, isDefinitivelyNotSubmitted, } from './batch-errors';
|
|
14
|
-
export { checkBatchOutcome, DEFAULT_BATCH_POLLING_POLICY, submitBatch, submitSponsoredCall, } from './batch-submission';
|
|
14
|
+
export { checkBatchOutcome, checkSponsoredCallOutcome, DEFAULT_BATCH_POLLING_POLICY, submitBatch, submitSponsoredCall, } from './batch-submission';
|
|
15
15
|
export { Flow } from './flow';
|
|
16
16
|
export { FlowStore } from './observable';
|
|
17
17
|
export { CONTRACT_TTL_MS, DepositFlow, INVALID_ACCEPTANCE_SIGNATURE_MESSAGE, INVALID_AUTH_SIGNATURE_MESSAGE, NO_SPENDER_MESSAGE, } from './deposit-flow';
|
package/dist/flows/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/flows/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACH,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,0BAA0B,GAC7B,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACH,iBAAiB,EACjB,4BAA4B,EAC5B,WAAW,EACX,mBAAmB,GACtB,MAAM,oBAAoB,CAAC;AAa5B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EACH,eAAe,EACf,WAAW,EACX,oCAAoC,EACpC,8BAA8B,EAC9B,kBAAkB,GACrB,MAAM,gBAAgB,CAAC;AAiBxB,OAAO,EACH,qBAAqB,EACrB,6BAA6B,EAC7B,6BAA6B,EAC7B,YAAY,GACf,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/flows/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACH,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,0BAA0B,GAC7B,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACH,iBAAiB,EACjB,yBAAyB,EACzB,4BAA4B,EAC5B,WAAW,EACX,mBAAmB,GACtB,MAAM,oBAAoB,CAAC;AAa5B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EACH,eAAe,EACf,WAAW,EACX,oCAAoC,EACpC,8BAA8B,EAC9B,kBAAkB,GACrB,MAAM,gBAAgB,CAAC;AAiBxB,OAAO,EACH,qBAAqB,EACrB,6BAA6B,EAC7B,6BAA6B,EAC7B,YAAY,GACf,MAAM,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kasufinance/kasu-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"description": "TypeScript SDK for the Kasu Finance protocol — pool data, portfolio analytics, and KYC-gated deposits and withdrawals on Base and XDC",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kasu",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"build-tc": "typechain --target ethers-v5 --out-dir src/contracts './abis/*.json'",
|
|
49
49
|
"build": "eslint . && tsc --build --force tsconfig.json",
|
|
50
50
|
"prepublishOnly": "npm run build && npm run rollup-build",
|
|
51
|
+
"prepare": "node .githooks/install.cjs",
|
|
51
52
|
"build:watch": "npx tsc -b --force --watch",
|
|
52
53
|
"rollup-build": "rollup -c",
|
|
53
54
|
"lint": "eslint . --fix"
|
package/src/domain/index.ts
CHANGED
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
* reconstructs byte-for-byte to verify a lender's signature. Those are not
|
|
17
17
|
* copy: nobody may reword them, in any language, without a matching backend
|
|
18
18
|
* change, which is exactly why they belong in one place.
|
|
19
|
+
*
|
|
20
|
+
* `pickShortDescription` returns a string but AUTHORS none: it selects and
|
|
21
|
+
* cleans editorial the CMS already holds, and an absent blurb is
|
|
22
|
+
* `undefined`, never a sentence of its own.
|
|
19
23
|
* 2. **Pure.** No network, no clock, no environment. Anything with I/O belongs
|
|
20
24
|
* in `facade/` (see `fetchUnusedPoolIds`).
|
|
21
25
|
*/
|
|
@@ -155,6 +159,7 @@ export {
|
|
|
155
159
|
encodeCancelDepositCall,
|
|
156
160
|
encodeCancelWithdrawalCall,
|
|
157
161
|
encodeRequestWithdrawalCall,
|
|
162
|
+
encodeStableTransfer,
|
|
158
163
|
encodeWithdrawAtExpiryCall,
|
|
159
164
|
SPONSORED_CALL_KINDS,
|
|
160
165
|
SPONSORED_CALL_SELECTORS,
|
|
@@ -162,6 +167,9 @@ export {
|
|
|
162
167
|
} from './sponsored-calls';
|
|
163
168
|
export type { SponsoredCall, SponsoredCallKind } from './sponsored-calls';
|
|
164
169
|
|
|
170
|
+
export { pickShortDescription } from './strategy-summary';
|
|
171
|
+
export type { ShortDescriptionSource } from './strategy-summary';
|
|
172
|
+
|
|
165
173
|
export { getTrancheDisplayName, UPPER_MEZZANINE } from './tranche-display-name';
|
|
166
174
|
|
|
167
175
|
export {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { BigNumber, BigNumberish, constants, utils } from 'ethers';
|
|
2
2
|
|
|
3
|
+
import { IERC20MetadataAbi__factory } from '../contracts/factories/IERC20MetadataAbi__factory';
|
|
3
4
|
import { ILendingPoolManagerAbi__factory } from '../contracts/factories/ILendingPoolManagerAbi__factory';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
* The single-call
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* The single-call requests a sponsored relay may carry — the four
|
|
8
|
+
* `LendingPoolManager` requests, plus the stable asset's own `transfer` (P2P
|
|
9
|
+
* Send) — encoded by the SDK so no application hand-builds calldata or
|
|
10
|
+
* hand-maps the relay's `kind` for them.
|
|
9
11
|
*
|
|
10
12
|
* Every function here is PURE: addresses and ids in, `{ kind, call }` out.
|
|
11
13
|
* Reading the chain (the shares a withdrawal is for) is the facade's job —
|
|
@@ -34,6 +36,11 @@ export const SPONSORED_CALL_KINDS = [
|
|
|
34
36
|
'cancel_withdrawal',
|
|
35
37
|
/** `LendingPoolManager.requestFixedTermDepositWithdrawal(pool, lockId)`. */
|
|
36
38
|
'withdraw_at_expiry',
|
|
39
|
+
/**
|
|
40
|
+
* `stableAsset.transfer(to, amount)` — P2P Send, to the chain's stable
|
|
41
|
+
* asset rather than the manager. See {@link encodeStableTransfer}.
|
|
42
|
+
*/
|
|
43
|
+
'transfer',
|
|
37
44
|
] as const;
|
|
38
45
|
|
|
39
46
|
export type SponsoredCallKind = (typeof SPONSORED_CALL_KINDS)[number];
|
|
@@ -56,18 +63,26 @@ export interface SponsoredCall {
|
|
|
56
63
|
const LENDING_POOL_MANAGER: utils.Interface =
|
|
57
64
|
ILendingPoolManagerAbi__factory.createInterface();
|
|
58
65
|
|
|
59
|
-
/** The `
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
/** The generated ERC-20 interface — the `transfer` kind's one function. */
|
|
67
|
+
const ERC20: utils.Interface = IERC20MetadataAbi__factory.createInterface();
|
|
68
|
+
|
|
69
|
+
/** The kinds whose call goes to the `LendingPoolManager`. */
|
|
70
|
+
type LendingPoolManagerKind = Exclude<SponsoredCallKind, 'transfer'>;
|
|
71
|
+
|
|
72
|
+
/** The `LendingPoolManager` function behind each manager kind. */
|
|
73
|
+
const FUNCTION_OF: Readonly<Record<LendingPoolManagerKind, string>> =
|
|
74
|
+
Object.freeze({
|
|
75
|
+
withdrawal: 'requestWithdrawal',
|
|
76
|
+
cancel_deposit: 'cancelDepositRequest',
|
|
77
|
+
cancel_withdrawal: 'cancelWithdrawalRequest',
|
|
78
|
+
withdraw_at_expiry: 'requestFixedTermDepositWithdrawal',
|
|
79
|
+
});
|
|
66
80
|
|
|
67
81
|
/**
|
|
68
82
|
* The 4-byte selector of each kind's function, DERIVED from the generated
|
|
69
|
-
* `ILendingPoolManager`
|
|
70
|
-
* it and the cross-check spec
|
|
83
|
+
* ABIs (`ILendingPoolManager`, and `IERC20Metadata` for `transfer`) — never
|
|
84
|
+
* typed in by hand, so an ABI change moves it and the cross-check spec
|
|
85
|
+
* against the relay's own pins goes red.
|
|
71
86
|
*/
|
|
72
87
|
export const SPONSORED_CALL_SELECTORS: Readonly<
|
|
73
88
|
Record<SponsoredCallKind, string>
|
|
@@ -80,6 +95,7 @@ export const SPONSORED_CALL_SELECTORS: Readonly<
|
|
|
80
95
|
withdraw_at_expiry: LENDING_POOL_MANAGER.getSighash(
|
|
81
96
|
FUNCTION_OF.withdraw_at_expiry,
|
|
82
97
|
),
|
|
98
|
+
transfer: ERC20.getSighash('transfer'),
|
|
83
99
|
});
|
|
84
100
|
|
|
85
101
|
/**
|
|
@@ -122,7 +138,7 @@ function toUint256(value: BigNumberish, code: string): BigNumber {
|
|
|
122
138
|
}
|
|
123
139
|
|
|
124
140
|
function encode(
|
|
125
|
-
kind:
|
|
141
|
+
kind: LendingPoolManagerKind,
|
|
126
142
|
lendingPoolManager: string,
|
|
127
143
|
args: readonly unknown[],
|
|
128
144
|
): SponsoredCall {
|
|
@@ -211,3 +227,53 @@ export function encodeWithdrawAtExpiryCall(
|
|
|
211
227
|
toUint256(fixedTermDepositId, 'lock-id'),
|
|
212
228
|
]);
|
|
213
229
|
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* `stableAsset.transfer(to, amount)` — `transfer`: P2P Send of the chain's
|
|
233
|
+
* stable asset from the sender's own account (`msg.sender`) to `to`.
|
|
234
|
+
*
|
|
235
|
+
* `amount` is in the token's BASE units (6 decimals for USDC), and must be
|
|
236
|
+
* greater than zero. `to` must be a well-formed, non-zero address (a
|
|
237
|
+
* mixed-case one with a valid EIP-55 checksum). That is
|
|
238
|
+
* ALL this encoder judges, because it is all a pure function can know.
|
|
239
|
+
*
|
|
240
|
+
* The recipient POLICY is the relay's job and is deliberately not restated
|
|
241
|
+
* here: it refuses the sender's own account, the stable asset, the
|
|
242
|
+
* `LendingPoolManager`, the precompile range, any address with contract code
|
|
243
|
+
* (read on chain at submission), a sender our identity store does not hold
|
|
244
|
+
* as verified, and anything over the sender's daily count and amount caps.
|
|
245
|
+
* A call this encoder accepts can therefore still be refused — the app maps
|
|
246
|
+
* the relay's refusal codes to its own words.
|
|
247
|
+
*
|
|
248
|
+
* Pass `stableAsset` from the chain config (`CHAIN_CONFIGS[chain].stableAsset
|
|
249
|
+
* .address`) — the relay compares `to` against its own configured token and
|
|
250
|
+
* refuses any other contract.
|
|
251
|
+
*/
|
|
252
|
+
export function encodeStableTransfer(input: {
|
|
253
|
+
stableAsset: string;
|
|
254
|
+
to: string;
|
|
255
|
+
amount: BigNumberish;
|
|
256
|
+
}): SponsoredCall {
|
|
257
|
+
assertAddress(input.stableAsset, 'stable-asset');
|
|
258
|
+
assertAddress(input.to, 'recipient');
|
|
259
|
+
// A mixed-case recipient carries an EIP-55 checksum, and one that does not
|
|
260
|
+
// match is a mistyped address: refuse it as `recipient` here rather than
|
|
261
|
+
// let the ABI coder throw its own error at the encode below.
|
|
262
|
+
try {
|
|
263
|
+
utils.getAddress(input.to);
|
|
264
|
+
} catch {
|
|
265
|
+
throw new SponsoredCallInputError('recipient');
|
|
266
|
+
}
|
|
267
|
+
if (BigNumber.from(input.to).isZero()) {
|
|
268
|
+
throw new SponsoredCallInputError('zero-recipient');
|
|
269
|
+
}
|
|
270
|
+
const amount = toUint256(input.amount, 'amount');
|
|
271
|
+
if (amount.isZero()) throw new SponsoredCallInputError('zero-amount');
|
|
272
|
+
return {
|
|
273
|
+
kind: 'transfer',
|
|
274
|
+
call: {
|
|
275
|
+
to: input.stableAsset,
|
|
276
|
+
data: ERC20.encodeFunctionData('transfer', [input.to, amount]),
|
|
277
|
+
},
|
|
278
|
+
};
|
|
279
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A strategy's SHORT blurb, as plain text: the CMS `liteDescription` first,
|
|
3
|
+
* else the first paragraph of the long `description`, else nothing.
|
|
4
|
+
*
|
|
5
|
+
* Lifted from kasu-ui (`pickShortDescription`, its deposit dialog and landing
|
|
6
|
+
* strategy card) so every app shows the same line, and pinned to its output
|
|
7
|
+
* for every live CMS row. The rules are facts about how the CMS is authored,
|
|
8
|
+
* not formatting preferences:
|
|
9
|
+
*
|
|
10
|
+
* - `liteDescription` IS THE SHORT ONE. `description` is the credit
|
|
11
|
+
* originator's several-paragraph profile; on a card it is a wall.
|
|
12
|
+
* - `"Not Available"` IS A PLACEHOLDER, not editorial. Several rows carry it
|
|
13
|
+
* verbatim, and it must read as missing, not print. Matched on the whole
|
|
14
|
+
* trimmed value, case-insensitively. It applies to `liteDescription` only.
|
|
15
|
+
* - EMPTY OR BLANK IS MISSING. The service maps a pool with no CMS record to
|
|
16
|
+
* `''`.
|
|
17
|
+
* - THE FIELDS HOLD MARKDOWN. `liteDescription` can open with a `**bold**`
|
|
18
|
+
* lead, and the surfaces this feeds render plain text, so the markers are
|
|
19
|
+
* stripped (bold, then italic, then inline code).
|
|
20
|
+
* - AND HARD NEWLINES. Every run of whitespace becomes one space, so a
|
|
21
|
+
* paragraph break inside the value is not a gap in a one-line slot.
|
|
22
|
+
* - NOT SANITISED. "Plain text" means text to render AS text. HTML tags,
|
|
23
|
+
* entities and link syntax (`<script>`, `<`, `[a](javascript:…)`) pass
|
|
24
|
+
* through unchanged, and removing markers can join fragments into a tag
|
|
25
|
+
* (`<scr**i**pt>` becomes `<script>`). Render it as a text node, never as
|
|
26
|
+
* HTML or markdown.
|
|
27
|
+
*
|
|
28
|
+
* Two refinements over the kasu-ui original, neither reachable by any live
|
|
29
|
+
* row: the cleaned text is trimmed (a CRLF value no longer ends in a space),
|
|
30
|
+
* and a `liteDescription` that cleans to nothing (`** **`) counts as missing,
|
|
31
|
+
* so the result is never a blank string.
|
|
32
|
+
*
|
|
33
|
+
* This authors no string of its own. It selects and cleans editorial the CMS
|
|
34
|
+
* already holds, and an absent blurb is `undefined`, never a fallback sentence:
|
|
35
|
+
* what "no blurb" means is the render site's decision.
|
|
36
|
+
*
|
|
37
|
+
* Pure. A value that is not a string reads as missing.
|
|
38
|
+
*/
|
|
39
|
+
export function pickShortDescription(
|
|
40
|
+
source: ShortDescriptionSource,
|
|
41
|
+
): string | undefined {
|
|
42
|
+
const lite = asTrimmed(source.liteDescription);
|
|
43
|
+
if (lite && !NOT_AVAILABLE.test(lite)) {
|
|
44
|
+
const summary = toOneLine(lite);
|
|
45
|
+
if (summary) return summary;
|
|
46
|
+
}
|
|
47
|
+
const long = asTrimmed(source.description);
|
|
48
|
+
if (long) {
|
|
49
|
+
const firstParagraph = long.split(PARAGRAPH_BREAK, 1)[0] ?? long;
|
|
50
|
+
return toOneLine(firstParagraph) || undefined;
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The two CMS fields `pickShortDescription` reads. A `PoolOverview` and a
|
|
57
|
+
* facade `Strategy` both satisfy it.
|
|
58
|
+
*/
|
|
59
|
+
export interface ShortDescriptionSource {
|
|
60
|
+
liteDescription?: string | null;
|
|
61
|
+
description?: string | null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const NOT_AVAILABLE = /^not available$/i;
|
|
65
|
+
const PARAGRAPH_BREAK = /\n\s*\n/;
|
|
66
|
+
|
|
67
|
+
function asTrimmed(value: unknown): string {
|
|
68
|
+
return typeof value === 'string' ? value.trim() : '';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Markers off, whitespace runs to one space, ends trimmed. `''` when nothing is left. */
|
|
72
|
+
function toOneLine(text: string): string {
|
|
73
|
+
return stripInlineMarkdown(text).replace(/\s+/gu, ' ').trim();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Inline markdown markers off, in the order bold → italic → code. The bold
|
|
78
|
+
* passes consume every `**` / `__` pair first, so the italic patterns can match
|
|
79
|
+
* a lone `*` / `_` without lookarounds.
|
|
80
|
+
*/
|
|
81
|
+
function stripInlineMarkdown(input: string): string {
|
|
82
|
+
return input
|
|
83
|
+
.replace(/\*\*(.+?)\*\*/g, '$1')
|
|
84
|
+
.replace(/__(.+?)__/g, '$1')
|
|
85
|
+
.replace(/\*(.+?)\*/g, '$1')
|
|
86
|
+
.replace(/_(.+?)_/g, '$1')
|
|
87
|
+
.replace(/`([^`]+)`/g, '$1');
|
|
88
|
+
}
|