@gearbox-protocol/sdk 16.0.0-next.20 → 16.0.0-next.21
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/offchain/opportunities/OffchainOpportunities.js +5 -6
- package/dist/cjs/offchain/opportunities/index.js +1 -0
- package/dist/cjs/offchain/opportunities/types.js +1 -0
- package/dist/cjs/offchain/positions/OffchainPositions.js +3 -3
- package/dist/cjs/offchain/positions/index.js +1 -0
- package/dist/cjs/offchain/positions/types.js +1 -0
- package/dist/cjs/onchain/opportunities/index.js +1 -0
- package/dist/cjs/onchain/opportunities/types.js +1 -0
- package/dist/cjs/sdk/execute/ExecuteApi.js +2 -2
- package/dist/cjs/sdk/execute/index.js +1 -0
- package/dist/cjs/sdk/execute/types.js +1 -0
- package/dist/cjs/sdk/liquidations/LiquidationsNamespace.js +5 -5
- package/dist/cjs/sdk/opportunities/OpportunitiesNamespace.js +9 -9
- package/dist/cjs/sdk/positions/PositionsNamespace.js +5 -5
- package/dist/cjs/sdk/prepare/PrepareApi.js +16 -16
- package/dist/cjs/sdk/preview/PreviewNamespace.js +2 -2
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/offchain/opportunities/OffchainOpportunities.js +5 -6
- package/dist/esm/offchain/opportunities/index.js +1 -0
- package/dist/esm/offchain/opportunities/types.js +1 -0
- package/dist/esm/offchain/positions/OffchainPositions.js +3 -3
- package/dist/esm/offchain/positions/index.js +1 -0
- package/dist/esm/offchain/positions/types.js +1 -0
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/onchain/base/TokensMeta.js +3 -3
- package/dist/esm/onchain/chain/detectNetwork.js +1 -1
- package/dist/esm/onchain/core/createAddressProvider.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/onchain/opportunities/index.js +1 -0
- package/dist/esm/onchain/opportunities/types.js +1 -0
- package/dist/esm/onchain/pools/PoolService.js +1 -1
- package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
- package/dist/esm/preview/trace/extractTransfers.js +1 -1
- package/dist/esm/sdk/execute/ExecuteApi.js +2 -2
- package/dist/esm/sdk/execute/index.js +1 -0
- package/dist/esm/sdk/execute/types.js +1 -0
- package/dist/esm/sdk/liquidations/LiquidationsNamespace.js +5 -5
- package/dist/esm/sdk/opportunities/OpportunitiesNamespace.js +9 -9
- package/dist/esm/sdk/positions/PositionsNamespace.js +5 -5
- package/dist/esm/sdk/prepare/PrepareApi.js +16 -16
- package/dist/esm/sdk/preview/PreviewNamespace.js +2 -2
- package/dist/types/offchain/index.d.ts +3 -1
- package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +8 -12
- package/dist/types/offchain/opportunities/index.d.ts +2 -1
- package/dist/types/offchain/opportunities/types.d.ts +36 -0
- package/dist/types/offchain/positions/OffchainPositions.d.ts +6 -9
- package/dist/types/offchain/positions/index.d.ts +2 -1
- package/dist/types/offchain/positions/types.d.ts +30 -0
- package/dist/types/onchain/index.d.ts +3 -2
- package/dist/types/onchain/opportunities/MultichainOpportunitiesService.d.ts +2 -1
- package/dist/types/onchain/opportunities/index.d.ts +2 -1
- package/dist/types/onchain/opportunities/types.d.ts +27 -0
- package/dist/types/onchain/positions/MultichainPositionsService.d.ts +2 -2
- package/dist/types/onchain/positions/index.d.ts +2 -2
- package/dist/types/onchain/positions/types.d.ts +12 -2
- package/dist/types/sdk/AbstractNamespace.d.ts +1 -1
- package/dist/types/sdk/GearboxSDK.d.ts +11 -11
- package/dist/types/sdk/execute/ExecuteApi.d.ts +5 -94
- package/dist/types/sdk/execute/index.d.ts +3 -2
- package/dist/types/sdk/execute/types.d.ts +96 -0
- package/dist/types/sdk/index.d.ts +12 -11
- package/dist/types/sdk/liquidations/LiquidationsNamespace.d.ts +7 -7
- package/dist/types/sdk/liquidations/index.d.ts +2 -2
- package/dist/types/sdk/liquidations/types.d.ts +5 -7
- package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +20 -20
- package/dist/types/sdk/opportunities/index.d.ts +2 -2
- package/dist/types/sdk/opportunities/types.d.ts +31 -40
- package/dist/types/sdk/positions/PositionsNamespace.d.ts +10 -10
- package/dist/types/sdk/positions/index.d.ts +2 -2
- package/dist/types/sdk/positions/types.d.ts +24 -33
- package/dist/types/sdk/prepare/PrepareApi.d.ts +18 -18
- package/dist/types/sdk/prepare/index.d.ts +2 -2
- package/dist/types/sdk/prepare/types.d.ts +8 -8
- package/dist/types/sdk/preview/PreviewNamespace.d.ts +4 -4
- package/dist/types/sdk/preview/index.d.ts +2 -2
- package/dist/types/sdk/preview/types.d.ts +5 -7
- package/dist/types/sdk/types.d.ts +65 -6
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
2
1
|
import { AP_MARKET_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR } from "../constants/address-provider.js";
|
|
3
2
|
import { isV310 } from "../constants/versions.js";
|
|
4
3
|
import "../constants/index.js";
|
|
5
4
|
import { hexEq } from "../utils/hex.js";
|
|
5
|
+
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
6
6
|
import { AddressProviderV310Contract } from "./AddressProviderV310Contract.js";
|
|
7
7
|
//#region src/onchain/core/createAddressProvider.ts
|
|
8
8
|
const OVERRIDE_ADDRESSES = { Mainnet: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { accountMigratorAbi } from "../../../../abi/AccountMigrator.js";
|
|
2
1
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
2
|
+
import { accountMigratorAbi } from "../../../../abi/AccountMigrator.js";
|
|
3
3
|
//#region src/onchain/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";
|
|
2
1
|
import { MissingSerializedParamsError } from "../../../base/errors.js";
|
|
3
2
|
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";
|
|
2
1
|
import { iCreditFacadeMulticallV310Abi, iCreditFacadeV310Abi } from "../../../abi/310/generated.js";
|
|
3
2
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
4
3
|
import "../../base/index.js";
|
|
4
|
+
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
5
5
|
//#region src/onchain/market/credit/CreditFacadeV310BaseContract.ts
|
|
6
6
|
const abi = [
|
|
7
7
|
...iCreditFacadeV310Abi,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
2
1
|
import { iPoolV310Abi } from "../../../abi/310/generated.js";
|
|
3
2
|
import { AddressMap } from "../../utils/AddressMap.js";
|
|
4
3
|
import { RAY } from "../../constants/math.js";
|
|
@@ -8,6 +7,7 @@ import "../../utils/index.js";
|
|
|
8
7
|
import { SdkRWADataNotLoadedError } from "../../core/errors.js";
|
|
9
8
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
10
9
|
import "../../base/index.js";
|
|
10
|
+
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
11
11
|
//#region src/onchain/market/pool/PoolV310Contract.ts
|
|
12
12
|
const abi = [...iPoolV310Abi, ...iPausableAbi];
|
|
13
13
|
var PoolV310Contract = class extends BaseContract {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { iethZapperAbi } from "../../../abi/iETHZapper.js";
|
|
2
1
|
import { ZapperContract } from "./ZapperContract.js";
|
|
2
|
+
import { iethZapperAbi } from "../../../abi/iETHZapper.js";
|
|
3
3
|
//#region src/onchain/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";
|
|
2
1
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
3
2
|
import "../../base/index.js";
|
|
3
|
+
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
4
4
|
import { UnsupportedZapperFunctionError } from "./errors.js";
|
|
5
5
|
//#region src/onchain/market/zapper/ZapperContract.ts
|
|
6
6
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
2
1
|
import { AddressSet } from "../utils/AddressSet.js";
|
|
2
|
+
import { ierc20Abi } from "../../abi/iERC20.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 { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
|
|
3
2
|
import { generateCastTraceCall } from "./cast.js";
|
|
3
|
+
import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.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";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { iZapperAbi } from "../../abi/iZapper.js";
|
|
2
1
|
import { iPoolV310Abi } from "../../abi/310/generated.js";
|
|
2
|
+
import { iZapperAbi } from "../../abi/iZapper.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";
|
|
2
1
|
import { iCreditFacadeV310Abi } from "../../abi/310/generated.js";
|
|
3
2
|
import { AddressMap } from "../../onchain/utils/AddressMap.js";
|
|
3
|
+
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
4
4
|
import "../../onchain/index.js";
|
|
5
5
|
import { UnexpectedFacadeEventOrderError } from "./errors.js";
|
|
6
6
|
import { getAddress, isAddressEqual, parseEventLogs } from "viem";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/sdk/execute/ExecuteApi.ts
|
|
2
2
|
/**
|
|
3
|
-
* {@inheritDoc
|
|
3
|
+
* {@inheritDoc IOpportunitiesExecute}
|
|
4
4
|
**/
|
|
5
5
|
var ExecuteApi = class {
|
|
6
6
|
#chainOf;
|
|
@@ -8,7 +8,7 @@ var ExecuteApi = class {
|
|
|
8
8
|
this.#chainOf = chainOf;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* {@inheritDoc
|
|
11
|
+
* {@inheritDoc IOpportunitiesExecute.buildTx}
|
|
12
12
|
**/
|
|
13
13
|
async buildTx(request) {
|
|
14
14
|
if (!request.sim.ok) throw new Error(`cannot build a transaction from a failed ${request.kind} simulation`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import { toChainIds } from "../../onchain/chain/chains.js";
|
|
|
2
2
|
import "../../onchain/index.js";
|
|
3
3
|
//#region src/sdk/liquidations/LiquidationsNamespace.ts
|
|
4
4
|
/**
|
|
5
|
-
* {@inheritDoc
|
|
5
|
+
* {@inheritDoc ILiquidations}
|
|
6
6
|
**/
|
|
7
7
|
var LiquidationsNamespace = class {
|
|
8
8
|
#onchain;
|
|
@@ -12,28 +12,28 @@ var LiquidationsNamespace = class {
|
|
|
12
12
|
this.#ensureFresh = options.ensureFresh;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* {@inheritDoc
|
|
15
|
+
* {@inheritDoc ILiquidations.getLiquidatableAccounts}
|
|
16
16
|
**/
|
|
17
17
|
async getLiquidatableAccounts(props) {
|
|
18
18
|
await this.#ensureFresh?.(props?.chainIds);
|
|
19
19
|
return this.#onchain.liquidations.getLiquidatableAccounts(props);
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* {@inheritDoc
|
|
22
|
+
* {@inheritDoc ILiquidations.getLiquidationDetails}
|
|
23
23
|
**/
|
|
24
24
|
async getLiquidationDetails(props) {
|
|
25
25
|
await this.#ensureFresh?.(toChainIds([props.network]));
|
|
26
26
|
return this.#onchain.liquidations.getLiquidationDetails(props);
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
* {@inheritDoc
|
|
29
|
+
* {@inheritDoc ILiquidations.buildLiquidationTx}
|
|
30
30
|
**/
|
|
31
31
|
async buildLiquidationTx(props) {
|
|
32
32
|
await this.#ensureFresh?.(toChainIds([props.network]));
|
|
33
33
|
return this.#onchain.liquidations.buildLiquidationTx(props);
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
* {@inheritDoc
|
|
36
|
+
* {@inheritDoc ILiquidations.getLiquidationPositions}
|
|
37
37
|
**/
|
|
38
38
|
async getLiquidationPositions(props) {
|
|
39
39
|
await this.#ensureFresh?.(props.chainIds);
|
|
@@ -13,11 +13,11 @@ import "../utils/index.js";
|
|
|
13
13
|
//#region src/sdk/opportunities/OpportunitiesNamespace.ts
|
|
14
14
|
/**
|
|
15
15
|
* The `opportunities` namespace of a {@link GearboxSDK}, see
|
|
16
|
-
* {@link
|
|
16
|
+
* {@link IOpportunitiesByMode} for what each mode offers.
|
|
17
17
|
**/
|
|
18
18
|
var OpportunitiesNamespace = class extends AbstractNamespace {
|
|
19
19
|
/**
|
|
20
|
-
* {@inheritDoc
|
|
20
|
+
* {@inheritDoc IOpportunitiesBase.merge}
|
|
21
21
|
**/
|
|
22
22
|
merge = {
|
|
23
23
|
list: (onchain, offchain) => mergeChainList(onchain, offchain, this.maxOffchainLagSeconds),
|
|
@@ -32,21 +32,21 @@ var OpportunitiesNamespace = class extends AbstractNamespace {
|
|
|
32
32
|
this.#execute = onchain && new ExecuteApi((chainId) => onchain.chain(chainId));
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
* {@inheritDoc
|
|
35
|
+
* {@inheritDoc IOpportunitiesOnchainOnly.prepare}
|
|
36
36
|
**/
|
|
37
37
|
get prepare() {
|
|
38
38
|
if (!this.#prepare) throw new SourceUnavailableError("Opportunities", "onchain");
|
|
39
39
|
return this.#prepare;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
* {@inheritDoc
|
|
42
|
+
* {@inheritDoc IOpportunitiesOnchainOnly.execute}
|
|
43
43
|
**/
|
|
44
44
|
get execute() {
|
|
45
45
|
if (!this.#execute) throw new SourceUnavailableError("Opportunities", "onchain");
|
|
46
46
|
return this.#execute;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
* {@inheritDoc
|
|
49
|
+
* {@inheritDoc IOpportunitiesBase.list}
|
|
50
50
|
**/
|
|
51
51
|
async list(filter) {
|
|
52
52
|
return this.merged("list opportunities", {
|
|
@@ -57,7 +57,7 @@ var OpportunitiesNamespace = class extends AbstractNamespace {
|
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
|
-
* {@inheritDoc
|
|
60
|
+
* {@inheritDoc IOpportunitiesBase.getPool}
|
|
61
61
|
**/
|
|
62
62
|
async getPool(key) {
|
|
63
63
|
return this.merged("get pool opportunity", {
|
|
@@ -68,7 +68,7 @@ var OpportunitiesNamespace = class extends AbstractNamespace {
|
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
|
-
* {@inheritDoc
|
|
71
|
+
* {@inheritDoc IOpportunitiesBase.getStrategy}
|
|
72
72
|
**/
|
|
73
73
|
async getStrategy(key) {
|
|
74
74
|
return this.merged("get strategy opportunity", {
|
|
@@ -79,13 +79,13 @@ var OpportunitiesNamespace = class extends AbstractNamespace {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
-
* {@inheritDoc
|
|
82
|
+
* {@inheritDoc IOpportunitiesBase.filter}
|
|
83
83
|
**/
|
|
84
84
|
filter(response, filter) {
|
|
85
85
|
return filterResponse(response, filter, matchesOpportunityFilter);
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
|
-
* {@inheritDoc
|
|
88
|
+
* {@inheritDoc IOpportunitiesOffchainOnly.totals}
|
|
89
89
|
**/
|
|
90
90
|
async totals() {
|
|
91
91
|
return this.offchain.getTotals();
|
|
@@ -7,18 +7,18 @@ import { mergePositionList } from "./mergePositionList.js";
|
|
|
7
7
|
//#region src/sdk/positions/PositionsNamespace.ts
|
|
8
8
|
/**
|
|
9
9
|
* The `positions` namespace of a {@link GearboxSDK}, see
|
|
10
|
-
* {@link
|
|
10
|
+
* {@link IPositionsByMode} for what each mode offers.
|
|
11
11
|
**/
|
|
12
12
|
var PositionsNamespace = class extends AbstractNamespace {
|
|
13
13
|
/**
|
|
14
|
-
* {@inheritDoc
|
|
14
|
+
* {@inheritDoc IPositionsBase.merge}
|
|
15
15
|
**/
|
|
16
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
|
}
|
|
20
20
|
/**
|
|
21
|
-
* {@inheritDoc
|
|
21
|
+
* {@inheritDoc IPositionsBase.list}
|
|
22
22
|
**/
|
|
23
23
|
async list(wallet, filter) {
|
|
24
24
|
return this.merged("list positions", {
|
|
@@ -35,13 +35,13 @@ var PositionsNamespace = class extends AbstractNamespace {
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
* {@inheritDoc
|
|
38
|
+
* {@inheritDoc IPositionsBase.filter}
|
|
39
39
|
**/
|
|
40
40
|
filter(response, filter) {
|
|
41
41
|
return filterResponse(response, filter, matchesPositionFilter);
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
* {@inheritDoc
|
|
44
|
+
* {@inheritDoc IPositionsOffchainOnly.totals}
|
|
45
45
|
**/
|
|
46
46
|
async totals(wallet) {
|
|
47
47
|
return this.offchain.getTotals(wallet);
|
|
@@ -7,7 +7,7 @@ import { CreditAccountOperationsService } from "../../onchain/accounts/intents/i
|
|
|
7
7
|
import "../../onchain/index.js";
|
|
8
8
|
//#region src/sdk/prepare/PrepareApi.ts
|
|
9
9
|
/**
|
|
10
|
-
* {@inheritDoc
|
|
10
|
+
* {@inheritDoc IOpportunitiesPrepare}
|
|
11
11
|
*
|
|
12
12
|
* Holds no state of its own: it owns the mapping from the public,
|
|
13
13
|
* read-model-shaped request to the engine's intent, and nothing else. All
|
|
@@ -30,7 +30,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
30
30
|
return super.queryChain(props);
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* {@inheritDoc
|
|
33
|
+
* {@inheritDoc IOpportunitiesPrepare.finalize}
|
|
34
34
|
**/
|
|
35
35
|
async finalize(position, params) {
|
|
36
36
|
return this.queryChain({
|
|
@@ -50,7 +50,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
* {@inheritDoc
|
|
53
|
+
* {@inheritDoc IOpportunitiesPrepare.deposit}
|
|
54
54
|
**/
|
|
55
55
|
deposit(pool, params) {
|
|
56
56
|
const chain = this.sdk.chain(pool.chainId);
|
|
@@ -79,7 +79,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
-
* {@inheritDoc
|
|
82
|
+
* {@inheritDoc IOpportunitiesPrepare.withdraw}
|
|
83
83
|
**/
|
|
84
84
|
withdraw(pool, params) {
|
|
85
85
|
const chain = this.sdk.chain(pool.chainId);
|
|
@@ -109,7 +109,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
|
-
* {@inheritDoc
|
|
112
|
+
* {@inheritDoc IOpportunitiesPrepare.redeem}
|
|
113
113
|
**/
|
|
114
114
|
redeem(pool, params) {
|
|
115
115
|
const chain = this.sdk.chain(pool.chainId);
|
|
@@ -139,7 +139,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
|
-
* {@inheritDoc
|
|
142
|
+
* {@inheritDoc IOpportunitiesPrepare.openNewStrategy}
|
|
143
143
|
**/
|
|
144
144
|
async openNewStrategy(strategy, params) {
|
|
145
145
|
return this.queryChain({
|
|
@@ -161,7 +161,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
163
|
/**
|
|
164
|
-
* {@inheritDoc
|
|
164
|
+
* {@inheritDoc IOpportunitiesPrepare.depositStrategy}
|
|
165
165
|
**/
|
|
166
166
|
async depositStrategy(position, params) {
|
|
167
167
|
return this.#startIntent(position, params, {
|
|
@@ -174,7 +174,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
174
174
|
});
|
|
175
175
|
}
|
|
176
176
|
/**
|
|
177
|
-
* {@inheritDoc
|
|
177
|
+
* {@inheritDoc IOpportunitiesPrepare.withdrawStrategy}
|
|
178
178
|
**/
|
|
179
179
|
async withdrawStrategy(position, params) {
|
|
180
180
|
return this.#startRoutes(position, params, {
|
|
@@ -186,7 +186,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
188
|
/**
|
|
189
|
-
* {@inheritDoc
|
|
189
|
+
* {@inheritDoc IOpportunitiesPrepare.maxWithdraw}
|
|
190
190
|
**/
|
|
191
191
|
async maxWithdraw(position) {
|
|
192
192
|
return this.queryChain({
|
|
@@ -198,7 +198,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
200
|
/**
|
|
201
|
-
* {@inheritDoc
|
|
201
|
+
* {@inheritDoc IOpportunitiesPrepare.repayStrategy}
|
|
202
202
|
**/
|
|
203
203
|
async repayStrategy(position, params) {
|
|
204
204
|
return this.#startIntent(position, params, {
|
|
@@ -209,7 +209,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
211
|
/**
|
|
212
|
-
* {@inheritDoc
|
|
212
|
+
* {@inheritDoc IOpportunitiesPrepare.maxRepay}
|
|
213
213
|
**/
|
|
214
214
|
async maxRepay(position) {
|
|
215
215
|
return this.queryChain({
|
|
@@ -221,7 +221,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
221
221
|
});
|
|
222
222
|
}
|
|
223
223
|
/**
|
|
224
|
-
* {@inheritDoc
|
|
224
|
+
* {@inheritDoc IOpportunitiesPrepare.adjustLeverage}
|
|
225
225
|
**/
|
|
226
226
|
async adjustLeverage(position, params) {
|
|
227
227
|
return this.#startRoutes(position, params, {
|
|
@@ -231,7 +231,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
231
231
|
});
|
|
232
232
|
}
|
|
233
233
|
/**
|
|
234
|
-
* {@inheritDoc
|
|
234
|
+
* {@inheritDoc IOpportunitiesPrepare.addCollateral}
|
|
235
235
|
**/
|
|
236
236
|
async addCollateral(position, params) {
|
|
237
237
|
return this.#startIntent(position, params, {
|
|
@@ -242,7 +242,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
244
|
/**
|
|
245
|
-
* {@inheritDoc
|
|
245
|
+
* {@inheritDoc IOpportunitiesPrepare.withdrawCollateral}
|
|
246
246
|
**/
|
|
247
247
|
async withdrawCollateral(position, params) {
|
|
248
248
|
return this.#startIntent(position, params, {
|
|
@@ -253,7 +253,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
253
253
|
});
|
|
254
254
|
}
|
|
255
255
|
/**
|
|
256
|
-
* {@inheritDoc
|
|
256
|
+
* {@inheritDoc IOpportunitiesPrepare.leverageBand}
|
|
257
257
|
**/
|
|
258
258
|
leverageBand(strategy, collateral, targetHF) {
|
|
259
259
|
const sdk = this.sdk.chain(strategy.chainId);
|
|
@@ -265,7 +265,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
265
265
|
});
|
|
266
266
|
}
|
|
267
267
|
/**
|
|
268
|
-
* {@inheritDoc
|
|
268
|
+
* {@inheritDoc IOpportunitiesPrepare.maxWithdrawCollateral}
|
|
269
269
|
**/
|
|
270
270
|
async maxWithdrawCollateral(position, token, targetHF) {
|
|
271
271
|
return this.queryChain({
|
|
@@ -2,7 +2,7 @@ import { previewOperation } from "../../preview/preview/previewOperation.js";
|
|
|
2
2
|
import "../../preview/index.js";
|
|
3
3
|
//#region src/sdk/preview/PreviewNamespace.ts
|
|
4
4
|
/**
|
|
5
|
-
* {@inheritDoc
|
|
5
|
+
* {@inheritDoc IPreview}
|
|
6
6
|
**/
|
|
7
7
|
var PreviewNamespace = class {
|
|
8
8
|
#onchain;
|
|
@@ -14,7 +14,7 @@ var PreviewNamespace = class {
|
|
|
14
14
|
this.#logger = options.logger?.child?.({ name: "Preview" }) ?? options.logger;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* {@inheritDoc
|
|
17
|
+
* {@inheritDoc IPreview.previewOperation}
|
|
18
18
|
**/
|
|
19
19
|
async previewOperation(input, options) {
|
|
20
20
|
await this.#ensureFresh?.([input.chainId]);
|
|
@@ -2,8 +2,10 @@ import { GearboxAPIOptions } from "./types.js";
|
|
|
2
2
|
import { AbstractOffchainNamespace, OffchainGetRequest, OffchainQuery } from "./AbstractOffchainNamespace.js";
|
|
3
3
|
import { OffchainNotices } from "./notices/OffchainNotices.js";
|
|
4
4
|
import "./notices/index.js";
|
|
5
|
+
import { IOffchainOpportunities, OpportunityChartMetricFor } from "./opportunities/types.js";
|
|
5
6
|
import { OffchainOpportunities } from "./opportunities/OffchainOpportunities.js";
|
|
6
7
|
import "./opportunities/index.js";
|
|
8
|
+
import { IOffchainPositions, PositionChartMetricFor } from "./positions/types.js";
|
|
7
9
|
import { OffchainPositions } from "./positions/OffchainPositions.js";
|
|
8
10
|
import "./positions/index.js";
|
|
9
11
|
import { GearboxAPI } from "./GearboxAPI.js";
|
|
@@ -18,4 +20,4 @@ import { backendMessage } from "./errors/backendMessage.js";
|
|
|
18
20
|
import { ErrorCause, errorCause } from "./errors/errorCause.js";
|
|
19
21
|
import { readResponseBody } from "./errors/readResponseBody.js";
|
|
20
22
|
import "./errors/index.js";
|
|
21
|
-
export { AbstractOffchainNamespace, ErrorCause, GearboxAPI, GearboxAPIOptions, OffchainGetRequest, OffchainInvalidJsonError, OffchainNotConfiguredError, OffchainNotImplementedError, OffchainNotices, OffchainOpportunities, OffchainPositions, OffchainQuery, OffchainRequestFailedError, OffchainStatusError, OffchainTransportError, OffchainTransportErrorParams, OffchainValidationError, backendMessage, errorCause, readResponseBody };
|
|
23
|
+
export { AbstractOffchainNamespace, ErrorCause, GearboxAPI, GearboxAPIOptions, IOffchainOpportunities, IOffchainPositions, OffchainGetRequest, OffchainInvalidJsonError, OffchainNotConfiguredError, OffchainNotImplementedError, OffchainNotices, OffchainOpportunities, OffchainPositions, OffchainQuery, OffchainRequestFailedError, OffchainStatusError, OffchainTransportError, OffchainTransportErrorParams, OffchainValidationError, OpportunityChartMetricFor, PositionChartMetricFor, backendMessage, errorCause, readResponseBody };
|
|
@@ -1,38 +1,34 @@
|
|
|
1
|
-
import { ChartBundle, ChartRange
|
|
1
|
+
import { ChartBundle, ChartRange } from "../../model/charts.js";
|
|
2
2
|
import { Opportunity, OpportunityFilter, OpportunityKey, OpportunityTotals, PoolOpportunityDetail, PoolOpportunityKey, StrategyOpportunityDetail, StrategyOpportunityKey } from "../../model/opportunities.js";
|
|
3
3
|
import { DataResponse } from "../../model/response.js";
|
|
4
4
|
import { GearboxAPIOptions } from "../types.js";
|
|
5
5
|
import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
|
|
6
|
+
import { IOffchainOpportunities, OpportunityChartMetricFor } from "./types.js";
|
|
6
7
|
//#region src/offchain/opportunities/OffchainOpportunities.d.ts
|
|
7
|
-
type OpportunityChartMetricFor<K extends OpportunityKey> = {
|
|
8
|
-
pool: PoolOpportunityChartMetric;
|
|
9
|
-
strategy: StrategyOpportunityChartMetric;
|
|
10
|
-
}[K["kind"]];
|
|
11
8
|
/**
|
|
12
9
|
* Backend counterpart of the `opportunities` namespace.
|
|
13
10
|
**/
|
|
14
|
-
declare class OffchainOpportunities extends AbstractOffchainNamespace {
|
|
11
|
+
declare class OffchainOpportunities extends AbstractOffchainNamespace implements IOffchainOpportunities {
|
|
15
12
|
#private;
|
|
16
13
|
constructor(options: GearboxAPIOptions);
|
|
17
14
|
/**
|
|
18
|
-
*
|
|
19
|
-
* by {@link OpportunityFilter}.
|
|
15
|
+
* {@inheritDoc IOffchainOpportunities.list}
|
|
20
16
|
**/
|
|
21
17
|
list(filter?: OpportunityFilter): Promise<DataResponse<Opportunity[]>>;
|
|
22
18
|
/**
|
|
23
|
-
*
|
|
19
|
+
* {@inheritDoc IOffchainOpportunities.getPool}
|
|
24
20
|
**/
|
|
25
21
|
getPool(key: PoolOpportunityKey): Promise<DataResponse<PoolOpportunityDetail>>;
|
|
26
22
|
/**
|
|
27
|
-
*
|
|
23
|
+
* {@inheritDoc IOffchainOpportunities.getStrategy}
|
|
28
24
|
**/
|
|
29
25
|
getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
|
|
30
26
|
/**
|
|
31
|
-
*
|
|
27
|
+
* {@inheritDoc IOffchainOpportunities.getTotals}
|
|
32
28
|
**/
|
|
33
29
|
getTotals(): Promise<DataResponse<OpportunityTotals>>;
|
|
34
30
|
/**
|
|
35
|
-
*
|
|
31
|
+
* {@inheritDoc IOffchainOpportunities.getCharts}
|
|
36
32
|
**/
|
|
37
33
|
getCharts<K extends OpportunityKey, const Metrics extends readonly OpportunityChartMetricFor<K>[]>(key: K, metrics: Metrics, range: ChartRange): Promise<DataResponse<ChartBundle<Metrics>>>;
|
|
38
34
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ChartBundle, ChartRange, PoolOpportunityChartMetric, StrategyOpportunityChartMetric } from "../../model/charts.js";
|
|
2
|
+
import { Opportunity, OpportunityFilter, OpportunityKey, OpportunityTotals, PoolOpportunityDetail, PoolOpportunityKey, StrategyOpportunityDetail, StrategyOpportunityKey } from "../../model/opportunities.js";
|
|
3
|
+
import { DataResponse } from "../../model/response.js";
|
|
4
|
+
//#region src/offchain/opportunities/types.d.ts
|
|
5
|
+
type OpportunityChartMetricFor<K extends OpportunityKey> = {
|
|
6
|
+
pool: PoolOpportunityChartMetric;
|
|
7
|
+
strategy: StrategyOpportunityChartMetric;
|
|
8
|
+
}[K["kind"]];
|
|
9
|
+
/**
|
|
10
|
+
* Backend counterpart of the `opportunities` namespace.
|
|
11
|
+
**/
|
|
12
|
+
interface IOffchainOpportunities {
|
|
13
|
+
/**
|
|
14
|
+
* Opportunities of the chains this client covers, optionally narrowed further
|
|
15
|
+
* by {@link OpportunityFilter}.
|
|
16
|
+
**/
|
|
17
|
+
list(filter?: OpportunityFilter): Promise<DataResponse<Opportunity[]>>;
|
|
18
|
+
/**
|
|
19
|
+
* Detailed view of one pool opportunity.
|
|
20
|
+
**/
|
|
21
|
+
getPool(key: PoolOpportunityKey): Promise<DataResponse<PoolOpportunityDetail>>;
|
|
22
|
+
/**
|
|
23
|
+
* Detailed view of one strategy opportunity.
|
|
24
|
+
**/
|
|
25
|
+
getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
|
|
26
|
+
/**
|
|
27
|
+
* Protocol-wide totals across every opportunity the backend serves.
|
|
28
|
+
**/
|
|
29
|
+
getTotals(): Promise<DataResponse<OpportunityTotals>>;
|
|
30
|
+
/**
|
|
31
|
+
* Charts of one opportunity: one series per metric, on a shared grid.
|
|
32
|
+
**/
|
|
33
|
+
getCharts<K extends OpportunityKey, const Metrics extends readonly OpportunityChartMetricFor<K>[]>(key: K, metrics: Metrics, range: ChartRange): Promise<DataResponse<ChartBundle<Metrics>>>;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { IOffchainOpportunities, OpportunityChartMetricFor };
|
|
@@ -1,31 +1,28 @@
|
|
|
1
|
-
import { ChartBundle, ChartRange
|
|
1
|
+
import { ChartBundle, ChartRange } from "../../model/charts.js";
|
|
2
2
|
import { Position, PositionKey, PositionsTotals } from "../../model/positions.js";
|
|
3
3
|
import { DataResponse } from "../../model/response.js";
|
|
4
4
|
import { ListPositionsPropsBase } from "../../onchain/positions/types.js";
|
|
5
5
|
import { GearboxAPIOptions } from "../types.js";
|
|
6
6
|
import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
|
|
7
|
+
import { IOffchainPositions, PositionChartMetricFor } from "./types.js";
|
|
7
8
|
import { Address } from "viem";
|
|
8
9
|
//#region src/offchain/positions/OffchainPositions.d.ts
|
|
9
|
-
type PositionChartMetricFor<K extends PositionKey> = {
|
|
10
|
-
pool: PoolPositionChartMetric;
|
|
11
|
-
strategy: StrategyPositionChartMetric;
|
|
12
|
-
}[K["kind"]];
|
|
13
10
|
/**
|
|
14
11
|
* Backend counterpart of the `positions` namespace.
|
|
15
12
|
**/
|
|
16
|
-
declare class OffchainPositions extends AbstractOffchainNamespace {
|
|
13
|
+
declare class OffchainPositions extends AbstractOffchainNamespace implements IOffchainPositions {
|
|
17
14
|
#private;
|
|
18
15
|
constructor(options: GearboxAPIOptions);
|
|
19
16
|
/**
|
|
20
|
-
*
|
|
17
|
+
* {@inheritDoc IOffchainPositions.list}
|
|
21
18
|
**/
|
|
22
19
|
list(props: ListPositionsPropsBase): Promise<DataResponse<Position[]>>;
|
|
23
20
|
/**
|
|
24
|
-
*
|
|
21
|
+
* {@inheritDoc IOffchainPositions.getTotals}
|
|
25
22
|
**/
|
|
26
23
|
getTotals(wallet: Address): Promise<DataResponse<PositionsTotals>>;
|
|
27
24
|
/**
|
|
28
|
-
*
|
|
25
|
+
* {@inheritDoc IOffchainPositions.getCharts}
|
|
29
26
|
**/
|
|
30
27
|
getCharts<K extends PositionKey, const Metrics extends readonly PositionChartMetricFor<K>[]>(key: K, metrics: Metrics, range: ChartRange): Promise<DataResponse<ChartBundle<Metrics>>>;
|
|
31
28
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ChartBundle, ChartRange, PoolPositionChartMetric, StrategyPositionChartMetric } from "../../model/charts.js";
|
|
2
|
+
import { Position, PositionKey, PositionsTotals } from "../../model/positions.js";
|
|
3
|
+
import { DataResponse } from "../../model/response.js";
|
|
4
|
+
import { ListPositionsPropsBase } from "../../onchain/positions/types.js";
|
|
5
|
+
import { Address } from "viem";
|
|
6
|
+
//#region src/offchain/positions/types.d.ts
|
|
7
|
+
type PositionChartMetricFor<K extends PositionKey> = {
|
|
8
|
+
pool: PoolPositionChartMetric;
|
|
9
|
+
strategy: StrategyPositionChartMetric;
|
|
10
|
+
}[K["kind"]];
|
|
11
|
+
/**
|
|
12
|
+
* Backend counterpart of the `positions` namespace.
|
|
13
|
+
**/
|
|
14
|
+
interface IOffchainPositions {
|
|
15
|
+
/**
|
|
16
|
+
* Everything a wallet holds, optionally narrowed by the filter on
|
|
17
|
+
* {@link ListPositionsPropsBase}.
|
|
18
|
+
**/
|
|
19
|
+
list(props: ListPositionsPropsBase): Promise<DataResponse<Position[]>>;
|
|
20
|
+
/**
|
|
21
|
+
* Aggregate over everything a wallet holds, see {@link PositionsTotals}.
|
|
22
|
+
**/
|
|
23
|
+
getTotals(wallet: Address): Promise<DataResponse<PositionsTotals>>;
|
|
24
|
+
/**
|
|
25
|
+
* Charts of one position: one series per metric, on a shared grid.
|
|
26
|
+
**/
|
|
27
|
+
getCharts<K extends PositionKey, const Metrics extends readonly PositionChartMetricFor<K>[]>(key: K, metrics: Metrics, range: ChartRange): Promise<DataResponse<ChartBundle<Metrics>>>;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { IOffchainPositions, PositionChartMetricFor };
|