@gearbox-protocol/sdk 14.12.0-next.22 → 14.12.0-next.24
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/abi/IWithdrawalCompressorV313.js +2 -1
- package/dist/cjs/abi/compressors/withdrawalCompressor.js +2 -1
- package/dist/cjs/plugins/adapters/contracts/AbstractAdapter.js +31 -9
- package/dist/cjs/plugins/adapters/contracts/AbstractCurveAdapter.js +8 -5
- package/dist/cjs/plugins/adapters/contracts/BalancerV3RouterAdapterContract.js +6 -4
- package/dist/cjs/plugins/adapters/contracts/BalancerV3WrapperAdapterContract.js +6 -4
- package/dist/cjs/plugins/adapters/contracts/CamelotV3AdapterContract.js +6 -9
- package/dist/cjs/plugins/adapters/contracts/ConvexV1BaseRewardPoolAdapterContract.js +7 -5
- package/dist/cjs/plugins/adapters/contracts/ConvexV1BoosterAdapterContract.js +6 -4
- package/dist/cjs/plugins/adapters/contracts/DaiUsdsAdapterContract.js +6 -4
- package/dist/cjs/plugins/adapters/contracts/ERC4626AdapterContract.js +13 -4
- package/dist/cjs/plugins/adapters/contracts/ERC4626ReferralAdapterContract.js +6 -4
- package/dist/cjs/plugins/adapters/contracts/FluidDexAdapterContract.js +8 -8
- package/dist/cjs/plugins/adapters/contracts/InfinifiGatewayAdapterContract.js +8 -5
- package/dist/cjs/plugins/adapters/contracts/KelpLRTDepositPoolAdapterContract.js +4 -3
- package/dist/cjs/plugins/adapters/contracts/LidoV1AdapterContract.js +4 -3
- package/dist/cjs/plugins/adapters/contracts/MellowClaimerAdapterContract.js +29 -0
- package/dist/cjs/plugins/adapters/contracts/MellowDVVAdapterContract.js +6 -4
- package/dist/cjs/plugins/adapters/contracts/MellowERC4626VaultAdapterContract.js +11 -4
- package/dist/cjs/plugins/adapters/contracts/MellowWrapperAdapterContract.js +4 -3
- package/dist/cjs/plugins/adapters/contracts/MidasGatewayAdapterContract.js +31 -4
- package/dist/cjs/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.js +4 -3
- package/dist/cjs/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.js +4 -3
- package/dist/cjs/plugins/adapters/contracts/PendleRouterAdapterContract.js +14 -16
- package/dist/cjs/plugins/adapters/contracts/SecuritizeOnRampAdapterContract.js +4 -3
- package/dist/cjs/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.js +14 -13
- package/dist/cjs/plugins/adapters/contracts/StakingRewardsAdapterContract.js +7 -5
- package/dist/cjs/plugins/adapters/contracts/TraderJoeRouterAdapterContract.js +4 -3
- package/dist/cjs/plugins/adapters/contracts/UniswapV2AdapterContract.js +4 -3
- package/dist/cjs/plugins/adapters/contracts/UniswapV3AdapterContract.js +6 -9
- package/dist/cjs/plugins/adapters/contracts/UniswapV4AdapterContract.js +8 -8
- package/dist/cjs/plugins/adapters/contracts/UpshiftVaultAdapterContract.js +6 -4
- package/dist/cjs/plugins/adapters/contracts/VelodromeV2AdapterContract.js +4 -3
- package/dist/cjs/plugins/adapters/contracts/WstETHV1AdapterContract.js +6 -4
- package/dist/cjs/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +1 -5
- package/dist/cjs/preview/preview/applyInnerOperations.js +83 -58
- package/dist/cjs/preview/preview/applyQuotaChanges.js +43 -0
- package/dist/cjs/preview/preview/errors.js +0 -16
- package/dist/cjs/preview/preview/index.js +2 -0
- package/dist/cjs/preview/preview/previewAdjustCreditAccount.js +19 -8
- package/dist/cjs/preview/preview/previewCloseOrRepayCreditAccount.js +18 -7
- package/dist/cjs/preview/preview/previewOpenCreditAccount.js +18 -6
- package/dist/cjs/preview/preview/types.js +30 -0
- package/dist/cjs/preview/preview/unwrapNativeCollateral.js +10 -4
- package/dist/cjs/sdk/OnchainSDK.js +3 -6
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +2 -4
- package/dist/cjs/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +14 -22
- package/dist/cjs/sdk/accounts/withdrawal-compressor/addresses.js +6 -18
- package/dist/cjs/sdk/accounts/withdrawal-compressor/createWithdrawalCompressor.js +3 -5
- package/dist/esm/abi/IWithdrawalCompressorV313.js +2 -1
- package/dist/esm/abi/compressors/withdrawalCompressor.js +2 -1
- package/dist/esm/plugins/adapters/contracts/AbstractAdapter.js +31 -9
- package/dist/esm/plugins/adapters/contracts/AbstractCurveAdapter.js +8 -5
- package/dist/esm/plugins/adapters/contracts/BalancerV3RouterAdapterContract.js +6 -4
- package/dist/esm/plugins/adapters/contracts/BalancerV3WrapperAdapterContract.js +6 -4
- package/dist/esm/plugins/adapters/contracts/CamelotV3AdapterContract.js +6 -9
- package/dist/esm/plugins/adapters/contracts/ConvexV1BaseRewardPoolAdapterContract.js +7 -5
- package/dist/esm/plugins/adapters/contracts/ConvexV1BoosterAdapterContract.js +6 -4
- package/dist/esm/plugins/adapters/contracts/DaiUsdsAdapterContract.js +6 -4
- package/dist/esm/plugins/adapters/contracts/ERC4626AdapterContract.js +13 -4
- package/dist/esm/plugins/adapters/contracts/ERC4626ReferralAdapterContract.js +6 -4
- package/dist/esm/plugins/adapters/contracts/FluidDexAdapterContract.js +8 -8
- package/dist/esm/plugins/adapters/contracts/InfinifiGatewayAdapterContract.js +8 -5
- package/dist/esm/plugins/adapters/contracts/KelpLRTDepositPoolAdapterContract.js +4 -3
- package/dist/esm/plugins/adapters/contracts/LidoV1AdapterContract.js +4 -3
- package/dist/esm/plugins/adapters/contracts/MellowClaimerAdapterContract.js +32 -1
- package/dist/esm/plugins/adapters/contracts/MellowDVVAdapterContract.js +6 -4
- package/dist/esm/plugins/adapters/contracts/MellowERC4626VaultAdapterContract.js +11 -4
- package/dist/esm/plugins/adapters/contracts/MellowWrapperAdapterContract.js +4 -3
- package/dist/esm/plugins/adapters/contracts/MidasGatewayAdapterContract.js +33 -5
- package/dist/esm/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.js +4 -3
- package/dist/esm/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.js +4 -3
- package/dist/esm/plugins/adapters/contracts/PendleRouterAdapterContract.js +14 -16
- package/dist/esm/plugins/adapters/contracts/SecuritizeOnRampAdapterContract.js +4 -3
- package/dist/esm/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.js +14 -13
- package/dist/esm/plugins/adapters/contracts/StakingRewardsAdapterContract.js +7 -5
- package/dist/esm/plugins/adapters/contracts/TraderJoeRouterAdapterContract.js +4 -3
- package/dist/esm/plugins/adapters/contracts/UniswapV2AdapterContract.js +4 -3
- package/dist/esm/plugins/adapters/contracts/UniswapV3AdapterContract.js +6 -9
- package/dist/esm/plugins/adapters/contracts/UniswapV4AdapterContract.js +8 -8
- package/dist/esm/plugins/adapters/contracts/UpshiftVaultAdapterContract.js +6 -4
- package/dist/esm/plugins/adapters/contracts/VelodromeV2AdapterContract.js +4 -3
- package/dist/esm/plugins/adapters/contracts/WstETHV1AdapterContract.js +6 -4
- package/dist/esm/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +2 -9
- package/dist/esm/preview/preview/applyInnerOperations.js +90 -59
- package/dist/esm/preview/preview/applyQuotaChanges.js +19 -0
- package/dist/esm/preview/preview/errors.js +0 -15
- package/dist/esm/preview/preview/index.js +1 -0
- package/dist/esm/preview/preview/previewAdjustCreditAccount.js +20 -8
- package/dist/esm/preview/preview/previewCloseOrRepayCreditAccount.js +18 -7
- package/dist/esm/preview/preview/previewOpenCreditAccount.js +20 -6
- package/dist/esm/preview/preview/types.js +16 -0
- package/dist/esm/preview/preview/unwrapNativeCollateral.js +12 -4
- package/dist/esm/sdk/OnchainSDK.js +3 -6
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -4
- package/dist/esm/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +14 -22
- package/dist/esm/sdk/accounts/withdrawal-compressor/addresses.js +6 -18
- package/dist/esm/sdk/accounts/withdrawal-compressor/createWithdrawalCompressor.js +3 -5
- package/dist/types/abi/IWithdrawalCompressorV313.d.ts +4 -0
- package/dist/types/abi/compressors/withdrawalCompressor.d.ts +4 -0
- package/dist/types/permissionless/bindings/compressors/withdrawal-compressor.d.ts +4 -0
- package/dist/types/plugins/adapters/contracts/AbstractAdapter.d.ts +27 -7
- package/dist/types/plugins/adapters/contracts/AbstractCurveAdapter.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/BalancerV3RouterAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/BalancerV3WrapperAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/CamelotV3AdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/ConvexV1BaseRewardPoolAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/ConvexV1BoosterAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/DaiUsdsAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/ERC4626AdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/ERC4626ReferralAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/FluidDexAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/InfinifiGatewayAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/KelpLRTDepositPoolAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/LidoV1AdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/MellowClaimerAdapterContract.d.ts +3 -2
- package/dist/types/plugins/adapters/contracts/MellowDVVAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/MellowERC4626VaultAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/MellowWrapperAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/MidasGatewayAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/PendleRouterAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/SecuritizeOnRampAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/StakingRewardsAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/TraderJoeRouterAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/UniswapV2AdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/UniswapV3AdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/UniswapV4AdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/UpshiftVaultAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/VelodromeV2AdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/WstETHV1AdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/types.d.ts +0 -10
- package/dist/types/preview/preview/applyInnerOperations.d.ts +8 -33
- package/dist/types/preview/preview/applyQuotaChanges.d.ts +24 -0
- package/dist/types/preview/preview/errors.d.ts +0 -12
- package/dist/types/preview/preview/index.d.ts +1 -0
- package/dist/types/preview/preview/previewAdjustCreditAccount.d.ts +1 -1
- package/dist/types/preview/preview/previewOpenCreditAccount.d.ts +1 -1
- package/dist/types/preview/preview/types.d.ts +81 -0
- package/dist/types/preview/preview/unwrapNativeCollateral.d.ts +19 -4
- package/dist/types/sdk/OnchainSDK.d.ts +3 -6
- package/dist/types/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.d.ts +4 -0
- package/dist/types/sdk/accounts/withdrawal-compressor/addresses.d.ts +1 -2
- package/dist/types/sdk/accounts/withdrawal-compressor/createWithdrawalCompressor.d.ts +2 -4
- package/dist/types/sdk/accounts/withdrawal-compressor/types.d.ts +7 -0
- package/package.json +1 -1
|
@@ -23,6 +23,8 @@ __export(previewAdjustCreditAccount_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(previewAdjustCreditAccount_exports);
|
|
24
24
|
var import_sdk = require("../../sdk/index.js");
|
|
25
25
|
var import_applyInnerOperations = require("./applyInnerOperations.js");
|
|
26
|
+
var import_applyQuotaChanges = require("./applyQuotaChanges.js");
|
|
27
|
+
var import_types = require("./types.js");
|
|
26
28
|
var import_unwrapNativeCollateral = require("./unwrapNativeCollateral.js");
|
|
27
29
|
async function previewAdjustCreditAccount(input, operation, options) {
|
|
28
30
|
const { sdk, value = 0n } = input;
|
|
@@ -53,22 +55,30 @@ async function previewAdjustCreditAccount(input, operation, options) {
|
|
|
53
55
|
state.balances = initialBalances.clone();
|
|
54
56
|
state.debt = ca.debt;
|
|
55
57
|
state.totalDebt = ca.debt + ca.accruedInterest + ca.accruedFees;
|
|
56
|
-
(0, import_applyInnerOperations.applyInnerOperations)(sdk, operation.multicall, state);
|
|
57
|
-
const collateralAdded = (0, import_unwrapNativeCollateral.unwrapNativeCollateral)(
|
|
58
|
+
let error = (0, import_applyInnerOperations.applyInnerOperations)(sdk, operation.multicall, state);
|
|
59
|
+
const { assets: collateralAdded, error: unwrapError } = (0, import_unwrapNativeCollateral.unwrapNativeCollateral)(
|
|
58
60
|
state.collateralAdded.toAssets(),
|
|
59
61
|
value,
|
|
60
62
|
sdk.addressProvider.getAddress(import_sdk.AP_WETH_TOKEN, import_sdk.NO_VERSION)
|
|
61
63
|
);
|
|
62
|
-
|
|
64
|
+
error ??= unwrapError;
|
|
65
|
+
const { quotas, quotasChange } = (0, import_applyQuotaChanges.applyQuotaChanges)(
|
|
63
66
|
initialQuotas,
|
|
64
67
|
state.quotaChanges
|
|
65
68
|
);
|
|
66
69
|
const assets = state.balances.toAssets(1n);
|
|
67
70
|
const assetsChange = state.balances.difference(initialBalances).toAssets(1n);
|
|
68
|
-
const totalValue = assets.reduce(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
const totalValue = assets.reduce((acc, { token, balance }) => {
|
|
72
|
+
try {
|
|
73
|
+
return acc + market.priceOracle.convert(token, market.underlying, balance);
|
|
74
|
+
} catch {
|
|
75
|
+
error ??= {
|
|
76
|
+
code: import_types.ERROR_UNPRICEABLE_TOKEN,
|
|
77
|
+
message: `cannot price token ${token}`
|
|
78
|
+
};
|
|
79
|
+
return acc;
|
|
80
|
+
}
|
|
81
|
+
}, 0n);
|
|
72
82
|
return {
|
|
73
83
|
operation: "AdjustCreditAccount",
|
|
74
84
|
creditManager: operation.creditManager,
|
|
@@ -81,7 +91,8 @@ async function previewAdjustCreditAccount(input, operation, options) {
|
|
|
81
91
|
quotas,
|
|
82
92
|
quotasChange,
|
|
83
93
|
assets,
|
|
84
|
-
assetsChange
|
|
94
|
+
assetsChange,
|
|
95
|
+
error
|
|
85
96
|
};
|
|
86
97
|
}
|
|
87
98
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -38,23 +38,31 @@ async function previewCloseCreditAccount(input, operation, permanent, options) {
|
|
|
38
38
|
const market = sdk.marketRegister.findByCreditManager(
|
|
39
39
|
operation.creditManager
|
|
40
40
|
);
|
|
41
|
-
const { state } = await replayMulticall(sdk, operation, options);
|
|
41
|
+
const { state, error } = await replayMulticall(sdk, operation, options);
|
|
42
42
|
return {
|
|
43
43
|
operation: "CloseCreditAccount",
|
|
44
44
|
permanent,
|
|
45
45
|
creditManager: operation.creditManager,
|
|
46
46
|
creditAccount: operation.creditAccount,
|
|
47
|
-
|
|
47
|
+
// On a malformed multicall the withdrawn amount depends on best-effort
|
|
48
|
+
// replayed balances and may be unreliable
|
|
49
|
+
receivedAmount: state.collateralWithdrawn.getOrZero(market.underlying),
|
|
50
|
+
error
|
|
48
51
|
};
|
|
49
52
|
}
|
|
50
53
|
async function previewRepayCreditAccount(input, operation, permanent, options) {
|
|
51
54
|
const { sdk, value = 0n } = input;
|
|
52
|
-
const {
|
|
53
|
-
|
|
55
|
+
const {
|
|
56
|
+
ca,
|
|
57
|
+
state,
|
|
58
|
+
error: replayError
|
|
59
|
+
} = await replayMulticall(sdk, operation, options);
|
|
60
|
+
const { assets: collateralAdded, error: unwrapError } = (0, import_unwrapNativeCollateral.unwrapNativeCollateral)(
|
|
54
61
|
state.collateralAdded.toAssets(),
|
|
55
62
|
value,
|
|
56
63
|
sdk.addressProvider.getAddress(import_sdk.AP_WETH_TOKEN, import_sdk.NO_VERSION)
|
|
57
64
|
);
|
|
65
|
+
const error = replayError ?? unwrapError;
|
|
58
66
|
const initialTotalDebt = ca.debt + ca.accruedInterest + ca.accruedFees;
|
|
59
67
|
return {
|
|
60
68
|
operation: "RepayCreditAccount",
|
|
@@ -63,7 +71,10 @@ async function previewRepayCreditAccount(input, operation, permanent, options) {
|
|
|
63
71
|
creditAccount: operation.creditAccount,
|
|
64
72
|
collateralAdded,
|
|
65
73
|
debtRepaid: initialTotalDebt - state.totalDebt,
|
|
66
|
-
|
|
74
|
+
// On a malformed multicall the MAX_UINT256 withdrawal sentinel resolves
|
|
75
|
+
// against best-effort replayed balances and may be unreliable
|
|
76
|
+
collateralWithdrawn: state.collateralWithdrawn.toAssets(),
|
|
77
|
+
error
|
|
67
78
|
};
|
|
68
79
|
}
|
|
69
80
|
async function replayMulticall(sdk, operation, options) {
|
|
@@ -85,8 +96,8 @@ async function replayMulticall(sdk, operation, options) {
|
|
|
85
96
|
}
|
|
86
97
|
state.debt = ca.debt;
|
|
87
98
|
state.totalDebt = ca.debt + ca.accruedInterest + ca.accruedFees;
|
|
88
|
-
(0, import_applyInnerOperations.applyInnerOperations)(sdk, operation.multicall, state);
|
|
89
|
-
return { ca, state };
|
|
99
|
+
const error = (0, import_applyInnerOperations.applyInnerOperations)(sdk, operation.multicall, state);
|
|
100
|
+
return { ca, state, error };
|
|
90
101
|
}
|
|
91
102
|
// Annotate the CommonJS export names for ESM import in node:
|
|
92
103
|
0 && (module.exports = {
|
|
@@ -23,6 +23,7 @@ __export(previewOpenCreditAccount_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(previewOpenCreditAccount_exports);
|
|
24
24
|
var import_sdk = require("../../sdk/index.js");
|
|
25
25
|
var import_applyInnerOperations = require("./applyInnerOperations.js");
|
|
26
|
+
var import_types = require("./types.js");
|
|
26
27
|
var import_unwrapNativeCollateral = require("./unwrapNativeCollateral.js");
|
|
27
28
|
function previewOpenCreditAccount(input, operation) {
|
|
28
29
|
const { sdk, value = 0n } = input;
|
|
@@ -30,15 +31,25 @@ function previewOpenCreditAccount(input, operation) {
|
|
|
30
31
|
operation.creditManager
|
|
31
32
|
);
|
|
32
33
|
const state = (0, import_applyInnerOperations.makeInnerOperationsState)();
|
|
33
|
-
(0, import_applyInnerOperations.applyInnerOperations)(sdk, operation.multicall, state);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
let error = (0, import_applyInnerOperations.applyInnerOperations)(sdk, operation.multicall, state);
|
|
35
|
+
let priceError;
|
|
36
|
+
const collateralValue = state.collateralAdded.sum((token, balance) => {
|
|
37
|
+
try {
|
|
38
|
+
return market.priceOracle.convert(token, market.underlying, balance);
|
|
39
|
+
} catch {
|
|
40
|
+
priceError ??= {
|
|
41
|
+
code: import_types.ERROR_UNPRICEABLE_TOKEN,
|
|
42
|
+
message: `cannot price token ${token}`
|
|
43
|
+
};
|
|
44
|
+
return 0n;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const { assets: collateral, error: unwrapError } = (0, import_unwrapNativeCollateral.unwrapNativeCollateral)(
|
|
38
48
|
state.collateralAdded.toAssets(),
|
|
39
49
|
value,
|
|
40
50
|
sdk.addressProvider.getAddress(import_sdk.AP_WETH_TOKEN, import_sdk.NO_VERSION)
|
|
41
51
|
);
|
|
52
|
+
error ??= unwrapError ?? priceError;
|
|
42
53
|
const assets = state.balances.toAssets(1n);
|
|
43
54
|
return {
|
|
44
55
|
operation: operation.operation,
|
|
@@ -49,7 +60,8 @@ function previewOpenCreditAccount(input, operation) {
|
|
|
49
60
|
debt: state.debt,
|
|
50
61
|
// On opening, initial quotas are zero, so the raw changes are the quotas.
|
|
51
62
|
quotas: state.quotaChanges,
|
|
52
|
-
assets
|
|
63
|
+
assets,
|
|
64
|
+
error
|
|
53
65
|
};
|
|
54
66
|
}
|
|
55
67
|
function inferTargetAsset(multicall, balances) {
|
|
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
6
10
|
var __copyProps = (to, from, except, desc) => {
|
|
7
11
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
12
|
for (let key of __getOwnPropNames(from))
|
|
@@ -13,4 +17,30 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
13
17
|
};
|
|
14
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
19
|
var types_exports = {};
|
|
20
|
+
__export(types_exports, {
|
|
21
|
+
ERROR_ADAPTER_CALL_OUTSIDE_BRACKET: () => ERROR_ADAPTER_CALL_OUTSIDE_BRACKET,
|
|
22
|
+
ERROR_INVALID_TRANSACTION_VALUE: () => ERROR_INVALID_TRANSACTION_VALUE,
|
|
23
|
+
ERROR_MALFORMED_BRACKET: () => ERROR_MALFORMED_BRACKET,
|
|
24
|
+
ERROR_NON_ADAPTER_CALL_IN_BRACKET: () => ERROR_NON_ADAPTER_CALL_IN_BRACKET,
|
|
25
|
+
ERROR_UNPREVIEWABLE_ADAPTER_CALL: () => ERROR_UNPREVIEWABLE_ADAPTER_CALL,
|
|
26
|
+
ERROR_UNPREVIEWABLE_RWA_WRAP_UNWRAP: () => ERROR_UNPREVIEWABLE_RWA_WRAP_UNWRAP,
|
|
27
|
+
ERROR_UNPRICEABLE_TOKEN: () => ERROR_UNPRICEABLE_TOKEN
|
|
28
|
+
});
|
|
16
29
|
module.exports = __toCommonJS(types_exports);
|
|
30
|
+
const ERROR_MALFORMED_BRACKET = 1001;
|
|
31
|
+
const ERROR_ADAPTER_CALL_OUTSIDE_BRACKET = 1002;
|
|
32
|
+
const ERROR_NON_ADAPTER_CALL_IN_BRACKET = 1003;
|
|
33
|
+
const ERROR_UNPREVIEWABLE_ADAPTER_CALL = 1004;
|
|
34
|
+
const ERROR_UNPREVIEWABLE_RWA_WRAP_UNWRAP = 1005;
|
|
35
|
+
const ERROR_INVALID_TRANSACTION_VALUE = 1006;
|
|
36
|
+
const ERROR_UNPRICEABLE_TOKEN = 2001;
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
ERROR_ADAPTER_CALL_OUTSIDE_BRACKET,
|
|
40
|
+
ERROR_INVALID_TRANSACTION_VALUE,
|
|
41
|
+
ERROR_MALFORMED_BRACKET,
|
|
42
|
+
ERROR_NON_ADAPTER_CALL_IN_BRACKET,
|
|
43
|
+
ERROR_UNPREVIEWABLE_ADAPTER_CALL,
|
|
44
|
+
ERROR_UNPREVIEWABLE_RWA_WRAP_UNWRAP,
|
|
45
|
+
ERROR_UNPRICEABLE_TOKEN
|
|
46
|
+
});
|
|
@@ -22,22 +22,28 @@ __export(unwrapNativeCollateral_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(unwrapNativeCollateral_exports);
|
|
24
24
|
var import_sdk = require("../../sdk/index.js");
|
|
25
|
-
var
|
|
25
|
+
var import_types = require("./types.js");
|
|
26
26
|
function unwrapNativeCollateral(collateral, nativeAmount, wethToken) {
|
|
27
27
|
if (nativeAmount === 0n) {
|
|
28
|
-
return collateral;
|
|
28
|
+
return { assets: collateral };
|
|
29
29
|
}
|
|
30
30
|
const balances = new import_sdk.AssetsMap(collateral);
|
|
31
31
|
const wethBalance = balances.get(wethToken) ?? 0n;
|
|
32
32
|
if (wethBalance < nativeAmount) {
|
|
33
|
-
|
|
33
|
+
return {
|
|
34
|
+
assets: collateral,
|
|
35
|
+
error: {
|
|
36
|
+
code: import_types.ERROR_INVALID_TRANSACTION_VALUE,
|
|
37
|
+
message: `transaction value ${nativeAmount} exceeds WETH collateral ${wethBalance}`
|
|
38
|
+
}
|
|
39
|
+
};
|
|
34
40
|
}
|
|
35
41
|
balances.upsert(
|
|
36
42
|
wethToken,
|
|
37
43
|
wethBalance === nativeAmount ? void 0 : wethBalance - nativeAmount
|
|
38
44
|
);
|
|
39
45
|
balances.inc(import_sdk.NATIVE_ADDRESS, nativeAmount);
|
|
40
|
-
return balances.toAssets();
|
|
46
|
+
return { assets: balances.toAssets() };
|
|
41
47
|
}
|
|
42
48
|
// Annotate the CommonJS export names for ESM import in node:
|
|
43
49
|
0 && (module.exports = {
|
|
@@ -538,13 +538,10 @@ class OnchainSDK extends import_base.ChainContractsRegister {
|
|
|
538
538
|
/**
|
|
539
539
|
* Lazily returns a withdrawal compressor contract for the current chain.
|
|
540
540
|
*
|
|
541
|
-
* @
|
|
542
|
-
* version supported on the current chain is used.
|
|
543
|
-
* @throws If no withdrawal compressor of the given version is supported
|
|
544
|
-
* on the current chain.
|
|
541
|
+
* @throws If no withdrawal compressor is supported on the current chain.
|
|
545
542
|
**/
|
|
546
|
-
withdrawalCompressor(
|
|
547
|
-
return (0, import_accounts.createWithdrawalCompressor)(this
|
|
543
|
+
get withdrawalCompressor() {
|
|
544
|
+
return (0, import_accounts.createWithdrawalCompressor)(this);
|
|
548
545
|
}
|
|
549
546
|
}
|
|
550
547
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -786,8 +786,7 @@ class CreditAccountsServiceV310 extends import_base.SDKConstruct {
|
|
|
786
786
|
token,
|
|
787
787
|
intent
|
|
788
788
|
}) {
|
|
789
|
-
|
|
790
|
-
return compressor.getWithdrawalRequestResult(
|
|
789
|
+
return this.sdk.withdrawalCompressor.getWithdrawalRequestResult(
|
|
791
790
|
creditAccount,
|
|
792
791
|
token,
|
|
793
792
|
amount,
|
|
@@ -800,8 +799,7 @@ class CreditAccountsServiceV310 extends import_base.SDKConstruct {
|
|
|
800
799
|
async getPendingWithdrawals({
|
|
801
800
|
creditAccount
|
|
802
801
|
}) {
|
|
803
|
-
const
|
|
804
|
-
const { claimable, pending } = await compressor.getCurrentWithdrawals(creditAccount);
|
|
802
|
+
const { claimable, pending } = await this.sdk.withdrawalCompressor.getCurrentWithdrawals(creditAccount);
|
|
805
803
|
return {
|
|
806
804
|
claimableNow: claimable,
|
|
807
805
|
pending
|
|
@@ -107,7 +107,7 @@ class AbstractWithdrawalCompressorContract extends import_base.BaseContract {
|
|
|
107
107
|
claimable: claimable.map(
|
|
108
108
|
(w) => toClaimableWithdrawal(w, creditManager, this.version >= 313)
|
|
109
109
|
),
|
|
110
|
-
pending: pending.map(toPendingWithdrawal).sort((a, b) => a.claimableAt < b.claimableAt ? -1 : 1)
|
|
110
|
+
pending: pending.map((w) => toPendingWithdrawal(w, creditManager, this.version >= 313)).sort((a, b) => a.claimableAt < b.claimableAt ? -1 : 1)
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
@@ -127,8 +127,8 @@ class AbstractWithdrawalCompressorContract extends import_base.BaseContract {
|
|
|
127
127
|
return {
|
|
128
128
|
token: resp.token,
|
|
129
129
|
amountIn: resp.amountIn,
|
|
130
|
-
outputs: resp.outputs
|
|
131
|
-
requestCalls: resp.requestCalls
|
|
130
|
+
outputs: [...resp.outputs],
|
|
131
|
+
requestCalls: [...resp.requestCalls],
|
|
132
132
|
claimableAt: resp.claimableAt
|
|
133
133
|
};
|
|
134
134
|
}
|
|
@@ -180,21 +180,8 @@ class AbstractWithdrawalCompressorContract extends import_base.BaseContract {
|
|
|
180
180
|
]);
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
function toWithdrawalOutput(o) {
|
|
184
|
-
return { token: o.token, isDelayed: o.isDelayed, amount: o.amount };
|
|
185
|
-
}
|
|
186
|
-
function toMultiCall(c) {
|
|
187
|
-
return { target: c.target, callData: c.callData };
|
|
188
|
-
}
|
|
189
183
|
function toWithdrawableAsset(a, creditManager) {
|
|
190
|
-
return {
|
|
191
|
-
creditManager,
|
|
192
|
-
token: a.token,
|
|
193
|
-
withdrawalPhantomToken: a.withdrawalPhantomToken,
|
|
194
|
-
underlying: a.underlying,
|
|
195
|
-
withdrawalLength: a.withdrawalLength,
|
|
196
|
-
maxWithdrawals: a.maxWithdrawals
|
|
197
|
-
};
|
|
184
|
+
return { creditManager, ...a };
|
|
198
185
|
}
|
|
199
186
|
function toClaimableWithdrawal(w, creditManager, decodeIntent) {
|
|
200
187
|
let intent;
|
|
@@ -205,17 +192,22 @@ function toClaimableWithdrawal(w, creditManager, decodeIntent) {
|
|
|
205
192
|
token: w.token,
|
|
206
193
|
withdrawalPhantomToken: w.withdrawalPhantomToken,
|
|
207
194
|
withdrawalTokenSpent: w.withdrawalTokenSpent,
|
|
208
|
-
outputs: w.outputs
|
|
209
|
-
claimCalls: w.claimCalls
|
|
195
|
+
outputs: [...w.outputs],
|
|
196
|
+
claimCalls: [...w.claimCalls],
|
|
210
197
|
intent
|
|
211
198
|
};
|
|
212
199
|
}
|
|
213
|
-
function toPendingWithdrawal(w) {
|
|
200
|
+
function toPendingWithdrawal(w, creditManager, decodeIntent) {
|
|
201
|
+
let intent;
|
|
202
|
+
if (decodeIntent && w.extraData && w.extraData !== "0x") {
|
|
203
|
+
intent = { ...(0, import_intent_codec.decodeDelayedIntent)(w.extraData), creditManager };
|
|
204
|
+
}
|
|
214
205
|
return {
|
|
215
206
|
token: w.token,
|
|
216
207
|
withdrawalPhantomToken: w.withdrawalPhantomToken,
|
|
217
|
-
expectedOutputs: w.expectedOutputs
|
|
218
|
-
claimableAt: w.claimableAt
|
|
208
|
+
expectedOutputs: [...w.expectedOutputs],
|
|
209
|
+
claimableAt: w.claimableAt,
|
|
210
|
+
intent
|
|
219
211
|
};
|
|
220
212
|
}
|
|
221
213
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -23,28 +23,16 @@ __export(addresses_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(addresses_exports);
|
|
24
24
|
const WITHDRAWAL_COMPRESSORS = {
|
|
25
25
|
Mainnet: {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
address: "0x83e5AaC6590Cf9c6Dd323851a0D66fEc2Bc4F5A3",
|
|
27
|
+
version: 313
|
|
28
28
|
},
|
|
29
29
|
Monad: {
|
|
30
|
-
|
|
30
|
+
address: "0x36F3d0Bb73CBC2E94fE24dF0f26a689409cF9023",
|
|
31
|
+
version: 310
|
|
31
32
|
}
|
|
32
33
|
};
|
|
33
|
-
function getWithdrawalCompressorAddress(network
|
|
34
|
-
|
|
35
|
-
if (!deployments) {
|
|
36
|
-
return void 0;
|
|
37
|
-
}
|
|
38
|
-
if (version !== void 0) {
|
|
39
|
-
const address2 = deployments[version];
|
|
40
|
-
return address2 ? { address: address2, version } : void 0;
|
|
41
|
-
}
|
|
42
|
-
const latest = Object.keys(deployments).map(Number).sort((a, b) => b - a)[0];
|
|
43
|
-
if (latest === void 0) {
|
|
44
|
-
return void 0;
|
|
45
|
-
}
|
|
46
|
-
const address = deployments[latest];
|
|
47
|
-
return address ? { address, version: latest } : void 0;
|
|
34
|
+
function getWithdrawalCompressorAddress(network) {
|
|
35
|
+
return WITHDRAWAL_COMPRESSORS[network];
|
|
48
36
|
}
|
|
49
37
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50
38
|
0 && (module.exports = {
|
|
@@ -25,12 +25,10 @@ var import_addresses = require("./addresses.js");
|
|
|
25
25
|
var import_WithdrawalCompressorV310Contract = require("./WithdrawalCompressorV310Contract.js");
|
|
26
26
|
var import_WithdrawalCompressorV311Contract = require("./WithdrawalCompressorV311Contract.js");
|
|
27
27
|
var import_WithdrawalCompressorV313Contract = require("./WithdrawalCompressorV313Contract.js");
|
|
28
|
-
function createWithdrawalCompressor(sdk
|
|
29
|
-
const location = (0, import_addresses.getWithdrawalCompressorAddress)(sdk.networkType
|
|
28
|
+
function createWithdrawalCompressor(sdk) {
|
|
29
|
+
const location = (0, import_addresses.getWithdrawalCompressorAddress)(sdk.networkType);
|
|
30
30
|
if (!location) {
|
|
31
|
-
throw new Error(
|
|
32
|
-
`no withdrawal compressor${version ? ` v${version}` : ""} on ${sdk.networkType}`
|
|
33
|
-
);
|
|
31
|
+
throw new Error(`no withdrawal compressor on ${sdk.networkType}`);
|
|
34
32
|
}
|
|
35
33
|
const cached = sdk.getContract(
|
|
36
34
|
location.address
|
|
@@ -72,7 +72,8 @@ const iWithdrawalCompressorV313Abi = [
|
|
|
72
72
|
{ name: "amount", type: "uint256", internalType: "uint256" }
|
|
73
73
|
]
|
|
74
74
|
},
|
|
75
|
-
{ name: "claimableAt", type: "uint256", internalType: "uint256" }
|
|
75
|
+
{ name: "claimableAt", type: "uint256", internalType: "uint256" },
|
|
76
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
76
77
|
]
|
|
77
78
|
}
|
|
78
79
|
],
|
|
@@ -94,7 +94,8 @@ const withdrawalCompressorAbi = [
|
|
|
94
94
|
{ name: "amount", type: "uint256", internalType: "uint256" }
|
|
95
95
|
]
|
|
96
96
|
},
|
|
97
|
-
{ name: "claimableAt", type: "uint256", internalType: "uint256" }
|
|
97
|
+
{ name: "claimableAt", type: "uint256", internalType: "uint256" },
|
|
98
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
98
99
|
]
|
|
99
100
|
}
|
|
100
101
|
],
|
|
@@ -104,8 +104,10 @@ class AbstractAdapterContract extends BaseContract {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
|
-
* Applies the balance changes implied by a
|
|
108
|
-
*
|
|
107
|
+
* Applies the balance changes implied by an adapter call to a map of
|
|
108
|
+
* credit-account token balances. Handles both router-generated diff-style
|
|
109
|
+
* calls and exact-input calls (e.g. those emitted by the withdrawal
|
|
110
|
+
* compressor).
|
|
109
111
|
*
|
|
110
112
|
* @param balances - Token balances before the call. Mutated in place.
|
|
111
113
|
* @param calldata - Raw ABI-encoded adapter calldata.
|
|
@@ -122,23 +124,43 @@ class AbstractAdapterContract extends BaseContract {
|
|
|
122
124
|
{ cause: e }
|
|
123
125
|
);
|
|
124
126
|
}
|
|
125
|
-
|
|
126
|
-
for (const { tokenIn, leftoverAmount } of leftovers) {
|
|
127
|
-
balances.upsert(tokenIn, leftoverAmount);
|
|
128
|
-
}
|
|
127
|
+
this.applyBalanceChanges(balances, decoded);
|
|
129
128
|
}
|
|
130
129
|
/**
|
|
131
|
-
*
|
|
130
|
+
* Applies the balance changes of a decoded adapter call to the running
|
|
131
|
+
* balances, mutating them in place. Overrides should express changes via
|
|
132
|
+
* {@link setLeftover} (diff-style calls) and {@link spendExact}
|
|
133
|
+
* (exact-input calls), and should resolve all tokens/amounts before the
|
|
134
|
+
* first write so a throw never leaves balances partially mutated.
|
|
132
135
|
*
|
|
136
|
+
* @param _balances - Token balances before the call. Mutated in place.
|
|
133
137
|
* @param decoded - The viem-decoded adapter call
|
|
134
|
-
* @param _balances - Token balances before the call
|
|
135
138
|
* @throws When the adapter (or the specific function) has no balance-changes support
|
|
136
139
|
*/
|
|
137
|
-
|
|
140
|
+
applyBalanceChanges(_balances, decoded) {
|
|
138
141
|
throw new Error(
|
|
139
142
|
`previewBalanceChanges is not supported for ${decoded.functionName} on ${this.contractType} adapter at ${this.address}`
|
|
140
143
|
);
|
|
141
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Diff-call semantics of a diff-style adapter call: the call spends the
|
|
147
|
+
* consumed token down to the exact `leftoverAmount` encoded in its
|
|
148
|
+
* calldata, so the post-call balance of `tokenIn` is `leftoverAmount`
|
|
149
|
+
* regardless of the actual amount spent.
|
|
150
|
+
*/
|
|
151
|
+
setLeftover(balances, tokenIn, leftoverAmount) {
|
|
152
|
+
balances.upsert(tokenIn, leftoverAmount);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Exact-input call semantics: spends exactly `amount` of `tokenIn` from
|
|
156
|
+
* the running balance, clamping at zero. Used for non-diff adapter calls
|
|
157
|
+
* (e.g. those generated by the withdrawal compressor) whose spent amount
|
|
158
|
+
* is present in calldata.
|
|
159
|
+
*/
|
|
160
|
+
spendExact(balances, tokenIn, amount) {
|
|
161
|
+
const balance = balances.getOrZero(tokenIn);
|
|
162
|
+
balances.upsert(tokenIn, balance > amount ? balance - amount : 0n);
|
|
163
|
+
}
|
|
142
164
|
/**
|
|
143
165
|
* Classifies an adapter call into a {@link LegacyAdapterOperation} using the
|
|
144
166
|
* parsed call and credit-account transfer deltas.
|
|
@@ -5,23 +5,26 @@ class AbstractCurveAdapterContract extends AbstractAdapterContract {
|
|
|
5
5
|
classifyLegacyOperation(parsed, transfers) {
|
|
6
6
|
return classifyCurveOperation(parsed.functionName, transfers) ?? super.classifyLegacyOperation(parsed, transfers);
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
applyBalanceChanges(balances, decoded) {
|
|
9
9
|
const { functionName, args } = decoded;
|
|
10
10
|
switch (functionName) {
|
|
11
11
|
case "exchange_diff": {
|
|
12
12
|
const [i, , leftoverAmount] = args;
|
|
13
|
-
|
|
13
|
+
this.setLeftover(balances, this.curveCoin(i), leftoverAmount);
|
|
14
|
+
break;
|
|
14
15
|
}
|
|
15
16
|
case "add_diff_liquidity_one_coin": {
|
|
16
17
|
const [leftoverAmount, i] = args;
|
|
17
|
-
|
|
18
|
+
this.setLeftover(balances, this.curveCoin(i), leftoverAmount);
|
|
19
|
+
break;
|
|
18
20
|
}
|
|
19
21
|
case "remove_diff_liquidity_one_coin": {
|
|
20
22
|
const [leftoverAmount] = args;
|
|
21
|
-
|
|
23
|
+
this.setLeftover(balances, this.lpToken, leftoverAmount);
|
|
24
|
+
break;
|
|
22
25
|
}
|
|
23
26
|
default:
|
|
24
|
-
|
|
27
|
+
super.applyBalanceChanges(balances, decoded);
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
30
|
/**
|
|
@@ -71,23 +71,25 @@ class BalancerV3RouterAdapterContract extends AbstractAdapterContract {
|
|
|
71
71
|
}))
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
applyBalanceChanges(balances, decoded) {
|
|
75
75
|
switch (decoded.functionName) {
|
|
76
76
|
case "swapSingleTokenDiffIn": {
|
|
77
77
|
const [, tokenIn, , leftoverAmount] = decoded.args;
|
|
78
|
-
|
|
78
|
+
this.setLeftover(balances, tokenIn, leftoverAmount);
|
|
79
|
+
break;
|
|
79
80
|
}
|
|
80
81
|
// BPT (pool token) is spent down to the leftover
|
|
81
82
|
case "removeLiquiditySingleTokenDiff": {
|
|
82
83
|
const [pool, leftoverAmount] = decoded.args;
|
|
83
|
-
|
|
84
|
+
this.setLeftover(balances, pool, leftoverAmount);
|
|
85
|
+
break;
|
|
84
86
|
}
|
|
85
87
|
case "addLiquidityUnbalancedDiff":
|
|
86
88
|
throw new Error(
|
|
87
89
|
`previewBalanceChanges cannot resolve pool tokens for addLiquidityUnbalancedDiff on ${this.contractType} adapter at ${this.address}`
|
|
88
90
|
);
|
|
89
91
|
default:
|
|
90
|
-
|
|
92
|
+
super.applyBalanceChanges(balances, decoded);
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
}
|
|
@@ -34,19 +34,21 @@ class BalancerV3WrapperAdapterContract extends AbstractAdapterContract {
|
|
|
34
34
|
balancerPoolToken: this.#balancerPoolToken ? this.labelAddress(this.#balancerPoolToken) : void 0
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
applyBalanceChanges(balances, decoded) {
|
|
38
38
|
switch (decoded.functionName) {
|
|
39
39
|
// mint spends the pool token, burn spends the wrapper (target contract)
|
|
40
40
|
case "mintDiff": {
|
|
41
41
|
const [leftoverAmount] = decoded.args;
|
|
42
|
-
|
|
42
|
+
this.setLeftover(balances, this.balancerPoolToken, leftoverAmount);
|
|
43
|
+
break;
|
|
43
44
|
}
|
|
44
45
|
case "burnDiff": {
|
|
45
46
|
const [leftoverAmount] = decoded.args;
|
|
46
|
-
|
|
47
|
+
this.setLeftover(balances, this.targetContract, leftoverAmount);
|
|
48
|
+
break;
|
|
47
49
|
}
|
|
48
50
|
default:
|
|
49
|
-
|
|
51
|
+
super.applyBalanceChanges(balances, decoded);
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
}
|
|
@@ -47,24 +47,21 @@ class CamelotV3AdapterContract extends AbstractAdapterContract {
|
|
|
47
47
|
}))
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
applyBalanceChanges(balances, decoded) {
|
|
51
51
|
switch (decoded.functionName) {
|
|
52
52
|
case "exactDiffInputSingle": {
|
|
53
53
|
const [params] = decoded.args;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
tokenIn: params.tokenIn,
|
|
57
|
-
leftoverAmount: params.leftoverAmount
|
|
58
|
-
}
|
|
59
|
-
];
|
|
54
|
+
this.setLeftover(balances, params.tokenIn, params.leftoverAmount);
|
|
55
|
+
break;
|
|
60
56
|
}
|
|
61
57
|
case "exactDiffInput": {
|
|
62
58
|
const [params] = decoded.args;
|
|
63
59
|
const tokenIn = `0x${params.path.replace("0x", "").slice(0, 40)}`;
|
|
64
|
-
|
|
60
|
+
this.setLeftover(balances, tokenIn, params.leftoverAmount);
|
|
61
|
+
break;
|
|
65
62
|
}
|
|
66
63
|
default:
|
|
67
|
-
|
|
64
|
+
super.applyBalanceChanges(balances, decoded);
|
|
68
65
|
}
|
|
69
66
|
}
|
|
70
67
|
}
|
|
@@ -116,22 +116,24 @@ class ConvexV1BaseRewardPoolAdapterContract extends AbstractAdapterContract {
|
|
|
116
116
|
withdrawAmount: swap.toAmount
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
|
-
|
|
119
|
+
applyBalanceChanges(balances, decoded) {
|
|
120
120
|
switch (decoded.functionName) {
|
|
121
121
|
case "stakeDiff": {
|
|
122
122
|
const [leftoverAmount] = decoded.args;
|
|
123
|
-
|
|
123
|
+
this.setLeftover(balances, this.stakingToken, leftoverAmount);
|
|
124
|
+
break;
|
|
124
125
|
}
|
|
125
126
|
case "withdrawDiff":
|
|
126
127
|
case "withdrawDiffAndUnwrap": {
|
|
127
128
|
const [leftoverAmount] = decoded.args;
|
|
128
|
-
|
|
129
|
+
this.setLeftover(balances, this.stakedPhantomToken, leftoverAmount);
|
|
130
|
+
break;
|
|
129
131
|
}
|
|
130
132
|
// no accrued rewards on a freshly opened account
|
|
131
133
|
case "getReward":
|
|
132
|
-
|
|
134
|
+
break;
|
|
133
135
|
default:
|
|
134
|
-
|
|
136
|
+
super.applyBalanceChanges(balances, decoded);
|
|
135
137
|
}
|
|
136
138
|
}
|
|
137
139
|
}
|