@kasufinance/kasu-sdk 2.7.1 → 2.10.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 (88) hide show
  1. package/README.md +162 -7
  2. package/dist/bundle.cjs.js +2292 -449
  3. package/dist/bundle.esm.js +2253 -451
  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 +40 -3
  34. package/dist/facade/flows.js +36 -3
  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 -4
  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 +128 -4
  53. package/dist/flows/deposit-flow.js +233 -4
  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 +3 -1
  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/UserLending/user-lending.d.ts +13 -0
  64. package/dist/services/UserLending/user-lending.js +25 -4
  65. package/dist/services/UserLending/user-lending.js.map +1 -1
  66. package/package.json +1 -1
  67. package/src/domain/batch-proof.ts +576 -0
  68. package/src/domain/explorer-urls.ts +74 -0
  69. package/src/domain/fixed-term.ts +115 -0
  70. package/src/domain/index.ts +56 -0
  71. package/src/domain/partners.ts +35 -0
  72. package/src/domain/requests.ts +37 -0
  73. package/src/domain/sponsored-calls.ts +213 -0
  74. package/src/domain/yields.ts +189 -0
  75. package/src/facade/calls.ts +135 -0
  76. package/src/facade/chain-configs.ts +5 -0
  77. package/src/facade/flows.ts +35 -2
  78. package/src/facade/index.ts +3 -0
  79. package/src/facade/kasu.ts +32 -2
  80. package/src/facade/strategies.ts +98 -7
  81. package/src/facade/types.ts +19 -0
  82. package/src/flows/batch-errors.ts +118 -0
  83. package/src/flows/batch-submission.ts +511 -0
  84. package/src/flows/deposit-flow.ts +379 -7
  85. package/src/flows/index.ts +34 -1
  86. package/src/flows/withdraw-flow.ts +219 -10
  87. package/src/services/DataService/queries.ts +1 -0
  88. package/src/services/UserLending/user-lending.ts +38 -10
@@ -1,5 +1,6 @@
1
1
  import type { IERC20MetadataAbi } from '../contracts';
2
2
  import { DepositFlow, DepositFlowOptions, DepositPorts, WithdrawFlow, WithdrawPorts } from '../flows';
3
+ import { CallsFacade } from './calls';
3
4
  import { DepositsFacade } from './deposits';
4
5
  /**
5
6
  * The ports a consumer MUST supply for a deposit, plus optional overrides for
@@ -12,8 +13,9 @@ import { DepositsFacade } from './deposits';
12
13
  */
13
14
  export type DepositFlowPortOverrides = Pick<DepositPorts, 'signMessage' | 'generateContract' | 'getKycSignature'> & Partial<DepositPorts>;
14
15
  /**
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.
16
+ * Every withdraw port has an SDK default except `getKycSignature` and
17
+ * `submitCall`, which have no default at all: supplying `getKycSignature`
18
+ * turns the KYC pre-check on, supplying `submitCall` the sponsored path.
17
19
  */
18
20
  export type WithdrawFlowPortOverrides = Partial<WithdrawPorts>;
19
21
  /**
@@ -55,6 +57,19 @@ export declare class FlowsFacade {
55
57
  * contract.
56
58
  */
57
59
  private readonly _spender;
60
+ /**
61
+ * This chain's stable token address — the target of the batch path's
62
+ * approve. `undefined` for a hand-built config without `stableAsset`,
63
+ * in which case a run never batches: it does not guess a token.
64
+ */
65
+ private readonly _stableAsset?;
66
+ /**
67
+ * This instance's call encoders — the sponsored withdraw path's
68
+ * default `encodeWithdrawal`. Optional so a hand-built facade keeps
69
+ * constructing; without it a sponsored run fails (`failed`, nothing
70
+ * sent) unless the consumer passes `encodeWithdrawal` itself.
71
+ */
72
+ private readonly _calls?;
58
73
  constructor(_deposits: DepositsFacade,
59
74
  /**
60
75
  * The chain's stable token, bound to whatever the Kasu instance holds.
@@ -71,7 +86,20 @@ export declare class FlowsFacade {
71
86
  * an address whose only wrong value grants an approval to the wrong
72
87
  * contract.
73
88
  */
74
- _spender: string);
89
+ _spender: string,
90
+ /**
91
+ * This chain's stable token address — the target of the batch path's
92
+ * approve. `undefined` for a hand-built config without `stableAsset`,
93
+ * in which case a run never batches: it does not guess a token.
94
+ */
95
+ _stableAsset?: string | undefined,
96
+ /**
97
+ * This instance's call encoders — the sponsored withdraw path's
98
+ * default `encodeWithdrawal`. Optional so a hand-built facade keeps
99
+ * constructing; without it a sponsored run fails (`failed`, nothing
100
+ * sent) unless the consumer passes `encodeWithdrawal` itself.
101
+ */
102
+ _calls?: CallsFacade | undefined);
75
103
  /**
76
104
  * A deposit pipeline. `readAllowance`, `approve`, `deposit` and
77
105
  * `buildKycParams` default to the SDK's own implementations; pass any of
@@ -83,13 +111,22 @@ export declare class FlowsFacade {
83
111
  * delete the default it was meant to keep, and
84
112
  * `approve: sponsoredGas ? sponsoredApprove : undefined` is exactly how a
85
113
  * consumer writes a conditional override.
114
+ *
115
+ * `depositBatch` has NO default: how several calls become one atomic
116
+ * transaction is the application's business. Supplying it lets a run
117
+ * whose allowance is short approve and deposit in one batch.
86
118
  */
