@gearbox-protocol/sdk 14.12.0-next.8 → 14.12.0-next.9
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/dev/AccountOpener.js +7 -13
- package/dist/cjs/history/classifyMulticallOperations.js +2 -0
- package/dist/cjs/history/mapOperations.js +7 -0
- package/dist/cjs/plugins/adapters/contracts/AbstractAdapter.js +10 -9
- package/dist/cjs/plugins/adapters/contracts/AbstractCurveAdapter.js +66 -0
- package/dist/cjs/plugins/adapters/contracts/BalancerV3RouterAdapterContract.js +4 -5
- package/dist/cjs/plugins/adapters/contracts/BalancerV3WrapperAdapterContract.js +4 -9
- package/dist/cjs/plugins/adapters/contracts/CamelotV3AdapterContract.js +9 -5
- package/dist/cjs/plugins/adapters/contracts/ConvexV1BaseRewardPoolAdapterContract.js +5 -10
- package/dist/cjs/plugins/adapters/contracts/ConvexV1BoosterAdapterContract.js +4 -5
- package/dist/cjs/plugins/adapters/contracts/Curve2AssetsAdapterContract.js +2 -34
- package/dist/cjs/plugins/adapters/contracts/Curve3AssetsAdapterContract.js +2 -34
- package/dist/cjs/plugins/adapters/contracts/Curve4AssetsAdapterContract.js +2 -34
- package/dist/cjs/plugins/adapters/contracts/CurveV1AdapterDeposit.js +2 -29
- package/dist/cjs/plugins/adapters/contracts/CurveV1AdapterStETHContract.js +2 -34
- package/dist/cjs/plugins/adapters/contracts/CurveV1StableNGAdapterContract.js +2 -34
- package/dist/cjs/plugins/adapters/contracts/DaiUsdsAdapterContract.js +4 -5
- package/dist/cjs/plugins/adapters/contracts/ERC4626AdapterContract.js +4 -5
- package/dist/cjs/plugins/adapters/contracts/ERC4626ReferralAdapterContract.js +4 -5
- package/dist/cjs/plugins/adapters/contracts/FluidDexAdapterContract.js +8 -8
- package/dist/cjs/plugins/adapters/contracts/InfinifiGatewayAdapterContract.js +5 -6
- package/dist/cjs/plugins/adapters/contracts/KelpLRTDepositPoolAdapterContract.js +4 -5
- package/dist/cjs/plugins/adapters/contracts/LidoV1AdapterContract.js +3 -4
- package/dist/cjs/plugins/adapters/contracts/MellowDVVAdapterContract.js +4 -5
- package/dist/cjs/plugins/adapters/contracts/MellowERC4626VaultAdapterContract.js +4 -5
- package/dist/cjs/plugins/adapters/contracts/MellowWrapperAdapterContract.js +3 -4
- package/dist/cjs/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.js +3 -4
- package/dist/cjs/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.js +3 -4
- package/dist/cjs/plugins/adapters/contracts/PendleRouterAdapterContract.js +16 -11
- package/dist/cjs/plugins/adapters/contracts/SecuritizeOnRampAdapterContract.js +3 -4
- package/dist/cjs/plugins/adapters/contracts/SecuritizeSwapAdapterContract.js +3 -4
- package/dist/cjs/plugins/adapters/contracts/StakingRewardsAdapterContract.js +5 -10
- package/dist/cjs/plugins/adapters/contracts/TraderJoeRouterAdapterContract.js +3 -4
- package/dist/cjs/plugins/adapters/contracts/UniswapV2AdapterContract.js +3 -4
- package/dist/cjs/plugins/adapters/contracts/UniswapV3AdapterContract.js +9 -5
- package/dist/cjs/plugins/adapters/contracts/UniswapV4AdapterContract.js +8 -8
- package/dist/cjs/plugins/adapters/contracts/UpshiftVaultAdapterContract.js +4 -5
- package/dist/cjs/plugins/adapters/contracts/VelodromeV2AdapterContract.js +3 -4
- package/dist/cjs/plugins/adapters/contracts/WstETHV1AdapterContract.js +4 -5
- package/dist/cjs/plugins/adapters/index.js +0 -2
- package/dist/cjs/preview/parse/classifyInnerOperations.js +14 -1
- package/dist/cjs/preview/prerequisites/buildPrerequisites.js +3 -8
- package/dist/cjs/preview/preview/previewOpenCreditAccount.js +51 -59
- package/dist/cjs/preview/preview/unwrapNativeCollateral.js +10 -24
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +3 -4
- package/dist/cjs/sdk/base/BaseContract.js +4 -2
- package/dist/cjs/sdk/base/ChainContractsRegister.js +1 -0
- package/dist/cjs/sdk/market/credit/CreditFacadeV310BaseContract.js +0 -31
- package/dist/cjs/sdk/market/rwa/securitize/SecuritizeRWAFactory.js +0 -25
- package/dist/cjs/sdk/router/AbstractRouterContract.js +21 -27
- package/dist/cjs/sdk/router/RouterV310Contract.js +11 -12
- package/dist/cjs/sdk/router/helpers.js +0 -5
- package/dist/cjs/sdk/utils/AddressMap.js +6 -0
- package/dist/cjs/sdk/utils/AssetsMap.js +61 -0
- package/dist/cjs/sdk/utils/index.js +2 -0
- package/dist/esm/dev/AccountOpener.js +8 -13
- package/dist/esm/history/classifyMulticallOperations.js +2 -0
- package/dist/esm/history/mapOperations.js +7 -0
- package/dist/esm/plugins/adapters/contracts/AbstractAdapter.js +10 -9
- package/dist/esm/plugins/adapters/contracts/AbstractCurveAdapter.js +42 -0
- package/dist/esm/plugins/adapters/contracts/BalancerV3RouterAdapterContract.js +4 -5
- package/dist/esm/plugins/adapters/contracts/BalancerV3WrapperAdapterContract.js +4 -9
- package/dist/esm/plugins/adapters/contracts/CamelotV3AdapterContract.js +9 -5
- package/dist/esm/plugins/adapters/contracts/ConvexV1BaseRewardPoolAdapterContract.js +5 -10
- package/dist/esm/plugins/adapters/contracts/ConvexV1BoosterAdapterContract.js +4 -5
- package/dist/esm/plugins/adapters/contracts/Curve2AssetsAdapterContract.js +3 -37
- package/dist/esm/plugins/adapters/contracts/Curve3AssetsAdapterContract.js +3 -37
- package/dist/esm/plugins/adapters/contracts/Curve4AssetsAdapterContract.js +3 -37
- package/dist/esm/plugins/adapters/contracts/CurveV1AdapterDeposit.js +3 -32
- package/dist/esm/plugins/adapters/contracts/CurveV1AdapterStETHContract.js +3 -37
- package/dist/esm/plugins/adapters/contracts/CurveV1StableNGAdapterContract.js +3 -37
- package/dist/esm/plugins/adapters/contracts/DaiUsdsAdapterContract.js +4 -5
- package/dist/esm/plugins/adapters/contracts/ERC4626AdapterContract.js +4 -5
- package/dist/esm/plugins/adapters/contracts/ERC4626ReferralAdapterContract.js +4 -5
- package/dist/esm/plugins/adapters/contracts/FluidDexAdapterContract.js +8 -8
- package/dist/esm/plugins/adapters/contracts/InfinifiGatewayAdapterContract.js +5 -6
- package/dist/esm/plugins/adapters/contracts/KelpLRTDepositPoolAdapterContract.js +4 -5
- package/dist/esm/plugins/adapters/contracts/LidoV1AdapterContract.js +3 -4
- package/dist/esm/plugins/adapters/contracts/MellowDVVAdapterContract.js +4 -5
- package/dist/esm/plugins/adapters/contracts/MellowERC4626VaultAdapterContract.js +4 -5
- package/dist/esm/plugins/adapters/contracts/MellowWrapperAdapterContract.js +3 -4
- package/dist/esm/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.js +3 -4
- package/dist/esm/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.js +3 -4
- package/dist/esm/plugins/adapters/contracts/PendleRouterAdapterContract.js +16 -11
- package/dist/esm/plugins/adapters/contracts/SecuritizeOnRampAdapterContract.js +3 -4
- package/dist/esm/plugins/adapters/contracts/SecuritizeSwapAdapterContract.js +3 -4
- package/dist/esm/plugins/adapters/contracts/StakingRewardsAdapterContract.js +5 -10
- package/dist/esm/plugins/adapters/contracts/TraderJoeRouterAdapterContract.js +3 -4
- package/dist/esm/plugins/adapters/contracts/UniswapV2AdapterContract.js +3 -4
- package/dist/esm/plugins/adapters/contracts/UniswapV3AdapterContract.js +9 -5
- package/dist/esm/plugins/adapters/contracts/UniswapV4AdapterContract.js +8 -8
- package/dist/esm/plugins/adapters/contracts/UpshiftVaultAdapterContract.js +4 -5
- package/dist/esm/plugins/adapters/contracts/VelodromeV2AdapterContract.js +3 -4
- package/dist/esm/plugins/adapters/contracts/WstETHV1AdapterContract.js +4 -5
- package/dist/esm/plugins/adapters/index.js +0 -1
- package/dist/esm/preview/parse/classifyInnerOperations.js +14 -1
- package/dist/esm/preview/prerequisites/buildPrerequisites.js +4 -8
- package/dist/esm/preview/preview/previewOpenCreditAccount.js +54 -67
- package/dist/esm/preview/preview/unwrapNativeCollateral.js +11 -25
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +4 -5
- package/dist/esm/sdk/base/BaseContract.js +4 -2
- package/dist/esm/sdk/base/ChainContractsRegister.js +1 -0
- package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +0 -33
- package/dist/esm/sdk/market/rwa/securitize/SecuritizeRWAFactory.js +1 -27
- package/dist/esm/sdk/router/AbstractRouterContract.js +25 -29
- package/dist/esm/sdk/router/RouterV310Contract.js +11 -12
- package/dist/esm/sdk/router/helpers.js +0 -4
- package/dist/esm/sdk/utils/AddressMap.js +6 -0
- package/dist/esm/sdk/utils/AssetsMap.js +37 -0
- package/dist/esm/sdk/utils/index.js +1 -0
- package/dist/types/common-utils/utils/strategies/assets/assets.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/credit-managers/get-wallet-balances-allowed-on-cm.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/strategy-info/calculate-total-apy.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/strategy-info/calculate-total-points.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/tokens/add-amount-in-target.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/tokens/get-list-with-amount-in-target.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/types/strategy-earnings.d.ts +1 -1
- package/dist/types/common-utils/utils/validation/validate-balances.d.ts +1 -1
- package/dist/types/common-utils/utils/validation/validate-open-account.d.ts +1 -1
- package/dist/types/common-utils/utils/validation/validate-quota.d.ts +1 -1
- package/dist/types/common-utils/utils/validation/validate-token-to-obtain.d.ts +1 -1
- package/dist/types/plugins/adapters/contracts/AbstractAdapter.d.ts +9 -11
- package/dist/types/plugins/adapters/contracts/AbstractCurveAdapter.d.ts +18 -0
- package/dist/types/plugins/adapters/contracts/BalancerV3RouterAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/BalancerV3WrapperAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/CamelotV3AdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/ConvexV1BaseRewardPoolAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/ConvexV1BoosterAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/Curve2AssetsAdapterContract.d.ts +4 -8
- package/dist/types/plugins/adapters/contracts/Curve3AssetsAdapterContract.d.ts +4 -9
- package/dist/types/plugins/adapters/contracts/Curve4AssetsAdapterContract.d.ts +4 -8
- package/dist/types/plugins/adapters/contracts/CurveV1AdapterDeposit.d.ts +4 -5
- package/dist/types/plugins/adapters/contracts/CurveV1AdapterStETHContract.d.ts +4 -8
- package/dist/types/plugins/adapters/contracts/CurveV1StableNGAdapterContract.d.ts +4 -8
- package/dist/types/plugins/adapters/contracts/DaiUsdsAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/ERC4626AdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/ERC4626ReferralAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/FluidDexAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/InfinifiGatewayAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/KelpLRTDepositPoolAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/LidoV1AdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/MellowDVVAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/MellowERC4626VaultAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/MellowWrapperAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/PendleRouterAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/SecuritizeOnRampAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/SecuritizeSwapAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/StakingRewardsAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/TraderJoeRouterAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/UniswapV2AdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/UniswapV3AdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/UniswapV4AdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/UpshiftVaultAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/VelodromeV2AdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/WstETHV1AdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/index.d.ts +0 -1
- package/dist/types/plugins/adapters/types.d.ts +10 -0
- package/dist/types/preview/parse/types-adapters.d.ts +5 -1
- package/dist/types/preview/parse/types-facades.d.ts +23 -1
- package/dist/types/preview/preview/types.d.ts +4 -0
- package/dist/types/preview/preview/unwrapNativeCollateral.d.ts +2 -2
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -1
- package/dist/types/sdk/accounts/types.d.ts +2 -2
- package/dist/types/sdk/base/BaseContract.d.ts +1 -1
- package/dist/types/sdk/base/TokensMeta.d.ts +1 -1
- package/dist/types/sdk/base/types.d.ts +18 -0
- package/dist/types/sdk/market/credit/CreditFacadeV310BaseContract.d.ts +1 -13
- package/dist/types/sdk/market/rwa/securitize/SecuritizeRWAFactory.d.ts +1 -13
- package/dist/types/sdk/pools/types.d.ts +1 -1
- package/dist/types/sdk/router/AbstractRouterContract.d.ts +5 -5
- package/dist/types/sdk/router/helpers.d.ts +1 -2
- package/dist/types/sdk/router/types.d.ts +1 -15
- package/dist/types/sdk/utils/AddressMap.d.ts +4 -0
- package/dist/types/sdk/utils/AssetsMap.d.ts +26 -0
- package/dist/types/sdk/utils/index.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/plugins/adapters/balanceChanges.js +0 -47
- package/dist/cjs/preview/preview/extractExpectedBalanceChanges.js +0 -70
- package/dist/esm/plugins/adapters/balanceChanges.js +0 -21
- package/dist/esm/preview/preview/extractExpectedBalanceChanges.js +0 -46
- package/dist/types/plugins/adapters/balanceChanges.d.ts +0 -21
- package/dist/types/preview/preview/extractExpectedBalanceChanges.d.ts +0 -33
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Address, type DecodeFunctionDataReturnType } from "viem";
|
|
2
2
|
import { type AddressMap, type ConstructOptions } from "../../../sdk/index.js";
|
|
3
|
+
import type { DiffLeftover } from "../types.js";
|
|
3
4
|
import type { ConcreteAdapterContractOptions } from "./AbstractAdapter.js";
|
|
4
5
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
5
6
|
declare const abi: readonly [{
|
|
@@ -280,6 +281,6 @@ export declare class StakingRewardsAdapterContract extends AbstractAdapterContra
|
|
|
280
281
|
version: number;
|
|
281
282
|
contractType?: string;
|
|
282
283
|
};
|
|
283
|
-
protected
|
|
284
|
+
protected decodeDiffLeftovers(decoded: DecodeFunctionDataReturnType<abi>, balances: AddressMap<bigint>): DiffLeftover[];
|
|
284
285
|
}
|
|
285
286
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Address, type DecodeFunctionDataReturnType } from "viem";
|
|
2
2
|
import type { AddressMap, ConstructOptions } from "../../../sdk/index.js";
|
|
3
|
+
import type { DiffLeftover } from "../types.js";
|
|
3
4
|
import type { ConcreteAdapterContractOptions } from "./AbstractAdapter.js";
|
|
4
5
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
5
6
|
export declare enum TraderJoePoolVersion {
|
|
@@ -483,6 +484,6 @@ export declare class TraderJoeRouterAdapterContract extends AbstractAdapterContr
|
|
|
483
484
|
version: number;
|
|
484
485
|
contractType?: string;
|
|
485
486
|
};
|
|
486
|
-
protected
|
|
487
|
+
protected decodeDiffLeftovers(decoded: DecodeFunctionDataReturnType<abi>, balances: AddressMap<bigint>): DiffLeftover[];
|
|
487
488
|
}
|
|
488
489
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Address, type DecodeFunctionDataReturnType } from "viem";
|
|
2
2
|
import type { AddressMap, ConstructOptions, ParsedCallV2 } from "../../../sdk/index.js";
|
|
3
3
|
import type { LegacyAdapterOperation, Transfers } from "../legacyAdapterOperations.js";
|
|
4
|
+
import type { DiffLeftover } from "../types.js";
|
|
4
5
|
import type { ConcreteAdapterContractOptions } from "./AbstractAdapter.js";
|
|
5
6
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
6
7
|
declare const abi: readonly [{
|
|
@@ -965,6 +966,6 @@ export declare class UniswapV2AdapterContract extends AbstractAdapterContract<ab
|
|
|
965
966
|
protected stringifyFunctionParams(params: DecodeFunctionDataReturnType<abi>): string[];
|
|
966
967
|
/** @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type.go#L81-L91 */
|
|
967
968
|
classifyLegacyOperation(_parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
|
|
968
|
-
protected
|
|
969
|
+
protected decodeDiffLeftovers(decoded: DecodeFunctionDataReturnType<abi>, balances: AddressMap<bigint>): DiffLeftover[];
|
|
969
970
|
}
|
|
970
971
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Address, type DecodeFunctionDataReturnType } from "viem";
|
|
2
2
|
import type { AddressMap, ConstructOptions } from "../../../sdk/index.js";
|
|
3
|
+
import type { DiffLeftover } from "../types.js";
|
|
3
4
|
import type { ConcreteAdapterContractOptions } from "./AbstractAdapter.js";
|
|
4
5
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
5
6
|
declare const abi: readonly [{
|
|
@@ -556,7 +557,7 @@ export declare class UniswapV3AdapterContract extends AbstractAdapterContract<ab
|
|
|
556
557
|
version: number;
|
|
557
558
|
contractType?: string;
|
|
558
559
|
};
|
|
559
|
-
protected
|
|
560
|
+
protected decodeDiffLeftovers(decoded: DecodeFunctionDataReturnType<abi>, balances: AddressMap<bigint>): DiffLeftover[];
|
|
560
561
|
protected stringifyFunctionParams(params: DecodeFunctionDataReturnType<abi>): string[];
|
|
561
562
|
private trackInputPath;
|
|
562
563
|
private trackOutputPath;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Address, type DecodeFunctionDataReturnType } from "viem";
|
|
2
2
|
import type { AddressMap, ConstructOptions, ParsedCallV2 } from "../../../sdk/index.js";
|
|
3
3
|
import type { LegacyAdapterOperation, Transfers } from "../legacyAdapterOperations.js";
|
|
4
|
+
import type { DiffLeftover } from "../types.js";
|
|
4
5
|
import type { ConcreteAdapterContractOptions } from "./AbstractAdapter.js";
|
|
5
6
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
6
7
|
declare const abi: readonly [{
|
|
@@ -421,6 +422,6 @@ export declare class UniswapV4AdapterContract extends AbstractAdapterContract<ab
|
|
|
421
422
|
};
|
|
422
423
|
/** @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type.go#L81-L91 */
|
|
423
424
|
classifyLegacyOperation(_parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
|
|
424
|
-
protected
|
|
425
|
+
protected decodeDiffLeftovers(decoded: DecodeFunctionDataReturnType<abi>, balances: AddressMap<bigint>): DiffLeftover[];
|
|
425
426
|
}
|
|
426
427
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Address, type DecodeFunctionDataReturnType } from "viem";
|
|
2
2
|
import { type AddressMap, type ConstructOptions } from "../../../sdk/index.js";
|
|
3
|
+
import type { DiffLeftover } from "../types.js";
|
|
3
4
|
import type { ConcreteAdapterContractOptions } from "./AbstractAdapter.js";
|
|
4
5
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
5
6
|
declare const abi: readonly [{
|
|
@@ -356,6 +357,6 @@ export declare class UpshiftVaultAdapterContract extends AbstractAdapterContract
|
|
|
356
357
|
version: number;
|
|
357
358
|
contractType?: string;
|
|
358
359
|
};
|
|
359
|
-
protected
|
|
360
|
+
protected decodeDiffLeftovers(decoded: DecodeFunctionDataReturnType<abi>, balances: AddressMap<bigint>): DiffLeftover[];
|
|
360
361
|
}
|
|
361
362
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Address, type DecodeFunctionDataReturnType } from "viem";
|
|
2
2
|
import type { AddressMap, ConstructOptions } from "../../../sdk/index.js";
|
|
3
|
+
import type { DiffLeftover } from "../types.js";
|
|
3
4
|
import type { ConcreteAdapterContractOptions } from "./AbstractAdapter.js";
|
|
4
5
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
5
6
|
declare const abi: readonly [{
|
|
@@ -361,6 +362,6 @@ export declare class VelodromeV2RouterAdapterContract extends AbstractAdapterCon
|
|
|
361
362
|
version: number;
|
|
362
363
|
contractType?: string;
|
|
363
364
|
};
|
|
364
|
-
protected
|
|
365
|
+
protected decodeDiffLeftovers(decoded: DecodeFunctionDataReturnType<abi>, balances: AddressMap<bigint>): DiffLeftover[];
|
|
365
366
|
}
|
|
366
367
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Address, type DecodeFunctionDataReturnType } from "viem";
|
|
2
2
|
import { type AddressMap, type ConstructOptions, type ParsedCallV2 } from "../../../sdk/index.js";
|
|
3
3
|
import type { LegacyAdapterOperation, Transfers } from "../legacyAdapterOperations.js";
|
|
4
|
+
import type { DiffLeftover } from "../types.js";
|
|
4
5
|
import type { ConcreteAdapterContractOptions } from "./AbstractAdapter.js";
|
|
5
6
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
6
7
|
declare const abi: readonly [{
|
|
@@ -393,6 +394,6 @@ export declare class WstETHV1AdapterContract extends AbstractAdapterContract<abi
|
|
|
393
394
|
};
|
|
394
395
|
/** @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type.go#L264-L275 */
|
|
395
396
|
classifyLegacyOperation(parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
|
|
396
|
-
protected
|
|
397
|
+
protected decodeDiffLeftovers(decoded: DecodeFunctionDataReturnType<abi>, balances: AddressMap<bigint>): DiffLeftover[];
|
|
397
398
|
}
|
|
398
399
|
export {};
|
|
@@ -51,6 +51,16 @@ export declare enum AdapterType {
|
|
|
51
51
|
VELODROME_V2_ROUTER = "VELODROME_V2_ROUTER",
|
|
52
52
|
YEARN_V2 = "YEARN_V2"
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Diff-call semantics of a diff-style adapter call: the call spends the
|
|
56
|
+
* consumed token down to the exact `leftoverAmount` encoded in its calldata,
|
|
57
|
+
* so the post-call balance of `tokenIn` is `leftoverAmount` regardless of the
|
|
58
|
+
* actual amount spent.
|
|
59
|
+
*/
|
|
60
|
+
export interface DiffLeftover {
|
|
61
|
+
tokenIn: Address;
|
|
62
|
+
leftoverAmount: bigint;
|
|
63
|
+
}
|
|
54
64
|
export interface AdapterContractStateHuman extends BaseContractStateHuman {
|
|
55
65
|
creditManager?: string;
|
|
56
66
|
targetContract?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Address } from "viem";
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
2
|
import type { AdapterProtocolOperation } from "../../plugins/adapters/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* A single ERC-20 Transfer event captured between Execute boundaries.
|
|
@@ -43,6 +43,10 @@ export interface AdapterOperationBase {
|
|
|
43
43
|
* Arguments of adapter contract
|
|
44
44
|
*/
|
|
45
45
|
adapterArgs: Record<string, unknown>;
|
|
46
|
+
/**
|
|
47
|
+
* Raw ABI-encoded adapter calldata
|
|
48
|
+
*/
|
|
49
|
+
calldata: Hex;
|
|
46
50
|
}
|
|
47
51
|
/**
|
|
48
52
|
* Adapter `Execute` operation, generic over the extra data added by consumers.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Address, Hex } from "viem";
|
|
2
|
+
import type { Asset } from "../../sdk/index.js";
|
|
2
3
|
import type { AdapterOperation } from "./types-adapters.js";
|
|
3
4
|
/**
|
|
4
5
|
* Increase debt (borrow more).
|
|
@@ -46,11 +47,32 @@ export interface UpdateQuotaOp {
|
|
|
46
47
|
token: Address;
|
|
47
48
|
change: bigint;
|
|
48
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Router-generated slippage-control call that declares expected minimal
|
|
52
|
+
* balance changes for the adapter calls that follow, up to the matching
|
|
53
|
+
* {@link CompareBalancesOp}.
|
|
54
|
+
*/
|
|
55
|
+
export interface StoreExpectedBalancesOp {
|
|
56
|
+
operation: "StoreExpectedBalances";
|
|
57
|
+
/**
|
|
58
|
+
* Declared minimal balance changes (relative to balances at
|
|
59
|
+
* `storeExpectedBalances` time).
|
|
60
|
+
*/
|
|
61
|
+
deltas: Asset[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Router-generated slippage-control call that validates the balance changes
|
|
65
|
+
* declared by the preceding {@link StoreExpectedBalancesOp}. Pure validation
|
|
66
|
+
* marker, carries no data.
|
|
67
|
+
*/
|
|
68
|
+
export interface CompareBalancesOp {
|
|
69
|
+
operation: "CompareBalances";
|
|
70
|
+
}
|
|
49
71
|
/**
|
|
50
72
|
* Union of facade inner-call operation types (non-adapter credit account operations).
|
|
51
73
|
* Discriminated on the `operation` field.
|
|
52
74
|
*/
|
|
53
|
-
export type InnerFacadeOperation = IncreaseDebtOp | DecreaseDebtOp | AddCollateralOp | WithdrawCollateralOp | UpdateQuotaOp;
|
|
75
|
+
export type InnerFacadeOperation = IncreaseDebtOp | DecreaseDebtOp | AddCollateralOp | WithdrawCollateralOp | UpdateQuotaOp | StoreExpectedBalancesOp | CompareBalancesOp;
|
|
54
76
|
/**
|
|
55
77
|
* All operations that can happen within a CreditFacade's multicall and that we're interested in.
|
|
56
78
|
*
|
|
@@ -69,6 +69,10 @@ export interface PoolOperationPreview {
|
|
|
69
69
|
}
|
|
70
70
|
export interface OpenCreditAccountPreview {
|
|
71
71
|
operation: "OpenCreditAccount" | "SecuritizeOpenCreditAccount";
|
|
72
|
+
/**
|
|
73
|
+
* Credit manager the account is opened in
|
|
74
|
+
*/
|
|
75
|
+
creditManager: Address;
|
|
72
76
|
/**
|
|
73
77
|
* Target token of strategy: the first quoted token, with its balance taken
|
|
74
78
|
* from `assets`. Undefined when nothing is quoted.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Address } from "viem";
|
|
2
2
|
import { type Asset } from "../../sdk/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Represents the transaction's attached native value as a `NATIVE_ADDRESS`
|
|
@@ -8,7 +8,7 @@ import { type Asset } from "../../sdk/index.js";
|
|
|
8
8
|
* pulls it, so the WETH collateral amount already includes the attached native
|
|
9
9
|
* value. This helper splits the WETH entry back: the native amount is shown as
|
|
10
10
|
* `NATIVE_ADDRESS` and the WETH entry is reduced accordingly (dropped when it
|
|
11
|
-
* reaches zero). Other entries
|
|
11
|
+
* reaches zero). Other entries are preserved.
|
|
12
12
|
*
|
|
13
13
|
* @param collateral - Collateral assets as declared by the multicall.
|
|
14
14
|
* @param nativeAmount - Transaction `msg.value`.
|
|
@@ -4,7 +4,7 @@ import { SDKConstruct } from "../base/index.js";
|
|
|
4
4
|
import { type PriceUpdate } from "../market/index.js";
|
|
5
5
|
import type { RWAOpenAccountRequirements } from "../market/rwa/index.js";
|
|
6
6
|
import type { OnchainSDK } from "../OnchainSDK.js";
|
|
7
|
-
import {
|
|
7
|
+
import type { RouterCASlice } from "../router/index.js";
|
|
8
8
|
import type { MultiCall, RawTx } from "../types/index.js";
|
|
9
9
|
import type { AccountToCheck, AddCollateralProps, AssembleCaUpdateCallsProps, ChangeDeptProps, ClaimDelayedProps, ClaimFarmRewardsProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, CreditAccountTokensSlice, CreditManagerOperationResult, DefaultPartialLiquidationParams, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, ICreditAccountsService, OpenCAProps, PartiallyLiquidateProps, PreviewDelayedWithdrawalProps, PreviewDelayedWithdrawalResult, RepayAndLiquidateCreditAccountProps, RepayCreditAccountProps, Rewards, SetBotProps, StartDelayedWithdrawalProps, UpdateQuotasProps, WithdrawCollateralProps } from "./types.js";
|
|
10
10
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Address, ContractFunctionArgs, GetContractReturnType, Hex, PublicClient } from "viem";
|
|
2
2
|
import type { creditAccountCompressorAbi } from "../../abi/compressors/creditAccountCompressor.js";
|
|
3
3
|
import type { iWithdrawalCompressorV310Abi } from "../../abi/IWithdrawalCompressorV310.js";
|
|
4
|
-
import type { ConnectedBotData, Construct, CreditAccountData } from "../base/index.js";
|
|
4
|
+
import type { Asset, ConnectedBotData, Construct, CreditAccountData } from "../base/index.js";
|
|
5
5
|
import type { CreditSuite, PriceUpdate, RWAOperationParams } from "../market/index.js";
|
|
6
6
|
import type { RWAOpenAccountRequirements } from "../market/rwa/index.js";
|
|
7
7
|
import type { OnchainSDK } from "../OnchainSDK.js";
|
|
8
|
-
import type {
|
|
8
|
+
import type { RouterCASlice, RouterCloseResult } from "../router/index.js";
|
|
9
9
|
import type { MultiCall, RawTx } from "../types/index.js";
|
|
10
10
|
/**
|
|
11
11
|
* @internal
|
|
@@ -151,7 +151,7 @@ export declare class BaseContract<abi extends Abi | readonly unknown[]> extends
|
|
|
151
151
|
* @param strict - propagated from parseFunctionDataV2 for recursive parsing
|
|
152
152
|
*/
|
|
153
153
|
protected parseFunctionParamsV2(params: DecodeFunctionDataReturnType<abi>, _strict?: boolean): Record<string, unknown>;
|
|
154
|
-
protected wrapParseCallV2(functionName: string, rawArgs: Record<string, unknown>): ParsedCallV2;
|
|
154
|
+
protected wrapParseCallV2(functionName: string, calldata: Hex, rawArgs: Record<string, unknown>): ParsedCallV2;
|
|
155
155
|
/**
|
|
156
156
|
* Creates a raw transaction for a function in this contract
|
|
157
157
|
* @param parameters
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Address, Chain, PublicClient, Transport } from "viem";
|
|
2
|
-
import type { Asset } from "../
|
|
2
|
+
import type { Asset } from "../index.js";
|
|
3
3
|
import type { ILogger } from "../types/logger.js";
|
|
4
4
|
import { AddressMap } from "../utils/index.js";
|
|
5
5
|
import type { PhantomTokenMeta, RWATokenMeta, TokenMetaData } from "./token-types.js";
|
|
@@ -87,6 +87,20 @@ export interface TokenInfo {
|
|
|
87
87
|
**/
|
|
88
88
|
success: boolean;
|
|
89
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* A token address paired with a balance, used throughout the SDK to
|
|
92
|
+
* represent holdings, collateral inputs, and leftover targets.
|
|
93
|
+
**/
|
|
94
|
+
export interface Asset {
|
|
95
|
+
/**
|
|
96
|
+
* ERC-20 token address.
|
|
97
|
+
**/
|
|
98
|
+
token: Address;
|
|
99
|
+
/**
|
|
100
|
+
* Token amount in the token's native decimals.
|
|
101
|
+
**/
|
|
102
|
+
balance: bigint;
|
|
103
|
+
}
|
|
90
104
|
/**
|
|
91
105
|
* Compile-time assertion: `U` must be assignable to `T`.
|
|
92
106
|
*
|
|
@@ -337,6 +351,10 @@ export interface ParsedCallV2 {
|
|
|
337
351
|
* For unknown selectors: `"unknown function 0x1a2b3c4d"`
|
|
338
352
|
*/
|
|
339
353
|
functionName: string;
|
|
354
|
+
/**
|
|
355
|
+
* Raw ABI-encoded calldata this call was parsed from.
|
|
356
|
+
**/
|
|
357
|
+
calldata: Hex;
|
|
340
358
|
/**
|
|
341
359
|
* Named arguments with their original types (bigint, Address, etc.).
|
|
342
360
|
**/
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DecodeFunctionDataReturnType } from "viem";
|
|
2
2
|
import type { BaseContractArgs, ConstructOptions } from "../../base/index.js";
|
|
3
3
|
import { BaseContract } from "../../base/index.js";
|
|
4
|
-
import type { MultiCall } from "../../types/index.js";
|
|
5
4
|
declare const abi: readonly [{
|
|
6
5
|
readonly type: "function";
|
|
7
6
|
readonly inputs: readonly [];
|
|
@@ -852,17 +851,6 @@ export { abi as creditFacadeV310Abi };
|
|
|
852
851
|
*/
|
|
853
852
|
export declare class CreditFacadeV310BaseContract extends BaseContract<abi> {
|
|
854
853
|
constructor(options: ConstructOptions, args: Omit<BaseContractArgs<abi>, "abi">);
|
|
855
|
-
/**
|
|
856
|
-
* Decodes entry-point calldata with the facade ABI and returns the untouched
|
|
857
|
-
* inner multicall structs (targets with still-ABI-encoded `callData`).
|
|
858
|
-
*
|
|
859
|
-
* Unlike {@link ChainContractsRegister.parseMultiCallV2}, the inner calls are
|
|
860
|
-
* not decoded, so callers can re-decode them with a specific contract's ABI.
|
|
861
|
-
*
|
|
862
|
-
* @throws When the calldata cannot be decoded or the function has no inner
|
|
863
|
-
* multicall argument.
|
|
864
|
-
*/
|
|
865
|
-
extractRawInnerCalls(calldata: Hex): MultiCall[];
|
|
866
854
|
protected parseFunctionParamsV2(params: DecodeFunctionDataReturnType<abi>, strict?: boolean): Record<string, unknown>;
|
|
867
855
|
protected stringifyFunctionParams(params: DecodeFunctionDataReturnType<abi>): string[];
|
|
868
856
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Address, type DecodeFunctionDataReturnType
|
|
1
|
+
import { type Address, type DecodeFunctionDataReturnType } from "viem";
|
|
2
2
|
import type { GetOpenAccountRequirementsProps } from "../../../accounts/types.js";
|
|
3
3
|
import { BaseContract } from "../../../base/index.js";
|
|
4
4
|
import type { OnchainSDK } from "../../../OnchainSDK.js";
|
|
@@ -463,18 +463,6 @@ export declare class SecuritizeRWAFactory extends BaseContract<abi> implements I
|
|
|
463
463
|
readonly dsTokens: DStokenData[];
|
|
464
464
|
readonly contractType = "RWA_FACTORY::SECURITIZE";
|
|
465
465
|
constructor(sdk: OnchainSDK, data: RWAFactoryData);
|
|
466
|
-
/**
|
|
467
|
-
* Decodes entry-point calldata with the factory ABI and returns the
|
|
468
|
-
* untouched inner multicall structs (targets with still-ABI-encoded
|
|
469
|
-
* `callData`).
|
|
470
|
-
*
|
|
471
|
-
* Unlike {@link ChainContractsRegister.parseMultiCallV2}, the inner calls are
|
|
472
|
-
* not decoded, so callers can re-decode them with a specific contract's ABI.
|
|
473
|
-
*
|
|
474
|
-
* @throws When the calldata cannot be decoded or the function has no inner
|
|
475
|
-
* multicall argument.
|
|
476
|
-
*/
|
|
477
|
-
extractRawInnerCalls(calldata: Hex): MultiCall[];
|
|
478
466
|
protected parseFunctionParamsV2(params: DecodeFunctionDataReturnType<abi>, strict?: boolean): Record<string, unknown>;
|
|
479
467
|
/**
|
|
480
468
|
* {@inheritDoc IRWAFactory.decodeInvestorData}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Abi, Address, ContractFunctionArgs, ContractFunctionName } from "viem";
|
|
2
|
+
import type { Asset } from "../base/index.js";
|
|
2
3
|
import type { IZapperContract } from "../market/index.js";
|
|
3
|
-
import type { Asset } from "../router/index.js";
|
|
4
4
|
import type { MultiCall, RawTx } from "../types/transactions.js";
|
|
5
5
|
interface PermitResult {
|
|
6
6
|
r: Address;
|
|
@@ -2,17 +2,17 @@ import type { Abi, Address } from "viem";
|
|
|
2
2
|
import { BaseContract, type BaseContractArgs } from "../base/index.js";
|
|
3
3
|
import type { IPriceOracleContract } from "../market/index.js";
|
|
4
4
|
import type { OnchainSDK } from "../OnchainSDK.js";
|
|
5
|
-
import {
|
|
6
|
-
import type {
|
|
5
|
+
import { AddressSet, AssetsMap } from "../utils/index.js";
|
|
6
|
+
import type { RouterCASlice, RouterCMSlice } from "./types.js";
|
|
7
7
|
export interface ExpectedAndLeftoverOptions {
|
|
8
8
|
balances?: Leftovers;
|
|
9
9
|
keepAssets?: Address[];
|
|
10
10
|
debtOnly?: boolean;
|
|
11
11
|
}
|
|
12
12
|
export interface Leftovers {
|
|
13
|
-
expectedBalances:
|
|
14
|
-
leftoverBalances:
|
|
15
|
-
tokensToClaim:
|
|
13
|
+
expectedBalances: AssetsMap;
|
|
14
|
+
leftoverBalances: AssetsMap;
|
|
15
|
+
tokensToClaim: AssetsMap;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* @internal
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
+
import type { Asset } from "../base/types.js";
|
|
2
3
|
import { AddressMap } from "../utils/index.js";
|
|
3
|
-
import type { Asset } from "./types.js";
|
|
4
|
-
export declare function balancesMap(assets: Array<Asset>): AddressMap<bigint>;
|
|
5
4
|
export declare function assetsMap<T extends Asset>(assets: Array<T> | readonly T[]): AddressMap<T>;
|
|
6
5
|
/**
|
|
7
6
|
* TODO: is this weird workaround still needed?
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
-
import type { CreditAccountData, IBaseContract } from "../base/index.js";
|
|
2
|
+
import type { Asset, CreditAccountData, IBaseContract } from "../base/index.js";
|
|
3
3
|
import type { MultiCall } from "../types/index.js";
|
|
4
4
|
/**
|
|
5
5
|
* Type of swap the router should perform.
|
|
@@ -65,20 +65,6 @@ export interface RouterCloseResult extends RouterResult {
|
|
|
65
65
|
*/
|
|
66
66
|
underlyingBalance: bigint;
|
|
67
67
|
}
|
|
68
|
-
/**
|
|
69
|
-
* A token address paired with a balance, used throughout the router to
|
|
70
|
-
* represent holdings, collateral inputs, and leftover targets.
|
|
71
|
-
**/
|
|
72
|
-
export interface Asset {
|
|
73
|
-
/**
|
|
74
|
-
* ERC-20 token address.
|
|
75
|
-
**/
|
|
76
|
-
token: Address;
|
|
77
|
-
/**
|
|
78
|
-
* Token amount in the token's native decimals.
|
|
79
|
-
**/
|
|
80
|
-
balance: bigint;
|
|
81
|
-
}
|
|
82
68
|
/**
|
|
83
69
|
* Slice of credit manager data required for router operations
|
|
84
70
|
*/
|
|
@@ -66,6 +66,10 @@ export declare class AddressMap<T> {
|
|
|
66
66
|
* Returns all checksummed addresses in insertion order.
|
|
67
67
|
**/
|
|
68
68
|
keys(): Address[];
|
|
69
|
+
/**
|
|
70
|
+
* Returns an unfrozen shallow copy of the map.
|
|
71
|
+
**/
|
|
72
|
+
clone(): AddressMap<T>;
|
|
69
73
|
/**
|
|
70
74
|
* Converts the map to a plain `Record<Address, T>` object.
|
|
71
75
|
**/
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Asset } from "../base/types.js";
|
|
2
|
+
import { AddressMap } from "./AddressMap.js";
|
|
3
|
+
/**
|
|
4
|
+
* Case-insensitive map from EVM token addresses to bigint balances.
|
|
5
|
+
* Missing keys are treated as `0n`.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AssetsMap extends AddressMap<bigint> {
|
|
8
|
+
/**
|
|
9
|
+
* @param entries - Optional initial entries as `[address, balance]` tuples or {@link Asset} objects.
|
|
10
|
+
* @param name - Optional label used in error messages when a lookup fails.
|
|
11
|
+
*/
|
|
12
|
+
constructor(entries?: Array<[string, bigint] | Asset>, name?: string);
|
|
13
|
+
/**
|
|
14
|
+
* Adds `amount` to the token balance, treating a missing key as `0n`.
|
|
15
|
+
*/
|
|
16
|
+
inc(address: string, amount: bigint): void;
|
|
17
|
+
/**
|
|
18
|
+
* Subtracts `amount` from the token balance, treating a missing key as `0n`.
|
|
19
|
+
*/
|
|
20
|
+
dec(address: string, amount: bigint): void;
|
|
21
|
+
/**
|
|
22
|
+
* Converts the map to an array of {@link Asset} objects.
|
|
23
|
+
*/
|
|
24
|
+
toAssets(): Asset[];
|
|
25
|
+
clone(): AssetsMap;
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
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
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var balanceChanges_exports = {};
|
|
20
|
-
__export(balanceChanges_exports, {
|
|
21
|
-
clampToLeftover: () => clampToLeftover,
|
|
22
|
-
copyBalances: () => copyBalances,
|
|
23
|
-
curveCoin: () => curveCoin
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(balanceChanges_exports);
|
|
26
|
-
var import_sdk = require("../../sdk/index.js");
|
|
27
|
-
function copyBalances(balances) {
|
|
28
|
-
return new import_sdk.AddressMap(balances.entries());
|
|
29
|
-
}
|
|
30
|
-
function clampToLeftover(balances, tokenIn, leftoverAmount) {
|
|
31
|
-
const next = copyBalances(balances);
|
|
32
|
-
next.upsert(tokenIn, leftoverAmount);
|
|
33
|
-
return next;
|
|
34
|
-
}
|
|
35
|
-
function curveCoin(tokens, i) {
|
|
36
|
-
const token = tokens[Number(i)];
|
|
37
|
-
if (!token) {
|
|
38
|
-
throw new Error(`curve coin index ${i} is out of range`);
|
|
39
|
-
}
|
|
40
|
-
return token;
|
|
41
|
-
}
|
|
42
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
-
0 && (module.exports = {
|
|
44
|
-
clampToLeftover,
|
|
45
|
-
copyBalances,
|
|
46
|
-
curveCoin
|
|
47
|
-
});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
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
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var extractExpectedBalanceChanges_exports = {};
|
|
20
|
-
__export(extractExpectedBalanceChanges_exports, {
|
|
21
|
-
extractExpectedBalanceChanges: () => extractExpectedBalanceChanges
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(extractExpectedBalanceChanges_exports);
|
|
24
|
-
function extractExpectedBalanceChanges(innerCalls) {
|
|
25
|
-
const storeIndices = [];
|
|
26
|
-
const compareIndices = [];
|
|
27
|
-
for (let i = 0; i < innerCalls.length; i++) {
|
|
28
|
-
const name = functionName(innerCalls[i]);
|
|
29
|
-
if (name === "storeExpectedBalances") {
|
|
30
|
-
storeIndices.push(i);
|
|
31
|
-
} else if (name === "compareBalances") {
|
|
32
|
-
compareIndices.push(i);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (storeIndices.length === 0 && compareIndices.length === 0) {
|
|
36
|
-
return void 0;
|
|
37
|
-
}
|
|
38
|
-
if (storeIndices.length !== 1 || compareIndices.length !== 1) {
|
|
39
|
-
throw new Error(
|
|
40
|
-
`malformed multicall: expected exactly one storeExpectedBalances/compareBalances pair, got ${storeIndices.length} storeExpectedBalances and ${compareIndices.length} compareBalances calls`
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
if (compareIndices[0] < storeIndices[0]) {
|
|
44
|
-
throw new Error(
|
|
45
|
-
"malformed multicall: compareBalances appears before storeExpectedBalances"
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
const store = innerCalls[storeIndices[0]];
|
|
49
|
-
const balanceDeltas = store.rawArgs.balanceDeltas;
|
|
50
|
-
if (!balanceDeltas) {
|
|
51
|
-
throw new Error(
|
|
52
|
-
"malformed multicall: storeExpectedBalances has no balanceDeltas argument"
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
deltas: balanceDeltas.map(({ token, amount }) => ({
|
|
57
|
-
token,
|
|
58
|
-
balance: amount
|
|
59
|
-
})),
|
|
60
|
-
startIndex: storeIndices[0],
|
|
61
|
-
endIndex: compareIndices[0]
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
function functionName(call) {
|
|
65
|
-
return call.functionName.split("(")[0];
|
|
66
|
-
}
|
|
67
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
-
0 && (module.exports = {
|
|
69
|
-
extractExpectedBalanceChanges
|
|
70
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { AddressMap } from "../../sdk/index.js";
|
|
2
|
-
function copyBalances(balances) {
|
|
3
|
-
return new AddressMap(balances.entries());
|
|
4
|
-
}
|
|
5
|
-
function clampToLeftover(balances, tokenIn, leftoverAmount) {
|
|
6
|
-
const next = copyBalances(balances);
|
|
7
|
-
next.upsert(tokenIn, leftoverAmount);
|
|
8
|
-
return next;
|
|
9
|
-
}
|
|
10
|
-
function curveCoin(tokens, i) {
|
|
11
|
-
const token = tokens[Number(i)];
|
|
12
|
-
if (!token) {
|
|
13
|
-
throw new Error(`curve coin index ${i} is out of range`);
|
|
14
|
-
}
|
|
15
|
-
return token;
|
|
16
|
-
}
|
|
17
|
-
export {
|
|
18
|
-
clampToLeftover,
|
|
19
|
-
copyBalances,
|
|
20
|
-
curveCoin
|
|
21
|
-
};
|