@gearbox-protocol/sdk 17.1.0-next.2 → 17.1.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/onchain/MultichainSDK.js +2 -27
- package/dist/cjs/onchain/OnchainSDK.js +5 -6
- package/dist/cjs/onchain/accounts/intents/borrow.js +47 -20
- package/dist/cjs/onchain/accounts/intents/guards.js +6 -4
- package/dist/cjs/onchain/accounts/intents/index.js +40 -9
- package/dist/cjs/onchain/accounts/intents/open-strategy.js +49 -17
- package/dist/cjs/onchain/accounts/intents/realize.js +55 -24
- package/dist/cjs/onchain/index.js +0 -5
- package/dist/cjs/onchain/market/credit/CreditSuite.js +6 -5
- package/dist/cjs/onchain/market/index.js +0 -5
- package/dist/cjs/onchain/market/pricefeeds/feeds/RedstonePriceFeed.js +1 -7
- package/dist/cjs/onchain/market/pricefeeds/index.js +0 -5
- package/dist/cjs/onchain/market/pricefeeds/updates/UpdatablePriceFeedRegistry.js +5 -5
- package/dist/cjs/onchain/market/pricefeeds/updates/index.js +0 -5
- package/dist/cjs/onchain/options.js +1 -7
- package/dist/cjs/permissionless/index.js +1 -5
- package/dist/cjs/permissionless/utils/index.js +1 -5
- package/dist/cjs/permissionless/utils/price-update/get-price-update-tx.js +5 -0
- package/dist/cjs/permissionless/utils/price-update/get-updatable-feeds.js +6 -4
- package/dist/cjs/permissionless/utils/price-update/index.js +1 -5
- package/dist/cjs/sdk/prepare/PrepareApi.js +83 -32
- package/dist/esm/onchain/MultichainSDK.js +2 -27
- package/dist/esm/onchain/OnchainSDK.js +5 -6
- package/dist/esm/onchain/accounts/intents/borrow.js +47 -20
- package/dist/esm/onchain/accounts/intents/guards.js +6 -4
- package/dist/esm/onchain/accounts/intents/index.js +40 -9
- package/dist/esm/onchain/accounts/intents/open-strategy.js +49 -17
- package/dist/esm/onchain/accounts/intents/realize.js +55 -24
- package/dist/esm/onchain/index.js +1 -3
- package/dist/esm/onchain/market/credit/CreditSuite.js +6 -5
- package/dist/esm/onchain/market/index.js +1 -3
- package/dist/esm/onchain/market/pricefeeds/feeds/RedstonePriceFeed.js +1 -7
- package/dist/esm/onchain/market/pricefeeds/index.js +1 -3
- package/dist/esm/onchain/market/pricefeeds/updates/UpdatablePriceFeedRegistry.js +5 -5
- package/dist/esm/onchain/market/pricefeeds/updates/index.js +1 -3
- package/dist/esm/onchain/options.js +1 -7
- package/dist/esm/permissionless/index.js +2 -3
- package/dist/esm/permissionless/utils/index.js +2 -3
- package/dist/esm/permissionless/utils/price-update/get-price-update-tx.js +5 -0
- package/dist/esm/permissionless/utils/price-update/get-updatable-feeds.js +6 -4
- package/dist/esm/permissionless/utils/price-update/index.js +2 -3
- package/dist/esm/sdk/prepare/PrepareApi.js +83 -32
- package/dist/types/onchain/MultichainSDK.d.ts +0 -10
- package/dist/types/onchain/OnchainSDK.d.ts +0 -10
- package/dist/types/onchain/accounts/index.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/borrow.d.ts +5 -0
- package/dist/types/onchain/accounts/intents/guards.d.ts +6 -4
- package/dist/types/onchain/accounts/intents/index.d.ts +4 -4
- package/dist/types/onchain/accounts/intents/open-strategy.d.ts +5 -0
- package/dist/types/onchain/accounts/intents/realize.d.ts +5 -0
- package/dist/types/onchain/accounts/intents/types.d.ts +49 -6
- package/dist/types/onchain/index.d.ts +4 -6
- package/dist/types/onchain/market/credit/CreditSuite.d.ts +10 -0
- package/dist/types/onchain/market/index.d.ts +3 -5
- package/dist/types/onchain/market/pricefeeds/feeds/RedstonePriceFeed.d.ts +1 -4
- package/dist/types/onchain/market/pricefeeds/index.d.ts +3 -5
- package/dist/types/onchain/market/pricefeeds/updates/UpdatablePriceFeedRegistry.d.ts +4 -4
- package/dist/types/onchain/market/pricefeeds/updates/index.d.ts +3 -5
- package/dist/types/onchain/market/pricefeeds/updates/types.d.ts +2 -16
- package/dist/types/onchain/options.d.ts +0 -7
- package/dist/types/permissionless/index.d.ts +2 -3
- package/dist/types/permissionless/utils/index.d.ts +2 -3
- package/dist/types/permissionless/utils/price-update/get-price-update-tx.d.ts +5 -0
- package/dist/types/permissionless/utils/price-update/get-updatable-feeds.d.ts +9 -3
- package/dist/types/permissionless/utils/price-update/index.d.ts +2 -3
- package/dist/types/sdk/index.d.ts +2 -2
- package/dist/types/sdk/prepare/PrepareApi.d.ts +16 -14
- package/dist/types/sdk/prepare/index.d.ts +2 -2
- package/dist/types/sdk/prepare/types.d.ts +21 -14
- package/package.json +1 -5
- package/dist/cjs/onchain/market/pricefeeds/updates/RedstoneUpdater.js +0 -193
- package/dist/cjs/onchain/market/pricefeeds/updates/fetchRedstonePayloads.js +0 -95
- package/dist/cjs/permissionless/utils/price-update/get-price-feeds.js +0 -60
- package/dist/esm/onchain/market/pricefeeds/updates/RedstoneUpdater.js +0 -191
- package/dist/esm/onchain/market/pricefeeds/updates/fetchRedstonePayloads.js +0 -94
- package/dist/esm/permissionless/utils/price-update/get-price-feeds.js +0 -57
- package/dist/types/onchain/market/pricefeeds/updates/RedstoneUpdater.d.ts +0 -37
- package/dist/types/onchain/market/pricefeeds/updates/fetchRedstonePayloads.d.ts +0 -62
- package/dist/types/permissionless/utils/price-update/get-price-feeds.d.ts +0 -22
|
@@ -16,6 +16,7 @@ var RedstonePriceFeedContract = class extends AbstractPriceFeedContract {
|
|
|
16
16
|
constructor(options, args) {
|
|
17
17
|
super(options, {
|
|
18
18
|
...args,
|
|
19
|
+
updatable: false,
|
|
19
20
|
name: "RedstonePriceFeed",
|
|
20
21
|
abi: redstonePriceFeedAbi
|
|
21
22
|
});
|
|
@@ -69,13 +70,6 @@ var RedstonePriceFeedContract = class extends AbstractPriceFeedContract {
|
|
|
69
70
|
lastPayloadTimestamp: this.lastPayloadTimestamp.toString()
|
|
70
71
|
};
|
|
71
72
|
}
|
|
72
|
-
createPriceUpdateTx(data) {
|
|
73
|
-
return this.createRawTx({
|
|
74
|
-
functionName: "updatePrice",
|
|
75
|
-
args: [data],
|
|
76
|
-
description: `updating redstone price for ${this.dataId} [${this.labelAddress(this.address)}]`
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
73
|
};
|
|
80
74
|
//#endregion
|
|
81
75
|
export { RedstonePriceFeedContract };
|
|
@@ -21,12 +21,10 @@ import { ZeroPriceFeedContract } from "./feeds/ZeroPriceFeed.js";
|
|
|
21
21
|
import "./feeds/index.js";
|
|
22
22
|
import { PriceFeedRegistry } from "./PriceFeedRegistry.js";
|
|
23
23
|
import "./types.js";
|
|
24
|
-
import { fetchRedstonePayloads } from "./updates/fetchRedstonePayloads.js";
|
|
25
24
|
import { getRawPriceUpdates } from "./updates/getRawPriceUpdates.js";
|
|
26
25
|
import { isUpdatablePriceFeed } from "./updates/isUpdatablePriceFeed.js";
|
|
27
26
|
import { PriceUpdatesCache } from "./updates/PriceUpdatesCache.js";
|
|
28
|
-
import { RedstoneOptions, RedstoneUpdater } from "./updates/RedstoneUpdater.js";
|
|
29
27
|
import { updatableDependencies } from "./updates/updatableDependencies.js";
|
|
30
28
|
import { UpdatablePriceFeedRegistry } from "./updates/UpdatablePriceFeedRegistry.js";
|
|
31
29
|
import "./updates/index.js";
|
|
32
|
-
export { AbstractLPPriceFeedContract, AbstractPriceFeedContract, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CompositePriceFeedContract, ConstantPriceFeedContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, MellowLRTPriceFeedContract, PartialPriceFeedInitError, PendleTWAPPTPriceFeed, PriceFeedRef, PriceFeedRegistry, PriceUpdatesCache, PythPriceFeed,
|
|
30
|
+
export { AbstractLPPriceFeedContract, AbstractPriceFeedContract, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CompositePriceFeedContract, ConstantPriceFeedContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, MellowLRTPriceFeedContract, PartialPriceFeedInitError, PendleTWAPPTPriceFeed, PriceFeedRef, PriceFeedRegistry, PriceUpdatesCache, PythPriceFeed, RedstonePriceFeedContract, UpdatablePriceFeedRegistry, WstETHPriceFeedContract, YearnPriceFeedContract, ZeroPriceFeedContract, getRawPriceUpdates, isLPPriceFeed, isUpdatablePriceFeed, updatableDependencies };
|
|
@@ -8,23 +8,22 @@ import { priceFeedCompressorAbi } from "../../../../abi/compressors/priceFeedCom
|
|
|
8
8
|
import { PriceFeedRegistry } from "../PriceFeedRegistry.js";
|
|
9
9
|
import { getRawPriceUpdates } from "./getRawPriceUpdates.js";
|
|
10
10
|
import { isUpdatablePriceFeed } from "./isUpdatablePriceFeed.js";
|
|
11
|
-
import { RedstoneUpdater } from "./RedstoneUpdater.js";
|
|
12
11
|
import { Hooks } from "../../../utils/internal/Hooks.js";
|
|
13
12
|
import "../../../utils/internal/index.js";
|
|
14
13
|
import { updatableDependencies } from "./updatableDependencies.js";
|
|
15
14
|
import { parseAbi } from "viem";
|
|
16
15
|
//#region src/onchain/market/pricefeeds/updates/UpdatablePriceFeedRegistry.ts
|
|
17
16
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* @deprecated Support for updatable price feeds is deprecated.
|
|
18
|
+
* {@link PriceFeedRegistry} that also orchestrates off-chain price updates.
|
|
20
19
|
**/
|
|
21
20
|
var UpdatablePriceFeedRegistry = class extends PriceFeedRegistry {
|
|
22
21
|
#hooks = new Hooks();
|
|
23
22
|
#updaters;
|
|
24
23
|
#latestUpdate;
|
|
25
|
-
constructor(sdk
|
|
24
|
+
constructor(sdk) {
|
|
26
25
|
super(sdk);
|
|
27
|
-
this.#updaters = [
|
|
26
|
+
this.#updaters = [];
|
|
28
27
|
}
|
|
29
28
|
/**
|
|
30
29
|
* @internal
|
|
@@ -121,6 +120,7 @@ var UpdatablePriceFeedRegistry = class extends PriceFeedRegistry {
|
|
|
121
120
|
* Discovered price feeds are not saved anywhere in PriceFeedRegistry, and can later be used to load price feed updates
|
|
122
121
|
*/
|
|
123
122
|
async getPartialUpdatablePriceFeeds(configurators) {
|
|
123
|
+
if (this.#updaters.length === 0) return [];
|
|
124
124
|
const [priceFeedCompressorAddress] = this.sdk.addressProvider.mustGetLatest(AP_PRICE_FEED_COMPRESSOR, VERSION_RANGE_310);
|
|
125
125
|
this.logger?.debug({ configurators }, `calling getUpdatablePriceFeeds in block ${this.sdk.currentBlock}`);
|
|
126
126
|
const result = await this.client.readContract({
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { fetchRedstonePayloads } from "./fetchRedstonePayloads.js";
|
|
2
1
|
import { getRawPriceUpdates } from "./getRawPriceUpdates.js";
|
|
3
2
|
import { isUpdatablePriceFeed } from "./isUpdatablePriceFeed.js";
|
|
4
3
|
import { PriceUpdatesCache } from "./PriceUpdatesCache.js";
|
|
5
|
-
import { RedstoneOptions, RedstoneUpdater } from "./RedstoneUpdater.js";
|
|
6
4
|
import { updatableDependencies } from "./updatableDependencies.js";
|
|
7
5
|
import { UpdatablePriceFeedRegistry } from "./UpdatablePriceFeedRegistry.js";
|
|
8
|
-
export { PriceUpdatesCache,
|
|
6
|
+
export { PriceUpdatesCache, UpdatablePriceFeedRegistry, getRawPriceUpdates, isUpdatablePriceFeed, updatableDependencies };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { ZodAddress } from "./utils/zod.js";
|
|
2
2
|
import "./utils/index.js";
|
|
3
|
-
import { RedstoneOptions } from "./market/pricefeeds/updates/RedstoneUpdater.js";
|
|
4
|
-
import "./market/pricefeeds/updates/index.js";
|
|
5
3
|
import { z } from "zod/v4";
|
|
6
4
|
//#region src/onchain/options.ts
|
|
7
5
|
/**
|
|
@@ -56,11 +54,7 @@ const attachOptionsSchema = z.object({
|
|
|
56
54
|
/**
|
|
57
55
|
* Pool addresses whose markets should be skipped.
|
|
58
56
|
**/
|
|
59
|
-
ignoreMarkets: z.array(ZodAddress()).optional()
|
|
60
|
-
/**
|
|
61
|
-
* Options for Redstone price-feed updates.
|
|
62
|
-
**/
|
|
63
|
-
redstone: RedstoneOptions.optional()
|
|
57
|
+
ignoreMarkets: z.array(ZodAddress()).optional()
|
|
64
58
|
});
|
|
65
59
|
//#endregion
|
|
66
60
|
export { attachOptionsSchema, onchainSDKOptionsSchema };
|
|
@@ -28,9 +28,8 @@ import { encodeFunctionParams } from "./utils/abi-encoder.js";
|
|
|
28
28
|
import { getBlockNumberByTimestamp } from "./utils/block-utils.js";
|
|
29
29
|
import { calculateChecksum, convertRawTxToSafeMultisigTx, getSafeBatch, getSafeBatches } from "./utils/governance/batch.js";
|
|
30
30
|
import { convertQueueBatchToExecuteTx } from "./utils/governance/timelock-txs.js";
|
|
31
|
-
import { getUpdatablePriceFeeds } from "./utils/price-update/get-updatable-feeds.js";
|
|
32
|
-
import { getCallTouchedPriceFeeds, getCallsTouchedPriceFeeds, getCallsTouchedUpdatablePriceFeeds } from "./utils/price-update/get-price-feeds.js";
|
|
33
31
|
import { getPriceUpdateTx } from "./utils/price-update/get-price-update-tx.js";
|
|
34
32
|
import { getPrices } from "./utils/price-update/get-prices.js";
|
|
33
|
+
import { getUpdatablePriceFeeds } from "./utils/price-update/get-updatable-feeds.js";
|
|
35
34
|
import "./utils/index.js";
|
|
36
|
-
export { AccessMode, AddressProviderContract, Addresses, ArchiveTransport, BYTECODE_REPOSITORY, BytecodeRepositoryContract, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, CrossChainMultisigContract, GovernorContract, INSTANCE_MANAGER, InstanceManagerContract, MAINNET_CCM_CONSTRUCTOR_PARAMS, MAINNET_DEPLOYMENT_BLOCK, MAINNET_DEPLOYMENT_CCM_SALT, MAINNET_DEPLOYMENT_IM_SALT, MARKET_CONFIGURATOR_FACTORY, MarketConfiguratorContract, MarketConfiguratorFactoryContract, PRICE_FEED_STORE, PUBLIC_CREATE2_FACTORY, PriceFeedStoreContract, RoutingManagerContract, TOKEN_COMPRESSOR, TimeLockContract, TokenCompressorContract, TreasurySplitterContract, WithdrawalCompressorContract, calculateChecksum, checkCreate2Deployment, checkCreate2DeploymentAddress, chunkedLogsTransport, convertPercent, convertQueueBatchToExecuteTx, convertRawTxToSafeMultisigTx, createCallData, createCreate2DeployRawTx, deepJsonParse, deployUsingPublicCreate2, encodeFunctionParams, formatBytecodeSize, formatBytecodeVersion, getBlockNumberByTimestamp,
|
|
35
|
+
export { AccessMode, AddressProviderContract, Addresses, ArchiveTransport, BYTECODE_REPOSITORY, BytecodeRepositoryContract, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, CrossChainMultisigContract, GovernorContract, INSTANCE_MANAGER, InstanceManagerContract, MAINNET_CCM_CONSTRUCTOR_PARAMS, MAINNET_DEPLOYMENT_BLOCK, MAINNET_DEPLOYMENT_CCM_SALT, MAINNET_DEPLOYMENT_IM_SALT, MARKET_CONFIGURATOR_FACTORY, MarketConfiguratorContract, MarketConfiguratorFactoryContract, PRICE_FEED_STORE, PUBLIC_CREATE2_FACTORY, PriceFeedStoreContract, RoutingManagerContract, TOKEN_COMPRESSOR, TimeLockContract, TokenCompressorContract, TreasurySplitterContract, WithdrawalCompressorContract, calculateChecksum, checkCreate2Deployment, checkCreate2DeploymentAddress, chunkedLogsTransport, convertPercent, convertQueueBatchToExecuteTx, convertRawTxToSafeMultisigTx, createCallData, createCreate2DeployRawTx, deepJsonParse, deployUsingPublicCreate2, encodeFunctionParams, formatBytecodeSize, formatBytecodeVersion, getBlockNumberByTimestamp, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, getPriceUpdateTx, getPrices, getSafeBatch, getSafeBatches, getUpdatablePriceFeeds, handleSalt, normalizeSignature, priceFeedSetupParams, shortenHash, significantTrunc };
|
|
@@ -7,9 +7,8 @@ import { getBlockNumberByTimestamp } from "./block-utils.js";
|
|
|
7
7
|
import { calculateChecksum, convertRawTxToSafeMultisigTx, getSafeBatch, getSafeBatches } from "./governance/batch.js";
|
|
8
8
|
import { convertQueueBatchToExecuteTx } from "./governance/timelock-txs.js";
|
|
9
9
|
import "./governance/index.js";
|
|
10
|
-
import { getUpdatablePriceFeeds } from "./price-update/get-updatable-feeds.js";
|
|
11
|
-
import { getCallTouchedPriceFeeds, getCallsTouchedPriceFeeds, getCallsTouchedUpdatablePriceFeeds } from "./price-update/get-price-feeds.js";
|
|
12
10
|
import { getPriceUpdateTx } from "./price-update/get-price-update-tx.js";
|
|
13
11
|
import { getPrices } from "./price-update/get-prices.js";
|
|
12
|
+
import { getUpdatablePriceFeeds } from "./price-update/get-updatable-feeds.js";
|
|
14
13
|
import "./price-update/index.js";
|
|
15
|
-
export { BYTECODE_REPOSITORY, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, INSTANCE_MANAGER, MARKET_CONFIGURATOR_FACTORY, PRICE_FEED_STORE, PUBLIC_CREATE2_FACTORY, TOKEN_COMPRESSOR, calculateChecksum, checkCreate2Deployment, checkCreate2DeploymentAddress, convertPercent, convertQueueBatchToExecuteTx, convertRawTxToSafeMultisigTx, createCreate2DeployRawTx, deepJsonParse, deployUsingPublicCreate2, encodeFunctionParams, formatBytecodeSize, formatBytecodeVersion, getBlockNumberByTimestamp,
|
|
14
|
+
export { BYTECODE_REPOSITORY, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, INSTANCE_MANAGER, MARKET_CONFIGURATOR_FACTORY, PRICE_FEED_STORE, PUBLIC_CREATE2_FACTORY, TOKEN_COMPRESSOR, calculateChecksum, checkCreate2Deployment, checkCreate2DeploymentAddress, convertPercent, convertQueueBatchToExecuteTx, convertRawTxToSafeMultisigTx, createCreate2DeployRawTx, deepJsonParse, deployUsingPublicCreate2, encodeFunctionParams, formatBytecodeSize, formatBytecodeVersion, getBlockNumberByTimestamp, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, getPriceUpdateTx, getPrices, getSafeBatch, getSafeBatches, getUpdatablePriceFeeds, handleSalt, normalizeSignature, shortenHash, significantTrunc };
|
|
@@ -7,6 +7,11 @@ import { PriceFeedStoreContract } from "../../bindings/price-feed-store.js";
|
|
|
7
7
|
import "../../bindings/index.js";
|
|
8
8
|
import { multicall3Abi } from "viem";
|
|
9
9
|
//#region src/permissionless/utils/price-update/get-price-update-tx.ts
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Support for updatable price feeds is deprecated.
|
|
12
|
+
* @param param0
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
10
15
|
async function getPriceUpdateTx({ client, priceFeeds, useMulticall3 = false, gasLimit }) {
|
|
11
16
|
const pfStore = new PriceFeedStoreContract("0x74A868AC479EE145029bB80827BB77F7B7c441cB", client);
|
|
12
17
|
const gearboxClient = client;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { bytes32ToString } from "../../../onchain/utils/bytes32ToString.js";
|
|
2
1
|
import { priceFeedCompressorAbi } from "../../../abi/compressors/priceFeedCompressor.js";
|
|
3
|
-
import { RedstonePriceFeedContract } from "../../../onchain/market/pricefeeds/feeds/RedstonePriceFeed.js";
|
|
4
|
-
import "../../../onchain/index.js";
|
|
5
2
|
import { getContract } from "viem";
|
|
6
3
|
//#region src/permissionless/utils/price-update/get-updatable-feeds.ts
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Support for updatable price feeds is deprecated.
|
|
6
|
+
* @param args
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
7
9
|
async function getUpdatablePriceFeeds(args) {
|
|
8
10
|
const { sdk, client, pfCompressor, priceFeeds } = args;
|
|
9
11
|
return (await getContract({
|
|
10
12
|
address: pfCompressor,
|
|
11
13
|
abi: priceFeedCompressorAbi,
|
|
12
14
|
client
|
|
13
|
-
}).read.loadPriceFeedTree([priceFeeds])).filter((data) =>
|
|
15
|
+
}).read.loadPriceFeedTree([priceFeeds])).filter((data) => data.updatable).map((data) => sdk.priceFeeds.create(data));
|
|
14
16
|
}
|
|
15
17
|
//#endregion
|
|
16
18
|
export { getUpdatablePriceFeeds };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { getUpdatablePriceFeeds } from "./get-updatable-feeds.js";
|
|
2
|
-
import { getCallTouchedPriceFeeds, getCallsTouchedPriceFeeds, getCallsTouchedUpdatablePriceFeeds } from "./get-price-feeds.js";
|
|
3
1
|
import { getPriceUpdateTx } from "./get-price-update-tx.js";
|
|
4
2
|
import { getPrices } from "./get-prices.js";
|
|
5
|
-
|
|
3
|
+
import { getUpdatablePriceFeeds } from "./get-updatable-feeds.js";
|
|
4
|
+
export { getPriceUpdateTx, getPrices, getUpdatablePriceFeeds };
|
|
@@ -50,48 +50,53 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
50
50
|
* {@inheritDoc IOpportunitiesPrepare.finalize}
|
|
51
51
|
**/
|
|
52
52
|
async finalize(position, params) {
|
|
53
|
+
const state = {};
|
|
53
54
|
try {
|
|
54
55
|
const sdk = await this.#chain(position.chainId);
|
|
55
56
|
const at = stateBlock(sdk);
|
|
56
57
|
const intent = resumable(params.intent ?? params.claimable.intent);
|
|
57
|
-
if (!intent) return
|
|
58
|
+
if (!intent) return refused(noRecordedIntent(), state);
|
|
58
59
|
const creditAccount = await slice$1(sdk, position.creditAccount);
|
|
59
|
-
if (!creditAccount) return
|
|
60
|
+
if (!creditAccount) return refused(creditAccountNotFound(position.creditAccount), state);
|
|
60
61
|
return finalized(await service(sdk).finishIntent({
|
|
61
62
|
intent,
|
|
62
63
|
claimable: toClaimableWithdrawal(params.claimable),
|
|
63
64
|
creditAccount,
|
|
64
65
|
sdk,
|
|
65
66
|
slippage: params.slippage,
|
|
66
|
-
quotaReserve: params.quotaReserve
|
|
67
|
+
quotaReserve: params.quotaReserve,
|
|
68
|
+
draft: state
|
|
67
69
|
}), at);
|
|
68
70
|
} catch (e) {
|
|
69
|
-
return
|
|
71
|
+
return refused(unexpectedFailure(e), state);
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
/**
|
|
73
75
|
* {@inheritDoc IOpportunitiesPrepare.deposit}
|
|
74
76
|
**/
|
|
75
77
|
async deposit(pool, params) {
|
|
78
|
+
const draft = {};
|
|
76
79
|
try {
|
|
77
80
|
const chain = await this.#chain(pool.chainId);
|
|
78
81
|
const { marketRegister, pools } = chain;
|
|
82
|
+
draft.curator = marketRegister.findByPool(pool.pool).curator;
|
|
79
83
|
const tokenIn = params.tokenIn ?? marketRegister.findByPool(pool.pool).pool.underlying;
|
|
80
84
|
const tokenOut = lpRoute(params.tokenOut, () => pools.getDepositTokensOut(pool.pool, tokenIn));
|
|
81
|
-
if (!tokenOut) return unroutable(chain, tokenIn, void 0);
|
|
85
|
+
if (!tokenOut) return unroutable(chain, tokenIn, void 0, draft);
|
|
82
86
|
const state = pools.simulateDeposit({
|
|
83
87
|
pool: pool.pool,
|
|
84
88
|
amount: params.amount,
|
|
85
89
|
tokenIn,
|
|
86
90
|
tokenOut
|
|
87
91
|
});
|
|
92
|
+
Object.assign(draft, state);
|
|
88
93
|
const [refusal] = checkPoolOperation({
|
|
89
94
|
sdk: chain,
|
|
90
95
|
pool: pool.pool,
|
|
91
96
|
isDeposit: true,
|
|
92
97
|
tokenOut: state.tokenOut
|
|
93
98
|
});
|
|
94
|
-
if (refusal) return
|
|
99
|
+
if (refusal) return refused(refusal, draft);
|
|
95
100
|
const call = pools.addLiquidity({
|
|
96
101
|
collateral: {
|
|
97
102
|
token: state.tokenIn.token.address,
|
|
@@ -101,7 +106,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
101
106
|
wallet: params.wallet,
|
|
102
107
|
meta: pools.getDepositMetadata(pool.pool, tokenIn, tokenOut)
|
|
103
108
|
});
|
|
104
|
-
if (!call) return unroutable(chain, tokenIn, tokenOut);
|
|
109
|
+
if (!call) return unroutable(chain, tokenIn, tokenOut, draft);
|
|
105
110
|
return sdkOk({
|
|
106
111
|
operations: [],
|
|
107
112
|
state: await lpState(chain, pool.pool, params.wallet, state, { mints: state.tokenOut.value }),
|
|
@@ -109,32 +114,35 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
109
114
|
...stateBlock(chain)
|
|
110
115
|
});
|
|
111
116
|
} catch (e) {
|
|
112
|
-
return
|
|
117
|
+
return refused(unexpectedFailure(e), draft);
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
120
|
/**
|
|
116
121
|
* {@inheritDoc IOpportunitiesPrepare.withdraw}
|
|
117
122
|
**/
|
|
118
123
|
async withdraw(pool, params) {
|
|
124
|
+
const draft = {};
|
|
119
125
|
try {
|
|
120
126
|
const chain = await this.#chain(pool.chainId);
|
|
121
127
|
const { pools } = chain;
|
|
128
|
+
draft.curator = chain.marketRegister.findByPool(pool.pool).curator;
|
|
122
129
|
const tokenIn = params.tokenIn ?? pool.pool;
|
|
123
130
|
const tokenOut = lpRoute(params.tokenOut, () => pools.getWithdrawalTokensOut(pool.pool, tokenIn));
|
|
124
|
-
if (!tokenOut) return unroutable(chain, tokenIn, void 0);
|
|
131
|
+
if (!tokenOut) return unroutable(chain, tokenIn, void 0, draft);
|
|
125
132
|
const state = pools.simulateWithdraw({
|
|
126
133
|
pool: pool.pool,
|
|
127
134
|
amount: params.amount,
|
|
128
135
|
tokenIn,
|
|
129
136
|
tokenOut
|
|
130
137
|
});
|
|
138
|
+
Object.assign(draft, state);
|
|
131
139
|
const [refusal] = checkPoolOperation({
|
|
132
140
|
sdk: chain,
|
|
133
141
|
pool: pool.pool,
|
|
134
142
|
isDeposit: false,
|
|
135
143
|
tokenOut: state.tokenOut
|
|
136
144
|
});
|
|
137
|
-
if (refusal) return
|
|
145
|
+
if (refusal) return refused(refusal, draft);
|
|
138
146
|
const { calls } = pools.removeLiquidity({
|
|
139
147
|
pool: pool.pool,
|
|
140
148
|
amount: params.amount,
|
|
@@ -150,32 +158,35 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
150
158
|
...stateBlock(chain)
|
|
151
159
|
});
|
|
152
160
|
} catch (e) {
|
|
153
|
-
return
|
|
161
|
+
return refused(unexpectedFailure(e), draft);
|
|
154
162
|
}
|
|
155
163
|
}
|
|
156
164
|
/**
|
|
157
165
|
* {@inheritDoc IOpportunitiesPrepare.redeem}
|
|
158
166
|
**/
|
|
159
167
|
async redeem(pool, params) {
|
|
168
|
+
const draft = {};
|
|
160
169
|
try {
|
|
161
170
|
const chain = await this.#chain(pool.chainId);
|
|
162
171
|
const { pools } = chain;
|
|
172
|
+
draft.curator = chain.marketRegister.findByPool(pool.pool).curator;
|
|
163
173
|
const tokenIn = params.tokenIn ?? pool.pool;
|
|
164
174
|
const tokenOut = lpRoute(params.tokenOut, () => pools.getWithdrawalTokensOut(pool.pool, tokenIn));
|
|
165
|
-
if (!tokenOut) return unroutable(chain, tokenIn, void 0);
|
|
175
|
+
if (!tokenOut) return unroutable(chain, tokenIn, void 0, draft);
|
|
166
176
|
const state = pools.simulateRedeem({
|
|
167
177
|
pool: pool.pool,
|
|
168
178
|
amount: params.amount,
|
|
169
179
|
tokenIn,
|
|
170
180
|
tokenOut
|
|
171
181
|
});
|
|
182
|
+
Object.assign(draft, state);
|
|
172
183
|
const [refusal] = checkPoolOperation({
|
|
173
184
|
sdk: chain,
|
|
174
185
|
pool: pool.pool,
|
|
175
186
|
isDeposit: false,
|
|
176
187
|
tokenOut: state.tokenOut
|
|
177
188
|
});
|
|
178
|
-
if (refusal) return
|
|
189
|
+
if (refusal) return refused(refusal, draft);
|
|
179
190
|
const { calls } = pools.removeLiquidity({
|
|
180
191
|
pool: pool.pool,
|
|
181
192
|
amount: params.amount,
|
|
@@ -191,7 +202,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
191
202
|
...stateBlock(chain)
|
|
192
203
|
});
|
|
193
204
|
} catch (e) {
|
|
194
|
-
return
|
|
205
|
+
return refused(unexpectedFailure(e), draft);
|
|
195
206
|
}
|
|
196
207
|
}
|
|
197
208
|
/**
|
|
@@ -214,13 +225,15 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
214
225
|
* {@inheritDoc IOpportunitiesPrepare.openNewStrategy}
|
|
215
226
|
**/
|
|
216
227
|
async openNewStrategy(strategy, params) {
|
|
228
|
+
const state = {};
|
|
217
229
|
try {
|
|
218
230
|
const sdk = await this.#chain(strategy.chainId);
|
|
219
231
|
const at = stateBlock(sdk);
|
|
232
|
+
Object.assign(state, marketOf(sdk, strategy.creditManager));
|
|
220
233
|
const targetToken = params.targetToken ?? sdk.marketRegister.findCreditManager(strategy.creditManager).strategyTargetCollateral;
|
|
221
|
-
if (!targetToken) return
|
|
234
|
+
if (!targetToken) return refused(noStrategyTargetCollateral(strategy.creditManager), state);
|
|
222
235
|
const reused = await reusable(sdk, strategy, params.creditAccount);
|
|
223
|
-
if (reused && "error" in reused) return reused;
|
|
236
|
+
if (reused && "error" in reused) return refused(reused.error, state);
|
|
224
237
|
const creditAccount = reused?.account;
|
|
225
238
|
return opened(await service(sdk).openStrategyIntent({
|
|
226
239
|
sdk,
|
|
@@ -231,21 +244,24 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
231
244
|
leftoverBalances: params.leftoverBalances,
|
|
232
245
|
slippage: params.slippage,
|
|
233
246
|
quotaReserve: params.quotaReserve,
|
|
234
|
-
creditAccount
|
|
247
|
+
creditAccount,
|
|
248
|
+
draft: state
|
|
235
249
|
}), at);
|
|
236
250
|
} catch (e) {
|
|
237
|
-
return
|
|
251
|
+
return refused(unexpectedFailure(e), state);
|
|
238
252
|
}
|
|
239
253
|
}
|
|
240
254
|
/**
|
|
241
255
|
* {@inheritDoc IOpportunitiesPrepare.borrow}
|
|
242
256
|
**/
|
|
243
257
|
async borrow(strategy, params) {
|
|
258
|
+
const state = {};
|
|
244
259
|
try {
|
|
245
260
|
const sdk = await this.#chain(strategy.chainId);
|
|
246
261
|
const at = stateBlock(sdk);
|
|
262
|
+
Object.assign(state, marketOf(sdk, strategy.creditManager));
|
|
247
263
|
const reused = await reusable(sdk, strategy, params.creditAccount);
|
|
248
|
-
if (reused && "error" in reused) return reused;
|
|
264
|
+
if (reused && "error" in reused) return refused(reused.error, state);
|
|
249
265
|
return borrowed(await service(sdk).borrowIntent({
|
|
250
266
|
sdk,
|
|
251
267
|
creditManager: strategy.creditManager,
|
|
@@ -255,10 +271,11 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
255
271
|
borrowAmount: params.borrowAmount,
|
|
256
272
|
slippage: params.slippage,
|
|
257
273
|
quotaReserve: params.quotaReserve,
|
|
258
|
-
creditAccount: reused?.account
|
|
274
|
+
creditAccount: reused?.account,
|
|
275
|
+
draft: state
|
|
259
276
|
}), at);
|
|
260
277
|
} catch (e) {
|
|
261
|
-
return
|
|
278
|
+
return refused(unexpectedFailure(e), state);
|
|
262
279
|
}
|
|
263
280
|
}
|
|
264
281
|
/**
|
|
@@ -418,20 +435,22 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
418
435
|
* ones, per the engine trace its signature spells out.
|
|
419
436
|
**/
|
|
420
437
|
async #startRoutes(position, options, intent) {
|
|
438
|
+
const state = {};
|
|
421
439
|
try {
|
|
422
440
|
const sdk = await this.#chain(position.chainId);
|
|
423
441
|
const at = stateBlock(sdk);
|
|
424
442
|
const creditAccount = await slice$1(sdk, position.creditAccount);
|
|
425
|
-
if (!creditAccount) return neitherRoute(creditAccountNotFound(position.creditAccount));
|
|
443
|
+
if (!creditAccount) return neitherRoute(creditAccountNotFound(position.creditAccount), state);
|
|
426
444
|
return routed(await service(sdk).intentRoutes({
|
|
427
445
|
intent,
|
|
428
446
|
creditAccount,
|
|
429
447
|
sdk,
|
|
430
448
|
slippage: options.slippage,
|
|
431
|
-
quotaReserve: options.quotaReserve
|
|
449
|
+
quotaReserve: options.quotaReserve,
|
|
450
|
+
draft: state
|
|
432
451
|
}), at);
|
|
433
452
|
} catch (e) {
|
|
434
|
-
return neitherRoute(unexpectedFailure(e));
|
|
453
|
+
return neitherRoute(unexpectedFailure(e), state);
|
|
435
454
|
}
|
|
436
455
|
}
|
|
437
456
|
/**
|
|
@@ -444,20 +463,22 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
444
463
|
* ones, per the engine trace its signature spells out.
|
|
445
464
|
**/
|
|
446
465
|
async #startIntent(position, options, intent) {
|
|
466
|
+
const state = {};
|
|
447
467
|
try {
|
|
448
468
|
const sdk = await this.#chain(position.chainId);
|
|
449
469
|
const at = stateBlock(sdk);
|
|
450
470
|
const creditAccount = await slice$1(sdk, position.creditAccount);
|
|
451
|
-
if (!creditAccount) return
|
|
471
|
+
if (!creditAccount) return refused(creditAccountNotFound(position.creditAccount), state);
|
|
452
472
|
return planned(await service(sdk).startIntent({
|
|
453
473
|
intent,
|
|
454
474
|
creditAccount,
|
|
455
475
|
sdk,
|
|
456
476
|
slippage: options.slippage,
|
|
457
|
-
quotaReserve: options.quotaReserve
|
|
477
|
+
quotaReserve: options.quotaReserve,
|
|
478
|
+
draft: state
|
|
458
479
|
}), at);
|
|
459
480
|
} catch (e) {
|
|
460
|
-
return
|
|
481
|
+
return refused(unexpectedFailure(e), state);
|
|
461
482
|
}
|
|
462
483
|
}
|
|
463
484
|
};
|
|
@@ -545,14 +566,44 @@ function methodError(result) {
|
|
|
545
566
|
return result;
|
|
546
567
|
}
|
|
547
568
|
/**
|
|
569
|
+
* An error the namespace decides on itself, carrying as much of the state as
|
|
570
|
+
* it can say — nothing at all where it stopped before there was a market to
|
|
571
|
+
* name, see {@link WithPartialState}.
|
|
572
|
+
*
|
|
573
|
+
* The engine attaches its own draft on the way out, so this is only for what
|
|
574
|
+
* is raised on this side of it: a chain that would not resolve, an account the
|
|
575
|
+
* markets do not hold, a pool pair with no route.
|
|
576
|
+
**/
|
|
577
|
+
function refused(error, state) {
|
|
578
|
+
return sdkErr({
|
|
579
|
+
...error,
|
|
580
|
+
state
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* The market fields of a request that names its credit manager, for what is
|
|
585
|
+
* turned down before the engine has been reached at all.
|
|
586
|
+
*
|
|
587
|
+
* Empty where the SDK holds no such manager, which is itself one of those
|
|
588
|
+
* answers.
|
|
589
|
+
**/
|
|
590
|
+
function marketOf(sdk, creditManager) {
|
|
591
|
+
try {
|
|
592
|
+
return sdk.marketRegister.findCreditManager(creditManager).creditOperationMarket();
|
|
593
|
+
} catch {
|
|
594
|
+
return {};
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
548
598
|
* A flow with two routes, stopped before either could be quoted: the error is
|
|
549
599
|
* the same one any other flow would report, with nothing to say about the
|
|
550
600
|
* routes because neither was reached.
|
|
551
601
|
**/
|
|
552
|
-
function neitherRoute(error) {
|
|
602
|
+
function neitherRoute(error, state) {
|
|
553
603
|
return sdkErr({
|
|
554
604
|
...error,
|
|
555
|
-
errors: {}
|
|
605
|
+
errors: {},
|
|
606
|
+
state
|
|
556
607
|
});
|
|
557
608
|
}
|
|
558
609
|
/**
|
|
@@ -671,11 +722,11 @@ async function lpState(sdk, pool, wallet, simulation, moved) {
|
|
|
671
722
|
* is the usual way of it; both are present where a pair exists but nothing of
|
|
672
723
|
* ours implements it.
|
|
673
724
|
**/
|
|
674
|
-
function unroutable(sdk, from, to) {
|
|
675
|
-
return
|
|
725
|
+
function unroutable(sdk, from, to, state) {
|
|
726
|
+
return refused(unsupportedTokenPair({
|
|
676
727
|
from: toToken(sdk, from),
|
|
677
728
|
to: to === void 0 ? void 0 : toToken(sdk, to)
|
|
678
|
-
}));
|
|
729
|
+
}), state);
|
|
679
730
|
}
|
|
680
731
|
/**
|
|
681
732
|
* Picks the route the operation takes out of `tokenIn`, as a value rather than
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { ILogger } from "./types/logger.js";
|
|
2
2
|
import { NetworkType } from "./chain/chains.js";
|
|
3
3
|
import { MultichainStateHuman } from "./types/state-human.js";
|
|
4
|
-
import { RedstoneOptions } from "./market/pricefeeds/updates/RedstoneUpdater.js";
|
|
5
|
-
import "./market/pricefeeds/updates/index.js";
|
|
6
4
|
import { PluginFactoriesMap, PluginsMap } from "./plugins/types.js";
|
|
7
5
|
import "./plugins/index.js";
|
|
8
6
|
import { MultichainOpportunitiesService } from "./opportunities/MultichainOpportunitiesService.js";
|
|
@@ -59,10 +57,6 @@ interface MultichainAttachOptions {
|
|
|
59
57
|
* Per-chain attach options.
|
|
60
58
|
**/
|
|
61
59
|
perChain?: Partial<Record<NetworkType, AttachOptions>>;
|
|
62
|
-
/**
|
|
63
|
-
* Options for Redstone price-feed updates (shared cache across chains).
|
|
64
|
-
**/
|
|
65
|
-
redstone?: RedstoneOptions;
|
|
66
60
|
}
|
|
67
61
|
/**
|
|
68
62
|
* Options for {@link MultichainSDK.hydrate}.
|
|
@@ -72,10 +66,6 @@ interface MultichainHydrateOptions {
|
|
|
72
66
|
* Per-chain hydrate options.
|
|
73
67
|
**/
|
|
74
68
|
perChain?: Partial<Record<NetworkType, HydrateOptions>>;
|
|
75
|
-
/**
|
|
76
|
-
* Options for Redstone price-feed updates (shared cache across chains).
|
|
77
|
-
**/
|
|
78
|
-
redstone?: RedstoneOptions;
|
|
79
69
|
/**
|
|
80
70
|
* When `true`, chains missing from the serialised state are silently skipped
|
|
81
71
|
* instead of throwing {@link SdkMissingChainStateError}.
|
|
@@ -6,9 +6,7 @@ import { VersionRange } from "./constants/versions.js";
|
|
|
6
6
|
import "./constants/index.js";
|
|
7
7
|
import { RWARegistry } from "./market/rwa/RWARegistry.js";
|
|
8
8
|
import { GearboxStateHuman } from "./types/state-human.js";
|
|
9
|
-
import { RedstoneOptions } from "./market/pricefeeds/updates/RedstoneUpdater.js";
|
|
10
9
|
import { UpdatablePriceFeedRegistry } from "./market/pricefeeds/updates/UpdatablePriceFeedRegistry.js";
|
|
11
|
-
import "./market/pricefeeds/updates/index.js";
|
|
12
10
|
import "./market/pricefeeds/index.js";
|
|
13
11
|
import { IRouterContract } from "./router/types.js";
|
|
14
12
|
import "./router/index.js";
|
|
@@ -128,10 +126,6 @@ interface AttachOptions {
|
|
|
128
126
|
* Pool addresses whose markets should be skipped.
|
|
129
127
|
**/
|
|
130
128
|
ignoreMarkets?: Address[];
|
|
131
|
-
/**
|
|
132
|
-
* Options for Redstone price-feed updates.
|
|
133
|
-
**/
|
|
134
|
-
redstone?: RedstoneOptions;
|
|
135
129
|
}
|
|
136
130
|
/**
|
|
137
131
|
* Options accepted by {@link OnchainSDK.hydrate}.
|
|
@@ -141,10 +135,6 @@ interface HydrateOptions {
|
|
|
141
135
|
* Pool addresses whose markets should be skipped.
|
|
142
136
|
**/
|
|
143
137
|
ignoreMarkets?: Address[];
|
|
144
|
-
/**
|
|
145
|
-
* Options for Redstone price-feed updates.
|
|
146
|
-
**/
|
|
147
|
-
redstone?: RedstoneOptions;
|
|
148
138
|
}
|
|
149
139
|
/**
|
|
150
140
|
* Options for {@link OnchainSDK.syncState}, controlling which block to
|
|
@@ -21,7 +21,7 @@ import "./bots/index.js";
|
|
|
21
21
|
import { CreditAccountsServiceV310 } from "./CreditAccountsServiceV310.js";
|
|
22
22
|
import { CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota } from "./quota-utils.js";
|
|
23
23
|
import { AccountCalculatorOperation } from "./intents/operations.js";
|
|
24
|
-
import { AddCollateralIntent, AdjustLeverageIntent, ClaimRemainder, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, ExecutionCost, FinishIntentProps, FinishIntentResult, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RepayStrategyIntent, ResumableIntent, RouteErrors, StartIntent, WithdrawAssetIntent, WithdrawCeilings, WithdrawStrategyIntent } from "./intents/types.js";
|
|
24
|
+
import { AddCollateralIntent, AdjustLeverageIntent, ClaimRemainder, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, ExecutionCost, FinishIntentProps, FinishIntentResult, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RefusedIntent, RepayStrategyIntent, ResumableIntent, RouteErrors, StartIntent, WithPartialState, WithdrawAssetIntent, WithdrawCeilings, WithdrawStrategyIntent } from "./intents/types.js";
|
|
25
25
|
import { BorrowProps, BorrowState } from "./intents/borrow.js";
|
|
26
26
|
import { LeverageBand } from "./intents/leverage-band.js";
|
|
27
27
|
import { OpenStrategyProps, OpenStrategyState } from "./intents/open-strategy.js";
|
|
@@ -33,4 +33,4 @@ import { BuildLiquidationTxProps, BuildLiquidationTxPropsBase, GetLiquidatableAc
|
|
|
33
33
|
import { LiquidationsService } from "./liquidations/LiquidationsService.js";
|
|
34
34
|
import { MultichainLiquidationsService } from "./liquidations/MultichainLiquidationsService.js";
|
|
35
35
|
import "./liquidations/index.js";
|
|
36
|
-
export { AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountToCheck, type AddCollateralIntent, type AdjustLeverageIntent, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BorrowPreviewResult, type BorrowProps, type BorrowState, BotStatusCall, BotsDirectResponse, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, ClaimFarmRewardsProps, type ClaimRemainder, ClaimableWithdrawal, CloseCreditAccountResult, ConnectedBotsCall, ConnectedBotsPerAccount, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountDataCall, CreditAccountFilter, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditManagerFilter, CreditManagerOperationResult, CurrentWithdrawals, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, EmptyAccountPreviewResult, EncodableCreditAccountOperation, type ExecutionCost, type FinishIntentProps, type FinishIntentResult, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, type LeverageBand, LiquidationsService, LoadRWALiquidatorsProps, MulticallWithFailure, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OpenCAProps, OpenStrategyPreviewResult, type OpenStrategyProps, type OpenStrategyState, type OperationState, PartiallyLiquidateProps, type PathLossRate, PendingWithdrawal, PeripheryCompressorV310Contract, PreviewDelayedWithdrawalProps, RWALiquidatorInfo, RedemptionLog, RedemptionLoggerV310Contract, type RepayStrategyIntent, RequestableWithdrawal, type ResumableIntent, Rewards, type RouteErrors, SetBotProps, SetBotResult, type StartIntent, type WithdrawAssetIntent, type WithdrawCeilings, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, fetchCreditAccountSlice, getWithdrawalCompressorAddress, iCreditAccountAbi, isPhantomToken, roundUpQuota, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
|
|
36
|
+
export { AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountToCheck, type AddCollateralIntent, type AdjustLeverageIntent, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BorrowPreviewResult, type BorrowProps, type BorrowState, BotStatusCall, BotsDirectResponse, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, ClaimFarmRewardsProps, type ClaimRemainder, ClaimableWithdrawal, CloseCreditAccountResult, ConnectedBotsCall, ConnectedBotsPerAccount, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountDataCall, CreditAccountFilter, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditManagerFilter, CreditManagerOperationResult, CurrentWithdrawals, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, EmptyAccountPreviewResult, EncodableCreditAccountOperation, type ExecutionCost, type FinishIntentProps, type FinishIntentResult, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, type LeverageBand, LiquidationsService, LoadRWALiquidatorsProps, MulticallWithFailure, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OpenCAProps, OpenStrategyPreviewResult, type OpenStrategyProps, type OpenStrategyState, type OperationState, PartiallyLiquidateProps, type PathLossRate, PendingWithdrawal, PeripheryCompressorV310Contract, PreviewDelayedWithdrawalProps, RWALiquidatorInfo, RedemptionLog, RedemptionLoggerV310Contract, type RefusedIntent, type RepayStrategyIntent, RequestableWithdrawal, type ResumableIntent, Rewards, type RouteErrors, SetBotProps, SetBotResult, type StartIntent, type WithPartialState, type WithdrawAssetIntent, type WithdrawCeilings, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, fetchCreditAccountSlice, getWithdrawalCompressorAddress, iCreditAccountAbi, isPhantomToken, roundUpQuota, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
|
|
@@ -45,6 +45,11 @@ interface BorrowProps {
|
|
|
45
45
|
* an account that already owes is what the `ADJUST_LEVERAGE` intent is for.
|
|
46
46
|
**/
|
|
47
47
|
creditAccount?: CreditAccountSlice;
|
|
48
|
+
/**
|
|
49
|
+
* Where the walk writes the state as it reaches it, see
|
|
50
|
+
* {@link StartIntentProps.draft}. Omitted by a walk nobody reports.
|
|
51
|
+
**/
|
|
52
|
+
draft?: Partial<BorrowState>;
|
|
48
53
|
}
|
|
49
54
|
/**
|
|
50
55
|
* Where a borrow leaves the wallet and the account it opens.
|
|
@@ -7,7 +7,8 @@ import { OnchainSDK } from "../../OnchainSDK.js";
|
|
|
7
7
|
import "../../index.js";
|
|
8
8
|
//#region src/onchain/accounts/intents/guards.d.ts
|
|
9
9
|
/**
|
|
10
|
-
* What the market itself refuses,
|
|
10
|
+
* What the market itself refuses, read from its loaded state rather than
|
|
11
|
+
* learned from a revert.
|
|
11
12
|
*
|
|
12
13
|
* The planners answer for the arithmetic of an intent and the ledger for the
|
|
13
14
|
* balances it moves, but neither can see that the facade is paused or that the
|
|
@@ -16,9 +17,10 @@ import "../../index.js";
|
|
|
16
17
|
* loaded market and reported as refusals instead.
|
|
17
18
|
*
|
|
18
19
|
* Every guard here refuses something the market decides rather than something
|
|
19
|
-
* the arithmetic cannot do,
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* the arithmetic cannot do, so where the account would have landed stays a
|
|
21
|
+
* question the walk can answer. The three that judge that end state — growth,
|
|
22
|
+
* quota limits, collateral — therefore run only once the projection exists,
|
|
23
|
+
* which is what lets them hand it back as `state` when they refuse.
|
|
22
24
|
*/
|
|
23
25
|
/**
|
|
24
26
|
* The facade takes no multicall while it is paused or past its expiration, so
|