87
119
  deposit(ports: DepositFlowPortOverrides, opts?: DepositFlowOptions): DepositFlow;
88
120
  /**
89
121
  * A withdrawal pipeline. Both write ports and `buildKycParams` default to
90
122
  * this instance; supplying `getKycSignature` turns the KYC pre-check on.
123
+ * Supplying `submitCall` turns the sponsored path on, and its encoder
124
+ * defaults to `kasu.calls.requestWithdrawal` on this instance — which
125
+ * reads, never writes, so it works on a read-only instance too.
91
126
  * Defaults are applied per key, for the reason `deposit()` gives.
92
127
  */
93
128
  withdraw(ports?: WithdrawFlowPortOverrides): WithdrawFlow;
129
+ /** `kasu.calls.requestWithdrawal`, when this facade was given the encoders. */
130
+ private _defaultEncoder;
94
131
  private _assertWritable;
95
132
  }
@@ -47,11 +47,26 @@ export class FlowsFacade {
47
47
  * an address whose only wrong value grants an approval to the wrong
48
48
  * contract.
49
49
  */
50
- _spender) {
50
+ _spender,
51
+ /**
52
+ * This chain's stable token address — the target of the batch path's
53
+ * approve. `undefined` for a hand-built config without `stableAsset`,
54
+ * in which case a run never batches: it does not guess a token.
55
+ */
56
+ _stableAsset,
57
+ /**
58
+ * This instance's call encoders — the sponsored withdraw path's
59
+ * default `encodeWithdrawal`. Optional so a hand-built facade keeps
60
+ * constructing; without it a sponsored run fails (`failed`, nothing
61
+ * sent) unless the consumer passes `encodeWithdrawal` itself.
62
+ */
63
+ _calls) {
51
64
  this._deposits = _deposits;
52
65
  this._erc20 = _erc20;
53
66
  this._isReadOnly = _isReadOnly;
54
67
  this._spender = _spender;
68
+ this._stableAsset = _stableAsset;
69
+ this._calls = _calls;
55
70
  }
56
71
  /**
57
72
  * A deposit pipeline. `readAllowance`, `approve`, `deposit` and
@@ -64,9 +79,13 @@ export class FlowsFacade {
64
79
  * delete the default it was meant to keep, and
65
80
  * `approve: sponsoredGas ? sponsoredApprove : undefined` is exactly how a
66
81
  * consumer writes a conditional override.
82
+ *
83
+ * `depositBatch` has NO default: how several calls become one atomic
84
+ * transaction is the application's business. Supplying it lets a run
85
+ * whose allowance is short approve and deposit in one batch.
67
86
  */
68
87
  deposit(ports, opts) {
69
- var _a, _b, _c, _d, _e;
88
+ var _a, _b, _c, _d, _e, _f;
70
89
  return new DepositFlow({
71
90
  signMessage: ports.signMessage,
72
91
  generateContract: ports.generateContract,
@@ -81,21 +100,26 @@ export class FlowsFacade {
81
100
  return yield this._erc20().approve(spender, amount);
82
101
  })),
83
102
  deposit: (_d = ports.deposit) !== null && _d !== void 0 ? _d : ((params) => this._deposits.deposit(params)),
103
+ depositBatch: ports.depositBatch,
84
104
  now: ports.now,
85
105
  }, {
86
106
  contractTtlMs: opts === null || opts === void 0 ? void 0 : opts.contractTtlMs,
87
107
  // Per key here too, for the same reason the ports are: an
88
108
  // explicit `spender: undefined` must not delete the default.
89
109
  spender: (_e = opts === null || opts === void 0 ? void 0 : opts.spender) !== null && _e !== void 0 ? _e : this._spender,
110
+ stableAsset: (_f = opts === null || opts === void 0 ? void 0 : opts.stableAsset) !== null && _f !== void 0 ? _f : this._stableAsset,
90
111
  });
