@gearbox-protocol/sdk 15.1.0-next.18 → 15.1.0-next.19
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/new-sdk/positions/PositionsNamespace.js +2 -2
- package/dist/cjs/new-sdk/positions/mergePositionList.js +23 -0
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/new-sdk/positions/PositionsNamespace.js +2 -2
- package/dist/esm/new-sdk/positions/mergePositionList.js +22 -0
- package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
- package/dist/esm/preview/trace/extractTransfers.js +1 -1
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/sdk/base/TokensMeta.js +3 -3
- package/dist/esm/sdk/chain/detectNetwork.js +1 -1
- package/dist/esm/sdk/core/createAddressProvider.js +1 -1
- package/dist/esm/sdk/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
- package/dist/esm/sdk/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/sdk/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/sdk/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/sdk/pools/PoolService.js +1 -1
- package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/types/model/positions.d.ts +7 -1
- package/dist/types/new-sdk/index.d.ts +3 -3
- package/dist/types/new-sdk/opportunities/index.d.ts +2 -2
- package/dist/types/new-sdk/opportunities/types.d.ts +2 -9
- package/dist/types/new-sdk/positions/index.d.ts +2 -2
- package/dist/types/new-sdk/positions/mergePositionList.d.ts +18 -0
- package/dist/types/new-sdk/positions/types.d.ts +2 -9
- package/package.json +1 -1
|
@@ -3,8 +3,8 @@ const require_model_positions = require("../../model/positions.js");
|
|
|
3
3
|
require("../../model/index.js");
|
|
4
4
|
const require_new_sdk_AbstractNamespace = require("../AbstractNamespace.js");
|
|
5
5
|
const require_new_sdk_utils_filterResponse = require("../utils/filterResponse.js");
|
|
6
|
-
const require_new_sdk_utils_mergeChains = require("../utils/mergeChains.js");
|
|
7
6
|
require("../utils/index.js");
|
|
7
|
+
const require_new_sdk_positions_mergePositionList = require("./mergePositionList.js");
|
|
8
8
|
//#region src/new-sdk/positions/PositionsNamespace.ts
|
|
9
9
|
/**
|
|
10
10
|
* The `positions` namespace of a {@link GearboxSDK}, see
|
|
@@ -14,7 +14,7 @@ var PositionsNamespace = class extends require_new_sdk_AbstractNamespace.Abstrac
|
|
|
14
14
|
/**
|
|
15
15
|
* {@inheritDoc PositionsBase.merge}
|
|
16
16
|
**/
|
|
17
|
-
merge = { list: (onchain, offchain) =>
|
|
17
|
+
merge = { list: (onchain, offchain) => require_new_sdk_positions_mergePositionList.mergePositionList(onchain, offchain, this.maxOffchainLagSeconds) };
|
|
18
18
|
constructor(onchain, offchain, options) {
|
|
19
19
|
super("Positions", onchain?.positions, offchain?.positions, options);
|
|
20
20
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_model_positions = require("../../model/positions.js");
|
|
3
|
+
require("../../model/index.js");
|
|
4
|
+
const require_new_sdk_utils_mergeChains = require("../utils/mergeChains.js");
|
|
5
|
+
//#region src/new-sdk/positions/mergePositionList.ts
|
|
6
|
+
function mergePositionList(onchain, offchain, maxLagSeconds) {
|
|
7
|
+
const merged = require_new_sdk_utils_mergeChains.mergeChainList(onchain, offchain, maxLagSeconds);
|
|
8
|
+
if (!merged || !offchain) return merged;
|
|
9
|
+
const backendById = new Map(offchain.data.filter((row) => row.kind === "strategy").map((row) => [require_model_positions.positionId(row), row]));
|
|
10
|
+
return {
|
|
11
|
+
...merged,
|
|
12
|
+
data: merged.data.map((row) => {
|
|
13
|
+
const backend = row.kind === "strategy" ? backendById.get(require_model_positions.positionId(row)) : void 0;
|
|
14
|
+
return backend ? {
|
|
15
|
+
...row,
|
|
16
|
+
targetCollateral: backend.targetCollateral,
|
|
17
|
+
name: backend.name
|
|
18
|
+
} : row;
|
|
19
|
+
})
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.mergePositionList = mergePositionList;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { ierc20Abi } from "../abi/iERC20.js";
|
|
1
2
|
import { iCreditFacadeV310Abi } from "../abi/310/generated.js";
|
|
2
3
|
import { AddressMap } from "../sdk/utils/AddressMap.js";
|
|
3
4
|
import { AddressSet } from "../sdk/utils/AddressSet.js";
|
|
4
5
|
import { AssetsMap } from "../sdk/utils/AssetsMap.js";
|
|
5
6
|
import { childLogger } from "../sdk/utils/childLogger.js";
|
|
6
|
-
import { ierc20Abi } from "../abi/iERC20.js";
|
|
7
7
|
import "../sdk/constants/addresses.js";
|
|
8
8
|
import { MAX_UINT256, PERCENTAGE_FACTOR } from "../sdk/constants/math.js";
|
|
9
9
|
import { SDKConstruct } from "../sdk/base/SDKConstruct.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
|
|
1
2
|
import { getNetworkType } from "../sdk/chain/chains.js";
|
|
2
3
|
import { getWithdrawalCompressorAddress } from "../sdk/accounts/withdrawal-compressor/addresses.js";
|
|
3
|
-
import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
|
|
4
4
|
import "../sdk/index.js";
|
|
5
5
|
import { iMidasDataFeedAbi, iMidasRedemptionVaultAbi, midasGatewayAbi, midasRedeemerAbi, midasRedemptionVaultPhantomTokenAbi, securitizeRedeemerAbi, securitizeRedemptionGatewayAbi, securitizeRedemptionPhantomTokenAbi } from "./withdrawalAbi.js";
|
|
6
6
|
import { erc20Abi, hexToString, parseAbi, parseEther } from "viem";
|
|
@@ -2,8 +2,8 @@ import { matchesPositionFilter } from "../../model/positions.js";
|
|
|
2
2
|
import "../../model/index.js";
|
|
3
3
|
import { AbstractNamespace } from "../AbstractNamespace.js";
|
|
4
4
|
import { filterResponse } from "../utils/filterResponse.js";
|
|
5
|
-
import { mergeChainList } from "../utils/mergeChains.js";
|
|
6
5
|
import "../utils/index.js";
|
|
6
|
+
import { mergePositionList } from "./mergePositionList.js";
|
|
7
7
|
//#region src/new-sdk/positions/PositionsNamespace.ts
|
|
8
8
|
/**
|
|
9
9
|
* The `positions` namespace of a {@link GearboxSDK}, see
|
|
@@ -13,7 +13,7 @@ var PositionsNamespace = class extends AbstractNamespace {
|
|
|
13
13
|
/**
|
|
14
14
|
* {@inheritDoc PositionsBase.merge}
|
|
15
15
|
**/
|
|
16
|
-
merge = { list: (onchain, offchain) =>
|
|
16
|
+
merge = { list: (onchain, offchain) => mergePositionList(onchain, offchain, this.maxOffchainLagSeconds) };
|
|
17
17
|
constructor(onchain, offchain, options) {
|
|
18
18
|
super("Positions", onchain?.positions, offchain?.positions, options);
|
|
19
19
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { positionId } from "../../model/positions.js";
|
|
2
|
+
import "../../model/index.js";
|
|
3
|
+
import { mergeChainList } from "../utils/mergeChains.js";
|
|
4
|
+
//#region src/new-sdk/positions/mergePositionList.ts
|
|
5
|
+
function mergePositionList(onchain, offchain, maxLagSeconds) {
|
|
6
|
+
const merged = mergeChainList(onchain, offchain, maxLagSeconds);
|
|
7
|
+
if (!merged || !offchain) return merged;
|
|
8
|
+
const backendById = new Map(offchain.data.filter((row) => row.kind === "strategy").map((row) => [positionId(row), row]));
|
|
9
|
+
return {
|
|
10
|
+
...merged,
|
|
11
|
+
data: merged.data.map((row) => {
|
|
12
|
+
const backend = row.kind === "strategy" ? backendById.get(positionId(row)) : void 0;
|
|
13
|
+
return backend ? {
|
|
14
|
+
...row,
|
|
15
|
+
targetCollateral: backend.targetCollateral,
|
|
16
|
+
name: backend.name
|
|
17
|
+
} : row;
|
|
18
|
+
})
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { mergePositionList };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { iPoolV310Abi } from "../../abi/310/generated.js";
|
|
2
1
|
import { iZapperAbi } from "../../abi/iZapper.js";
|
|
2
|
+
import { iPoolV310Abi } from "../../abi/310/generated.js";
|
|
3
3
|
import { asPreviewSimulationError } from "./errors.js";
|
|
4
4
|
//#region src/preview/simulate/simulatePoolOperation.ts
|
|
5
5
|
function previewRead(operation) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
1
2
|
import { iCreditFacadeV310Abi } from "../../abi/310/generated.js";
|
|
2
3
|
import { AddressMap } from "../../sdk/utils/AddressMap.js";
|
|
3
|
-
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
4
4
|
import "../../sdk/index.js";
|
|
5
5
|
import { UnexpectedFacadeEventOrderError } from "./errors.js";
|
|
6
6
|
import { getAddress, isAddressEqual, parseEventLogs } from "viem";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
|
|
2
|
+
import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
|
|
1
3
|
import { AP_REWARDS_COMPRESSOR } from "../constants/address-provider.js";
|
|
2
4
|
import { ADDRESS_0X0 } from "../constants/addresses.js";
|
|
3
5
|
import { MAX_UINT256 } from "../constants/math.js";
|
|
@@ -8,8 +10,6 @@ import "../base/index.js";
|
|
|
8
10
|
import { AccountBotsService } from "./bots/AccountBotsService.js";
|
|
9
11
|
import "./bots/index.js";
|
|
10
12
|
import { rewardsCompressorAbi } from "../../abi/compressors/rewardsCompressor.js";
|
|
11
|
-
import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
|
|
12
|
-
import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
|
|
13
13
|
import { expectedBalanceDeltas } from "../market/credit/expectedBalanceDeltas.js";
|
|
14
14
|
import "../market/index.js";
|
|
15
15
|
import { CreditAccountCompressor } from "./credit-account-compressor/CreditAccountCompressor.js";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
|
|
1
2
|
import { AddressSet } from "../../utils/AddressSet.js";
|
|
2
3
|
import { bytes32ToString } from "../../utils/bytes32ToString.js";
|
|
3
4
|
import { ADDRESS_0X0 } from "../../constants/addresses.js";
|
|
@@ -19,7 +20,6 @@ import { SecuritizeLiquidatorContract } from "../../market/rwa/securitize/Securi
|
|
|
19
20
|
import "../../market/rwa/securitize/index.js";
|
|
20
21
|
import "../../market/index.js";
|
|
21
22
|
import { LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./constants.js";
|
|
22
|
-
import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
|
|
23
23
|
//#region src/sdk/accounts/liquidations/LiquidationsService.ts
|
|
24
24
|
/**
|
|
25
25
|
* Service for discovering liquidatable credit accounts and previewing manual
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
1
2
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
2
3
|
import "../../base/index.js";
|
|
3
4
|
import { decodeDelayedIntent } from "./intent-codec.js";
|
|
4
|
-
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
5
5
|
import { InvalidDelayedIntentError } from "./errors.js";
|
|
6
6
|
//#region src/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.ts
|
|
7
7
|
const abi = iRedemptionLoggerV310Abi;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
2
1
|
import { iWithdrawalCompressorV310Abi } from "../../../abi/IWithdrawalCompressorV310.js";
|
|
2
|
+
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
3
|
//#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.ts
|
|
4
4
|
const abi = iWithdrawalCompressorV310Abi;
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
2
1
|
import { iWithdrawalCompressorV311Abi } from "../../../abi/IWithdrawalCompressorV311.js";
|
|
2
|
+
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
3
|
//#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.ts
|
|
4
4
|
const abi = iWithdrawalCompressorV311Abi;
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
|
|
1
2
|
import { encodeDelayedIntent } from "./intent-codec.js";
|
|
2
3
|
import { AbstractWithdrawalCompressorContract, iCreditAccountAbi, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
|
-
import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
|
|
4
4
|
import { toWithdrawalStatus } from "./types.js";
|
|
5
5
|
//#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.ts
|
|
6
6
|
const abi = iWithdrawalCompressorV313Abi;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { iExpirableAbi } from "../../abi/iExpirable.js";
|
|
2
|
+
import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
|
|
3
|
+
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
1
4
|
import { AddressMap } from "../utils/AddressMap.js";
|
|
2
5
|
import { AddressSet } from "../utils/AddressSet.js";
|
|
3
6
|
import { bytes32ToString } from "../utils/bytes32ToString.js";
|
|
4
7
|
import { getAssetType } from "../chain/chains.js";
|
|
5
8
|
import { formatBN } from "../utils/formatter.js";
|
|
6
9
|
import "../utils/index.js";
|
|
7
|
-
import { iExpirableAbi } from "../../abi/iExpirable.js";
|
|
8
|
-
import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
|
|
9
|
-
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
10
10
|
import { executeMulticallBatches } from "../utils/viem/executeMulticallBatches.js";
|
|
11
11
|
//#region src/sdk/base/TokensMeta.ts
|
|
12
12
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
1
2
|
import { AP_MARKET_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR } from "../constants/address-provider.js";
|
|
2
3
|
import { isV310 } from "../constants/versions.js";
|
|
3
4
|
import "../constants/index.js";
|
|
4
5
|
import { hexEq } from "../utils/hex.js";
|
|
5
|
-
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
6
6
|
import { AddressProviderV310Contract } from "./AddressProviderV310Contract.js";
|
|
7
7
|
//#region src/sdk/core/createAddressProvider.ts
|
|
8
8
|
const OVERRIDE_ADDRESSES = { Mainnet: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
2
1
|
import { accountMigratorAbi } from "../../../../abi/AccountMigrator.js";
|
|
2
|
+
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
3
3
|
//#region src/sdk/market/adapters/contracts/AccountMigratorAdapterContract.ts
|
|
4
4
|
const abi = accountMigratorAbi;
|
|
5
5
|
const protocolAbi = accountMigratorAbi;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ierc4626AdapterAbi } from "../../../../abi/ierc4626Adapter.js";
|
|
1
2
|
import { MissingSerializedParamsError } from "../../../base/errors.js";
|
|
2
3
|
import "../../../base/index.js";
|
|
3
|
-
import { ierc4626AdapterAbi } from "../../../../abi/ierc4626Adapter.js";
|
|
4
4
|
import { iERC4626Abi } from "../abi/targetContractAbi.js";
|
|
5
5
|
import { fnSigToName, swapFromTransfers } from "../transferHelpers.js";
|
|
6
6
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
1
2
|
import { iCreditFacadeMulticallV310Abi, iCreditFacadeV310Abi } from "../../../abi/310/generated.js";
|
|
2
3
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
3
4
|
import "../../base/index.js";
|
|
4
|
-
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
5
5
|
//#region src/sdk/market/credit/CreditFacadeV310BaseContract.ts
|
|
6
6
|
const abi = [
|
|
7
7
|
...iCreditFacadeV310Abi,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
1
2
|
import { iPoolV310Abi } from "../../../abi/310/generated.js";
|
|
2
3
|
import { AddressMap } from "../../utils/AddressMap.js";
|
|
3
4
|
import { RAY } from "../../constants/math.js";
|
|
@@ -6,7 +7,6 @@ import { formatBN, formatBNvalue, percentFmt } from "../../utils/formatter.js";
|
|
|
6
7
|
import "../../utils/index.js";
|
|
7
8
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
8
9
|
import "../../base/index.js";
|
|
9
|
-
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
10
10
|
import { calcUtilization } from "../math.js";
|
|
11
11
|
//#region src/sdk/market/pool/PoolV310Contract.ts
|
|
12
12
|
const abi = [...iPoolV310Abi, ...iPausableAbi];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ZapperContract } from "./ZapperContract.js";
|
|
2
1
|
import { iethZapperAbi } from "../../../abi/iETHZapper.js";
|
|
2
|
+
import { ZapperContract } from "./ZapperContract.js";
|
|
3
3
|
//#region src/sdk/market/zapper/IETHZapperContract.ts
|
|
4
4
|
const abi = iethZapperAbi;
|
|
5
5
|
var IETHZapperContract = class extends ZapperContract {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
1
2
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
2
3
|
import "../../base/index.js";
|
|
3
|
-
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
4
4
|
import { UnsupportedZapperFunctionError } from "./errors.js";
|
|
5
5
|
//#region src/sdk/market/zapper/ZapperContract.ts
|
|
6
6
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AddressSet } from "../utils/AddressSet.js";
|
|
2
1
|
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
2
|
+
import { AddressSet } from "../utils/AddressSet.js";
|
|
3
3
|
import "../constants/addresses.js";
|
|
4
4
|
import { PERCENTAGE_FACTOR, RAY } from "../constants/math.js";
|
|
5
5
|
import "../constants/index.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { errorAbis } from "../../../abi/errors.js";
|
|
2
|
-
import { generateCastTraceCall } from "./cast.js";
|
|
3
2
|
import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
|
|
3
|
+
import { generateCastTraceCall } from "./cast.js";
|
|
4
4
|
import { simulateMulticall } from "./simulateMulticall.js";
|
|
5
5
|
import { BaseError, CallExecutionError, ContractFunctionRevertedError, decodeFunctionData, decodeFunctionResult, encodeFunctionData, parseAbi } from "viem";
|
|
6
6
|
import { getAction, parseAccount } from "viem/utils";
|
|
@@ -183,7 +183,9 @@ interface StrategyPosition {
|
|
|
183
183
|
**/
|
|
184
184
|
kind: "strategy";
|
|
185
185
|
/**
|
|
186
|
-
* Human-readable strategy name, e.g. `"wstETH / WETH"`.
|
|
186
|
+
* Human-readable strategy name, e.g. `"wstETH / WETH"`. Derived from
|
|
187
|
+
* {@link targetCollateral}, so in `both` mode it follows the same backend
|
|
188
|
+
* override as that field.
|
|
187
189
|
**/
|
|
188
190
|
name: string;
|
|
189
191
|
/**
|
|
@@ -203,6 +205,10 @@ interface StrategyPosition {
|
|
|
203
205
|
* block (greatest opening-block USD value) — the asset the position was
|
|
204
206
|
* initially leveraged into. `null` when the opening snapshot holds only the
|
|
205
207
|
* underlying.
|
|
208
|
+
*
|
|
209
|
+
* In `both` mode the backend's value is always preferred when it has the
|
|
210
|
+
* row, even if the chain wins the freshness race: the chain can only guess
|
|
211
|
+
* from current holdings.
|
|
206
212
|
**/
|
|
207
213
|
targetCollateral: Token | null;
|
|
208
214
|
/**
|
|
@@ -12,10 +12,10 @@ import { ChainOf, PrepareApi } from "./prepare/PrepareApi.js";
|
|
|
12
12
|
import "./prepare/index.js";
|
|
13
13
|
import { AccountPrepareRequest, ExecuteApi, OpenPrepareRequest, OpportunitiesExecute, PoolPrepareRequest, PrepareRequest } from "./execute/ExecuteApi.js";
|
|
14
14
|
import "./execute/index.js";
|
|
15
|
-
import { Opportunities, OpportunitiesBase, OpportunitiesByMode,
|
|
15
|
+
import { Opportunities, OpportunitiesBase, OpportunitiesByMode, OpportunitiesOffchainBranch, OpportunitiesOffchainOnly, OpportunitiesOnchainBranch, OpportunitiesOnchainOnly, OpportunityMergers } from "./opportunities/types.js";
|
|
16
16
|
import { OpportunitiesNamespace } from "./opportunities/OpportunitiesNamespace.js";
|
|
17
17
|
import "./opportunities/index.js";
|
|
18
|
-
import { PositionMergers, Positions, PositionsBase, PositionsByMode,
|
|
18
|
+
import { PositionMergers, Positions, PositionsBase, PositionsByMode, PositionsOffchainBranch, PositionsOffchainOnly, PositionsOnchainBranch, PositionsOnchainOnly } from "./positions/types.js";
|
|
19
19
|
import { PositionsNamespace } from "./positions/PositionsNamespace.js";
|
|
20
20
|
import "./positions/index.js";
|
|
21
21
|
import { Preview, PreviewByMode } from "./preview/types.js";
|
|
@@ -30,4 +30,4 @@ import { SourceUnavailableError } from "./errors/SourceUnavailableError.js";
|
|
|
30
30
|
import { assertSameChains } from "./errors/assertSameChains.js";
|
|
31
31
|
import { everyChainFailed } from "./errors/everyChainFailed.js";
|
|
32
32
|
import "./errors/index.js";
|
|
33
|
-
export { AbstractNamespace, AccountPrepareRequest, AddCollateralParams, AdjustLeverageParams, AllSourcesFailedError, ChainOf, ChainRef, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, DelayedStrategySimulate, DepositStrategyParams, EnsureFreshChains, type EntityMerger, ExecuteApi, type FilterResult, FinalizeParams, GearboxSDK, GearboxSDKOptions, Liquidations, LiquidationsByMode, LiquidationsNamespace, type ListMerger, LpParams, LpRedeemParams, LpSimulate, type MergeListResult, MergedQuery, MissingSourceError, Mode, NamespaceOptions, NoSourceServedError, NoticesByMode, OffchainByMode, OffchainSource, OnchainByMode, OnchainSource, OpenPrepareRequest, OpenStrategyParams, OpenStrategySimulate, Opportunities, OpportunitiesBase, OpportunitiesByMode, OpportunitiesExecute,
|
|
33
|
+
export { AbstractNamespace, AccountPrepareRequest, AddCollateralParams, AdjustLeverageParams, AllSourcesFailedError, ChainOf, ChainRef, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, DelayedStrategySimulate, DepositStrategyParams, EnsureFreshChains, type EntityMerger, ExecuteApi, type FilterResult, FinalizeParams, GearboxSDK, GearboxSDKOptions, Liquidations, LiquidationsByMode, LiquidationsNamespace, type ListMerger, LpParams, LpRedeemParams, LpSimulate, type MergeListResult, MergedQuery, MissingSourceError, Mode, NamespaceOptions, NoSourceServedError, NoticesByMode, OffchainByMode, OffchainSource, OnchainByMode, OnchainSource, OpenPrepareRequest, OpenStrategyParams, OpenStrategySimulate, Opportunities, OpportunitiesBase, OpportunitiesByMode, OpportunitiesExecute, OpportunitiesNamespace, OpportunitiesOffchainBranch, OpportunitiesOffchainOnly, OpportunitiesOnchainBranch, OpportunitiesOnchainOnly, OpportunitiesPrepare, OpportunityMergers, PlainMultichainSDKOptions, PoolInput, PoolPrepareRequest, PositionInput, PositionMergers, Positions, PositionsBase, PositionsByMode, PositionsNamespace, PositionsOffchainBranch, PositionsOffchainOnly, PositionsOnchainBranch, PositionsOnchainOnly, PrepareApi, PrepareOptions, PrepareRequest, Preview, PreviewByMode, PreviewNamespace, RepayStrategyParams, SourceChainMismatchError, SourceUnavailableError, StrategyInput, StrategyRoutesSimulate, StrategySimulate, WithdrawCollateralParams, WithdrawStrategyParams, assertSameChains, everyChainFailed, filterResponse, mergeChainList, mergeChainOne };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Opportunities, OpportunitiesBase, OpportunitiesByMode,
|
|
1
|
+
import { Opportunities, OpportunitiesBase, OpportunitiesByMode, OpportunitiesOffchainBranch, OpportunitiesOffchainOnly, OpportunitiesOnchainBranch, OpportunitiesOnchainOnly, OpportunityMergers } from "./types.js";
|
|
2
2
|
import { OpportunitiesNamespace } from "./OpportunitiesNamespace.js";
|
|
3
|
-
export { Opportunities, OpportunitiesBase, OpportunitiesByMode,
|
|
3
|
+
export { Opportunities, OpportunitiesBase, OpportunitiesByMode, OpportunitiesNamespace, OpportunitiesOffchainBranch, OpportunitiesOffchainOnly, OpportunitiesOnchainBranch, OpportunitiesOnchainOnly, OpportunityMergers };
|
|
@@ -103,20 +103,13 @@ interface OpportunitiesOffchainBranch {
|
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
105
|
* Merge policy of each read, exposed so that a consumer reading the two
|
|
106
|
-
* branches itself combines them exactly as `both` mode would
|
|
107
|
-
* by the backend when it is fresh enough, and by the chain otherwise.
|
|
106
|
+
* branches itself combines them exactly as `both` mode would.
|
|
108
107
|
**/
|
|
109
108
|
interface OpportunityMergers {
|
|
110
109
|
list: ListMerger<Opportunity[]>;
|
|
111
110
|
pool: EntityMerger<PoolOpportunityDetail>;
|
|
112
111
|
strategy: EntityMerger<StrategyOpportunityDetail>;
|
|
113
112
|
}
|
|
114
|
-
/**
|
|
115
|
-
* Merging, which only exists where there are two sources to merge.
|
|
116
|
-
**/
|
|
117
|
-
interface OpportunitiesMerged {
|
|
118
|
-
readonly merge: OpportunityMergers;
|
|
119
|
-
}
|
|
120
113
|
/**
|
|
121
114
|
* Which methods the `opportunities` namespace has in each mode.
|
|
122
115
|
**/
|
|
@@ -130,4 +123,4 @@ interface OpportunitiesByMode {
|
|
|
130
123
|
**/
|
|
131
124
|
type Opportunities<M extends Mode = Mode> = OpportunitiesByMode[M];
|
|
132
125
|
//#endregion
|
|
133
|
-
export { Opportunities, OpportunitiesBase, OpportunitiesByMode,
|
|
126
|
+
export { Opportunities, OpportunitiesBase, OpportunitiesByMode, OpportunitiesOffchainBranch, OpportunitiesOffchainOnly, OpportunitiesOnchainBranch, OpportunitiesOnchainOnly, OpportunityMergers };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { PositionMergers, Positions, PositionsBase, PositionsByMode,
|
|
1
|
+
import { PositionMergers, Positions, PositionsBase, PositionsByMode, PositionsOffchainBranch, PositionsOffchainOnly, PositionsOnchainBranch, PositionsOnchainOnly } from "./types.js";
|
|
2
2
|
import { PositionsNamespace } from "./PositionsNamespace.js";
|
|
3
|
-
export { PositionMergers, Positions, PositionsBase, PositionsByMode,
|
|
3
|
+
export { PositionMergers, Positions, PositionsBase, PositionsByMode, PositionsNamespace, PositionsOffchainBranch, PositionsOffchainOnly, PositionsOnchainBranch, PositionsOnchainOnly };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Position } from "../../model/positions.js";
|
|
2
|
+
import { DataResponse } from "../../model/response.js";
|
|
3
|
+
import "../../model/index.js";
|
|
4
|
+
import { MergeListResult } from "../utils/types.js";
|
|
5
|
+
//#region src/new-sdk/positions/mergePositionList.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Merges two position lists under the same per-chain freshness rule as
|
|
8
|
+
* {@link mergeChainList}, then overlays the backend's `targetCollateral` and
|
|
9
|
+
* `name` onto every strategy row the backend has — even when that chain was
|
|
10
|
+
* served from on-chain data because the backend was stale.
|
|
11
|
+
*
|
|
12
|
+
* The backend records the collateral the strategy was opened into; the chain
|
|
13
|
+
* can only guess from current holdings. `name` is derived from that collateral,
|
|
14
|
+
* so it follows the same override.
|
|
15
|
+
**/
|
|
16
|
+
declare function mergePositionList<Onchain extends DataResponse<Position[]> | undefined, Offchain extends DataResponse<Position[]> | undefined>(onchain: Onchain, offchain: Offchain, maxLagSeconds?: number): MergeListResult<Onchain, Offchain, Position[]>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { mergePositionList };
|
|
@@ -78,18 +78,11 @@ interface PositionsOffchainBranch {
|
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* Merge policy of each read, exposed so that a consumer reading the two
|
|
81
|
-
* branches itself combines them exactly as `both` mode would
|
|
82
|
-
* by the backend when it is fresh enough, and by the chain otherwise.
|
|
81
|
+
* branches itself combines them exactly as `both` mode would.
|
|
83
82
|
**/
|
|
84
83
|
interface PositionMergers {
|
|
85
84
|
list: ListMerger<Position[]>;
|
|
86
85
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Merging, which only exists where there are two sources to merge.
|
|
89
|
-
**/
|
|
90
|
-
interface PositionsMerged {
|
|
91
|
-
readonly merge: PositionMergers;
|
|
92
|
-
}
|
|
93
86
|
/**
|
|
94
87
|
* Which methods the `positions` namespace has in each mode.
|
|
95
88
|
**/
|
|
@@ -103,4 +96,4 @@ interface PositionsByMode {
|
|
|
103
96
|
**/
|
|
104
97
|
type Positions<M extends Mode = Mode> = PositionsByMode[M];
|
|
105
98
|
//#endregion
|
|
106
|
-
export { PositionMergers, Positions, PositionsBase, PositionsByMode,
|
|
99
|
+
export { PositionMergers, Positions, PositionsBase, PositionsByMode, PositionsOffchainBranch, PositionsOffchainOnly, PositionsOnchainBranch, PositionsOnchainOnly };
|