@gearbox-protocol/sdk 17.3.1 → 17.4.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/dist/cjs/model/opportunities.schema.js +2 -0
- package/dist/cjs/onchain/market/credit/CreditSuiteStrategy.js +2 -0
- package/dist/cjs/sdk/opportunities/OpportunitiesNamespace.js +8 -5
- package/dist/esm/model/opportunities.schema.js +3 -1
- package/dist/esm/onchain/market/credit/CreditSuiteStrategy.js +2 -0
- package/dist/esm/sdk/opportunities/OpportunitiesNamespace.js +8 -5
- package/dist/types/model/opportunities.d.ts +13 -0
- package/dist/types/model/opportunities.schema.d.ts +20 -0
- package/package.json +1 -1
|
@@ -112,6 +112,8 @@ const strategyOpportunitySchema = zod_v4.z.object({
|
|
|
112
112
|
totalValue: require_model_compare_schema.offchainOnly(require_model_primitives_schema.amountSchema).optional(),
|
|
113
113
|
utilization: require_model_compare_schema.offchainOnly(require_model_primitives_schema.bpsSchema).optional(),
|
|
114
114
|
availableLiquidity: require_model_compare_schema.tolerance(require_model_primitives_schema.amountSchema, "amount"),
|
|
115
|
+
totalSupply: require_model_compare_schema.onchainOnly(require_model_primitives_schema.amountSchema).optional(),
|
|
116
|
+
feeInterest: require_model_compare_schema.onchainOnly(require_model_primitives_schema.bpsSchema).optional(),
|
|
115
117
|
minDebt: require_model_primitives_schema.amountSchema,
|
|
116
118
|
totalDebtLimit: require_model_primitives_schema.amountSchema,
|
|
117
119
|
maxBorrowAmount: require_model_compare_schema.tolerance(require_model_primitives_schema.amountSchema, "amount"),
|
|
@@ -132,6 +132,8 @@ var CreditSuiteStrategy = class {
|
|
|
132
132
|
borrowApy: require_onchain_market_math.calcBorrowApy(pool.baseInterestRate, cm.feeInterest),
|
|
133
133
|
quotaRate: require_onchain_market_math.calcQuotaRate(market.pool.pqk.quotaRate(targetCollateral), cm.feeInterest),
|
|
134
134
|
availableLiquidity: oracle.toAmount(pool.underlying, pool.availableLiquidity),
|
|
135
|
+
totalSupply: oracle.toAmount(pool.underlying, pool.expectedLiquidity),
|
|
136
|
+
feeInterest: cm.feeInterest,
|
|
135
137
|
minDebt: oracle.toAmount(pool.underlying, suite.creditFacade.minDebt),
|
|
136
138
|
totalDebtLimit: oracle.toAmount(pool.underlying, debtParams?.limit ?? 0n),
|
|
137
139
|
maxBorrowAmount: oracle.toAmount(pool.underlying, this.maxBorrowAmount().amount.value),
|
|
@@ -23,7 +23,7 @@ var OpportunitiesNamespace = class extends require_sdk_AbstractNamespace.Abstrac
|
|
|
23
23
|
merge = {
|
|
24
24
|
list: (onchain, offchain) => require_sdk_utils_mergeChains.mergeChainList(onchain, offchain, this.maxOffchainLagSeconds),
|
|
25
25
|
pool: (onchain, offchain) => require_sdk_utils_mergeChains.mergeChainOne(onchain, offchain, this.maxOffchainLagSeconds),
|
|
26
|
-
strategy: (onchain, offchain) =>
|
|
26
|
+
strategy: (onchain, offchain) => overlayOnchainFields(require_sdk_utils_mergeChains.mergeChainOne(onchain, offchain, this.maxOffchainLagSeconds), onchain)
|
|
27
27
|
};
|
|
28
28
|
#prepare;
|
|
29
29
|
#execute;
|
|
@@ -102,17 +102,20 @@ var OpportunitiesNamespace = class extends require_sdk_AbstractNamespace.Abstrac
|
|
|
102
102
|
}
|
|
103
103
|
};
|
|
104
104
|
/**
|
|
105
|
-
* Freshness still picks the body;
|
|
106
|
-
*
|
|
105
|
+
* Freshness still picks the body; fields the backend does not serve are taken
|
|
106
|
+
* from a successful chain response.
|
|
107
107
|
**/
|
|
108
|
-
function
|
|
108
|
+
function overlayOnchainFields(merged, onchain) {
|
|
109
109
|
if (!merged || !onchain || onchain.meta.chains[0]?.status !== "success") return merged;
|
|
110
110
|
if (merged === onchain) return merged;
|
|
111
111
|
return {
|
|
112
112
|
...merged,
|
|
113
113
|
data: {
|
|
114
114
|
...merged.data,
|
|
115
|
-
kyc: onchain.data.kyc
|
|
115
|
+
kyc: onchain.data.kyc,
|
|
116
|
+
feeInterest: onchain.data.feeInterest,
|
|
117
|
+
totalSupply: onchain.data.totalSupply,
|
|
118
|
+
availableLiquidity: onchain.data.availableLiquidity
|
|
116
119
|
}
|
|
117
120
|
};
|
|
118
121
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ZodAddress } from "../onchain/utils/zod.js";
|
|
2
|
-
import { offchainOnly, tolerance } from "./compare.schema.js";
|
|
2
|
+
import { offchainOnly, onchainOnly, tolerance } from "./compare.schema.js";
|
|
3
3
|
import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenSchema, underlyingTokenSchema } from "./primitives.schema.js";
|
|
4
4
|
import { isFilterSet } from "./filters.js";
|
|
5
5
|
import { booleanParamSchema, encodeFlag, filterable } from "./filters.schema.js";
|
|
@@ -111,6 +111,8 @@ const strategyOpportunitySchema = z.object({
|
|
|
111
111
|
totalValue: offchainOnly(amountSchema).optional(),
|
|
112
112
|
utilization: offchainOnly(bpsSchema).optional(),
|
|
113
113
|
availableLiquidity: tolerance(amountSchema, "amount"),
|
|
114
|
+
totalSupply: onchainOnly(amountSchema).optional(),
|
|
115
|
+
feeInterest: onchainOnly(bpsSchema).optional(),
|
|
114
116
|
minDebt: amountSchema,
|
|
115
117
|
totalDebtLimit: amountSchema,
|
|
116
118
|
maxBorrowAmount: tolerance(amountSchema, "amount"),
|
|
@@ -131,6 +131,8 @@ var CreditSuiteStrategy = class {
|
|
|
131
131
|
borrowApy: calcBorrowApy(pool.baseInterestRate, cm.feeInterest),
|
|
132
132
|
quotaRate: calcQuotaRate(market.pool.pqk.quotaRate(targetCollateral), cm.feeInterest),
|
|
133
133
|
availableLiquidity: oracle.toAmount(pool.underlying, pool.availableLiquidity),
|
|
134
|
+
totalSupply: oracle.toAmount(pool.underlying, pool.expectedLiquidity),
|
|
135
|
+
feeInterest: cm.feeInterest,
|
|
134
136
|
minDebt: oracle.toAmount(pool.underlying, suite.creditFacade.minDebt),
|
|
135
137
|
totalDebtLimit: oracle.toAmount(pool.underlying, debtParams?.limit ?? 0n),
|
|
136
138
|
maxBorrowAmount: oracle.toAmount(pool.underlying, this.maxBorrowAmount().amount.value),
|
|
@@ -22,7 +22,7 @@ var OpportunitiesNamespace = class extends AbstractNamespace {
|
|
|
22
22
|
merge = {
|
|
23
23
|
list: (onchain, offchain) => mergeChainList(onchain, offchain, this.maxOffchainLagSeconds),
|
|
24
24
|
pool: (onchain, offchain) => mergeChainOne(onchain, offchain, this.maxOffchainLagSeconds),
|
|
25
|
-
strategy: (onchain, offchain) =>
|
|
25
|
+
strategy: (onchain, offchain) => overlayOnchainFields(mergeChainOne(onchain, offchain, this.maxOffchainLagSeconds), onchain)
|
|
26
26
|
};
|
|
27
27
|
#prepare;
|
|
28
28
|
#execute;
|
|
@@ -101,17 +101,20 @@ var OpportunitiesNamespace = class extends AbstractNamespace {
|
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
103
|
/**
|
|
104
|
-
* Freshness still picks the body;
|
|
105
|
-
*
|
|
104
|
+
* Freshness still picks the body; fields the backend does not serve are taken
|
|
105
|
+
* from a successful chain response.
|
|
106
106
|
**/
|
|
107
|
-
function
|
|
107
|
+
function overlayOnchainFields(merged, onchain) {
|
|
108
108
|
if (!merged || !onchain || onchain.meta.chains[0]?.status !== "success") return merged;
|
|
109
109
|
if (merged === onchain) return merged;
|
|
110
110
|
return {
|
|
111
111
|
...merged,
|
|
112
112
|
data: {
|
|
113
113
|
...merged.data,
|
|
114
|
-
kyc: onchain.data.kyc
|
|
114
|
+
kyc: onchain.data.kyc,
|
|
115
|
+
feeInterest: onchain.data.feeInterest,
|
|
116
|
+
totalSupply: onchain.data.totalSupply,
|
|
117
|
+
availableLiquidity: onchain.data.availableLiquidity
|
|
115
118
|
}
|
|
116
119
|
};
|
|
117
120
|
}
|
|
@@ -325,6 +325,19 @@ interface StrategyOpportunity extends OpportunityBase {
|
|
|
325
325
|
* underlying. Same value the market's {@link PoolOpportunity} reports.
|
|
326
326
|
**/
|
|
327
327
|
availableLiquidity: Amount;
|
|
328
|
+
/**
|
|
329
|
+
* Size of the pool the strategy borrows from, `pool.expectedLiquidity`.
|
|
330
|
+
* Same value the market's {@link PoolOpportunity} reports.
|
|
331
|
+
*
|
|
332
|
+
* @mode onchain
|
|
333
|
+
**/
|
|
334
|
+
totalSupply?: Amount;
|
|
335
|
+
/**
|
|
336
|
+
* Percentage of accrued interest in bps taken by the protocol as profit.
|
|
337
|
+
*
|
|
338
|
+
* @mode onchain
|
|
339
|
+
**/
|
|
340
|
+
feeInterest?: Bps;
|
|
328
341
|
/**
|
|
329
342
|
* Smallest debt a position in this credit manager may hold, denominated in
|
|
330
343
|
* the underlying (`creditFacade.minDebt`).
|
|
@@ -425,6 +425,11 @@ declare const strategyOpportunitySchema: z.ZodObject<{
|
|
|
425
425
|
value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
|
|
426
426
|
valueUsd: z.ZodNullable<z.ZodNumber>;
|
|
427
427
|
}, z.core.$strip>;
|
|
428
|
+
totalSupply: z.ZodOptional<z.ZodObject<{
|
|
429
|
+
value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
|
|
430
|
+
valueUsd: z.ZodNullable<z.ZodNumber>;
|
|
431
|
+
}, z.core.$strip>>;
|
|
432
|
+
feeInterest: z.ZodOptional<z.ZodNumber>;
|
|
428
433
|
minDebt: z.ZodObject<{
|
|
429
434
|
value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
|
|
430
435
|
valueUsd: z.ZodNullable<z.ZodNumber>;
|
|
@@ -693,6 +698,11 @@ declare const opportunitySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
693
698
|
value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
|
|
694
699
|
valueUsd: z.ZodNullable<z.ZodNumber>;
|
|
695
700
|
}, z.core.$strip>;
|
|
701
|
+
totalSupply: z.ZodOptional<z.ZodObject<{
|
|
702
|
+
value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
|
|
703
|
+
valueUsd: z.ZodNullable<z.ZodNumber>;
|
|
704
|
+
}, z.core.$strip>>;
|
|
705
|
+
feeInterest: z.ZodOptional<z.ZodNumber>;
|
|
696
706
|
minDebt: z.ZodObject<{
|
|
697
707
|
value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
|
|
698
708
|
valueUsd: z.ZodNullable<z.ZodNumber>;
|
|
@@ -1080,6 +1090,11 @@ declare const strategyOpportunityDetailSchema: z.ZodObject<{
|
|
|
1080
1090
|
value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
|
|
1081
1091
|
valueUsd: z.ZodNullable<z.ZodNumber>;
|
|
1082
1092
|
}, z.core.$strip>;
|
|
1093
|
+
totalSupply: z.ZodOptional<z.ZodObject<{
|
|
1094
|
+
value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
|
|
1095
|
+
valueUsd: z.ZodNullable<z.ZodNumber>;
|
|
1096
|
+
}, z.core.$strip>>;
|
|
1097
|
+
feeInterest: z.ZodOptional<z.ZodNumber>;
|
|
1083
1098
|
minDebt: z.ZodObject<{
|
|
1084
1099
|
value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
|
|
1085
1100
|
valueUsd: z.ZodNullable<z.ZodNumber>;
|
|
@@ -1396,6 +1411,11 @@ declare const opportunityDetailSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1396
1411
|
value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
|
|
1397
1412
|
valueUsd: z.ZodNullable<z.ZodNumber>;
|
|
1398
1413
|
}, z.core.$strip>;
|
|
1414
|
+
totalSupply: z.ZodOptional<z.ZodObject<{
|
|
1415
|
+
value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
|
|
1416
|
+
valueUsd: z.ZodNullable<z.ZodNumber>;
|
|
1417
|
+
}, z.core.$strip>>;
|
|
1418
|
+
feeInterest: z.ZodOptional<z.ZodNumber>;
|
|
1399
1419
|
minDebt: z.ZodObject<{
|
|
1400
1420
|
value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
|
|
1401
1421
|
valueUsd: z.ZodNullable<z.ZodNumber>;
|