91
112
  }
92
113
  /**
93
114
  * A withdrawal pipeline. Both write ports and `buildKycParams` default to
94
115
  * this instance; supplying `getKycSignature` turns the KYC pre-check on.
116
+ * Supplying `submitCall` turns the sponsored path on, and its encoder
117
+ * defaults to `kasu.calls.requestWithdrawal` on this instance — which
118
+ * reads, never writes, so it works on a read-only instance too.
95
119
  * Defaults are applied per key, for the reason `deposit()` gives.
96
120
  */
97
121
  withdraw(ports = {}) {
98
- var _a, _b, _c;
122
+ var _a, _b, _c, _d;
99
123
  return new WithdrawFlow({
100
124
  buildKycParams: (_a = ports.buildKycParams) !== null && _a !== void 0 ? _a : ((userAddress) => this._deposits.buildKycParams(userAddress)),
101
125
  getKycSignature: ports.getKycSignature,
@@ -105,8 +129,17 @@ export class FlowsFacade {
105
129
  amount: params.amount,
106
130
  })),
107
131
  withdrawMax: (_c = ports.withdrawMax) !== null && _c !== void 0 ? _c : ((poolId, trancheId, userAddress) => this._deposits.withdrawMax(poolId, trancheId, userAddress)),
132
+ submitCall: ports.submitCall,
133
+ encodeWithdrawal: (_d = ports.encodeWithdrawal) !== null && _d !== void 0 ? _d : this._defaultEncoder(),
108
134
  });
109
135
  }
