@oceanprotocol/lib 9.2.2-next.0 → 9.3.0-next.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.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Per-token subsidy configuration as returned by `OPFSubsidyProvider.getTokenLimits`.
3
+ * Amount fields (`daily`, `weekly`, `monthly`) are expressed in human-readable token
4
+ * units; `pctBps` is the percentage-of-job ceiling in basis points (not converted).
5
+ */
6
+ export interface TokenLimits {
7
+ /** Percentage-of-job ceiling in basis points (1% = 100 bps). */
8
+ pctBps: string;
9
+ /** Per-user daily cap, in human-readable token units. */
10
+ daily: string;
11
+ /** Per-user weekly cap, in human-readable token units. */
12
+ weekly: string;
13
+ /** Per-user monthly cap, in human-readable token units. */
14
+ monthly: string;
15
+ /** The token is only subsidised when this is `true`. */
16
+ enabled: boolean;
17
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Per-token configuration of a `OneTimeSubsidyProvider`, as returned by `getTokenConfig`.
3
+ * `defaultCredit` is expressed in human-readable token units; `pctBps` is the OPTIONAL
4
+ * per-job percentage ceiling in basis points (here `0` means "no per-job cap" — the whole
5
+ * remaining credit may go to a single job — the inverse of `OPFSubsidyProvider`).
6
+ */
7
+ export interface OneTimeTokenConfig {
8
+ /** Optional per-job ceiling in basis points (1% = 100 bps); `'0'` = no per-job cap. */
9
+ pctBps: string;
10
+ /** Global one-time credit granted per user for this token, in human-readable token units. */
11
+ defaultCredit: string;
12
+ /** The token is only subsidised when this is `true`. */
13
+ enabled: boolean;
14
+ }
@@ -81,7 +81,6 @@ export interface NodeStatus {
81
81
  uptime: number;
82
82
  persistentStorage?: {
83
83
  accessLists?: AccessList[];
84
- allowBucketSharing?: boolean;
85
84
  };
86
85
  }
87
86
  /**
@@ -244,7 +243,6 @@ export declare const PROTOCOL_COMMANDS: {
244
243
  SERVICE_LIST: string;
245
244
  SERVICE_EXTEND: string;
246
245
  SERVICE_GET_STREAMABLE_LOGS: string;
247
- SERVICE_GET_RESULT: string;
248
246
  };
249
247
  export interface NodeLogsParams {
250
248
  logId?: string;
@@ -66,13 +66,6 @@ export interface ServiceJobPayment {
66
66
  cost?: string | number;
67
67
  [key: string]: any;
68
68
  }
69
- export interface ServiceOutputArchive {
70
- index: number;
71
- filename: string;
72
- filesize: number;
73
- createdAt: number;
74
- containerId: string;
75
- }
76
69
  export interface ServiceJob {
77
70
  serviceId: string;
78
71
  clusterHash: string;
@@ -101,10 +94,8 @@ export interface ServiceJob {
101
94
  extendPayments?: ServiceJobPayment[];
102
95
  runtimeMetrics?: ContainerMetricsSnapshot;
103
96
  metadata?: ComputeJobMetadata;
104
- outputBucketId?: string;
105
- outputArchives?: ServiceOutputArchive[];
106
97
  }
107
- export type ServiceJobListed = Omit<ServiceJob, 'dockerCmd' | 'dockerEntrypoint' | 'dockerfile' | 'additionalDockerFiles' | 'runtimeMetrics' | 'outputArchives'>;
98
+ export type ServiceJobListed = Omit<ServiceJob, 'dockerCmd' | 'dockerEntrypoint' | 'dockerfile' | 'additionalDockerFiles' | 'runtimeMetrics'>;
108
99
  export interface ServiceListFilters {
109
100
  status?: ServiceStatusNumber;
110
101
  includeAllStatuses?: boolean;
@@ -136,4 +127,5 @@ export interface ServiceStartParams extends ServiceContainerSpec {
136
127
  duration: number;
137
128
  payment: ServicePayment;
138
129
  outputBucketId?: string;
130
+ subsidyProviders?: string[];
139
131
  }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Types for the `ISubsidyView` interface — the standardized, read-only view that every
3
+ * Ocean subsidy provider (OPF rolling-window, one-time onboarding credits, ...) exposes
4
+ * so dashboards can query subsidy availability uniformly and discover providers via
5
+ * ERC-165. See `SubsidyView` in `contracts/` and the "Dashboard integration guide".
6
+ */
7
+ /**
8
+ * Coarse window kind for UI grouping. Always render the actual window length from
9
+ * `SubsidyBucket.periodSeconds`, not from this enum — `MONTH`, for example, is a fixed
10
+ * 28-day window on OPF, not a calendar month. `CUSTOM` is anything outside the common set.
11
+ */
12
+ export declare enum SubsidyPeriod {
13
+ ONE_TIME = 0,
14
+ DAY = 1,
15
+ WEEK = 2,
16
+ MONTH = 3,
17
+ CUSTOM = 4
18
+ }
19
+ /** Broad category of a provider, from `ISubsidyView.subsidyKind()`, used for grouping. */
20
+ export declare enum SubsidyKind {
21
+ ROLLING_WINDOW = 0,
22
+ ONE_TIME = 1,
23
+ OTHER = 2
24
+ }
25
+ /**
26
+ * One budget window as reported by `subsidyBuckets`. Amount fields (`limit`, `used`,
27
+ * `remaining`) are in human-readable token units. Always check `unlimited` first: when
28
+ * `true`, `limit` and `remaining` are `'0'` and meaningless (`used` stays valid).
29
+ */
30
+ export interface SubsidyBucket {
31
+ /** Coarse window kind for UI grouping (see {@link SubsidyPeriod}). */
32
+ period: SubsidyPeriod;
33
+ /** Exact window length in seconds; `'0'` means one-time / no fixed window. */
34
+ periodSeconds: string;
35
+ /** `true` => no cap this window; `limit` & `remaining` are `'0'` and meaningless. */
36
+ unlimited: boolean;
37
+ /** Cap for this window, in human-readable token units (`'0'` when unlimited). */
38
+ limit: string;
39
+ /** Real cumulative spend this window, in human-readable token units (valid even when unlimited). */
40
+ used: string;
41
+ /** `limit - used`, in human-readable token units; `'0'` when unlimited (read `unlimited`). */
42
+ remaining: string;
43
+ /** Unix timestamp (seconds) of the next automatic reset; `'0'` = admin-driven / no timer. */
44
+ resetsAt: string;
45
+ }
46
+ /**
47
+ * Full payer/token budget report from `subsidyBuckets`. The top-level flags describe
48
+ * payer-side eligibility; `buckets` holds the per-window budgets.
49
+ */
50
+ export interface SubsidyBucketReport {
51
+ /** Provider is paused: nothing is drawable right now. */
52
+ paused: boolean;
53
+ /** The payer passes the user AccessList gate. */
54
+ userAllowed: boolean;
55
+ /** The token is configured and enabled. */
56
+ tokenEnabled: boolean;
57
+ /** Per-window budgets. Within one provider, take the MIN of `remaining` — never the sum. */
58
+ buckets: SubsidyBucket[];
59
+ }
60
+ /**
61
+ * Result of `quoteSubsidy`, in human-readable token units. `subsidy` is released to the
62
+ * payer (cost reduction); `bonus` rewards the node (both current providers return `'0'`
63
+ * for `bonus`, but the field accommodates future node-incentive providers).
64
+ */
65
+ export interface SubsidyQuote {
66
+ /** Subsidy released to the payer, in human-readable token units. */
67
+ subsidy: string;
68
+ /** Bonus paid to the node, in human-readable token units. */
69
+ bonus: string;
70
+ }
71
+ /** ERC-165 base interface id (`IERC165.supportsInterface`). */
72
+ export declare const ERC165_INTERFACE_ID = "0x01ffc9a7";
73
+ /** ERC-165 interface id of `ISubsidyView` (the read/quote surface dashboards consume). */
74
+ export declare const ISUBSIDY_VIEW_INTERFACE_ID = "0xcf08f23a";
75
+ /** ERC-165 interface id of `ISubsidyProvider` (the escrow-facing claim surface). */
76
+ export declare const ISUBSIDY_PROVIDER_INTERFACE_ID = "0x659fa925";
@@ -15,3 +15,6 @@ export * from './Provider.js';
15
15
  export * from './Router.js';
16
16
  export * from './ReturnTypes.js';
17
17
  export * from './Escrow.js';
18
+ export * from './OPFSubsidyProvider.js';
19
+ export * from './OneTimeSubsidyProvider.js';
20
+ export * from './SubsidyView.js';
@@ -146,5 +146,11 @@ export declare class Config {
146
146
  sdk?: SDK;
147
147
  accessListFactory?: string;
148
148
  escrow?: string;
149
+ /**
150
+ * Addresses of all deployed subsidy providers (OPF, one-time, ...). Discover each one's
151
+ * kind/interface at runtime via a `SubsidyView` (`subsidyKind()` / `supportsInterface`).
152
+ * @type {string[]}
153
+ */
154
+ SubsidyProviders?: string[];
149
155
  }
150
156
  export {};
@@ -0,0 +1,190 @@
1
+ import { Signer } from 'ethers';
2
+ import { AbiItem, TokenLimits } from '../@types/index.js';
3
+ import { Config } from '../config/index.js';
4
+ import { SubsidyView } from './SubsidyView.js';
5
+ /**
6
+ * Read-only wrapper for the `OPFSubsidyProvider` contract (Ocean Protocol Foundation
7
+ * job-cost sponsorship). It extends {@link SubsidyView} — inheriting the standardized
8
+ * `ISubsidyView` read surface (`subsidyBuckets`, `remainingSubsidy`, `quoteSubsidy`,
9
+ * eligibility gates, `subsidyKind`/`version`, ERC-165 `supportsInterface`) — and adds the
10
+ * OPF-specific getters: per-user rolling budgets (daily / weekly / monthly), token limits,
11
+ * period indexes and reset timers.
12
+ *
13
+ * Owner/admin operations (`setTokenLimits`, `setAuthorizedEscrow`, `pause`,
14
+ * `withdrawTokens`, ...) and the escrow-only `onSubsidyClaim` callback are intentionally
15
+ * **not** wrapped.
16
+ *
17
+ * There is no single configured default address (a deployment can host several providers):
18
+ * read addresses from `config.SubsidyProviders` and identify the OPF one via
19
+ * `subsidyKind()`, then pass its address here.
20
+ */
21
+ export declare class OPFSubsidyProvider extends SubsidyView {
22
+ getDefaultAbi(): AbiItem[];
23
+ /**
24
+ * Instantiate OPFSubsidyProvider class
25
+ * @param {Signer} signer The signer object.
26
+ * @param {string} address The contract address (required; discover it via
27
+ * `config.SubsidyProviders` + `subsidyKind()`).
28
+ * @param {string | number} [network] Network id or name
29
+ * @param {Config} [config] The configuration object.
30
+ * @param {AbiItem[]} [abi] ABI array of the smart contract
31
+ */
32
+ constructor(signer: Signer, address: string, network?: string | number, config?: Config, abi?: AbiItem[]);
33
+ /**
34
+ * Get the subsidy configuration for a token.
35
+ * @param {string} token Token address
36
+ * @param {number} [tokenDecimals] optional number of decimals of the token
37
+ * @return {Promise<TokenLimits>} the token limits (amounts in human-readable units)
38
+ */
39
+ getTokenLimits(token: string, tokenDecimals?: number): Promise<TokenLimits>;
40
+ /**
41
+ * Get the remaining daily subsidy budget for a payer/token.
42
+ * @param {string} payer Payer address
43
+ * @param {string} token Token address
44
+ * @param {number} [tokenDecimals] optional number of decimals of the token
45
+ * @return {Promise<string>} remaining daily budget in human-readable token units, or
46
+ * `MaxUint256` (as a string) when the daily cap is disabled (unlimited)
47
+ */
48
+ remainingDaily(payer: string, token: string, tokenDecimals?: number): Promise<string>;
49
+ /**
50
+ * Get the remaining weekly subsidy budget for a payer/token.
51
+ * @param {string} payer Payer address
52
+ * @param {string} token Token address
53
+ * @param {number} [tokenDecimals] optional number of decimals of the token
54
+ * @return {Promise<string>} remaining weekly budget in human-readable token units, or
55
+ * `MaxUint256` (as a string) when the weekly cap is disabled (unlimited)
56
+ */
57
+ remainingWeekly(payer: string, token: string, tokenDecimals?: number): Promise<string>;
58
+ /**
59
+ * Get the remaining monthly subsidy budget for a payer/token.
60
+ * @param {string} payer Payer address
61
+ * @param {string} token Token address
62
+ * @param {number} [tokenDecimals] optional number of decimals of the token
63
+ * @return {Promise<string>} remaining monthly budget in human-readable token units, or
64
+ * `MaxUint256` (as a string) when the monthly cap is disabled (unlimited)
65
+ */
66
+ remainingMonthly(payer: string, token: string, tokenDecimals?: number): Promise<string>;
67
+ /**
68
+ * Get the daily subsidy already used by a payer/token.
69
+ * @param {string} payer Payer address
70
+ * @param {string} token Token address
71
+ * @param {number} [tokenDecimals] optional number of decimals of the token
72
+ * @return {Promise<string>} used daily amount, in human-readable token units
73
+ */
74
+ dailyUsedBy(payer: string, token: string, tokenDecimals?: number): Promise<string>;
75
+ /**
76
+ * Get the weekly subsidy already used by a payer/token.
77
+ * @param {string} payer Payer address
78
+ * @param {string} token Token address
79
+ * @param {number} [tokenDecimals] optional number of decimals of the token
80
+ * @return {Promise<string>} used weekly amount, in human-readable token units
81
+ */
82
+ weeklyUsedBy(payer: string, token: string, tokenDecimals?: number): Promise<string>;
83
+ /**
84
+ * Get the monthly subsidy already used by a payer/token.
85
+ * @param {string} payer Payer address
86
+ * @param {string} token Token address
87
+ * @param {number} [tokenDecimals] optional number of decimals of the token
88
+ * @return {Promise<string>} used monthly amount, in human-readable token units
89
+ */
90
+ monthlyUsedBy(payer: string, token: string, tokenDecimals?: number): Promise<string>;
91
+ /**
92
+ * Get the daily subsidy used by a payer/token at a specific timestamp.
93
+ * @param {string} payer Payer address
94
+ * @param {string} token Token address
95
+ * @param {number | string} timestamp Unix timestamp (seconds)
96
+ * @param {number} [tokenDecimals] optional number of decimals of the token
97
+ * @return {Promise<string>} used daily amount, in human-readable token units
98
+ */
99
+ dailyUsedByAt(payer: string, token: string, timestamp: number | string, tokenDecimals?: number): Promise<string>;
100
+ /**
101
+ * Get the weekly subsidy used by a payer/token at a specific timestamp.
102
+ * @param {string} payer Payer address
103
+ * @param {string} token Token address
104
+ * @param {number | string} timestamp Unix timestamp (seconds)
105
+ * @param {number} [tokenDecimals] optional number of decimals of the token
106
+ * @return {Promise<string>} used weekly amount, in human-readable token units
107
+ */
108
+ weeklyUsedByAt(payer: string, token: string, timestamp: number | string, tokenDecimals?: number): Promise<string>;
109
+ /**
110
+ * Get the monthly subsidy used by a payer/token at a specific timestamp.
111
+ * @param {string} payer Payer address
112
+ * @param {string} token Token address
113
+ * @param {number | string} timestamp Unix timestamp (seconds)
114
+ * @param {number} [tokenDecimals] optional number of decimals of the token
115
+ * @return {Promise<string>} used monthly amount, in human-readable token units
116
+ */
117
+ monthlyUsedByAt(payer: string, token: string, timestamp: number | string, tokenDecimals?: number): Promise<string>;
118
+ /**
119
+ * Get the access list gating payers: a payer must hold a token in this list to be
120
+ * eligible. `ZERO_ADDRESS` means the payer gate is off.
121
+ * @return {Promise<string>} the user access list address
122
+ */
123
+ getUserAccessList(): Promise<string>;
124
+ /**
125
+ * Get the access list gating nodes: a node must hold a token in this list to be
126
+ * eligible. `ZERO_ADDRESS` means the node gate is off.
127
+ * @return {Promise<string>} the node access list address
128
+ */
129
+ getNodeAccessList(): Promise<string>;
130
+ /**
131
+ * Get the current daily period index.
132
+ * @return {Promise<string>} the current day index
133
+ */
134
+ currentDayIndex(): Promise<string>;
135
+ /**
136
+ * Get the current weekly period index.
137
+ * @return {Promise<string>} the current week index
138
+ */
139
+ currentWeekIndex(): Promise<string>;
140
+ /**
141
+ * Get the current monthly period index.
142
+ * @return {Promise<string>} the current month index
143
+ */
144
+ currentMonthIndex(): Promise<string>;
145
+ /**
146
+ * Get the daily period index for a given timestamp.
147
+ * @param {number | string} timestamp Unix timestamp (seconds)
148
+ * @return {Promise<string>} the day index
149
+ */
150
+ getDayByTimestamp(timestamp: number | string): Promise<string>;
151
+ /**
152
+ * Get the weekly period index for a given timestamp.
153
+ * @param {number | string} timestamp Unix timestamp (seconds)
154
+ * @return {Promise<string>} the week index
155
+ */
156
+ getWeekByTimestamp(timestamp: number | string): Promise<string>;
157
+ /**
158
+ * Get the monthly period index for a given timestamp.
159
+ * @param {number | string} timestamp Unix timestamp (seconds)
160
+ * @return {Promise<string>} the month index
161
+ */
162
+ getMonthByTimestamp(timestamp: number | string): Promise<string>;
163
+ /**
164
+ * Get the number of seconds until the daily budget resets.
165
+ * @return {Promise<string>} seconds until the daily reset
166
+ */
167
+ secondsUntilDayReset(): Promise<string>;
168
+ /**
169
+ * Get the number of seconds until the weekly budget resets.
170
+ * @return {Promise<string>} seconds until the weekly reset
171
+ */
172
+ secondsUntilWeekReset(): Promise<string>;
173
+ /**
174
+ * Get the number of seconds until the monthly budget resets.
175
+ * @return {Promise<string>} seconds until the monthly reset
176
+ */
177
+ secondsUntilMonthReset(): Promise<string>;
178
+ /**
179
+ * Formats a `remaining*` period budget. The contract returns `type(uint256).max` when
180
+ * the period cap is disabled (unlimited); that sentinel is returned as-is (never run
181
+ * through the token-decimals conversion, which would yield a meaningless huge number).
182
+ * Finite values are converted to human-readable token units.
183
+ * @param {bigint} remaining Raw remaining value from the contract
184
+ * @param {string} token Token address
185
+ * @param {number} [tokenDecimals] optional number of decimals of the token
186
+ * @return {Promise<string>} `MaxUint256` (as a string) when unlimited, otherwise the
187
+ * remaining budget in human-readable token units
188
+ */
189
+ private formatRemaining;
190
+ }
@@ -0,0 +1,117 @@
1
+ import { Signer } from 'ethers';
2
+ import { AbiItem, OneTimeTokenConfig } from '../@types/index.js';
3
+ import { Config } from '../config/index.js';
4
+ import { SubsidyView } from './SubsidyView.js';
5
+ /**
6
+ * Read-only wrapper for the `OneTimeSubsidyProvider` contract — a one-time onboarding-credit
7
+ * program (e.g. "every eligible user gets 10 USDC of free compute"). It extends
8
+ * {@link SubsidyView} — inheriting the standardized `ISubsidyView` read surface
9
+ * (`subsidyBuckets`, `remainingSubsidy`, `quoteSubsidy`, eligibility gates,
10
+ * `subsidyKind`/`version`, ERC-165 `supportsInterface`) — and adds the OneTime-specific
11
+ * getters: the per-user cumulative credit, how much of it has been used, the credit
12
+ * override flag, the per-token config, and the round accounting behind admin resets.
13
+ *
14
+ * Unlike `OPFSubsidyProvider` there are no rolling day/week/month windows: the credit is a
15
+ * single cumulative budget drawn down across jobs until exhausted, and it only refreshes
16
+ * when an admin resets it. Owner/admin operations (`setTokenConfig`, `setUserCredit(s)`,
17
+ * `resetAllUsers`/`resetUser`, `pause`, `withdrawTokens`, ...) and the escrow-only
18
+ * `onSubsidyClaim` callback are intentionally **not** wrapped.
19
+ *
20
+ * There is no single configured default address (a deployment can host several providers):
21
+ * read addresses from `config.SubsidyProviders` and identify the OneTime one via
22
+ * `subsidyKind()`, then pass its address here. Amount fields are returned in human-readable
23
+ * token units.
24
+ */
25
+ export declare class OneTimeSubsidyProvider extends SubsidyView {
26
+ getDefaultAbi(): AbiItem[];
27
+ /**
28
+ * Instantiate the OneTimeSubsidyProvider wrapper against a specific contract.
29
+ * @param {Signer} signer The signer object.
30
+ * @param {string} address The contract address (required; discover it via
31
+ * `config.SubsidyProviders` + `subsidyKind()`).
32
+ * @param {string | number} [network] Network id or name.
33
+ * @param {Config} [config] The configuration object.
34
+ * @param {AbiItem[]} [abi] ABI array of the smart contract.
35
+ */
36
+ constructor(signer: Signer, address: string, network?: string | number, config?: Config, abi?: AbiItem[]);
37
+ /**
38
+ * Get the per-token configuration (per-job ceiling, default credit, enabled flag).
39
+ * @param {string} token Token address.
40
+ * @param {number} [tokenDecimals] optional number of decimals of the token.
41
+ * @return {Promise<OneTimeTokenConfig>} the token config (amounts in human-readable units)
42
+ */
43
+ getTokenConfig(token: string, tokenDecimals?: number): Promise<OneTimeTokenConfig>;
44
+ /**
45
+ * Get the one-time credit a payer is granted for a token: their override if set, else the
46
+ * token's default. Independent of how much has already been used.
47
+ * @param {string} payer Payer address.
48
+ * @param {string} token Token address.
49
+ * @param {number} [tokenDecimals] optional number of decimals of the token.
50
+ * @return {Promise<string>} the effective credit, in human-readable token units
51
+ */
52
+ effectiveCredit(payer: string, token: string, tokenDecimals?: number): Promise<string>;
53
+ /**
54
+ * Get the credit a payer has left in their current round — `effectiveCredit - used`.
55
+ * Unlike the inherited `remainingSubsidy`, this is NOT capped by the contract balance and
56
+ * NOT gated (use `remainingSubsidy` for the "claimable now" figure).
57
+ * @param {string} payer Payer address.
58
+ * @param {string} token Token address.
59
+ * @param {number} [tokenDecimals] optional number of decimals of the token.
60
+ * @return {Promise<string>} the remaining credit, in human-readable token units
61
+ */
62
+ remainingCredit(payer: string, token: string, tokenDecimals?: number): Promise<string>;
63
+ /**
64
+ * Get the cumulative subsidy a payer has used in their CURRENT round.
65
+ * @param {string} payer Payer address.
66
+ * @param {string} token Token address.
67
+ * @param {number} [tokenDecimals] optional number of decimals of the token.
68
+ * @return {Promise<string>} the used amount, in human-readable token units
69
+ */
70
+ usedBy(payer: string, token: string, tokenDecimals?: number): Promise<string>;
71
+ /**
72
+ * Get the subsidy a payer used in a specific round (e.g. a past round's consumption).
73
+ * @param {string} payer Payer address.
74
+ * @param {string} token Token address.
75
+ * @param {number | string} round The round index.
76
+ * @param {number} [tokenDecimals] optional number of decimals of the token.
77
+ * @return {Promise<string>} the used amount, in human-readable token units
78
+ */
79
+ usedByAt(payer: string, token: string, round: number | string, tokenDecimals?: number): Promise<string>;
80
+ /**
81
+ * Check whether a payer has a per-user credit override set (as opposed to the token default).
82
+ * @param {string} payer Payer address.
83
+ * @param {string} token Token address.
84
+ * @return {Promise<boolean>} true if an override is set for this payer/token
85
+ */
86
+ hasUserCredit(payer: string, token: string): Promise<boolean>;
87
+ /**
88
+ * Get the round whose usage slot a payer currently draws from
89
+ * (`globalRound + userRound[payer]`).
90
+ * @param {string} payer Payer address.
91
+ * @return {Promise<string>} the effective round index
92
+ */
93
+ effectiveRound(payer: string): Promise<string>;
94
+ /**
95
+ * Get the global round index (advanced by an admin `resetAllUsers`).
96
+ * @return {Promise<string>} the global round index
97
+ */
98
+ globalRound(): Promise<string>;
99
+ /**
100
+ * Get a payer's per-user reset offset (advanced by an admin `resetUser`).
101
+ * @param {string} payer Payer address.
102
+ * @return {Promise<string>} the per-user round offset
103
+ */
104
+ userRound(payer: string): Promise<string>;
105
+ /**
106
+ * Get the access list gating payers: a payer must hold a token in this list to be
107
+ * eligible. `ZERO_ADDRESS` means the payer gate is off.
108
+ * @return {Promise<string>} the user access list address
109
+ */
110
+ getUserAccessList(): Promise<string>;
111
+ /**
112
+ * Get the access list gating nodes: a node must hold a token in this list to be
113
+ * eligible. `ZERO_ADDRESS` means the node gate is off.
114
+ * @return {Promise<string>} the node access list address
115
+ */
116
+ getNodeAccessList(): Promise<string>;
117
+ }
@@ -0,0 +1,129 @@
1
+ import { Signer } from 'ethers';
2
+ import { AbiItem, SubsidyBucketReport, SubsidyKind, SubsidyQuote } from '../@types/index.js';
3
+ import { Config } from '../config/index.js';
4
+ import { SmartContractWithAddress } from './SmartContractWithAddress.js';
5
+ /**
6
+ * Read-only wrapper for any contract implementing the `ISubsidyView` interface — the
7
+ * standardized view that every Ocean subsidy provider exposes (OPF rolling-window,
8
+ * one-time onboarding credits, and future providers). It lets a dashboard query subsidy
9
+ * availability uniformly, regardless of the underlying provider, and discover providers
10
+ * through ERC-165 (`supportsInterface`, `subsidyKind`, `version`).
11
+ *
12
+ * The contract address is a **required** constructor parameter: there is no single
13
+ * default because a deployment can host several providers (read them from the
14
+ * `SubsidyProviders` registry and instantiate one `SubsidyView` per address). Provider-
15
+ * specific getters (OPF's daily/weekly/monthly budgets, one-time credit rounds, ...) live
16
+ * on the concrete wrappers such as {@link OPFSubsidyProvider}, which extend this class.
17
+ *
18
+ * Amount fields are returned in human-readable token units (see the per-method notes).
19
+ */
20
+ export declare class SubsidyView extends SmartContractWithAddress {
21
+ getDefaultAbi(): AbiItem[];
22
+ /**
23
+ * Instantiate the SubsidyView wrapper against a specific provider contract.
24
+ * @param {Signer} signer The signer object.
25
+ * @param {string} address The subsidy provider contract address (required).
26
+ * @param {string | number} [network] Network id or name.
27
+ * @param {Config} [config] The configuration object.
28
+ * @param {AbiItem[]} [abi] ABI array of the smart contract (defaults to the ISubsidyView ABI).
29
+ */
30
+ constructor(signer: Signer, address: string, network?: string | number, config?: Config, abi?: AbiItem[]);
31
+ /**
32
+ * Get the broad category of this provider, for UI grouping.
33
+ * @return {Promise<SubsidyKind>} the subsidy kind (rolling window, one-time, other)
34
+ */
35
+ subsidyKind(): Promise<SubsidyKind>;
36
+ /**
37
+ * Get the `ISubsidyView` interface revision this provider implements. Newer revisions
38
+ * stay backwards-compatible; use it to gate optional, version-specific reads.
39
+ * @return {Promise<number>} the interface version
40
+ */
41
+ version(): Promise<number>;
42
+ /**
43
+ * Check whether the provider advertises a given ERC-165 interface id. Use it for
44
+ * feature detection when walking the `SubsidyProviders` registry; treat a revert as
45
+ * `false`.
46
+ * @param {string} interfaceId The 4-byte interface id (e.g. `0xcf08f23a`).
47
+ * @return {Promise<boolean>} true if the interface is supported
48
+ */
49
+ supportsInterface(interfaceId: string): Promise<boolean>;
50
+ /**
51
+ * Convenience check that the provider implements `ISubsidyView` (the read surface this
52
+ * wrapper consumes).
53
+ * @return {Promise<boolean>} true if `ISubsidyView` is supported
54
+ */
55
+ isSubsidyView(): Promise<boolean>;
56
+ /**
57
+ * Convenience check that the provider implements `ISubsidyProvider` (the escrow-facing
58
+ * claim surface).
59
+ * @return {Promise<boolean>} true if `ISubsidyProvider` is supported
60
+ */
61
+ isSubsidyProvider(): Promise<boolean>;
62
+ /**
63
+ * Get the full per-window budget report for a payer/token — the data behind a
64
+ * per-provider breakdown card. Amount fields are converted to human-readable token
65
+ * units; `unlimited` buckets carry `limit = remaining = '0'` (check the flag, never the
66
+ * value). Within a single provider, take the MIN of the buckets' `remaining` — never
67
+ * the sum, since windows can nest (OPF's day ⊂ week ⊂ month).
68
+ * @param {string} payer Payer address.
69
+ * @param {string} token Token address.
70
+ * @param {number} [tokenDecimals] optional number of decimals of the token.
71
+ * @return {Promise<SubsidyBucketReport>} the eligibility flags and per-window budgets
72
+ */
73
+ subsidyBuckets(payer: string, token: string, tokenDecimals?: number): Promise<SubsidyBucketReport>;
74
+ /**
75
+ * Get the single "claimable now" figure for a payer/token: the min across the
76
+ * provider's windows, capped by the contract's balance and gated by eligibility. This
77
+ * is the figure that is safe to sum across providers for a portfolio total.
78
+ * @param {string} payer Payer address.
79
+ * @param {string} token Token address.
80
+ * @param {number} [tokenDecimals] optional number of decimals of the token.
81
+ * @return {Promise<string>} remaining subsidy, in human-readable token units
82
+ */
83
+ remainingSubsidy(payer: string, token: string, tokenDecimals?: number): Promise<string>;
84
+ /**
85
+ * Quote the subsidy a specific job would receive, without changing state — the
86
+ * authoritative per-job figure once node and job type are known (it applies the
87
+ * percentage cap, all window caps, the balance and every gate).
88
+ * @param {string} node Node address.
89
+ * @param {string} payer Payer address.
90
+ * @param {number | string} jobType Job type identifier.
91
+ * @param {string} token Token address.
92
+ * @param {string} amount Job cost, in human-readable token units.
93
+ * @param {string} subsidyNeeded Subsidy requested, in human-readable token units.
94
+ * @param {number} [tokenDecimals] optional number of decimals of the token.
95
+ * @return {Promise<SubsidyQuote>} the granted `subsidy` (to payer) and `bonus` (to node),
96
+ * in human-readable token units
97
+ */
98
+ quoteSubsidy(node: string, payer: string, jobType: number | string, token: string, amount: string, subsidyNeeded: string, tokenDecimals?: number): Promise<SubsidyQuote>;
99
+ /**
100
+ * Check whether a payer passes the user AccessList gate.
101
+ * @param {string} payer Payer address.
102
+ * @return {Promise<boolean>} true if the payer is allowed
103
+ */
104
+ isUserAllowed(payer: string): Promise<boolean>;
105
+ /**
106
+ * Check whether a node passes the node AccessList gate.
107
+ * @param {string} node Node address.
108
+ * @return {Promise<boolean>} true if the node is allowed
109
+ */
110
+ isNodeAllowed(node: string): Promise<boolean>;
111
+ /**
112
+ * Check whether a job type is subsidised.
113
+ * @param {number | string} jobType Job type identifier.
114
+ * @return {Promise<boolean>} true if the job type is subsidised
115
+ */
116
+ isJobTypeSubsidized(jobType: number | string): Promise<boolean>;
117
+ /**
118
+ * Get the list of subsidised job types.
119
+ * @return {Promise<string[]>} allowed job type identifiers
120
+ */
121
+ getAllowedJobTypes(): Promise<string[]>;
122
+ /**
123
+ * Get the token balance the provider holds and can draw subsidies from.
124
+ * @param {string} token Token address.
125
+ * @param {number} [tokenDecimals] optional number of decimals of the token.
126
+ * @return {Promise<string>} available balance, in human-readable token units
127
+ */
128
+ availableBalance(token: string, tokenDecimals?: number): Promise<string>;
129
+ }
@@ -14,3 +14,6 @@ export * from './AccessList.js';
14
14
  export * from './AccessListFactory.js';
15
15
  export * from './Escrow.js';
16
16
  export * from './EnterpriseFeeCollector.js';
17
+ export * from './SubsidyView.js';
18
+ export * from './OPFSubsidyProvider.js';
19
+ export * from './OneTimeSubsidyProvider.js';