@defisaver/automation-sdk 3.3.10-aave-v4-3-dev → 3.3.10-aave-v4-5-dev
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/cjs/constants/index.d.ts +1 -0
- package/cjs/constants/index.js +2 -1
- package/cjs/services/strategySubService.test.js +4 -4
- package/cjs/services/subDataService.js +18 -1
- package/cjs/services/subDataService.test.js +8 -8
- package/esm/constants/index.d.ts +1 -0
- package/esm/constants/index.js +1 -0
- package/esm/services/strategySubService.test.js +4 -4
- package/esm/services/subDataService.js +19 -2
- package/esm/services/subDataService.test.js +8 -8
- package/package.json +2 -2
- package/src/constants/index.ts +2 -0
- package/src/services/strategySubService.test.ts +4 -4
- package/src/services/subDataService.test.ts +8 -8
- package/src/services/subDataService.ts +19 -2
package/cjs/constants/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ArbitrumBundleInfo, ArbitrumStrategiesInfo, BundlesInfo, EthereumAddress, Interfaces, MainnetBundleInfo, MainnetStrategiesInfo, OptimismBundleInfo, OptimismStrategiesInfo, BaseBundleInfo, BaseStrategiesInfo, StrategiesInfo } from '../types';
|
|
2
2
|
import { ProtocolIdentifiers, Strategies, Bundles } from '../types/enums';
|
|
3
3
|
export declare const ZERO_ADDRESS: EthereumAddress;
|
|
4
|
+
export declare const EMPTY_SLOT: string;
|
|
4
5
|
export declare const AAVE_V3_VARIABLE_BORROW_RATE = 2;
|
|
5
6
|
export declare const PROTOCOLS: Record<keyof typeof ProtocolIdentifiers.StrategiesAutomation, Interfaces.Protocol>;
|
|
6
7
|
export declare const LEGACY_PROTOCOLS: Record<keyof typeof ProtocolIdentifiers.LegacyAutomation, Interfaces.LegacyProtocol>;
|
package/cjs/constants/index.js
CHANGED
|
@@ -3,12 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.BUNDLE_IDS = exports.BUNDLES_INFO = exports.ARBITRUM_BUNDLES_INFO = exports.BASE_BUNDLES_INFO = exports.OPTIMISM_BUNDLES_INFO = exports.MAINNET_BUNDLES_INFO = exports.STRATEGY_IDS = exports.STRATEGIES_INFO = exports.ARBITRUM_STRATEGIES_INFO = exports.BASE_STRATEGIES_INFO = exports.OPTIMISM_STRATEGIES_INFO = exports.MAINNET_STRATEGIES_INFO = exports.LEGACY_PROTOCOLS = exports.PROTOCOLS = exports.AAVE_V3_VARIABLE_BORROW_RATE = exports.ZERO_ADDRESS = void 0;
|
|
6
|
+
exports.BUNDLE_IDS = exports.BUNDLES_INFO = exports.ARBITRUM_BUNDLES_INFO = exports.BASE_BUNDLES_INFO = exports.OPTIMISM_BUNDLES_INFO = exports.MAINNET_BUNDLES_INFO = exports.STRATEGY_IDS = exports.STRATEGIES_INFO = exports.ARBITRUM_STRATEGIES_INFO = exports.BASE_STRATEGIES_INFO = exports.OPTIMISM_STRATEGIES_INFO = exports.MAINNET_STRATEGIES_INFO = exports.LEGACY_PROTOCOLS = exports.PROTOCOLS = exports.AAVE_V3_VARIABLE_BORROW_RATE = exports.EMPTY_SLOT = exports.ZERO_ADDRESS = void 0;
|
|
7
7
|
const enums_1 = require("../types/enums");
|
|
8
8
|
const Protocol_1 = __importDefault(require("../automation/private/Protocol"));
|
|
9
9
|
const LegacyProtocol_1 = __importDefault(require("../automation/private/LegacyProtocol"));
|
|
10
10
|
// General
|
|
11
11
|
exports.ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
12
|
+
exports.EMPTY_SLOT = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
|
12
13
|
exports.AAVE_V3_VARIABLE_BORROW_RATE = 2;
|
|
13
14
|
exports.PROTOCOLS = (() => {
|
|
14
15
|
const protocolsMapping = {};
|
|
@@ -1618,7 +1618,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1618
1618
|
describe('leverageManagement()', () => {
|
|
1619
1619
|
const examples = [
|
|
1620
1620
|
[
|
|
1621
|
-
[1, true, ["0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000001"], ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x00000000000000000000000000000000000000000000000014d1120d7b160000"]],
|
|
1621
|
+
[1, true, ["0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000001"], ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x00000000000000000000000000000000000000000000000014d1120d7b160000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"]],
|
|
1622
1622
|
[
|
|
1623
1623
|
1,
|
|
1624
1624
|
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
@@ -1638,7 +1638,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1638
1638
|
describe('leverageManagementOnPrice()', () => {
|
|
1639
1639
|
const examples = [
|
|
1640
1640
|
[
|
|
1641
|
-
[2, true, ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000000000000000"], ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x00000000000000000000000000000000000000000000000016345785d8a00000"]],
|
|
1641
|
+
[2, true, ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000000000000000"], ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x00000000000000000000000000000000000000000000000016345785d8a00000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"]],
|
|
1642
1642
|
[
|
|
1643
1643
|
2,
|
|
1644
1644
|
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
@@ -1663,7 +1663,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1663
1663
|
describe('closeOnPrice()', () => {
|
|
1664
1664
|
const examples = [
|
|
1665
1665
|
[
|
|
1666
|
-
[3, true, ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000002098a678000000000000000000000000000000000000000000000000000000000000000000"], ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000003"]],
|
|
1666
|
+
[3, true, ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000002098a678000000000000000000000000000000000000000000000000000000000000000000"], ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000003", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"]],
|
|
1667
1667
|
[
|
|
1668
1668
|
3,
|
|
1669
1669
|
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
@@ -1688,7 +1688,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1688
1688
|
describe('collateralSwitch()', () => {
|
|
1689
1689
|
const examples = [
|
|
1690
1690
|
[
|
|
1691
|
-
[4, false, ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000000000000001"], ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"]],
|
|
1691
|
+
[4, false, ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000000000000001"], ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"]],
|
|
1692
1692
|
[
|
|
1693
1693
|
4,
|
|
1694
1694
|
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
@@ -599,7 +599,15 @@ exports.aaveV4LeverageManagementSubData = {
|
|
|
599
599
|
const ownerEncoded = web3_eth_abi_1.default.encodeParameter('address', owner);
|
|
600
600
|
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
601
601
|
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
602
|
-
|
|
602
|
+
// Add two empty slots for future addons (e.g tsi or slippage settings)
|
|
603
|
+
return [
|
|
604
|
+
spokeEncoded,
|
|
605
|
+
ownerEncoded,
|
|
606
|
+
ratioStateEncoded,
|
|
607
|
+
targetRatioEncoded,
|
|
608
|
+
constants_1.EMPTY_SLOT,
|
|
609
|
+
constants_1.EMPTY_SLOT,
|
|
610
|
+
];
|
|
603
611
|
},
|
|
604
612
|
decode: (subData) => {
|
|
605
613
|
const spoke = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
@@ -621,6 +629,7 @@ exports.aaveV4LeverageManagementOnPriceSubData = {
|
|
|
621
629
|
const debtAssetIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', debtAssetId);
|
|
622
630
|
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
623
631
|
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
632
|
+
// Add two empty slots for future addons (e.g tsi or slippage settings)
|
|
624
633
|
return [
|
|
625
634
|
spokeEncoded,
|
|
626
635
|
ownerEncoded,
|
|
@@ -630,6 +639,8 @@ exports.aaveV4LeverageManagementOnPriceSubData = {
|
|
|
630
639
|
debtAssetIdEncoded,
|
|
631
640
|
ratioStateEncoded,
|
|
632
641
|
targetRatioEncoded,
|
|
642
|
+
constants_1.EMPTY_SLOT,
|
|
643
|
+
constants_1.EMPTY_SLOT,
|
|
633
644
|
];
|
|
634
645
|
},
|
|
635
646
|
decode: (subData) => {
|
|
@@ -655,6 +666,7 @@ exports.aaveV4CloseSubData = {
|
|
|
655
666
|
const debtAssetEncoded = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
656
667
|
const debtAssetIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', debtAssetId);
|
|
657
668
|
const closeTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
669
|
+
// Add two empty slots for future addons (e.g tsi or slippage settings)
|
|
658
670
|
return [
|
|
659
671
|
spokeEncoded,
|
|
660
672
|
ownerEncoded,
|
|
@@ -663,6 +675,8 @@ exports.aaveV4CloseSubData = {
|
|
|
663
675
|
debtAssetEncoded,
|
|
664
676
|
debtAssetIdEncoded,
|
|
665
677
|
closeTypeEncoded,
|
|
678
|
+
constants_1.EMPTY_SLOT,
|
|
679
|
+
constants_1.EMPTY_SLOT,
|
|
666
680
|
];
|
|
667
681
|
},
|
|
668
682
|
decode: (subData) => {
|
|
@@ -687,6 +701,7 @@ exports.aaveV4CollateralSwitchSubData = {
|
|
|
687
701
|
const toAssetEncoded = web3_eth_abi_1.default.encodeParameter('address', toAsset);
|
|
688
702
|
const toAssetIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', toAssetId);
|
|
689
703
|
const amountToSwitchEncoded = web3_eth_abi_1.default.encodeParameter('uint256', amountToSwitch);
|
|
704
|
+
// Add two empty slots for future addons (e.g tsi or slippage settings)
|
|
690
705
|
return [
|
|
691
706
|
spokeEncoded,
|
|
692
707
|
ownerEncoded,
|
|
@@ -695,6 +710,8 @@ exports.aaveV4CollateralSwitchSubData = {
|
|
|
695
710
|
toAssetEncoded,
|
|
696
711
|
toAssetIdEncoded,
|
|
697
712
|
amountToSwitchEncoded,
|
|
713
|
+
constants_1.EMPTY_SLOT,
|
|
714
|
+
constants_1.EMPTY_SLOT,
|
|
698
715
|
];
|
|
699
716
|
},
|
|
700
717
|
decode: (subData) => {
|
|
@@ -2150,7 +2150,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2150
2150
|
describe('encode()', () => {
|
|
2151
2151
|
const examples = [
|
|
2152
2152
|
[
|
|
2153
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x00000000000000000000000000000000000000000000000014d1120d7b160000"],
|
|
2153
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x00000000000000000000000000000000000000000000000014d1120d7b160000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2154
2154
|
[web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), enums_1.RatioState.UNDER, 150]
|
|
2155
2155
|
],
|
|
2156
2156
|
];
|
|
@@ -2169,7 +2169,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2169
2169
|
ratioState: enums_1.RatioState.UNDER,
|
|
2170
2170
|
targetRatio: 150,
|
|
2171
2171
|
},
|
|
2172
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x00000000000000000000000000000000000000000000000014d1120d7b160000"],
|
|
2172
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x00000000000000000000000000000000000000000000000014d1120d7b160000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2173
2173
|
],
|
|
2174
2174
|
];
|
|
2175
2175
|
examples.forEach(([expected, actual]) => {
|
|
@@ -2183,7 +2183,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2183
2183
|
describe('encode()', () => {
|
|
2184
2184
|
const examples = [
|
|
2185
2185
|
[
|
|
2186
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x00000000000000000000000000000000000000000000000016345785d8a00000"],
|
|
2186
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x00000000000000000000000000000000000000000000000016345785d8a00000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2187
2187
|
[
|
|
2188
2188
|
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2189
2189
|
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
|
|
@@ -2211,7 +2211,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2211
2211
|
ratioState: enums_1.RatioState.OVER,
|
|
2212
2212
|
targetRatio: 160,
|
|
2213
2213
|
},
|
|
2214
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x00000000000000000000000000000000000000000000000016345785d8a00000"],
|
|
2214
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x00000000000000000000000000000000000000000000000016345785d8a00000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2215
2215
|
],
|
|
2216
2216
|
];
|
|
2217
2217
|
examples.forEach(([expected, actual]) => {
|
|
@@ -2225,7 +2225,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2225
2225
|
describe('encode()', () => {
|
|
2226
2226
|
const examples = [
|
|
2227
2227
|
[
|
|
2228
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000001"],
|
|
2228
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2229
2229
|
[
|
|
2230
2230
|
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2231
2231
|
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
|
|
@@ -2252,7 +2252,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2252
2252
|
debtAssetId: 20,
|
|
2253
2253
|
closeType: enums_1.CloseStrategyType.STOP_LOSS_IN_COLLATERAL,
|
|
2254
2254
|
},
|
|
2255
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000001"],
|
|
2255
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2256
2256
|
],
|
|
2257
2257
|
];
|
|
2258
2258
|
examples.forEach(([expected, actual]) => {
|
|
@@ -2266,7 +2266,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2266
2266
|
describe('encode()', () => {
|
|
2267
2267
|
const examples = [
|
|
2268
2268
|
[
|
|
2269
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"],
|
|
2269
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2270
2270
|
[
|
|
2271
2271
|
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2272
2272
|
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
|
|
@@ -2293,7 +2293,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2293
2293
|
toAssetId: 20,
|
|
2294
2294
|
amountToSwitch: '1000000000000000000'
|
|
2295
2295
|
},
|
|
2296
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"],
|
|
2296
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2297
2297
|
],
|
|
2298
2298
|
];
|
|
2299
2299
|
examples.forEach(([expected, actual]) => {
|
package/esm/constants/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ArbitrumBundleInfo, ArbitrumStrategiesInfo, BundlesInfo, EthereumAddress, Interfaces, MainnetBundleInfo, MainnetStrategiesInfo, OptimismBundleInfo, OptimismStrategiesInfo, BaseBundleInfo, BaseStrategiesInfo, StrategiesInfo } from '../types';
|
|
2
2
|
import { ProtocolIdentifiers, Strategies, Bundles } from '../types/enums';
|
|
3
3
|
export declare const ZERO_ADDRESS: EthereumAddress;
|
|
4
|
+
export declare const EMPTY_SLOT: string;
|
|
4
5
|
export declare const AAVE_V3_VARIABLE_BORROW_RATE = 2;
|
|
5
6
|
export declare const PROTOCOLS: Record<keyof typeof ProtocolIdentifiers.StrategiesAutomation, Interfaces.Protocol>;
|
|
6
7
|
export declare const LEGACY_PROTOCOLS: Record<keyof typeof ProtocolIdentifiers.LegacyAutomation, Interfaces.LegacyProtocol>;
|
package/esm/constants/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import Protocol from '../automation/private/Protocol';
|
|
|
3
3
|
import LegacyProtocol from '../automation/private/LegacyProtocol';
|
|
4
4
|
// General
|
|
5
5
|
export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
6
|
+
export const EMPTY_SLOT = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
|
6
7
|
export const AAVE_V3_VARIABLE_BORROW_RATE = 2;
|
|
7
8
|
export const PROTOCOLS = (() => {
|
|
8
9
|
const protocolsMapping = {};
|
|
@@ -1590,7 +1590,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1590
1590
|
describe('leverageManagement()', () => {
|
|
1591
1591
|
const examples = [
|
|
1592
1592
|
[
|
|
1593
|
-
[1, true, ["0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000001"], ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x00000000000000000000000000000000000000000000000014d1120d7b160000"]],
|
|
1593
|
+
[1, true, ["0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000001"], ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x00000000000000000000000000000000000000000000000014d1120d7b160000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"]],
|
|
1594
1594
|
[
|
|
1595
1595
|
1,
|
|
1596
1596
|
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
@@ -1610,7 +1610,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1610
1610
|
describe('leverageManagementOnPrice()', () => {
|
|
1611
1611
|
const examples = [
|
|
1612
1612
|
[
|
|
1613
|
-
[2, true, ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000000000000000"], ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x00000000000000000000000000000000000000000000000016345785d8a00000"]],
|
|
1613
|
+
[2, true, ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000000000000000"], ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x00000000000000000000000000000000000000000000000016345785d8a00000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"]],
|
|
1614
1614
|
[
|
|
1615
1615
|
2,
|
|
1616
1616
|
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
@@ -1635,7 +1635,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1635
1635
|
describe('closeOnPrice()', () => {
|
|
1636
1636
|
const examples = [
|
|
1637
1637
|
[
|
|
1638
|
-
[3, true, ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000002098a678000000000000000000000000000000000000000000000000000000000000000000"], ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000003"]],
|
|
1638
|
+
[3, true, ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000002098a678000000000000000000000000000000000000000000000000000000000000000000"], ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000003", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"]],
|
|
1639
1639
|
[
|
|
1640
1640
|
3,
|
|
1641
1641
|
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
@@ -1660,7 +1660,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1660
1660
|
describe('collateralSwitch()', () => {
|
|
1661
1661
|
const examples = [
|
|
1662
1662
|
[
|
|
1663
|
-
[4, false, ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000000000000001"], ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"]],
|
|
1663
|
+
[4, false, ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000000000000001"], ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"]],
|
|
1664
1664
|
[
|
|
1665
1665
|
4,
|
|
1666
1666
|
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
@@ -4,7 +4,7 @@ import { fromWei, toWei } from 'web3-utils';
|
|
|
4
4
|
import { assetAmountInEth, getAssetInfo, getAssetInfoByAddress } from '@defisaver/tokens';
|
|
5
5
|
import { otherAddresses } from '@defisaver/sdk';
|
|
6
6
|
import { ChainId, CollActionType, DebtActionType, RatioState, } from '../types/enums';
|
|
7
|
-
import { ZERO_ADDRESS } from '../constants';
|
|
7
|
+
import { EMPTY_SLOT, ZERO_ADDRESS } from '../constants';
|
|
8
8
|
import { compareAddresses, ratioPercentageToWei, weiToRatioPercentage } from './utils';
|
|
9
9
|
/**
|
|
10
10
|
_______ _______ .______ .______ _______ ______ ___ .___________. _______ _______
|
|
@@ -593,7 +593,15 @@ export const aaveV4LeverageManagementSubData = {
|
|
|
593
593
|
const ownerEncoded = AbiCoder.encodeParameter('address', owner);
|
|
594
594
|
const ratioStateEncoded = AbiCoder.encodeParameter('uint8', ratioState);
|
|
595
595
|
const targetRatioEncoded = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
|
|
596
|
-
|
|
596
|
+
// Add two empty slots for future addons (e.g tsi or slippage settings)
|
|
597
|
+
return [
|
|
598
|
+
spokeEncoded,
|
|
599
|
+
ownerEncoded,
|
|
600
|
+
ratioStateEncoded,
|
|
601
|
+
targetRatioEncoded,
|
|
602
|
+
EMPTY_SLOT,
|
|
603
|
+
EMPTY_SLOT,
|
|
604
|
+
];
|
|
597
605
|
},
|
|
598
606
|
decode: (subData) => {
|
|
599
607
|
const spoke = AbiCoder.decodeParameter('address', subData[0]);
|
|
@@ -615,6 +623,7 @@ export const aaveV4LeverageManagementOnPriceSubData = {
|
|
|
615
623
|
const debtAssetIdEncoded = AbiCoder.encodeParameter('uint256', debtAssetId);
|
|
616
624
|
const ratioStateEncoded = AbiCoder.encodeParameter('uint8', ratioState);
|
|
617
625
|
const targetRatioEncoded = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
|
|
626
|
+
// Add two empty slots for future addons (e.g tsi or slippage settings)
|
|
618
627
|
return [
|
|
619
628
|
spokeEncoded,
|
|
620
629
|
ownerEncoded,
|
|
@@ -624,6 +633,8 @@ export const aaveV4LeverageManagementOnPriceSubData = {
|
|
|
624
633
|
debtAssetIdEncoded,
|
|
625
634
|
ratioStateEncoded,
|
|
626
635
|
targetRatioEncoded,
|
|
636
|
+
EMPTY_SLOT,
|
|
637
|
+
EMPTY_SLOT,
|
|
627
638
|
];
|
|
628
639
|
},
|
|
629
640
|
decode: (subData) => {
|
|
@@ -649,6 +660,7 @@ export const aaveV4CloseSubData = {
|
|
|
649
660
|
const debtAssetEncoded = AbiCoder.encodeParameter('address', debtAsset);
|
|
650
661
|
const debtAssetIdEncoded = AbiCoder.encodeParameter('uint256', debtAssetId);
|
|
651
662
|
const closeTypeEncoded = AbiCoder.encodeParameter('uint8', closeType);
|
|
663
|
+
// Add two empty slots for future addons (e.g tsi or slippage settings)
|
|
652
664
|
return [
|
|
653
665
|
spokeEncoded,
|
|
654
666
|
ownerEncoded,
|
|
@@ -657,6 +669,8 @@ export const aaveV4CloseSubData = {
|
|
|
657
669
|
debtAssetEncoded,
|
|
658
670
|
debtAssetIdEncoded,
|
|
659
671
|
closeTypeEncoded,
|
|
672
|
+
EMPTY_SLOT,
|
|
673
|
+
EMPTY_SLOT,
|
|
660
674
|
];
|
|
661
675
|
},
|
|
662
676
|
decode: (subData) => {
|
|
@@ -681,6 +695,7 @@ export const aaveV4CollateralSwitchSubData = {
|
|
|
681
695
|
const toAssetEncoded = AbiCoder.encodeParameter('address', toAsset);
|
|
682
696
|
const toAssetIdEncoded = AbiCoder.encodeParameter('uint256', toAssetId);
|
|
683
697
|
const amountToSwitchEncoded = AbiCoder.encodeParameter('uint256', amountToSwitch);
|
|
698
|
+
// Add two empty slots for future addons (e.g tsi or slippage settings)
|
|
684
699
|
return [
|
|
685
700
|
spokeEncoded,
|
|
686
701
|
ownerEncoded,
|
|
@@ -689,6 +704,8 @@ export const aaveV4CollateralSwitchSubData = {
|
|
|
689
704
|
toAssetEncoded,
|
|
690
705
|
toAssetIdEncoded,
|
|
691
706
|
amountToSwitchEncoded,
|
|
707
|
+
EMPTY_SLOT,
|
|
708
|
+
EMPTY_SLOT,
|
|
692
709
|
];
|
|
693
710
|
},
|
|
694
711
|
decode: (subData) => {
|
|
@@ -2122,7 +2122,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2122
2122
|
describe('encode()', () => {
|
|
2123
2123
|
const examples = [
|
|
2124
2124
|
[
|
|
2125
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x00000000000000000000000000000000000000000000000014d1120d7b160000"],
|
|
2125
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x00000000000000000000000000000000000000000000000014d1120d7b160000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2126
2126
|
[web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), RatioState.UNDER, 150]
|
|
2127
2127
|
],
|
|
2128
2128
|
];
|
|
@@ -2141,7 +2141,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2141
2141
|
ratioState: RatioState.UNDER,
|
|
2142
2142
|
targetRatio: 150,
|
|
2143
2143
|
},
|
|
2144
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x00000000000000000000000000000000000000000000000014d1120d7b160000"],
|
|
2144
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x00000000000000000000000000000000000000000000000014d1120d7b160000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2145
2145
|
],
|
|
2146
2146
|
];
|
|
2147
2147
|
examples.forEach(([expected, actual]) => {
|
|
@@ -2155,7 +2155,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2155
2155
|
describe('encode()', () => {
|
|
2156
2156
|
const examples = [
|
|
2157
2157
|
[
|
|
2158
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x00000000000000000000000000000000000000000000000016345785d8a00000"],
|
|
2158
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x00000000000000000000000000000000000000000000000016345785d8a00000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2159
2159
|
[
|
|
2160
2160
|
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2161
2161
|
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
|
|
@@ -2183,7 +2183,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2183
2183
|
ratioState: RatioState.OVER,
|
|
2184
2184
|
targetRatio: 160,
|
|
2185
2185
|
},
|
|
2186
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x00000000000000000000000000000000000000000000000016345785d8a00000"],
|
|
2186
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x00000000000000000000000000000000000000000000000016345785d8a00000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2187
2187
|
],
|
|
2188
2188
|
];
|
|
2189
2189
|
examples.forEach(([expected, actual]) => {
|
|
@@ -2197,7 +2197,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2197
2197
|
describe('encode()', () => {
|
|
2198
2198
|
const examples = [
|
|
2199
2199
|
[
|
|
2200
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000001"],
|
|
2200
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2201
2201
|
[
|
|
2202
2202
|
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2203
2203
|
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
|
|
@@ -2224,7 +2224,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2224
2224
|
debtAssetId: 20,
|
|
2225
2225
|
closeType: CloseStrategyType.STOP_LOSS_IN_COLLATERAL,
|
|
2226
2226
|
},
|
|
2227
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000001"],
|
|
2227
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2228
2228
|
],
|
|
2229
2229
|
];
|
|
2230
2230
|
examples.forEach(([expected, actual]) => {
|
|
@@ -2238,7 +2238,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2238
2238
|
describe('encode()', () => {
|
|
2239
2239
|
const examples = [
|
|
2240
2240
|
[
|
|
2241
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"],
|
|
2241
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2242
2242
|
[
|
|
2243
2243
|
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2244
2244
|
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
|
|
@@ -2265,7 +2265,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2265
2265
|
toAssetId: 20,
|
|
2266
2266
|
amountToSwitch: '1000000000000000000'
|
|
2267
2267
|
},
|
|
2268
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"],
|
|
2268
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2269
2269
|
],
|
|
2270
2270
|
];
|
|
2271
2271
|
examples.forEach(([expected, actual]) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defisaver/automation-sdk",
|
|
3
|
-
"version": "3.3.10-aave-v4-
|
|
3
|
+
"version": "3.3.10-aave-v4-5-dev",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"repository": "https://github.com/defisaver/automation-sdk",
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@defisaver/sdk": "1.3.18-aave-v4-
|
|
26
|
+
"@defisaver/sdk": "1.3.18-aave-v4-2-dev",
|
|
27
27
|
"@defisaver/tokens": "^1.6.19",
|
|
28
28
|
"@ethersproject/address": "^5.0.10",
|
|
29
29
|
"@ethersproject/solidity": "^5.0.9",
|
package/src/constants/index.ts
CHANGED
|
@@ -23,6 +23,8 @@ import LegacyProtocol from '../automation/private/LegacyProtocol';
|
|
|
23
23
|
// General
|
|
24
24
|
export const ZERO_ADDRESS: EthereumAddress = '0x0000000000000000000000000000000000000000';
|
|
25
25
|
|
|
26
|
+
export const EMPTY_SLOT: string = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
|
27
|
+
|
|
26
28
|
export const AAVE_V3_VARIABLE_BORROW_RATE = 2;
|
|
27
29
|
|
|
28
30
|
export const PROTOCOLS: Record<keyof typeof ProtocolIdentifiers.StrategiesAutomation, Interfaces.Protocol> = (() => {
|
|
@@ -1902,7 +1902,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1902
1902
|
]
|
|
1903
1903
|
]> = [
|
|
1904
1904
|
[
|
|
1905
|
-
[1,true,["0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000001"],["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x0000000000000000000000000000000000000000000000000000000000000001","0x00000000000000000000000000000000000000000000000014d1120d7b160000"]],
|
|
1905
|
+
[1,true,["0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000001"],["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x0000000000000000000000000000000000000000000000000000000000000001","0x00000000000000000000000000000000000000000000000014d1120d7b160000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"]],
|
|
1906
1906
|
[
|
|
1907
1907
|
1,
|
|
1908
1908
|
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
@@ -1929,7 +1929,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1929
1929
|
]
|
|
1930
1930
|
]> = [
|
|
1931
1931
|
[
|
|
1932
|
-
[2,true,["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000000000000000"],["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000000000000000000","0x00000000000000000000000000000000000000000000000016345785d8a00000"]],
|
|
1932
|
+
[2,true,["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000000000000000"],["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000000000000000000","0x00000000000000000000000000000000000000000000000016345785d8a00000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"]],
|
|
1933
1933
|
[
|
|
1934
1934
|
2,
|
|
1935
1935
|
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
@@ -1961,7 +1961,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1961
1961
|
]
|
|
1962
1962
|
]> = [
|
|
1963
1963
|
[
|
|
1964
|
-
[3,true,["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000002098a678000000000000000000000000000000000000000000000000000000000000000000"],["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000000000000000003"]],
|
|
1964
|
+
[3,true,["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000002098a678000000000000000000000000000000000000000000000000000000000000000000"],["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000000000000000003","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"]],
|
|
1965
1965
|
[
|
|
1966
1966
|
3,
|
|
1967
1967
|
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
@@ -1993,7 +1993,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1993
1993
|
]
|
|
1994
1994
|
]> = [
|
|
1995
1995
|
[
|
|
1996
|
-
[4,false,["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000000000000001"],["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"]],
|
|
1996
|
+
[4,false,["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000000000000001"],["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000de0b6b3a7640000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"]],
|
|
1997
1997
|
[
|
|
1998
1998
|
4,
|
|
1999
1999
|
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
@@ -2334,7 +2334,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2334
2334
|
describe('encode()', () => {
|
|
2335
2335
|
const examples: Array<[SubData, [spoke: EthereumAddress, owner: EthereumAddress, ratioState: RatioState, targetRatio: number]]> = [
|
|
2336
2336
|
[
|
|
2337
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x0000000000000000000000000000000000000000000000000000000000000001","0x00000000000000000000000000000000000000000000000014d1120d7b160000"],
|
|
2337
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x0000000000000000000000000000000000000000000000000000000000000001","0x00000000000000000000000000000000000000000000000014d1120d7b160000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2338
2338
|
[web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), RatioState.UNDER, 150]
|
|
2339
2339
|
],
|
|
2340
2340
|
];
|
|
@@ -2355,7 +2355,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2355
2355
|
ratioState: RatioState.UNDER,
|
|
2356
2356
|
targetRatio: 150,
|
|
2357
2357
|
},
|
|
2358
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x0000000000000000000000000000000000000000000000000000000000000001","0x00000000000000000000000000000000000000000000000014d1120d7b160000"],
|
|
2358
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x0000000000000000000000000000000000000000000000000000000000000001","0x00000000000000000000000000000000000000000000000014d1120d7b160000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2359
2359
|
],
|
|
2360
2360
|
];
|
|
2361
2361
|
|
|
@@ -2371,7 +2371,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2371
2371
|
describe('encode()', () => {
|
|
2372
2372
|
const examples: Array<[SubData, [spoke: EthereumAddress, owner: EthereumAddress, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, ratioState: RatioState, targetRatio: number]]> = [
|
|
2373
2373
|
[
|
|
2374
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000000000000000000","0x00000000000000000000000000000000000000000000000016345785d8a00000"],
|
|
2374
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000000000000000000","0x00000000000000000000000000000000000000000000000016345785d8a00000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2375
2375
|
[
|
|
2376
2376
|
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2377
2377
|
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
|
|
@@ -2401,7 +2401,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2401
2401
|
ratioState: RatioState.OVER,
|
|
2402
2402
|
targetRatio: 160,
|
|
2403
2403
|
},
|
|
2404
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000000000000000000","0x00000000000000000000000000000000000000000000000016345785d8a00000"],
|
|
2404
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000000000000000000","0x00000000000000000000000000000000000000000000000016345785d8a00000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2405
2405
|
],
|
|
2406
2406
|
];
|
|
2407
2407
|
|
|
@@ -2417,7 +2417,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2417
2417
|
describe('encode()', () => {
|
|
2418
2418
|
const examples: Array<[SubData, [spoke: EthereumAddress, owner: EthereumAddress, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, closeType: CloseStrategyType]]> = [
|
|
2419
2419
|
[
|
|
2420
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000000000000000001"],
|
|
2420
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000000000000000001","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2421
2421
|
[
|
|
2422
2422
|
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2423
2423
|
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
|
|
@@ -2446,7 +2446,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2446
2446
|
debtAssetId: 20,
|
|
2447
2447
|
closeType: CloseStrategyType.STOP_LOSS_IN_COLLATERAL,
|
|
2448
2448
|
},
|
|
2449
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000000000000000001"],
|
|
2449
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000000000000000001","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2450
2450
|
],
|
|
2451
2451
|
];
|
|
2452
2452
|
|
|
@@ -2462,7 +2462,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2462
2462
|
describe('encode()', () => {
|
|
2463
2463
|
const examples: Array<[SubData, [spoke: EthereumAddress, owner: EthereumAddress, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, amountToSwitch: string]]> = [
|
|
2464
2464
|
[
|
|
2465
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"],
|
|
2465
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000de0b6b3a7640000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2466
2466
|
[
|
|
2467
2467
|
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2468
2468
|
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
|
|
@@ -2491,7 +2491,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2491
2491
|
toAssetId: 20,
|
|
2492
2492
|
amountToSwitch: '1000000000000000000'
|
|
2493
2493
|
},
|
|
2494
|
-
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"],
|
|
2494
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000de0b6b3a7640000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2495
2495
|
],
|
|
2496
2496
|
];
|
|
2497
2497
|
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
ChainId, CollActionType, DebtActionType, RatioState,
|
|
12
12
|
} from '../types/enums';
|
|
13
13
|
|
|
14
|
-
import { ZERO_ADDRESS } from '../constants';
|
|
14
|
+
import { EMPTY_SLOT, ZERO_ADDRESS } from '../constants';
|
|
15
15
|
|
|
16
16
|
import { compareAddresses, ratioPercentageToWei, weiToRatioPercentage } from './utils';
|
|
17
17
|
|
|
@@ -811,7 +811,15 @@ export const aaveV4LeverageManagementSubData = {
|
|
|
811
811
|
const ownerEncoded = AbiCoder.encodeParameter('address', owner);
|
|
812
812
|
const ratioStateEncoded = AbiCoder.encodeParameter('uint8', ratioState);
|
|
813
813
|
const targetRatioEncoded = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
|
|
814
|
-
|
|
814
|
+
// Add two empty slots for future addons (e.g tsi or slippage settings)
|
|
815
|
+
return [
|
|
816
|
+
spokeEncoded,
|
|
817
|
+
ownerEncoded,
|
|
818
|
+
ratioStateEncoded,
|
|
819
|
+
targetRatioEncoded,
|
|
820
|
+
EMPTY_SLOT,
|
|
821
|
+
EMPTY_SLOT,
|
|
822
|
+
];
|
|
815
823
|
},
|
|
816
824
|
decode: (subData: SubData) => {
|
|
817
825
|
const spoke = AbiCoder.decodeParameter('address', subData[0]) as unknown as EthereumAddress;
|
|
@@ -842,6 +850,7 @@ export const aaveV4LeverageManagementOnPriceSubData = {
|
|
|
842
850
|
const debtAssetIdEncoded = AbiCoder.encodeParameter('uint256', debtAssetId);
|
|
843
851
|
const ratioStateEncoded = AbiCoder.encodeParameter('uint8', ratioState);
|
|
844
852
|
const targetRatioEncoded = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
|
|
853
|
+
// Add two empty slots for future addons (e.g tsi or slippage settings)
|
|
845
854
|
return [
|
|
846
855
|
spokeEncoded,
|
|
847
856
|
ownerEncoded,
|
|
@@ -851,6 +860,8 @@ export const aaveV4LeverageManagementOnPriceSubData = {
|
|
|
851
860
|
debtAssetIdEncoded,
|
|
852
861
|
ratioStateEncoded,
|
|
853
862
|
targetRatioEncoded,
|
|
863
|
+
EMPTY_SLOT,
|
|
864
|
+
EMPTY_SLOT,
|
|
854
865
|
];
|
|
855
866
|
},
|
|
856
867
|
decode: (subData: SubData) => {
|
|
@@ -884,6 +895,7 @@ export const aaveV4CloseSubData = {
|
|
|
884
895
|
const debtAssetEncoded = AbiCoder.encodeParameter('address', debtAsset);
|
|
885
896
|
const debtAssetIdEncoded = AbiCoder.encodeParameter('uint256', debtAssetId);
|
|
886
897
|
const closeTypeEncoded = AbiCoder.encodeParameter('uint8', closeType);
|
|
898
|
+
// Add two empty slots for future addons (e.g tsi or slippage settings)
|
|
887
899
|
return [
|
|
888
900
|
spokeEncoded,
|
|
889
901
|
ownerEncoded,
|
|
@@ -892,6 +904,8 @@ export const aaveV4CloseSubData = {
|
|
|
892
904
|
debtAssetEncoded,
|
|
893
905
|
debtAssetIdEncoded,
|
|
894
906
|
closeTypeEncoded,
|
|
907
|
+
EMPTY_SLOT,
|
|
908
|
+
EMPTY_SLOT,
|
|
895
909
|
];
|
|
896
910
|
},
|
|
897
911
|
decode: (subData: SubData) => {
|
|
@@ -924,6 +938,7 @@ export const aaveV4CollateralSwitchSubData = {
|
|
|
924
938
|
const toAssetEncoded = AbiCoder.encodeParameter('address', toAsset);
|
|
925
939
|
const toAssetIdEncoded = AbiCoder.encodeParameter('uint256', toAssetId);
|
|
926
940
|
const amountToSwitchEncoded = AbiCoder.encodeParameter('uint256', amountToSwitch);
|
|
941
|
+
// Add two empty slots for future addons (e.g tsi or slippage settings)
|
|
927
942
|
return [
|
|
928
943
|
spokeEncoded,
|
|
929
944
|
ownerEncoded,
|
|
@@ -932,6 +947,8 @@ export const aaveV4CollateralSwitchSubData = {
|
|
|
932
947
|
toAssetEncoded,
|
|
933
948
|
toAssetIdEncoded,
|
|
934
949
|
amountToSwitchEncoded,
|
|
950
|
+
EMPTY_SLOT,
|
|
951
|
+
EMPTY_SLOT,
|
|
935
952
|
];
|
|
936
953
|
},
|
|
937
954
|
decode: (subData: SubData) => {
|