136
+ /** `kasu.calls.requestWithdrawal`, when this facade was given the encoders. */
137
+ _defaultEncoder() {
138
+ const calls = this._calls;
139
+ if (!calls)
140
+ return undefined;
141
+ return (params) => calls.requestWithdrawal(params);
142
+ }
110
143
  _assertWritable() {
111
144
  if (this._isReadOnly) {
112
145
  throw new Error(READ_ONLY_MESSAGE);
@@ -1 +1 @@
1
- {"version":3,"file":"flows.js","sourceRoot":"","sources":["../../src/facade/flows.ts"],"names":[],"mappings":";;;;;;;;;AAGA,OAAO,EACH,WAAW,EAIX,YAAY,GAEf,MAAM,UAAU,C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P,MAAA,KAAK,CAAC,WAAW,mCACjB,CAAC,CACG,MAAc,EACd,SAAiB,EACjB,WAAmB,EACS,EAAE,CAC9B,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;YACnE,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,gBAAgB,EAAE,MAAA,KAAK,CAAC,gBAAgB,mCAAI,IAAI,CAAC,eAAe,EAAE;SACrE,CAAC,CAAC;IACP,CAAC;IAED,+EAA+E;IACvE,eAAe;QACnB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,KAAK;YAAE,OAAO,SAAS,CAAC;QAC7B,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACvD,CAAC;IAEO,eAAe;QACnB,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACvC,CAAC;IACL,CAAC;CACJ"}
@@ -3,8 +3,10 @@ export { StrategiesFacade } from './strategies';
3
3
  export { DepositsFacade } from './deposits';
4
4
  export { PortfolioFacade } from './user-portfolio';
5
5
  export { FlowsFacade } from './flows';
6
+ export { CallsFacade } from './calls';
7
+ export type { RequestWithdrawalCallParams } from './calls';
6
8
  export type { DepositFlowPortOverrides, WithdrawFlowPortOverrides, } from './flows';
7
9
  export { READ_ONLY_MESSAGE } from './read-only';
8
10
  export { CHAIN_CONFIGS } from './chain-configs';
9
11
  export { fetchUnusedPoolIds } from './unused-pool-ids';
10
- export type { SupportedChain, ChainConfigEntry, StableAsset, KasuOptions, Strategy, StrategyTranche, FixedTermOption, DepositParams, WithdrawParams, DepositLimits, KycParams, UserPositions, PlatformStats, } from './types';
12
+ export type { SupportedChain, ChainConfigEntry, StableAsset, KasuOptions, Strategy, StrategyTranche, FixedTermOption, DepositParams, WithdrawParams, DepositLimits, KycParams, UserPositions, PlatformStats, StrategyRiskPerformance, } from './types';
@@ -5,6 +5,7 @@ export { StrategiesFacade } from './strategies';
5
5
  export { DepositsFacade } from './deposits';
6
6
  export { PortfolioFacade } from './user-portfolio';
7
7
  export { FlowsFacade } from './flows';
8
+ export { CallsFacade } from './calls';
8
9
  // The one refusal every write path shares
9
10
  export { READ_ONLY_MESSAGE } from './read-only';
10
11
  // Chain configurations
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/facade/index.ts"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,gDAAgD;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAMtC,0CAA0C;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,uBAAuB;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,wDAAwD;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/facade/index.ts"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,gDAAgD;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAOtC,0CAA0C;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,uBAAuB;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,wDAAwD;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { Provider } from '@ethersproject/providers';
2
2
  import { Signer } from 'ethers';
3
3
  import { KasuSdk } from '../kasu-sdk';
4
+ import { CallsFacade } from './calls';
4
5
  import { DepositsFacade } from './deposits';
5
6
  import { FlowsFacade } from './flows';
6
7
  import { StrategiesFacade } from './strategies';
@@ -9,8 +10,8 @@ import { PortfolioFacade } from './user-portfolio';
9
10
  /**
10
11
  * High-level entry point for external integrators.
11
12
  *
12
- * Provides four domain facades — `strategies`, `deposits`, `portfolio`,
13
- * `flows` — and exposes the underlying `KasuSdk` services via `.services` for
13
+ * Provides five domain facades — `strategies`, `deposits`, `portfolio`,
14
+ * `flows`, `calls` — and exposes the underlying `KasuSdk` services via `.services` for
14
15
  * power-users.
15
16
  *
16
17
  * ```ts
@@ -37,6 +38,11 @@ export declare class Kasu {
37
38
  readonly portfolio: PortfolioFacade;
38
39
  /** Headless deposit / withdraw state machines. */
39
40
  readonly flows: FlowsFacade;
41
+ /**
42
+ * Encoded `LendingPoolManager` calls for a sponsored relay — withdraw,
43
+ * cancel, withdraw at expiry. Read, then encode; never sends.
44
+ */
45
+ readonly calls: CallsFacade;
40
46
  private readonly _sdk;
41
47
  private readonly _chainConfig;
42
48
  private readonly _signerOrProvider;
@@ -2,6 +2,7 @@ import { providers, Signer } from 'ethers';
2
2
  import { IERC20MetadataAbi__factory } from '../contracts';
3
3
  import { KasuSdk } from '../kasu-sdk';
4
4
  import { SdkConfig } from '../sdk-config';
5
+ import { CallsFacade } from './calls';
5
6
  import { CHAIN_CONFIGS } from './chain-configs';
6
7
  import { DepositsFacade } from './deposits';
7
8
  import { FlowsFacade } from './flows';
@@ -10,8 +11,8 @@ import { PortfolioFacade } from './user-portfolio';
10
11
  /**
11
12
  * High-level entry point for external integrators.
12
13
  *
13
- * Provides four domain facades — `strategies`, `deposits`, `portfolio`,
14
- * `flows` — and exposes the underlying `KasuSdk` services via `.services` for
14
+ * Provides five domain facades — `strategies`, `deposits`, `portfolio`,
15
+ * `flows`, `calls` — and exposes the underlying `KasuSdk` services via `.services` for
15
16
  * power-users.
16
17
  *
17
18
  * ```ts
@@ -31,18 +32,22 @@ import { PortfolioFacade } from './user-portfolio';
31
32
  */
32
33
  export class Kasu {
33
34
  constructor(sdk, chainConfig, signerOrProvider, configOverrides) {
35
+ var _a, _b;
34
36
  this._sdk = sdk;
35
37
  this._chainConfig = chainConfig;
36
38
  this._signerOrProvider = signerOrProvider;
37
39
  this._configOverrides = configOverrides;
38
- this.strategies = new StrategiesFacade(sdk.DataService, sdk.UserLending);
40
+ this.strategies = new StrategiesFacade(sdk.DataService, sdk.UserLending, normaliseMapping((_a = configOverrides.poolMetadataMapping) !== null && _a !== void 0 ? _a : chainConfig.poolMetadataMapping));
39
41
  // Derived ONCE and handed to every facade that needs it. Each of them
40
42
  // re-deriving `Signer.isSigner` is how two facades come to disagree
41
43
  // about whether the same instance can write.
42
44
  const isReadOnly = !Signer.isSigner(signerOrProvider);
43
45
  this.deposits = new DepositsFacade(sdk.UserLending, chainConfig.chainId.toString(), isReadOnly);
44
46
  this.portfolio = new PortfolioFacade(sdk.DataService, sdk.UserLending, sdk.Portfolio);
45
- this.flows = new FlowsFacade(this.deposits, () => erc20Of(chainConfig, signerOrProvider), isReadOnly, chainConfig.contracts.LendingPoolManager);
47
+ // The same `LendingPoolManager` the deposit flow approves and calls:
48
+ // the chain config's, which is what a relay allow-lists `to` against.
49
+ this.calls = new CallsFacade(sdk.UserLending, chainConfig.contracts.LendingPoolManager);
50
+ this.flows = new FlowsFacade(this.deposits, () => erc20Of(chainConfig, signerOrProvider), isReadOnly, chainConfig.contracts.LendingPoolManager, (_b = stableAssetOf(chainConfig)) === null || _b === void 0 ? void 0 : _b.address, this.calls);
46
51
  }
47
52
  /**
48
53
  * Create a Kasu instance with built-in chain config.
@@ -227,4 +232,12 @@ function resolveChainConfig(chain) {
227
232
  }
228
233
  return chain;
229
234
  }
235
+ /** Lowercase both sides, so a lookup by any casing of a pool id matches. */
236
+ function normaliseMapping(mapping) {
237
+ const out = {};
238
+ for (const [from, to] of Object.entries(mapping !== null && mapping !== void 0 ? mapping : {})) {
239
+ out[from.toLowerCase()] = to.toLowerCase();
240
+ }
241
+ return out;
242
+ }
230
243
  //# sourceMappingURL=kasu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"kasu.js","sourceRoot":"","sources":["../../src/facade/kasu.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,SAAS,EAAoB,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAOhD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,IAAI;IAoBb,YACI,GAAY,EACZ,WAA6B,EAC7B,gBAAmC,EACnC,eAA0C;QAE1C,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,CAAC;QAC1C,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;QAExC,IAAI,CAAC,UAAU,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,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACX,6FAA6F,CAChG,CAAC;IACN,CAAC;IACD,OAAO,0BAA0B,CAAC,OAAO,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;AACzE,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAS,eAAe,CACpB,WAA6B,EAC7B,UAAkB;IAElB,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,IAAI,CAAC,GAAG,EAAE,CAAC;QACP,MAAM,IAAI,KAAK,CACX,uBAAuB,UAAU,uDAAuD,CAC3F,CAAC;IACN,CAAC;IACD,OAAO,IAAI,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,kBAAkB,CACvB,KAAwC;IAExC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,4EAA4E;AAC5E,SAAS,gBAAgB,CACrB,OAA2C;IAE3C,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC,EAAE,CAAC;QACrD,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC;IAC/C,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { DataService } from '../services/DataService/data-service';
2
+ import { PoolDelegateProfileAndHistory } from '../services/DataService/types';
2
3
  import { UserLending } from '../services/UserLending/user-lending';
3
- import { DepositLimits, PlatformStats, Strategy, StrategyTranche } from './types';
4
+ import { DepositLimits, PlatformStats, Strategy, StrategyRiskPerformance, StrategyTranche } from './types';
4
5
  /**
5
6
  * High-level facade for browsing Kasu lending strategies (pools).
6
7
  *
@@ -9,7 +10,47 @@ import { DepositLimits, PlatformStats, Strategy, StrategyTranche } from './types
9
10
  export declare class StrategiesFacade {
10
11
  private _dataService;
11
12
  private _userLending;
12
- constructor(_dataService: DataService, _userLending: UserLending);
13
+ /**
14
+ * Chain pool id → the pool id its CMS record is keyed by (XDC pools
15
+ * share their Base counterpart's editorial record). Lowercase keys.
16
+ */
17
+ private _poolMetadataMapping;
18
+ constructor(_dataService: DataService, _userLending: UserLending,
19
+ /**
20
+ * Chain pool id → the pool id its CMS record is keyed by (XDC pools
21
+ * share their Base counterpart's editorial record). Lowercase keys.
22
+ */
23
+ _poolMetadataMapping?: Record<string, string>);
24
+ /**
25
+ * The pool's loss rate and first-loss capital, from its CMS
26
+ * risk-management record. `null` when the pool has no record.
27
+ *
28
+ * Each figure is a NUMBER or `null` — never a guess. The CMS returns
29
+ * "numeric" fields as a number, a numeric string, an empty string or
30
+ * null, and an empty string must not become a confident `0`: anything that
31
+ * is not a finite number reads as `null` (render "—"). `poolLossRate` is a
32
+ * 0..1 fraction.
33
+ *
34
+ * Requires `directusUrl`; without it the call rejects with
35
+ * `NO_DIRECTUS_URL_MESSAGE`, like every CMS-only read.
36
+ */
37
+ getRiskPerformance(poolId: string): Promise<StrategyRiskPerformance | null>;
38
+ /**
39
+ * The credit originator's profile and lending history for a pool — the
40
+ * CMS record whose `otherKASUPools` lists it. `null` when none does.
41
+ *
42
+ * Matched on the chain pool id, then on its metadata id, case-
43
+ * insensitively. The record is returned as the service maps it; its
44
+ * numeric fields are CMS-authored, so read them defensively.
45
+ *
46
+ * The service filters `otherKASUPools` through the CURRENT chain's
47
+ * subgraph with the CMS record's (Base-keyed) ids, so on an XDC
48
+ * deployment every profile lists no pools and this resolves `null` —
49
+ * the same answer kasu-ui's own lookup gives there today. The metadata
50
+ * candidate becomes live once the service resolves the mapping.
51
+ */
52
+ getOriginator(poolId: string): Promise<PoolDelegateProfileAndHistory | null>;
53
+ private _metadataIdOf;
13
54
  /**
14
55
  * Fetch all active lending strategies.
15
56
  *
@@ -14,9 +14,72 @@ import { selectVisiblePools } from '../domain/pools';
14
14
  * Handles epoch fetching internally so callers never need to know about epochs.
15
15
  */
16
16
  export class StrategiesFacade {
17
- constructor(_dataService, _userLending) {
17
+ constructor(_dataService, _userLending,
18
+ /**
19
+ * Chain pool id → the pool id its CMS record is keyed by (XDC pools
20
+ * share their Base counterpart's editorial record). Lowercase keys.
21
+ */
22
+ _poolMetadataMapping = {}) {
18
23
  this._dataService = _dataService;
19
24
  this._userLending = _userLending;
25
+ this._poolMetadataMapping = _poolMetadataMapping;
26
+ }
27
+ /**
28
+ * The pool's loss rate and first-loss capital, from its CMS
29
+ * risk-management record. `null` when the pool has no record.
30
+ *
31
+ * Each figure is a NUMBER or `null` — never a guess. The CMS returns
32
+ * "numeric" fields as a number, a numeric string, an empty string or
33
+ * null, and an empty string must not become a confident `0`: anything that
34
+ * is not a finite number reads as `null` (render "—"). `poolLossRate` is a
35
+ * 0..1 fraction.
36
+ *
37
+ * Requires `directusUrl`; without it the call rejects with
38
+ * `NO_DIRECTUS_URL_MESSAGE`, like every CMS-only read.
39
+ */
40
+ getRiskPerformance(poolId) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const metadataId = this._metadataIdOf(poolId);
43
+ const records = yield this._dataService.getRiskManagement();
44
+ const record = records.find((r) => String(r.poolIdFK).toLowerCase() === metadataId);
45
+ if (!record)
46
+ return null;
47
+ const performance = record.riskPerformance;
48
+ return {
49
+ poolLossRate: finiteOrNull(performance === null || performance === void 0 ? void 0 : performance.poolLossRate),
50
+ firstLossCapital: finiteOrNull(performance === null || performance === void 0 ? void 0 : performance.firstLossCapital),
51
+ };
52
+ });
53
+ }
54
+ /**
55
+ * The credit originator's profile and lending history for a pool — the
56
+ * CMS record whose `otherKASUPools` lists it. `null` when none does.
57
+ *
58
+ * Matched on the chain pool id, then on its metadata id, case-
59
+ * insensitively. The record is returned as the service maps it; its
60
+ * numeric fields are CMS-authored, so read them defensively.
61
+ *
62
+ * The service filters `otherKASUPools` through the CURRENT chain's
63
+ * subgraph with the CMS record's (Base-keyed) ids, so on an XDC
64
+ * deployment every profile lists no pools and this resolves `null` —
65
+ * the same answer kasu-ui's own lookup gives there today. The metadata
66
+ * candidate becomes live once the service resolves the mapping.
67
+ */
68
+ getOriginator(poolId) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ var _a;
71
+ const candidates = new Set([
72
+ poolId.toLowerCase(),
73
+ this._metadataIdOf(poolId),
74
+ ]);
75
+ const profiles = yield this._dataService.getPoolDelegateProfileAndHistory();
76
+ return ((_a = profiles.find((profile) => profile.otherKASUPools.some((pool) => candidates.has(String(pool.id).toLowerCase())))) !== null && _a !== void 0 ? _a : null);
77
+ });
78
+ }
79
+ _metadataIdOf(poolId) {
80
+ var _a;
81
+ const lower = poolId.toLowerCase();
82
+ return ((_a = this._poolMetadataMapping[lower]) !== null && _a !== void 0 ? _a : lower).toLowerCase();
20
83
  }
