@gearbox-protocol/sdk 16.0.0-next.44 → 16.0.0-next.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/model/index.js +1 -0
- package/dist/cjs/model/withdrawals.schema.js +7 -2
- package/dist/cjs/onchain/accounts/intents/index.js +38 -13
- package/dist/cjs/onchain/accounts/intents/tail.js +112 -5
- package/dist/cjs/onchain/market/adapters/contracts/BalancerV3RouterAdapterContract.js +33 -1
- package/dist/cjs/onchain/pools/PoolService.js +20 -4
- package/dist/cjs/onchain/positions/PositionsService.js +8 -2
- package/dist/cjs/sdk/prepare/PrepareApi.js +133 -82
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/model/index.js +2 -2
- package/dist/esm/model/withdrawals.schema.js +7 -3
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/onchain/accounts/intents/index.js +38 -13
- package/dist/esm/onchain/accounts/intents/tail.js +112 -5
- 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/core/createAddressProvider.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/BalancerV3RouterAdapterContract.js +33 -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/pools/PoolService.js +20 -4
- package/dist/esm/onchain/positions/PositionsService.js +8 -2
- 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/prepare/PrepareApi.js +133 -82
- package/dist/types/model/index.d.ts +3 -3
- package/dist/types/model/withdrawals.d.ts +24 -5
- package/dist/types/model/withdrawals.schema.d.ts +21 -1
- package/dist/types/onchain/accounts/index.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/index.d.ts +19 -11
- package/dist/types/onchain/accounts/intents/tail.d.ts +13 -3
- package/dist/types/onchain/accounts/intents/types.d.ts +74 -1
- package/dist/types/onchain/index.d.ts +3 -3
- package/dist/types/onchain/pools/PoolService.d.ts +10 -1
- package/dist/types/onchain/pools/index.d.ts +2 -2
- package/dist/types/onchain/pools/types.d.ts +40 -1
- package/dist/types/sdk/index.d.ts +3 -3
- package/dist/types/sdk/prepare/PrepareApi.d.ts +8 -7
- package/dist/types/sdk/prepare/index.d.ts +3 -3
- package/dist/types/sdk/prepare/types.d.ts +85 -28
- package/package.json +1 -1
package/dist/esm/model/index.js
CHANGED
|
@@ -22,5 +22,5 @@ import "./response.js";
|
|
|
22
22
|
import { chainFailedSchema, chainMetadataSchema, chainSucceededSchema, dataSourceSchema, responseMetadataSchema, responseSchema } from "./response.schema.js";
|
|
23
23
|
import { isSDKError, sdkErr, sdkOk } from "./result.js";
|
|
24
24
|
import "./withdrawals.js";
|
|
25
|
-
import { positionClaimableWithdrawalSchema, positionPendingWithdrawalSchema, positionWithdrawalsSchema } from "./withdrawals.schema.js";
|
|
26
|
-
export { CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ERROR_ADAPTER_CALL_OUTSIDE_BRACKET, ERROR_INVALID_TRANSACTION_VALUE, ERROR_MALFORMED_BRACKET, ERROR_NON_ADAPTER_CALL_IN_BRACKET, ERROR_UNPREVIEWABLE_ADAPTER_CALL, ERROR_UNPRICEABLE_TOKEN, ERROR_UNSUPPORTED_OUT_OF_BRACKET_CALL, FILTER_ALL, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, amountSchema, apyBreakdownSchema, asEstimated, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, curatorNameSchema, curatorSchema, dataSourceSchema, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, instantReceivedAssetSchema, isFilterSet, isSDKError, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, positionClaimableWithdrawalSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionPendingWithdrawalSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionWithdrawalsSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, sdkErr, sdkOk, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema };
|
|
25
|
+
import { positionClaimableWithdrawalSchema, positionPendingWithdrawalSchema, positionWithdrawalsSchema, withdrawalOutputAmountSchema } from "./withdrawals.schema.js";
|
|
26
|
+
export { CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ERROR_ADAPTER_CALL_OUTSIDE_BRACKET, ERROR_INVALID_TRANSACTION_VALUE, ERROR_MALFORMED_BRACKET, ERROR_NON_ADAPTER_CALL_IN_BRACKET, ERROR_UNPREVIEWABLE_ADAPTER_CALL, ERROR_UNPRICEABLE_TOKEN, ERROR_UNSUPPORTED_OUT_OF_BRACKET_CALL, FILTER_ALL, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, amountSchema, apyBreakdownSchema, asEstimated, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, curatorNameSchema, curatorSchema, dataSourceSchema, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, instantReceivedAssetSchema, isFilterSet, isSDKError, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, positionClaimableWithdrawalSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionPendingWithdrawalSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionWithdrawalsSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, sdkErr, sdkOk, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema, withdrawalOutputAmountSchema };
|
|
@@ -4,12 +4,16 @@ import { delayedIntentSchema } from "./delayed-intent.schema.js";
|
|
|
4
4
|
import { z } from "zod/v4";
|
|
5
5
|
//#region src/model/withdrawals.schema.ts
|
|
6
6
|
/**
|
|
7
|
+
* {@link WithdrawalOutputAmount}
|
|
8
|
+
**/
|
|
9
|
+
const withdrawalOutputAmountSchema = tokenAmountSchema.extend({ isDelayed: z.boolean() });
|
|
10
|
+
/**
|
|
7
11
|
* {@link PositionClaimableWithdrawal}
|
|
8
12
|
**/
|
|
9
13
|
const positionClaimableWithdrawalSchema = z.object({
|
|
10
14
|
sourceToken: tokenSchema,
|
|
11
15
|
withdrawalPhantomToken: tokenAmountSchema,
|
|
12
|
-
outputs: z.array(
|
|
16
|
+
outputs: z.array(withdrawalOutputAmountSchema),
|
|
13
17
|
claimCall: txCallSchema,
|
|
14
18
|
redeemer: ZodAddress().optional(),
|
|
15
19
|
intent: delayedIntentSchema.optional()
|
|
@@ -20,7 +24,7 @@ const positionClaimableWithdrawalSchema = z.object({
|
|
|
20
24
|
const positionPendingWithdrawalSchema = z.object({
|
|
21
25
|
sourceToken: tokenSchema,
|
|
22
26
|
withdrawalPhantomToken: tokenSchema,
|
|
23
|
-
expectedOutputs: z.array(
|
|
27
|
+
expectedOutputs: z.array(withdrawalOutputAmountSchema),
|
|
24
28
|
claimableAt: timestampSchema,
|
|
25
29
|
redeemer: ZodAddress().optional(),
|
|
26
30
|
intent: delayedIntentSchema.optional()
|
|
@@ -33,4 +37,4 @@ const positionWithdrawalsSchema = z.object({
|
|
|
33
37
|
pending: z.array(positionPendingWithdrawalSchema)
|
|
34
38
|
});
|
|
35
39
|
//#endregion
|
|
36
|
-
export { positionClaimableWithdrawalSchema, positionPendingWithdrawalSchema, positionWithdrawalsSchema };
|
|
40
|
+
export { positionClaimableWithdrawalSchema, positionPendingWithdrawalSchema, positionWithdrawalsSchema, withdrawalOutputAmountSchema };
|
|
@@ -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";
|
|
@@ -45,21 +45,27 @@ var CreditAccountOperationsService = class extends SDKConstruct {
|
|
|
45
45
|
}));
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
48
|
+
* Both ends of what a `WITHDRAW` can take out, in underlying: the largest
|
|
49
|
+
* partial withdrawal that keeps leverage and stays inside the facade's debt
|
|
50
|
+
* band, and the net value an exit hands over. They are reported together
|
|
51
|
+
* because a withdraw form needs both — the range it may offer, and the one
|
|
52
|
+
* amount past it that is allowed — and because the distance between them is
|
|
53
|
+
* the account's own, not a constant a caller could assume.
|
|
52
54
|
*
|
|
53
55
|
* Takes no target health factor, unlike {@link maxWithdrawCollateral}: a
|
|
54
56
|
* proportional withdrawal leaves the factor where it found it, and the
|
|
55
57
|
* facade's `minDebt` is what bounds it.
|
|
56
58
|
*
|
|
57
59
|
* @param props - Account slice and the SDK holding its market
|
|
58
|
-
* @returns
|
|
60
|
+
* @returns The two ceilings, see {@link WithdrawCeilings} for the gap between
|
|
61
|
+
* them
|
|
59
62
|
*/
|
|
60
63
|
maxWithdraw(props) {
|
|
61
64
|
const view = accountView(props.creditAccount, props.sdk);
|
|
62
|
-
return
|
|
65
|
+
return {
|
|
66
|
+
partial: maxProportionalWithdrawal(view, view.band),
|
|
67
|
+
exit: view.collateral > 0n ? view.collateral : 0n
|
|
68
|
+
};
|
|
63
69
|
}
|
|
64
70
|
/**
|
|
65
71
|
* Debt a `REPAY` would have to cover to settle the account, in underlying
|
|
@@ -229,17 +235,36 @@ var CreditAccountOperationsService = class extends SDKConstruct {
|
|
|
229
235
|
* whole tail: the tokens land on the account and only their quota has to
|
|
230
236
|
* catch up.
|
|
231
237
|
*
|
|
238
|
+
* A claim that brought only part of what the request queued — a legacy Mellow
|
|
239
|
+
* multivault, which pays out what it holds liquid and re-queues the rest — is
|
|
240
|
+
* served in proportion, and what it did not settle comes back as `remainder`:
|
|
241
|
+
* the withdrawal still in flight and the intent to finish it with.
|
|
242
|
+
*
|
|
232
243
|
* @param props - The recorded intent, the account slice as it stands now, and
|
|
233
244
|
* the matured claimable
|
|
234
|
-
* @returns Shaped exactly like {@link startIntent}'s result
|
|
235
|
-
* an operation are consumed the same way
|
|
245
|
+
* @returns Shaped exactly like {@link startIntent}'s result with the remainder
|
|
246
|
+
* beside it, so both halves of an operation are consumed the same way
|
|
236
247
|
*/
|
|
237
248
|
async finishIntent(props) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
249
|
+
let remainder;
|
|
250
|
+
const result = await this.#preview(props, () => {
|
|
251
|
+
const tail = planTail({
|
|
252
|
+
intent: props.intent,
|
|
253
|
+
claimable: props.claimable,
|
|
254
|
+
view: accountView(props.creditAccount, props.sdk)
|
|
255
|
+
});
|
|
256
|
+
remainder = tail.remainder;
|
|
257
|
+
return tail.steps;
|
|
258
|
+
});
|
|
259
|
+
if (!result.ok) return result;
|
|
260
|
+
const { operations, state, calls } = result;
|
|
261
|
+
return {
|
|
262
|
+
ok: true,
|
|
263
|
+
operations,
|
|
264
|
+
state,
|
|
265
|
+
calls,
|
|
266
|
+
remainder
|
|
267
|
+
};
|
|
243
268
|
}
|
|
244
269
|
/**
|
|
245
270
|
* Previews opening a brand-new leveraged position.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { IntentPreviewError } from "../../validation/refusal.js";
|
|
2
|
+
import { toTokenAmount } from "../../validation/token.js";
|
|
3
|
+
import { toTargetDecimals } from "./utils/common.js";
|
|
2
4
|
import { createOraclePaths } from "./utils/router-path.js";
|
|
3
5
|
import { planFinishClaimOnly, planFinishCloseAccount, planFinishDecreaseLeverage, planFinishWithdraw } from "./plan.js";
|
|
4
6
|
import { instantOutput } from "./operations.js";
|
|
@@ -12,6 +14,10 @@ import { accountView } from "./view.js";
|
|
|
12
14
|
* Shared by the two callers that need it and must not disagree — the tail as
|
|
13
15
|
* it is previewed days later against the account that really exists, and the
|
|
14
16
|
* tail as it is projected the moment the request is made.
|
|
17
|
+
*
|
|
18
|
+
* A claim that brought only part of what was queued is served in proportion,
|
|
19
|
+
* see {@link partialTail}: the intent's payout and its repayment are cut to the
|
|
20
|
+
* share that arrived, and the rest of both is handed to the next claim.
|
|
15
21
|
*/
|
|
16
22
|
function planTail(args) {
|
|
17
23
|
const { intent, claimable, view } = args;
|
|
@@ -20,17 +26,118 @@ function planTail(args) {
|
|
|
20
26
|
if (!output) throw new IntentPreviewError("insufficientSourceBalance", void 0, "finishIntent: the claim credits nothing to spend");
|
|
21
27
|
return output;
|
|
22
28
|
};
|
|
29
|
+
const queued = claimable.outputs.find((o) => o.isDelayed && o.amount > 0n);
|
|
30
|
+
if (queued) return partialTail({
|
|
31
|
+
intent,
|
|
32
|
+
claimable,
|
|
33
|
+
queued,
|
|
34
|
+
view
|
|
35
|
+
});
|
|
23
36
|
switch (intent.type) {
|
|
24
|
-
case "WITHDRAW_COLLATERAL": return planFinishWithdraw(intent, claimable, claimed(), view);
|
|
25
|
-
case "DECREASE_LEVERAGE": return planFinishDecreaseLeverage(claimable, claimed(), view);
|
|
26
|
-
case "CLOSE_ACCOUNT": return planFinishCloseAccount(intent, claimable, claimed(), view);
|
|
37
|
+
case "WITHDRAW_COLLATERAL": return whole(planFinishWithdraw(intent, claimable, claimed(), view));
|
|
38
|
+
case "DECREASE_LEVERAGE": return whole(planFinishDecreaseLeverage(claimable, claimed(), view));
|
|
39
|
+
case "CLOSE_ACCOUNT": return whole(planFinishCloseAccount(intent, claimable, claimed(), view));
|
|
27
40
|
case "ADD_COLLATERAL":
|
|
28
41
|
case "INCREASE_LEVERAGE":
|
|
29
42
|
case "DEPOSIT":
|
|
30
|
-
case "DEPOSIT_AND_INCREASE_LEVERAGE": return planFinishClaimOnly(claimable);
|
|
43
|
+
case "DEPOSIT_AND_INCREASE_LEVERAGE": return whole(planFinishClaimOnly(claimable));
|
|
31
44
|
default: throw new Error(`${intent.type} - not implemented`);
|
|
32
45
|
}
|
|
33
46
|
}
|
|
47
|
+
const whole = (steps) => ({
|
|
48
|
+
steps,
|
|
49
|
+
remainder: void 0
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* The tail of a claim that settled only part of the withdrawal it matured.
|
|
53
|
+
*
|
|
54
|
+
* Only a legacy Mellow multivault answers one this way — it pays out what its
|
|
55
|
+
* subvaults hold liquid and queues the rest — and the engine cannot finish an
|
|
56
|
+
* intent it has been given a fraction of the funds for. So the fraction is what
|
|
57
|
+
* it serves: the payout and the repayment are cut in the proportion that
|
|
58
|
+
* arrived, which keeps the withdrawal at the fixed leverage it was asked for
|
|
59
|
+
* instead of paying the wallet out first and deleveraging a claim later, and
|
|
60
|
+
* the untouched half of each is carried to the next claim by the remainder.
|
|
61
|
+
*
|
|
62
|
+
* Two intents cannot be served in part at all. An exit sells the account whole,
|
|
63
|
+
* and it cannot while a withdrawal is in flight — the phantom is neither
|
|
64
|
+
* sellable nor transferable — so a partial claim only repays what it brought
|
|
65
|
+
* and the account is emptied by the claim that brings the last of it. A claim
|
|
66
|
+
* that credited nothing at all leaves nothing to spend, so it is taken alone:
|
|
67
|
+
* it is still worth sending, since it is what moves the queue.
|
|
68
|
+
*/
|
|
69
|
+
function partialTail(args) {
|
|
70
|
+
const { intent, claimable, queued, view } = args;
|
|
71
|
+
const inFlight = toTokenAmount(view.sdk, queued.token, queued.amount);
|
|
72
|
+
const claimed = instantOutput(claimable.outputs);
|
|
73
|
+
if (!claimed) return {
|
|
74
|
+
steps: planFinishClaimOnly(claimable),
|
|
75
|
+
remainder: {
|
|
76
|
+
inFlight,
|
|
77
|
+
intent
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
switch (intent.type) {
|
|
81
|
+
case "WITHDRAW_COLLATERAL": {
|
|
82
|
+
const served = arrivedShare(claimed, queued, view.sdk);
|
|
83
|
+
const withdrawAmount = part(intent.withdrawAmount, served);
|
|
84
|
+
const debtRepaid = part(intent.debtRepaid, served);
|
|
85
|
+
return {
|
|
86
|
+
steps: planFinishWithdraw({
|
|
87
|
+
...intent,
|
|
88
|
+
withdrawAmount,
|
|
89
|
+
debtRepaid
|
|
90
|
+
}, claimable, claimed, view),
|
|
91
|
+
remainder: {
|
|
92
|
+
inFlight,
|
|
93
|
+
intent: {
|
|
94
|
+
...intent,
|
|
95
|
+
withdrawAmount: intent.withdrawAmount - withdrawAmount,
|
|
96
|
+
debtRepaid: intent.debtRepaid - debtRepaid
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
case "DECREASE_LEVERAGE":
|
|
102
|
+
case "CLOSE_ACCOUNT": return {
|
|
103
|
+
steps: planFinishDecreaseLeverage(claimable, claimed, view),
|
|
104
|
+
remainder: {
|
|
105
|
+
inFlight,
|
|
106
|
+
intent
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
case "ADD_COLLATERAL":
|
|
110
|
+
case "INCREASE_LEVERAGE":
|
|
111
|
+
case "DEPOSIT":
|
|
112
|
+
case "DEPOSIT_AND_INCREASE_LEVERAGE": return {
|
|
113
|
+
steps: planFinishClaimOnly(claimable),
|
|
114
|
+
remainder: {
|
|
115
|
+
inFlight,
|
|
116
|
+
intent
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
default: throw new Error(`${intent.type} - not implemented`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* How much of the redemption this claim was: what it credited, over that plus
|
|
124
|
+
* what it left queued.
|
|
125
|
+
*
|
|
126
|
+
* The phantom stands for its payout one for one — the same reading the request
|
|
127
|
+
* side takes when it names the claim it expects — so only the decimals of the
|
|
128
|
+
* two have to be reconciled before they can be added up.
|
|
129
|
+
*/
|
|
130
|
+
function arrivedShare(claimed, queued, sdk) {
|
|
131
|
+
const rest = toTargetDecimals(queued.amount, queued.token, claimed.token, sdk);
|
|
132
|
+
return {
|
|
133
|
+
got: claimed.amount,
|
|
134
|
+
of: claimed.amount + rest
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/** A share of an amount, rounded down: a tail never promises more than it has. */
|
|
138
|
+
function part(amount, share) {
|
|
139
|
+
return share.of > 0n ? amount * share.got / share.of : 0n;
|
|
140
|
+
}
|
|
34
141
|
/**
|
|
35
142
|
* Where a delayed intent ends up, worked out at the moment it is started.
|
|
36
143
|
*
|
|
@@ -55,7 +162,7 @@ async function projectTail(args) {
|
|
|
55
162
|
const queued = request.outputs.find((o) => o.isDelayed);
|
|
56
163
|
if (!queued || !claim) throw new IntentPreviewError("noRecordedIntent", void 0, "projectTail: the request queued nothing to claim");
|
|
57
164
|
const next = sliceAfter(creditAccount, delayed.afterRequest);
|
|
58
|
-
const steps = planTail({
|
|
165
|
+
const { steps } = planTail({
|
|
59
166
|
intent: delayed.record,
|
|
60
167
|
claimable: projectedClaimable(request, queued.token, queued.amount, claim),
|
|
61
168
|
view: accountView(next, sdk)
|
|
@@ -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
|
import { skipLiquidatableAccount } from "./skipLiquidatableAccount.js";
|
|
24
24
|
//#region src/onchain/accounts/liquidations/LiquidationsService.ts
|
|
25
25
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
1
2
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
2
3
|
import "../../base/index.js";
|
|
3
4
|
import { sdkErr, sdkOk } from "../../../model/result.js";
|
|
4
5
|
import "../../../model/index.js";
|
|
5
6
|
import { decodeDelayedIntent } from "./intent-codec.js";
|
|
6
|
-
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
7
7
|
//#region src/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.ts
|
|
8
8
|
const abi = iRedemptionLoggerV310Abi;
|
|
9
9
|
/**
|
|
@@ -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/onchain/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/onchain/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/onchain/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 { SdkRWADataNotLoadedError } from "../core/errors.js";
|
|
11
11
|
import { executeMulticallBatches } from "../utils/viem/executeMulticallBatches.js";
|
|
12
12
|
//#region src/onchain/base/TokensMeta.ts
|
|
@@ -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/onchain/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/onchain/market/adapters/contracts/AccountMigratorAdapterContract.ts
|
|
4
4
|
const abi = accountMigratorAbi;
|
|
5
5
|
const protocolAbi = accountMigratorAbi;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { AddressMap } from "../../../utils/AddressMap.js";
|
|
2
|
+
import "../../../utils/index.js";
|
|
1
3
|
import { MissingSerializedParamsError } from "../../../base/errors.js";
|
|
2
4
|
import "../../../base/index.js";
|
|
3
5
|
import { iBalancerV3RouterAdapterAbi } from "../abi/adapters/iBalancerV3RouterAdapter.js";
|
|
@@ -6,6 +8,30 @@ import { iBalancerV3RouterAbi } from "../abi/targetContractAbi.js";
|
|
|
6
8
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
7
9
|
import { decodeAbiParameters } from "viem";
|
|
8
10
|
//#region src/onchain/market/adapters/contracts/BalancerV3RouterAdapterContract.ts
|
|
11
|
+
const BALANCER_V3_POOL_TOKENS = {
|
|
12
|
+
Mainnet: new AddressMap([
|
|
13
|
+
["0x121edB0bADc036F5FC610D015EE14093C142313B", ["0x775F661b0bD1739349b9A2A3EF60be277c5d2D29", "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a"]],
|
|
14
|
+
["0x1ea5870f7C037930CE1d5d8d9317c670e89e13E3", ["0x0bfc9d54Fc184518A81162F8fB99c2eACa081202", "0xae78736Cd615f374D3085123A210448E74Fc6393"]],
|
|
15
|
+
["0x57c23c58B1D8C3292c15BEcF07c62C5c52457A42", ["0x0bfc9d54Fc184518A81162F8fB99c2eACa081202", "0xf1C9acDc66974dFB6dEcB12aA385b9cD01190E38"]],
|
|
16
|
+
["0x6b31a94029fd7840d780191B6D63Fa0D269bd883", ["0x2411802D8BEA09be0aF8fD8D08314a63e706b29C", "0x90551c1795392094FE6D29B758EcCD233cFAa260"]],
|
|
17
|
+
["0x85B2b559bC2D21104C4DEFdd6EFcA8A20343361D", [
|
|
18
|
+
"0x7Bc3485026Ac48b6cf9BaF0A377477Fff5703Af8",
|
|
19
|
+
"0xC71Ea051a5F82c67ADcF634c36FFE6334793D24C",
|
|
20
|
+
"0xD4fa2D31b7968E448877f69A96DE69f5de8cD23E"
|
|
21
|
+
]],
|
|
22
|
+
["0x9ED5175aeCB6653C1BDaa19793c16fd74fBeEB37", ["0x775F661b0bD1739349b9A2A3EF60be277c5d2D29", "0xD11c452fc99cF405034ee446803b6F6c1F6d5ED8"]],
|
|
23
|
+
["0xc4Ce391d82D164c166dF9c8336DDF84206b2F812", ["0x0FE906e030a44eF24CA8c7dC7B7c53A6C4F00ce9", "0x775F661b0bD1739349b9A2A3EF60be277c5d2D29"]]
|
|
24
|
+
]),
|
|
25
|
+
Plasma: new AddressMap([
|
|
26
|
+
["0x01E2C7fCde2B8D5d1413732c4e274Ba5B06B1E54", ["0x0A1a1A107E45b7Ced86833863f482BC5f4ed82EF", "0xE0126F0c4451B2B917064A93040fd4770D6774b5"]],
|
|
27
|
+
["0x694c009aa31B3F80EE18C218B02390ca2D7151e7", ["0x6eAf19b2FC24552925dB245F9Ff613157a7dbb4C", "0xE0126F0c4451B2B917064A93040fd4770D6774b5"]],
|
|
28
|
+
["0x6a74BE33B5393D8A3EbA4D69B78f9D9da947C48c", ["0xC63F1a8c0cD4493E18f6f3371182BE01Ce0BeF02", "0xE0126F0c4451B2B917064A93040fd4770D6774b5"]],
|
|
29
|
+
["0xB3Ca3ead1c59dEd552cD30a6992038284B418b65", ["0x0B2b2B2076d95dda7817e785989fE353fe955ef9", "0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb"]],
|
|
30
|
+
["0xD931775d9AcA9859c9fDc53C63ae32EF21551492", ["0x9c46EE1f01d2b551048F5fF99a4659D98d04BED1", "0xC8A8DF9B210243c55D31c73090F06787aD0A1Bf6"]],
|
|
31
|
+
["0xd9c4e277c93374a9f8C877a9D06707a88092E8F0", ["0x211Cc4DD073734dA055fbF44a2b4667d5E5fE5d2", "0xE0126F0c4451B2B917064A93040fd4770D6774b5"]],
|
|
32
|
+
["0xDE0cfD933D2036d99048a04acF5Bacfb45492377", ["0x76309A9a56309104518847BbA321c261B7B4a43f", "0xA29420057F3e3B9512D4786df135Da1674BD74D4"]]
|
|
33
|
+
])
|
|
34
|
+
};
|
|
9
35
|
let BalancerV3PoolStatus = /* @__PURE__ */ function(BalancerV3PoolStatus) {
|
|
10
36
|
BalancerV3PoolStatus[BalancerV3PoolStatus["NOT_ALLOWED"] = 0] = "NOT_ALLOWED";
|
|
11
37
|
BalancerV3PoolStatus[BalancerV3PoolStatus["ALLOWED"] = 1] = "ALLOWED";
|
|
@@ -98,7 +124,13 @@ var BalancerV3RouterAdapterContract = class extends AbstractAdapterContract {
|
|
|
98
124
|
this.setLeftover(balances, pool, leftoverAmount);
|
|
99
125
|
break;
|
|
100
126
|
}
|
|
101
|
-
case "addLiquidityUnbalancedDiff":
|
|
127
|
+
case "addLiquidityUnbalancedDiff": {
|
|
128
|
+
const [pool, leftoverAmounts] = decoded.args;
|
|
129
|
+
const tokens = BALANCER_V3_POOL_TOKENS[this.networkType]?.get(pool);
|
|
130
|
+
if (!tokens || tokens.length !== leftoverAmounts.length) throw new Error(`previewBalanceChanges cannot resolve pool tokens for addLiquidityUnbalancedDiff on ${this.contractType} adapter at ${this.address} (pool ${pool})`);
|
|
131
|
+
for (let i = 0; i < leftoverAmounts.length; i++) this.setLeftover(balances, tokens[i], leftoverAmounts[i]);
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
102
134
|
default: super.applyBalanceChanges(balances, decoded);
|
|
103
135
|
}
|
|
104
136
|
}
|
|
@@ -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/onchain/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";
|
|
@@ -7,7 +8,6 @@ import "../../utils/index.js";
|
|
|
7
8
|
import { SdkRWADataNotLoadedError } from "../../core/errors.js";
|
|
8
9
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
9
10
|
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 { ZapperContract } from "./ZapperContract.js";
|
|
2
1
|
import { iethZapperAbi } from "../../../abi/iETHZapper.js";
|
|
2
|
+
import { ZapperContract } from "./ZapperContract.js";
|
|
3
3
|
//#region src/onchain/market/zapper/IETHZapperContract.ts
|
|
4
4
|
const abi = iethZapperAbi;
|
|
5
5
|
var IETHZapperContract = class extends ZapperContract {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
1
2
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
2
3
|
import "../../base/index.js";
|
|
3
4
|
import { sdkErr, sdkOk } from "../../../model/result.js";
|
|
4
5
|
import "../../../model/index.js";
|
|
5
|
-
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
6
6
|
//#region src/onchain/market/zapper/ZapperContract.ts
|
|
7
7
|
/**
|
|
8
8
|
* Base contract for every Gearbox zapper. Specialized zappers (e.g.
|
|
@@ -29,6 +29,25 @@ function payoutCeiling(market) {
|
|
|
29
29
|
return market.priceOracle.toAmount(pool.underlying, pool.pool.availableLiquidity * LIQUIDITY_SAFETY_NUM / LIQUIDITY_SAFETY_DENOM);
|
|
30
30
|
}
|
|
31
31
|
var PoolService = class extends SDKConstruct {
|
|
32
|
+
/**
|
|
33
|
+
* {@inheritDoc IPoolsService.getShareBalance}
|
|
34
|
+
*/
|
|
35
|
+
async getShareBalance(props) {
|
|
36
|
+
return this.client.readContract({
|
|
37
|
+
address: this.sdk.marketRegister.findByPool(props.pool).pool.pool.address,
|
|
38
|
+
abi: ierc20Abi,
|
|
39
|
+
functionName: "balanceOf",
|
|
40
|
+
args: [props.wallet],
|
|
41
|
+
blockNumber: props.blockNumber
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* {@inheritDoc IPoolsService.sharesToUnderlying}
|
|
46
|
+
*/
|
|
47
|
+
sharesToUnderlying(pool, shares) {
|
|
48
|
+
const market = this.sdk.marketRegister.findByPool(pool);
|
|
49
|
+
return market.toUnderlyingAmount(shares * market.pool.pool.dieselRate / RAY);
|
|
50
|
+
}
|
|
32
51
|
/**
|
|
33
52
|
* {@inheritDoc IPoolsService.getDepositTokensIn}
|
|
34
53
|
*/
|
|
@@ -414,10 +433,7 @@ var PoolService = class extends SDKConstruct {
|
|
|
414
433
|
chainId: this.chainId,
|
|
415
434
|
pool: pool.address,
|
|
416
435
|
underlyingToken: market.underlyingToken,
|
|
417
|
-
netValue:
|
|
418
|
-
token: this.sdk.tokensMeta.mustGetToken(market.unwrappedUnderlying),
|
|
419
|
-
...market.priceOracle.toAmount(market.underlying, shares * pool.dieselRate / RAY)
|
|
420
|
-
},
|
|
436
|
+
netValue: this.sharesToUnderlying(pool.address, shares),
|
|
421
437
|
apy: { organicApy: rayToBps(pool.supplyRate) }
|
|
422
438
|
};
|
|
423
439
|
}
|
|
@@ -372,7 +372,10 @@ var PositionsService = class extends SDKConstruct {
|
|
|
372
372
|
return {
|
|
373
373
|
sourceToken: this.sdk.tokensMeta.mustGetToken(w.token),
|
|
374
374
|
withdrawalPhantomToken: priceOracle.toTokenAmount(w.withdrawalPhantomToken, w.withdrawalTokenSpent),
|
|
375
|
-
outputs: w.outputs.map((o) =>
|
|
375
|
+
outputs: w.outputs.map((o) => ({
|
|
376
|
+
...priceOracle.toTokenAmount(o.token, o.amount),
|
|
377
|
+
isDelayed: o.isDelayed
|
|
378
|
+
})),
|
|
376
379
|
claimCall: this.#claimTx(w.claimCalls, w.token),
|
|
377
380
|
redeemer: w.redeemer,
|
|
378
381
|
intent: w.intent
|
|
@@ -382,7 +385,10 @@ var PositionsService = class extends SDKConstruct {
|
|
|
382
385
|
return {
|
|
383
386
|
sourceToken: this.sdk.tokensMeta.mustGetToken(w.token),
|
|
384
387
|
withdrawalPhantomToken: this.sdk.tokensMeta.mustGetToken(w.withdrawalPhantomToken),
|
|
385
|
-
expectedOutputs: w.expectedOutputs.map((o) =>
|
|
388
|
+
expectedOutputs: w.expectedOutputs.map((o) => ({
|
|
389
|
+
...priceOracle.toTokenAmount(o.token, o.amount),
|
|
390
|
+
isDelayed: o.isDelayed
|
|
391
|
+
})),
|
|
386
392
|
claimableAt: Number(w.claimableAt),
|
|
387
393
|
redeemer: w.redeemer,
|
|
388
394
|
intent: w.intent
|
|
@@ -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";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { iZapperAbi } from "../../abi/iZapper.js";
|
|
1
2
|
import { iPoolV310Abi } from "../../abi/310/generated.js";
|
|
2
3
|
import { sdkErr, sdkOk } from "../../model/result.js";
|
|
3
4
|
import "../../model/index.js";
|
|
4
|
-
import { iZapperAbi } from "../../abi/iZapper.js";
|
|
5
5
|
import { asPreviewSimulationError } from "./errors.js";
|
|
6
6
|
//#region src/preview/simulate/simulatePoolOperation.ts
|
|
7
7
|
function previewRead(operation) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { iCreditFacadeV310Abi } from "../../abi/310/generated.js";
|
|
2
1
|
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
2
|
+
import { iCreditFacadeV310Abi } from "../../abi/310/generated.js";
|
|
3
3
|
import { AddressMap } from "../../onchain/utils/AddressMap.js";
|
|
4
4
|
import "../../onchain/index.js";
|
|
5
5
|
import { UnexpectedFacadeEventOrderError } from "./errors.js";
|