@augustdigital/sdk 8.13.0 → 8.14.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.
@@ -3,4 +3,4 @@
3
3
  * Generated during publish from package.json version
4
4
  * This file is gitignored and created at publish time
5
5
  */
6
- export declare const SDK_VERSION = "8.13.0";
6
+ export declare const SDK_VERSION = "8.14.0";
@@ -6,5 +6,5 @@ exports.SDK_VERSION = void 0;
6
6
  * Generated during publish from package.json version
7
7
  * This file is gitignored and created at publish time
8
8
  */
9
- exports.SDK_VERSION = '8.13.0';
9
+ exports.SDK_VERSION = '8.14.0';
10
10
  //# sourceMappingURL=version.js.map
@@ -46,3 +46,44 @@ export declare const SUBGRAPH_POOL_URLS: (apiKey: string, chainId?: number, pool
46
46
  * generated fallback.
47
47
  */
48
48
  export declare const getDefaultSubgraphUrl: (_network: string, _symbol: string) => string | undefined;
49
+ /**
50
+ * Resolve whether a single fee (management or performance) is currently waived.
51
+ *
52
+ * Backend-driven, per AUGUST-5584. This centralizes logic that previously lived —
53
+ * and diverged — across two upshift-app components. The resolution is deliberately
54
+ * split between the backend and the SDK:
55
+ *
56
+ * - The backend `isFeeWaivedToggle` (`platform_fee_override.is_fee_waived`) is both
57
+ * the master enable AND the TVL latch. Retool config takes precedence over live
58
+ * TVL, and the backend flips this flag `false` once live TVL crosses the
59
+ * configured threshold. That flip is one-way: if TVL later falls back below the
60
+ * threshold the waiver does NOT re-apply. The SDK therefore does no TVL math and
61
+ * never reads `latest_reported_tvl` here — trusting the flag preserves the latch.
62
+ * - The **date** window is time-dependent, so it cannot be a static DB flag; the SDK
63
+ * evaluates it live against the clock.
64
+ *
65
+ * Resolution:
66
+ * - Toggle off → never waived (also the only "hide" path once TVL trips the latch).
67
+ * - Toggle on, both date and TVL blank → indefinite manual waiver → waived.
68
+ * - Toggle on with a date window → waived while `now < waivedUntilDate`.
69
+ * - Toggle on with a TVL threshold configured → waived (the backend keeps the toggle
70
+ * on only while live TVL is under the threshold).
71
+ *
72
+ * @param isFeeWaivedToggle - Backend master/TVL-latch flag. `false` ⇒ never waived.
73
+ * @param waivedUntilDate - ISO datetime string the waiver runs until, or `null` for
74
+ * no date window. An unparseable string yields `NaN`, which is never `> now`, so
75
+ * it correctly contributes no date-based waiver.
76
+ * @param waivedUntilTvl - Configured TVL threshold in whole USD, or `null`. Used only
77
+ * to detect that a TVL-based waiver was set (values `<= 0` are treated as unset);
78
+ * the threshold comparison itself is owned by the backend.
79
+ * @param now - Clock, injected for deterministic testing. Defaults to `new Date()`.
80
+ * @returns `true` if the UI should present this fee as "Fee Waived" right now.
81
+ * @example
82
+ * ```ts
83
+ * // Toggle on, 30-day window still open → waived.
84
+ * resolveFeeWaived(true, '2099-01-01T00:00:00Z', null); // true
85
+ * // Toggle off overrides everything → not waived.
86
+ * resolveFeeWaived(false, '2099-01-01T00:00:00Z', 10_000_000); // false
87
+ * ```
88
+ */
89
+ export declare function resolveFeeWaived(isFeeWaivedToggle: boolean, waivedUntilDate: string | null, waivedUntilTvl: number | null, now?: Date): boolean;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getDefaultSubgraphUrl = exports.SUBGRAPH_POOL_URLS = exports.AVAX_PRICE_FEED_ADDRESS = exports.REWARD_DISTRIBUTOR_ADDRESS = exports.getVaultVersionV2 = exports.getVaultVersion = exports.getAddressChainType = exports.isBadVault = exports.isBadTransaction = void 0;
4
4
  exports.getVaultSymbol = getVaultSymbol;
5
+ exports.resolveFeeWaived = resolveFeeWaived;
5
6
  const ethers_1 = require("ethers");
6
7
  const vaults_1 = require("../constants/vaults");
7
8
  const web3_1 = require("./web3");
@@ -179,4 +180,56 @@ const getDefaultSubgraphUrl = (_network, _symbol) => {
179
180
  return undefined;
180
181
  };
181
182
  exports.getDefaultSubgraphUrl = getDefaultSubgraphUrl;
183
+ /**
184
+ * Resolve whether a single fee (management or performance) is currently waived.
185
+ *
186
+ * Backend-driven, per AUGUST-5584. This centralizes logic that previously lived —
187
+ * and diverged — across two upshift-app components. The resolution is deliberately
188
+ * split between the backend and the SDK:
189
+ *
190
+ * - The backend `isFeeWaivedToggle` (`platform_fee_override.is_fee_waived`) is both
191
+ * the master enable AND the TVL latch. Retool config takes precedence over live
192
+ * TVL, and the backend flips this flag `false` once live TVL crosses the
193
+ * configured threshold. That flip is one-way: if TVL later falls back below the
194
+ * threshold the waiver does NOT re-apply. The SDK therefore does no TVL math and
195
+ * never reads `latest_reported_tvl` here — trusting the flag preserves the latch.
196
+ * - The **date** window is time-dependent, so it cannot be a static DB flag; the SDK
197
+ * evaluates it live against the clock.
198
+ *
199
+ * Resolution:
200
+ * - Toggle off → never waived (also the only "hide" path once TVL trips the latch).
201
+ * - Toggle on, both date and TVL blank → indefinite manual waiver → waived.
202
+ * - Toggle on with a date window → waived while `now < waivedUntilDate`.
203
+ * - Toggle on with a TVL threshold configured → waived (the backend keeps the toggle
204
+ * on only while live TVL is under the threshold).
205
+ *
206
+ * @param isFeeWaivedToggle - Backend master/TVL-latch flag. `false` ⇒ never waived.
207
+ * @param waivedUntilDate - ISO datetime string the waiver runs until, or `null` for
208
+ * no date window. An unparseable string yields `NaN`, which is never `> now`, so
209
+ * it correctly contributes no date-based waiver.
210
+ * @param waivedUntilTvl - Configured TVL threshold in whole USD, or `null`. Used only
211
+ * to detect that a TVL-based waiver was set (values `<= 0` are treated as unset);
212
+ * the threshold comparison itself is owned by the backend.
213
+ * @param now - Clock, injected for deterministic testing. Defaults to `new Date()`.
214
+ * @returns `true` if the UI should present this fee as "Fee Waived" right now.
215
+ * @example
216
+ * ```ts
217
+ * // Toggle on, 30-day window still open → waived.
218
+ * resolveFeeWaived(true, '2099-01-01T00:00:00Z', null); // true
219
+ * // Toggle off overrides everything → not waived.
220
+ * resolveFeeWaived(false, '2099-01-01T00:00:00Z', 10_000_000); // false
221
+ * ```
222
+ */
223
+ function resolveFeeWaived(isFeeWaivedToggle, waivedUntilDate, waivedUntilTvl, now = new Date()) {
224
+ // Master toggle off ⇒ never waived. Also satisfies the one-way TVL latch: the
225
+ // backend has already flipped this false when live TVL crossed the threshold.
226
+ if (!isFeeWaivedToggle)
227
+ return false;
228
+ const isDateActive = waivedUntilDate != null && new Date(waivedUntilDate) > now;
229
+ const isTvlConfigured = waivedUntilTvl != null && waivedUntilTvl > 0;
230
+ // Toggle on but neither trigger configured ⇒ indefinite manual waiver.
231
+ if (waivedUntilDate == null && !isTvlConfigured)
232
+ return true;
233
+ return isDateActive || isTvlConfigured;
234
+ }
182
235
  //# sourceMappingURL=vaults.js.map
@@ -353,10 +353,10 @@ function buildBackendVault(tokenizedVault, overrides) {
353
353
  fees: {
354
354
  performance: tokenizedVault.weekly_performance_fee_bps || 0,
355
355
  management: tokenizedVault.platform_fee_override?.management_fee || 0,
356
- isManagementWaived: false,
356
+ isManagementWaived: (0, vaults_1.resolveFeeWaived)(tokenizedVault.platform_fee_override?.is_fee_waived ?? false, tokenizedVault.management_fee_waived_until_date ?? null, tokenizedVault.management_fee_waived_until_tvl ?? null),
357
357
  managementFeeWaivedUntilDate: tokenizedVault.management_fee_waived_until_date ?? null,
358
358
  managementFeeWaivedUntilTvl: tokenizedVault.management_fee_waived_until_tvl ?? null,
359
- isPerformanceWaived: false,
359
+ isPerformanceWaived: (0, vaults_1.resolveFeeWaived)(tokenizedVault.platform_fee_override?.is_fee_waived ?? false, tokenizedVault.performance_fee_waived_until_date ?? null, tokenizedVault.performance_fee_waived_until_tvl ?? null),
360
360
  performanceFeeWaivedUntilDate: tokenizedVault.performance_fee_waived_until_date ?? null,
361
361
  performanceFeeWaivedUntilTvl: tokenizedVault.performance_fee_waived_until_tvl ?? null,
362
362
  },
@@ -466,10 +466,10 @@ async function buildFormattedVault(provider, tokenizedVault, contractCalls) {
466
466
  fees: {
467
467
  performance: tokenizedVault.weekly_performance_fee_bps,
468
468
  management: tokenizedVault.platform_fee_override.management_fee,
469
- isManagementWaived: tokenizedVault.platform_fee_override.is_fee_waived,
469
+ isManagementWaived: (0, vaults_1.resolveFeeWaived)(tokenizedVault.platform_fee_override.is_fee_waived, tokenizedVault.management_fee_waived_until_date, tokenizedVault.management_fee_waived_until_tvl),
470
470
  managementFeeWaivedUntilDate: tokenizedVault.management_fee_waived_until_date,
471
471
  managementFeeWaivedUntilTvl: tokenizedVault.management_fee_waived_until_tvl,
472
- isPerformanceWaived: tokenizedVault.platform_fee_override.is_fee_waived,
472
+ isPerformanceWaived: (0, vaults_1.resolveFeeWaived)(tokenizedVault.platform_fee_override.is_fee_waived, tokenizedVault.performance_fee_waived_until_date, tokenizedVault.performance_fee_waived_until_tvl),
473
473
  performanceFeeWaivedUntilDate: tokenizedVault.performance_fee_waived_until_date,
474
474
  performanceFeeWaivedUntilTvl: tokenizedVault.performance_fee_waived_until_tvl,
475
475
  },
package/lib/sdk.d.ts CHANGED
@@ -23141,6 +23141,48 @@ export declare function depositNative(signer: Signer | Wallet, options: INativeD
23141
23141
 
23142
23142
  /* Excluded from this release type: resolveDepositTokenDecimals */
23143
23143
 
23144
+ /**
23145
+ * Resolve whether a single fee (management or performance) is currently waived.
23146
+ *
23147
+ * Backend-driven, per AUGUST-5584. This centralizes logic that previously lived —
23148
+ * and diverged — across two upshift-app components. The resolution is deliberately
23149
+ * split between the backend and the SDK:
23150
+ *
23151
+ * - The backend `isFeeWaivedToggle` (`platform_fee_override.is_fee_waived`) is both
23152
+ * the master enable AND the TVL latch. Retool config takes precedence over live
23153
+ * TVL, and the backend flips this flag `false` once live TVL crosses the
23154
+ * configured threshold. That flip is one-way: if TVL later falls back below the
23155
+ * threshold the waiver does NOT re-apply. The SDK therefore does no TVL math and
23156
+ * never reads `latest_reported_tvl` here — trusting the flag preserves the latch.
23157
+ * - The **date** window is time-dependent, so it cannot be a static DB flag; the SDK
23158
+ * evaluates it live against the clock.
23159
+ *
23160
+ * Resolution:
23161
+ * - Toggle off → never waived (also the only "hide" path once TVL trips the latch).
23162
+ * - Toggle on, both date and TVL blank → indefinite manual waiver → waived.
23163
+ * - Toggle on with a date window → waived while `now < waivedUntilDate`.
23164
+ * - Toggle on with a TVL threshold configured → waived (the backend keeps the toggle
23165
+ * on only while live TVL is under the threshold).
23166
+ *
23167
+ * @param isFeeWaivedToggle - Backend master/TVL-latch flag. `false` ⇒ never waived.
23168
+ * @param waivedUntilDate - ISO datetime string the waiver runs until, or `null` for
23169
+ * no date window. An unparseable string yields `NaN`, which is never `> now`, so
23170
+ * it correctly contributes no date-based waiver.
23171
+ * @param waivedUntilTvl - Configured TVL threshold in whole USD, or `null`. Used only
23172
+ * to detect that a TVL-based waiver was set (values `<= 0` are treated as unset);
23173
+ * the threshold comparison itself is owned by the backend.
23174
+ * @param now - Clock, injected for deterministic testing. Defaults to `new Date()`.
23175
+ * @returns `true` if the UI should present this fee as "Fee Waived" right now.
23176
+ * @example
23177
+ * ```ts
23178
+ * // Toggle on, 30-day window still open → waived.
23179
+ * resolveFeeWaived(true, '2099-01-01T00:00:00Z', null); // true
23180
+ * // Toggle off overrides everything → not waived.
23181
+ * resolveFeeWaived(false, '2099-01-01T00:00:00Z', 10_000_000); // false
23182
+ * ```
23183
+ */
23184
+ export declare function resolveFeeWaived(isFeeWaivedToggle: boolean, waivedUntilDate: string | null, waivedUntilTvl: number | null, now?: Date): boolean;
23185
+
23144
23186
  /**
23145
23187
  * Normalize an optional origin code to the value to send on-chain.
23146
23188
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augustdigital/sdk",
3
- "version": "8.13.0",
3
+ "version": "8.14.0",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/sdk.d.ts",
6
6
  "keywords": [