21
84
  /**
22
85
  * Fetch all active lending strategies.
@@ -95,9 +158,7 @@ export class StrategiesFacade {
95
158
  */
96
159
  calculateDepositLimits(tranche) {
97
160
  const raw = tranche._raw;
98
- const min = parseFloat(raw.minimumDeposit) < 1
99
- ? '1'
100
- : raw.minimumDeposit;
161
+ const min = parseFloat(raw.minimumDeposit) < 1 ? '1' : raw.minimumDeposit;
101
162
  const max = parseFloat(raw.maximumDeposit) > parseFloat(raw.poolCapacity)
102
163
  ? raw.poolCapacity
103
164
  : raw.maximumDeposit;
@@ -145,4 +206,19 @@ export class StrategiesFacade {
145
206
  };
146
207
  }
147
208
  }
209
+ /**
210
+ * A CMS "numeric" field as a finite number, or `null`. An empty or blank
211
+ * string is UNAUTHORED, not zero.
212
+ */
213
+ function finiteOrNull(value) {
214
+ if (typeof value === 'number')
215
+ return Number.isFinite(value) ? value : null;
216
+ if (typeof value === 'string') {
217
+ if (value.trim() === '')
218
+ return null;
219
+ const numeric = Number(value);
220
+ return Number.isFinite(numeric) ? numeric : null;
221
+ }
222
+ return null;
223
+ }
148
224
  //# sourceMappingURL=strategies.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"strategies.js","sourceRoot":"","sources":["../../src/facade/strategies.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAarD;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IACzB,YACY,YAAyB,EACzB,YAAyB;QADzB,iBAAY,GAAZ,YAAY,CAAa;QACzB,iBAAY,GAAZ,YAAY,CAAa;IAClC,CAAC;IAEJ;;;;;;OAMG;IACG,MAAM,CAAC,OAAkB;;YAC3B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,CAAC;YAC1D,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACxE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7D,CAAC;KAAA;IAED;;;;;;;;OAQG;IACG,UAAU,CAAC,OAAkB;;YAC/B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,CAAC;YAC1D,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACxE,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAC1C,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAC/B,CAAC;QACN,CAAC;KAAA;IAED;;;;;;;;;;;;;OAaG;IACG,wBAAwB;;YAC1B,OAAO,MAAM,IAAI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;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"}
