@gearbox-protocol/sdk 15.1.0-next.19 → 15.1.0-next.20
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/common-utils/charts/credit-session.js +1 -1
- package/dist/cjs/model/opportunities.js +4 -4
- package/dist/cjs/model/opportunities.schema.js +1 -2
- package/dist/cjs/new-sdk/prepare/PrepareApi.js +14 -10
- package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +1 -1
- package/dist/cjs/plugins/accounts-counter/AccountsCounterPlugin.js +1 -1
- package/dist/cjs/sdk/OnchainSDK.js +2 -2
- package/dist/cjs/sdk/accounts/intents/testing/market.js +2 -1
- package/dist/cjs/sdk/accounts/intents/testing/sdk-mock.js +1 -0
- package/dist/cjs/sdk/accounts/intents/utils/pick-token.js +2 -2
- package/dist/cjs/sdk/accounts/intents/utils/quotas-for-update.js +1 -1
- package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +2 -2
- package/dist/cjs/sdk/chain/chains.js +140 -51
- package/dist/cjs/sdk/chain/index.js +3 -0
- package/dist/cjs/sdk/constants/networks.js +1 -1
- package/dist/cjs/sdk/core/AbstractAddressProviderContract.js +1 -1
- package/dist/cjs/sdk/index.js +11 -7
- package/dist/cjs/sdk/market/MarketSuite.js +8 -39
- package/dist/cjs/sdk/market/credit/CreditSuite.js +61 -37
- package/dist/cjs/sdk/market/credit/{isStrategyCollateral.js → collateralUtils.js} +52 -5
- package/dist/cjs/sdk/market/credit/index.js +5 -6
- package/dist/cjs/sdk/market/index.js +7 -6
- package/dist/cjs/sdk/market/strategyName.js +19 -0
- package/dist/cjs/sdk/opportunities/OpportunitiesService.js +5 -3
- package/dist/cjs/sdk/positions/PositionsService.js +5 -10
- package/dist/cjs/sdk/utils/index.js +1 -1
- package/dist/esm/common-utils/charts/credit-session.js +1 -1
- package/dist/esm/model/opportunities.js +4 -4
- package/dist/esm/model/opportunities.schema.js +1 -2
- package/dist/esm/new-sdk/prepare/PrepareApi.js +14 -10
- package/dist/esm/offchain/opportunities/OffchainOpportunities.js +1 -1
- package/dist/esm/plugins/accounts-counter/AccountsCounterPlugin.js +1 -1
- package/dist/esm/sdk/OnchainSDK.js +2 -2
- package/dist/esm/sdk/accounts/intents/testing/market.js +2 -1
- package/dist/esm/sdk/accounts/intents/testing/sdk-mock.js +1 -0
- package/dist/esm/sdk/accounts/intents/utils/pick-token.js +1 -1
- package/dist/esm/sdk/accounts/intents/utils/quotas-for-update.js +1 -1
- package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/sdk/chain/chains.js +139 -53
- package/dist/esm/sdk/chain/index.js +2 -2
- package/dist/esm/sdk/constants/networks.js +1 -1
- package/dist/esm/sdk/core/AbstractAddressProviderContract.js +1 -1
- package/dist/esm/sdk/index.js +5 -5
- package/dist/esm/sdk/market/MarketSuite.js +8 -39
- package/dist/esm/sdk/market/credit/CreditSuite.js +62 -38
- package/dist/esm/sdk/market/credit/{isStrategyCollateral.js → collateralUtils.js} +51 -6
- package/dist/esm/sdk/market/credit/index.js +2 -3
- package/dist/esm/sdk/market/index.js +3 -3
- package/dist/esm/sdk/market/strategyName.js +18 -0
- package/dist/esm/sdk/opportunities/OpportunitiesService.js +5 -3
- package/dist/esm/sdk/positions/PositionsService.js +5 -10
- package/dist/esm/sdk/utils/index.js +1 -1
- package/dist/types/model/index.d.ts +1 -1
- package/dist/types/model/opportunities.d.ts +8 -15
- package/dist/types/model/opportunities.schema.d.ts +0 -2
- package/dist/types/model/positions.d.ts +2 -10
- package/dist/types/new-sdk/errors/SourceChainMismatchError.d.ts +1 -1
- package/dist/types/new-sdk/positions/mergePositionList.d.ts +3 -2
- package/dist/types/new-sdk/types.d.ts +1 -1
- package/dist/types/sdk/accounts/intents/testing/sdk-mock.d.ts +5 -0
- package/dist/types/sdk/accounts/liquidations/types.d.ts +1 -1
- package/dist/types/sdk/base/MultichainConstruct.d.ts +1 -1
- package/dist/types/sdk/base/TokensMeta.d.ts +1 -1
- package/dist/types/sdk/chain/chains.d.ts +51 -7
- package/dist/types/sdk/chain/index.d.ts +2 -2
- package/dist/types/sdk/index.d.ts +7 -7
- package/dist/types/sdk/market/MarketRegister.d.ts +1 -1
- package/dist/types/sdk/market/MarketSuite.d.ts +4 -34
- package/dist/types/sdk/market/ZapperRegister.d.ts +1 -1
- package/dist/types/sdk/market/credit/CreditSuite.d.ts +23 -14
- package/dist/types/sdk/market/credit/{isStrategyCollateral.d.ts → collateralUtils.d.ts} +36 -8
- package/dist/types/sdk/market/credit/index.d.ts +2 -3
- package/dist/types/sdk/market/index.d.ts +4 -4
- package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +1 -1
- package/dist/types/sdk/market/oracle/types.d.ts +1 -1
- package/dist/types/sdk/market/strategyName.d.ts +18 -0
- package/dist/types/sdk/opportunities/OpportunitiesService.d.ts +2 -2
- package/dist/types/sdk/positions/types.d.ts +1 -1
- package/package.json +1 -1
- package/dist/cjs/sdk/market/credit/dominantCollateral.js +0 -47
- package/dist/esm/sdk/market/credit/dominantCollateral.js +0 -45
- package/dist/types/sdk/market/credit/dominantCollateral.d.ts +0 -29
package/package.json
CHANGED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("../../constants/math.js");
|
|
3
|
-
require("../../constants/index.js");
|
|
4
|
-
const require_sdk_utils_hex = require("../../utils/hex.js");
|
|
5
|
-
require("../../utils/index.js");
|
|
6
|
-
//#region src/sdk/market/credit/dominantCollateral.ts
|
|
7
|
-
/**
|
|
8
|
-
* The account's dominant collateral: the most valuable enabled non-underlying
|
|
9
|
-
* token it holds above dust, by USD value.
|
|
10
|
-
*
|
|
11
|
-
* This is the single definition of "what this account is a position in".
|
|
12
|
-
* Using onchain-only data we can only determine at the time of the call (without
|
|
13
|
-
* unreasably difficult calls)
|
|
14
|
-
*
|
|
15
|
-
* @param account - Account to inspect.
|
|
16
|
-
* @param market - Market of the account, whose oracle prices the candidates.
|
|
17
|
-
* @returns The dominant collateral, or `undefined` when the account holds
|
|
18
|
-
* nothing but its underlying, or nothing the oracle can price.
|
|
19
|
-
**/
|
|
20
|
-
function dominantCollateral(account, market) {
|
|
21
|
-
let bestValue = 0;
|
|
22
|
-
let dominant;
|
|
23
|
-
for (const t of account.tokens) {
|
|
24
|
-
if (require_sdk_utils_hex.hexEq(t.token, account.underlying) || (t.mask & account.enabledTokensMask) === 0n || t.balance <= 10n) continue;
|
|
25
|
-
const value = market.priceOracle.safeUsdValue(t.token, t.balance) ?? 0;
|
|
26
|
-
if (value > bestValue) {
|
|
27
|
-
bestValue = value;
|
|
28
|
-
dominant = t.token;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return dominant;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* {@link dominantCollateral}, for callers that cannot proceed without one, such
|
|
35
|
-
* as picking the collateral a partial liquidation seizes.
|
|
36
|
-
*
|
|
37
|
-
* @throws If the account holds no enabled non-underlying collateral the oracle
|
|
38
|
-
* can price.
|
|
39
|
-
**/
|
|
40
|
-
function mustGetDominantCollateral(account, market) {
|
|
41
|
-
const collateral = dominantCollateral(account, market);
|
|
42
|
-
if (!collateral) throw new Error(`cannot determine tokenOut for partial liquidation of ${market.sdk.labelAddress(account.creditAccount)}: no enabled non-underlying collateral with value`);
|
|
43
|
-
return collateral;
|
|
44
|
-
}
|
|
45
|
-
//#endregion
|
|
46
|
-
exports.dominantCollateral = dominantCollateral;
|
|
47
|
-
exports.mustGetDominantCollateral = mustGetDominantCollateral;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import "../../constants/math.js";
|
|
2
|
-
import "../../constants/index.js";
|
|
3
|
-
import { hexEq } from "../../utils/hex.js";
|
|
4
|
-
import "../../utils/index.js";
|
|
5
|
-
//#region src/sdk/market/credit/dominantCollateral.ts
|
|
6
|
-
/**
|
|
7
|
-
* The account's dominant collateral: the most valuable enabled non-underlying
|
|
8
|
-
* token it holds above dust, by USD value.
|
|
9
|
-
*
|
|
10
|
-
* This is the single definition of "what this account is a position in".
|
|
11
|
-
* Using onchain-only data we can only determine at the time of the call (without
|
|
12
|
-
* unreasably difficult calls)
|
|
13
|
-
*
|
|
14
|
-
* @param account - Account to inspect.
|
|
15
|
-
* @param market - Market of the account, whose oracle prices the candidates.
|
|
16
|
-
* @returns The dominant collateral, or `undefined` when the account holds
|
|
17
|
-
* nothing but its underlying, or nothing the oracle can price.
|
|
18
|
-
**/
|
|
19
|
-
function dominantCollateral(account, market) {
|
|
20
|
-
let bestValue = 0;
|
|
21
|
-
let dominant;
|
|
22
|
-
for (const t of account.tokens) {
|
|
23
|
-
if (hexEq(t.token, account.underlying) || (t.mask & account.enabledTokensMask) === 0n || t.balance <= 10n) continue;
|
|
24
|
-
const value = market.priceOracle.safeUsdValue(t.token, t.balance) ?? 0;
|
|
25
|
-
if (value > bestValue) {
|
|
26
|
-
bestValue = value;
|
|
27
|
-
dominant = t.token;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return dominant;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* {@link dominantCollateral}, for callers that cannot proceed without one, such
|
|
34
|
-
* as picking the collateral a partial liquidation seizes.
|
|
35
|
-
*
|
|
36
|
-
* @throws If the account holds no enabled non-underlying collateral the oracle
|
|
37
|
-
* can price.
|
|
38
|
-
**/
|
|
39
|
-
function mustGetDominantCollateral(account, market) {
|
|
40
|
-
const collateral = dominantCollateral(account, market);
|
|
41
|
-
if (!collateral) throw new Error(`cannot determine tokenOut for partial liquidation of ${market.sdk.labelAddress(account.creditAccount)}: no enabled non-underlying collateral with value`);
|
|
42
|
-
return collateral;
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
|
-
export { dominantCollateral, mustGetDominantCollateral };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { CreditAccountData } from "../../base/types.js";
|
|
2
|
-
import { MarketSuite } from "../MarketSuite.js";
|
|
3
|
-
import "../../base/index.js";
|
|
4
|
-
import { Address } from "viem";
|
|
5
|
-
//#region src/sdk/market/credit/dominantCollateral.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* The account's dominant collateral: the most valuable enabled non-underlying
|
|
8
|
-
* token it holds above dust, by USD value.
|
|
9
|
-
*
|
|
10
|
-
* This is the single definition of "what this account is a position in".
|
|
11
|
-
* Using onchain-only data we can only determine at the time of the call (without
|
|
12
|
-
* unreasably difficult calls)
|
|
13
|
-
*
|
|
14
|
-
* @param account - Account to inspect.
|
|
15
|
-
* @param market - Market of the account, whose oracle prices the candidates.
|
|
16
|
-
* @returns The dominant collateral, or `undefined` when the account holds
|
|
17
|
-
* nothing but its underlying, or nothing the oracle can price.
|
|
18
|
-
**/
|
|
19
|
-
declare function dominantCollateral(account: CreditAccountData, market: MarketSuite): Address | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* {@link dominantCollateral}, for callers that cannot proceed without one, such
|
|
22
|
-
* as picking the collateral a partial liquidation seizes.
|
|
23
|
-
*
|
|
24
|
-
* @throws If the account holds no enabled non-underlying collateral the oracle
|
|
25
|
-
* can price.
|
|
26
|
-
**/
|
|
27
|
-
declare function mustGetDominantCollateral(account: CreditAccountData, market: MarketSuite): Address;
|
|
28
|
-
//#endregion
|
|
29
|
-
export { dominantCollateral, mustGetDominantCollateral };
|