@@ -55,6 +55,13 @@ export interface ChainConfigEntry {
55
55
  * Empty on a retired deployment, which has no read-only default.
56
56
  */
57
57
  rpcUrls: string[];
58
+ /**
59
+ * Origin of the chain's block explorer, `https://…` with NO trailing
60
+ * slash (`https://basescan.org`). Never append a path to it by hand: build
61
+ * links with `explorerTxUrl` / `explorerAddressUrl`, which validate the
62
+ * hash or address first, so no app turns an unchecked string into a URL.
63
+ */
64
+ blockExplorerUrl: string;
58
65
  /**
59
66
  * True for a wound-down deployment kept only as frozen history. It has no
60
67
  * default RPC, so a read-only `Kasu.create` on it throws.
@@ -180,3 +187,14 @@ export interface UserPositions {
180
187
  summary: PortfolioSummary;
181
188
  }
182
189
  export type PlatformStats = LendingTotals;
190
+ /**
191
+ * A strategy's risk figures, from its CMS risk-management record
192
+ * (`kasu.strategies.getRiskPerformance`). Each is `null` when unauthored or
193
+ * not a finite number — render "—", never `0`.
194
+ */
195
+ export interface StrategyRiskPerformance {
196
+ /** Realised loss rate, a 0..1 fraction. */
197
+ poolLossRate: number | null;
198
+ /** First-loss capital, exactly as the CMS record authors it. */
199
+ firstLossCapital: number | null;
200
+ }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * The errors an atomic-batch submitter throws, in one module both
3
+ * `DepositFlow` and `submitBatch` import — so `instanceof` is one class
4
+ * whichever of them a consumer imports it through.
5
+ */
6
+ /**
7
+ * What a `depositBatch` port throws when it KNOWS the batch reverted — from a
8
+ * simulation before sending, from the submitter refusing to broadcast a batch
9
+ * that would revert, or from a mined receipt whose user operation reverted.
10
+ * The run ends `{ step: 'request', reason: 'reverted', revertError }`.
11
+ *
12
+ * `revertError` is the custom error the contract named (`'ClearingIsPending'`,
13
+ * `'UserNotKycd'`, …), exactly as the ABI declares it. Pass `''` when the
14
+ * batch is known to revert but not why: the consumer then renders its generic
15
+ * `reverted` copy, which is what an unknown name gets anyway.
16
+ *
17
+ * A revert is DEFINITIVE — nothing was deposited. Throw it only when that is
18
+ * known; anything less certain is a `BatchPendingError`.
19
+ */
20
+ export declare class BatchRevertedError extends Error {
21
+ readonly revertError: string;
22
+ constructor(revertError: string, message?: string);
23
+ }
24
+ /**
25
+ * What became of a batch submission that did NOT end in a proven result and is
26
+ * not a known revert:
27
+ *
28
+ * - `failed` — nothing was sent and nothing can land: refused before the
29
+ * batch left (no session, a validation mismatch, a definitive refusal).
30
+ * "Please try again" is true.
31
+ * - `pending` — the batch was, or may have been, accepted, and nothing says
32
+ * whether it deposited. Calling that "failed" invites a second deposit; the
33
+ * lender is told it may still be processing.
34
+ * - `already-submitted` — an earlier submission has since been proven, so this
35
+ * one is refused rather than lend twice.
36
+ */
37
+ export type BatchSubmissionOutcome = 'failed' | 'pending' | 'already-submitted';
38
+ /**
39
+ * Every non-revert failure of a batch submission, carrying its outcome and a
40
+ * short code (`'status_timeout'`, `'receipt_unavailable'`, …).
41
+ *
42
+ * The message is fixed and names no party: the wallet-error classifier reads a
43
+ * thrown error's text for a USER rejection, and a relay outage worded "…wallet
44
+ * refused…" must never reach the lender as something they did.
45
+ *
46
+ * `outcome` has NO default. `failed` is the one outcome that invites a second
47
+ * deposit, so a port author has to spell it out — a `throw new
48
+ * BatchSubmissionError(code)` written in a catch block after the POST left
49
+ * must not quietly become "try again".
50
+ */
51
+ export declare class BatchSubmissionError extends Error {
52
+ readonly code: string;
53
+ readonly outcome: BatchSubmissionOutcome;
54
+ constructor(code: string, outcome: BatchSubmissionOutcome, options?: {
55
+ cause?: unknown;
56
+ });
57
+ }
58
+ /**
59
+ * The ambiguous outcome: the batch may have landed. An instance of
60
+ * `BatchSubmissionError` with `outcome: 'pending'`.
61
+ */
62
+ export declare class BatchPendingError extends BatchSubmissionError {
63
+ constructor(code: string, options?: {
64
+ cause?: unknown;
65
+ });
66
+ }
67
+ /** The outcome a thrown error stands for, or `null` if it is not a submission error. */
68
+ export declare function batchOutcomeOf(err: unknown): BatchSubmissionOutcome | null;
69
+ /**
70
+ * Nothing was deposited and nothing can be: a known revert, or a definitive
71
+ * `failed` refusal. Everything else — including an error this SDK did not
72
+ * produce — is NOT proof of that, and a consumer must not invite a retry on it.
73
+ */
74
+ export declare function isDefinitivelyNotSubmitted(err: unknown): boolean;