@defisaver/automation-sdk 3.3.18 → 3.3.19-sub-fetching.1-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/automation/private/StrategiesAutomation.d.ts +5 -1
- package/cjs/automation/private/StrategiesAutomation.js +29 -2
- package/cjs/automation/private/StrategiesAutomation.test.js +66 -0
- package/cjs/constants/index.js +35 -0
- package/cjs/services/apiSubscriptionsService.d.ts +7 -0
- package/cjs/services/apiSubscriptionsService.js +33 -0
- package/cjs/services/apiSubscriptionsService.test.d.ts +1 -0
- package/cjs/services/apiSubscriptionsService.test.js +69 -0
- package/cjs/services/ethereumService.test.js +4 -7
- package/cjs/services/strategiesService.js +40 -9
- package/cjs/services/strategiesService.test.js +0 -1
- package/cjs/services/strategySubService.d.ts +4 -0
- package/cjs/services/strategySubService.js +24 -0
- package/cjs/services/strategySubService.test.js +295 -0
- package/cjs/services/subDataService.d.ts +38 -0
- package/cjs/services/subDataService.js +76 -2
- package/cjs/services/subDataService.test.js +494 -4
- package/cjs/types/enums.d.ts +15 -2
- package/cjs/types/enums.js +15 -1
- package/cjs/types/index.d.ts +32 -3
- package/esm/automation/private/StrategiesAutomation.d.ts +5 -1
- package/esm/automation/private/StrategiesAutomation.js +29 -2
- package/esm/automation/private/StrategiesAutomation.test.js +67 -1
- package/esm/constants/index.js +35 -0
- package/esm/services/apiSubscriptionsService.d.ts +7 -0
- package/esm/services/apiSubscriptionsService.js +29 -0
- package/esm/services/apiSubscriptionsService.test.d.ts +1 -0
- package/esm/services/apiSubscriptionsService.test.js +67 -0
- package/esm/services/ethereumService.test.js +4 -7
- package/esm/services/strategiesService.js +40 -9
- package/esm/services/strategiesService.test.js +0 -1
- package/esm/services/strategySubService.d.ts +4 -0
- package/esm/services/strategySubService.js +24 -0
- package/esm/services/strategySubService.test.js +295 -0
- package/esm/services/subDataService.d.ts +38 -0
- package/esm/services/subDataService.js +74 -0
- package/esm/services/subDataService.test.js +494 -4
- package/esm/types/enums.d.ts +15 -2
- package/esm/types/enums.js +14 -0
- package/esm/types/index.d.ts +32 -3
- package/package.json +1 -1
- package/src/automation/private/StrategiesAutomation.test.ts +84 -1
- package/src/automation/private/StrategiesAutomation.ts +33 -0
- package/src/constants/index.ts +35 -0
- package/src/services/apiSubscriptionsService.test.ts +75 -0
- package/src/services/apiSubscriptionsService.ts +33 -0
- package/src/services/ethereumService.test.ts +5 -8
- package/src/services/strategiesService.test.ts +0 -1
- package/src/services/strategiesService.ts +43 -10
- package/src/services/strategySubService.test.ts +382 -0
- package/src/services/strategySubService.ts +87 -0
- package/src/services/subDataService.test.ts +608 -4
- package/src/services/subDataService.ts +107 -0
- package/src/types/enums.ts +14 -0
- package/src/types/index.ts +34 -2
|
@@ -1453,6 +1453,224 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1453
1453
|
});
|
|
1454
1454
|
});
|
|
1455
1455
|
});
|
|
1456
|
+
describe('leverageManagementGeneric()', () => {
|
|
1457
|
+
const examples = [
|
|
1458
|
+
[
|
|
1459
|
+
[
|
|
1460
|
+
Bundles.MainnetIds.SPARK_EOA_REPAY,
|
|
1461
|
+
true,
|
|
1462
|
+
['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee000000000000000000000000000000000000000000000000136dcc951d8c00000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1463
|
+
[
|
|
1464
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
1465
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1466
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1467
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1468
|
+
],
|
|
1469
|
+
],
|
|
1470
|
+
[
|
|
1471
|
+
Bundles.MainnetIds.SPARK_EOA_REPAY,
|
|
1472
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1473
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1474
|
+
RatioState.UNDER,
|
|
1475
|
+
180,
|
|
1476
|
+
140,
|
|
1477
|
+
],
|
|
1478
|
+
],
|
|
1479
|
+
[
|
|
1480
|
+
[
|
|
1481
|
+
Bundles.MainnetIds.SPARK_EOA_BOOST,
|
|
1482
|
+
true,
|
|
1483
|
+
['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee0000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1484
|
+
[
|
|
1485
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1486
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1487
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1488
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1489
|
+
],
|
|
1490
|
+
],
|
|
1491
|
+
[
|
|
1492
|
+
Bundles.MainnetIds.SPARK_EOA_BOOST,
|
|
1493
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1494
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1495
|
+
RatioState.OVER,
|
|
1496
|
+
160,
|
|
1497
|
+
200,
|
|
1498
|
+
],
|
|
1499
|
+
],
|
|
1500
|
+
];
|
|
1501
|
+
examples.forEach(([expected, actual]) => {
|
|
1502
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1503
|
+
expect(sparkEncode.leverageManagementGeneric(...actual)).to.eql(expected);
|
|
1504
|
+
});
|
|
1505
|
+
});
|
|
1506
|
+
});
|
|
1507
|
+
describe('liquidationProtection()', () => {
|
|
1508
|
+
const examples = [
|
|
1509
|
+
[
|
|
1510
|
+
[
|
|
1511
|
+
Bundles.MainnetIds.SPARK_SW_LIQUIDATION_PROTECTION,
|
|
1512
|
+
true,
|
|
1513
|
+
['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee000000000000000000000000000000000000000000000000136dcc951d8c00000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1514
|
+
[
|
|
1515
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
1516
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1517
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1518
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1519
|
+
],
|
|
1520
|
+
],
|
|
1521
|
+
[
|
|
1522
|
+
Bundles.MainnetIds.SPARK_SW_LIQUIDATION_PROTECTION,
|
|
1523
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1524
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1525
|
+
RatioState.UNDER,
|
|
1526
|
+
180,
|
|
1527
|
+
140,
|
|
1528
|
+
],
|
|
1529
|
+
],
|
|
1530
|
+
[
|
|
1531
|
+
[
|
|
1532
|
+
Bundles.MainnetIds.SPARK_SW_LIQUIDATION_PROTECTION,
|
|
1533
|
+
true,
|
|
1534
|
+
['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee0000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1535
|
+
[
|
|
1536
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1537
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1538
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1539
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1540
|
+
],
|
|
1541
|
+
],
|
|
1542
|
+
[
|
|
1543
|
+
Bundles.MainnetIds.SPARK_SW_LIQUIDATION_PROTECTION,
|
|
1544
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1545
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1546
|
+
RatioState.OVER,
|
|
1547
|
+
160,
|
|
1548
|
+
200,
|
|
1549
|
+
],
|
|
1550
|
+
],
|
|
1551
|
+
];
|
|
1552
|
+
examples.forEach(([expected, actual]) => {
|
|
1553
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1554
|
+
expect(sparkEncode.liquidationProtection(...actual)).to.eql(expected);
|
|
1555
|
+
});
|
|
1556
|
+
});
|
|
1557
|
+
});
|
|
1558
|
+
describe('liquidationProtectionGeneric()', () => {
|
|
1559
|
+
const examples = [
|
|
1560
|
+
[
|
|
1561
|
+
[
|
|
1562
|
+
Bundles.MainnetIds.SPARK_EOA_LIQUIDATION_PROTECTION,
|
|
1563
|
+
true,
|
|
1564
|
+
['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee000000000000000000000000000000000000000000000000136dcc951d8c00000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1565
|
+
[
|
|
1566
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
1567
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1568
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1569
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1570
|
+
],
|
|
1571
|
+
],
|
|
1572
|
+
[
|
|
1573
|
+
Bundles.MainnetIds.SPARK_EOA_LIQUIDATION_PROTECTION,
|
|
1574
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1575
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1576
|
+
RatioState.UNDER,
|
|
1577
|
+
180,
|
|
1578
|
+
140,
|
|
1579
|
+
],
|
|
1580
|
+
],
|
|
1581
|
+
[
|
|
1582
|
+
[
|
|
1583
|
+
Bundles.MainnetIds.SPARK_EOA_LIQUIDATION_PROTECTION,
|
|
1584
|
+
true,
|
|
1585
|
+
['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee0000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1586
|
+
[
|
|
1587
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1588
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1589
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1590
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1591
|
+
],
|
|
1592
|
+
],
|
|
1593
|
+
[
|
|
1594
|
+
Bundles.MainnetIds.SPARK_EOA_LIQUIDATION_PROTECTION,
|
|
1595
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1596
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1597
|
+
RatioState.OVER,
|
|
1598
|
+
160,
|
|
1599
|
+
200,
|
|
1600
|
+
],
|
|
1601
|
+
],
|
|
1602
|
+
];
|
|
1603
|
+
examples.forEach(([expected, actual]) => {
|
|
1604
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1605
|
+
expect(sparkEncode.liquidationProtectionGeneric(...actual)).to.eql(expected);
|
|
1606
|
+
});
|
|
1607
|
+
});
|
|
1608
|
+
});
|
|
1609
|
+
describe('leverageManagementOnPriceGeneric()', () => {
|
|
1610
|
+
const examples = [
|
|
1611
|
+
[
|
|
1612
|
+
[
|
|
1613
|
+
Bundles.MainnetIds.SPARK_EOA_REPAY_ON_PRICE,
|
|
1614
|
+
true,
|
|
1615
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1616
|
+
[
|
|
1617
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1618
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1619
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1620
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1621
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1622
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1623
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1624
|
+
],
|
|
1625
|
+
],
|
|
1626
|
+
[
|
|
1627
|
+
Bundles.MainnetIds.SPARK_EOA_REPAY_ON_PRICE,
|
|
1628
|
+
2500,
|
|
1629
|
+
RatioState.UNDER,
|
|
1630
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1631
|
+
0,
|
|
1632
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1633
|
+
1,
|
|
1634
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1635
|
+
200,
|
|
1636
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1637
|
+
],
|
|
1638
|
+
],
|
|
1639
|
+
[
|
|
1640
|
+
[
|
|
1641
|
+
Bundles.MainnetIds.SPARK_EOA_BOOST_ON_PRICE,
|
|
1642
|
+
true,
|
|
1643
|
+
['0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000417bce6c8000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1644
|
+
[
|
|
1645
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1646
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1647
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
1648
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
1649
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1650
|
+
'0x00000000000000000000000000000000000000000000000022b1c8c1227a0000',
|
|
1651
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1652
|
+
],
|
|
1653
|
+
],
|
|
1654
|
+
[
|
|
1655
|
+
Bundles.MainnetIds.SPARK_EOA_BOOST_ON_PRICE,
|
|
1656
|
+
45000,
|
|
1657
|
+
RatioState.OVER,
|
|
1658
|
+
web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
1659
|
+
2,
|
|
1660
|
+
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
1661
|
+
4,
|
|
1662
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1663
|
+
250,
|
|
1664
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1665
|
+
],
|
|
1666
|
+
],
|
|
1667
|
+
];
|
|
1668
|
+
examples.forEach(([expected, actual]) => {
|
|
1669
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1670
|
+
expect(sparkEncode.leverageManagementOnPriceGeneric(...actual)).to.eql(expected);
|
|
1671
|
+
});
|
|
1672
|
+
});
|
|
1673
|
+
});
|
|
1456
1674
|
describe('closeOnPrice()', () => {
|
|
1457
1675
|
const examples = [
|
|
1458
1676
|
[
|
|
@@ -1491,6 +1709,44 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1491
1709
|
});
|
|
1492
1710
|
});
|
|
1493
1711
|
});
|
|
1712
|
+
describe('closeOnPriceGeneric()', () => {
|
|
1713
|
+
const examples = [
|
|
1714
|
+
[
|
|
1715
|
+
[
|
|
1716
|
+
Bundles.MainnetIds.SPARK_EOA_CLOSE,
|
|
1717
|
+
true,
|
|
1718
|
+
['0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000003a35294400000000000000000000000000000000000000000000000000000000574fbde6000'],
|
|
1719
|
+
[
|
|
1720
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1721
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1722
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
1723
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
1724
|
+
'0x0000000000000000000000000000000000000000000000000000000000000005',
|
|
1725
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1726
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1727
|
+
],
|
|
1728
|
+
],
|
|
1729
|
+
[
|
|
1730
|
+
Bundles.MainnetIds.SPARK_EOA_CLOSE,
|
|
1731
|
+
web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
1732
|
+
2,
|
|
1733
|
+
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
1734
|
+
4,
|
|
1735
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1736
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1737
|
+
40000,
|
|
1738
|
+
CloseToAssetType.DEBT,
|
|
1739
|
+
60000,
|
|
1740
|
+
CloseToAssetType.COLLATERAL,
|
|
1741
|
+
],
|
|
1742
|
+
],
|
|
1743
|
+
];
|
|
1744
|
+
examples.forEach(([expected, actual]) => {
|
|
1745
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1746
|
+
expect(sparkEncode.closeOnPriceGeneric(...actual)).to.eql(expected);
|
|
1747
|
+
});
|
|
1748
|
+
});
|
|
1749
|
+
});
|
|
1494
1750
|
describe('collateralSwitch()', () => {
|
|
1495
1751
|
const examples = [
|
|
1496
1752
|
// WETH -> cbBTC, price 0.025 WETH/cbBTC, state UNDER
|
|
@@ -1590,6 +1846,45 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1590
1846
|
});
|
|
1591
1847
|
});
|
|
1592
1848
|
});
|
|
1849
|
+
describe('collateralSwitchGeneric()', () => {
|
|
1850
|
+
const examples = [
|
|
1851
|
+
[
|
|
1852
|
+
[
|
|
1853
|
+
Strategies.MainnetIds.SPARK_GENERIC_FL_COLLATERAL_SWITCH,
|
|
1854
|
+
false,
|
|
1855
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf00000000000000000000000000000000000000000000000000000000002625a00000000000000000000000000000000000000000000000000000000000000001'],
|
|
1856
|
+
[
|
|
1857
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1858
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1859
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
1860
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
1861
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1862
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
1863
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1864
|
+
],
|
|
1865
|
+
],
|
|
1866
|
+
[
|
|
1867
|
+
Strategies.MainnetIds.SPARK_GENERIC_FL_COLLATERAL_SWITCH,
|
|
1868
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1869
|
+
0,
|
|
1870
|
+
web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
|
|
1871
|
+
7,
|
|
1872
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1873
|
+
'10000000000000000000',
|
|
1874
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1875
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1876
|
+
web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
|
|
1877
|
+
0.025,
|
|
1878
|
+
RatioState.UNDER,
|
|
1879
|
+
],
|
|
1880
|
+
],
|
|
1881
|
+
];
|
|
1882
|
+
examples.forEach(([expected, actual]) => {
|
|
1883
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1884
|
+
expect(sparkEncode.collateralSwitchGeneric(...actual)).to.eql(expected);
|
|
1885
|
+
});
|
|
1886
|
+
});
|
|
1887
|
+
});
|
|
1593
1888
|
});
|
|
1594
1889
|
describe('When testing strategySubService.aaveV4Encode', () => {
|
|
1595
1890
|
describe('leverageManagement()', () => {
|
|
@@ -468,6 +468,20 @@ export declare const sparkLiquidationProtectionSubData: {
|
|
|
468
468
|
ratioState: RatioState;
|
|
469
469
|
};
|
|
470
470
|
};
|
|
471
|
+
export declare const sparkGenericLeverageManagementSubData: {
|
|
472
|
+
encode(targetRatio: number, ratioState: RatioState, market: EthereumAddress, user: EthereumAddress): string[];
|
|
473
|
+
decode(subData: string[]): {
|
|
474
|
+
targetRatio: number;
|
|
475
|
+
ratioState: RatioState;
|
|
476
|
+
};
|
|
477
|
+
};
|
|
478
|
+
export declare const sparkGenericLiquidationProtectionSubData: {
|
|
479
|
+
encode(targetRatio: number, ratioState: RatioState, market: EthereumAddress, user: EthereumAddress): string[];
|
|
480
|
+
decode(subData: string[]): {
|
|
481
|
+
targetRatio: number;
|
|
482
|
+
ratioState: RatioState;
|
|
483
|
+
};
|
|
484
|
+
};
|
|
471
485
|
export declare const sparkCloseGenericSubData: {
|
|
472
486
|
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, closeType: CloseStrategyType, marketAddr: EthereumAddress, user: EthereumAddress): string[];
|
|
473
487
|
decode(subData: string[]): {
|
|
@@ -491,6 +505,18 @@ export declare const sparkLeverageManagementOnPriceSubData: {
|
|
|
491
505
|
targetRatio: number;
|
|
492
506
|
};
|
|
493
507
|
};
|
|
508
|
+
export declare const sparkLeverageManagementOnPriceGenericSubData: {
|
|
509
|
+
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number, user: EthereumAddress): string[];
|
|
510
|
+
decode(subData: string[]): {
|
|
511
|
+
collAsset: string;
|
|
512
|
+
collAssetId: number;
|
|
513
|
+
debtAsset: string;
|
|
514
|
+
debtAssetId: number;
|
|
515
|
+
marketAddr: string;
|
|
516
|
+
targetRatio: number;
|
|
517
|
+
user: string;
|
|
518
|
+
};
|
|
519
|
+
};
|
|
494
520
|
export declare const sparkCollateralSwitchSubData: {
|
|
495
521
|
encode(fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, useOnBehalf?: boolean): string[];
|
|
496
522
|
decode(subData: string[]): {
|
|
@@ -502,6 +528,18 @@ export declare const sparkCollateralSwitchSubData: {
|
|
|
502
528
|
amountToSwitch: string;
|
|
503
529
|
};
|
|
504
530
|
};
|
|
531
|
+
export declare const sparkGenericFLCollateralSwitchSubData: {
|
|
532
|
+
encode(fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, user: EthereumAddress): string[];
|
|
533
|
+
decode(subData: string[]): {
|
|
534
|
+
fromAsset: EthereumAddress;
|
|
535
|
+
fromAssetId: number;
|
|
536
|
+
toAsset: EthereumAddress;
|
|
537
|
+
toAssetId: number;
|
|
538
|
+
marketAddr: EthereumAddress;
|
|
539
|
+
amountToSwitch: string;
|
|
540
|
+
user: EthereumAddress;
|
|
541
|
+
};
|
|
542
|
+
};
|
|
505
543
|
/**
|
|
506
544
|
______ .______ ____ ____ __ __ _______. _______
|
|
507
545
|
/ || _ \ \ \ / / | | | | / || \
|
|
@@ -933,6 +933,21 @@ export const sparkLeverageManagementSubData = {
|
|
|
933
933
|
},
|
|
934
934
|
};
|
|
935
935
|
export const sparkLiquidationProtectionSubData = sparkLeverageManagementSubData;
|
|
936
|
+
export const sparkGenericLeverageManagementSubData = {
|
|
937
|
+
encode(targetRatio, ratioState, market, user) {
|
|
938
|
+
const encodedTargetRatio = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
|
|
939
|
+
const encodedRatioState = AbiCoder.encodeParameter('uint8', ratioState);
|
|
940
|
+
const encodedMarket = AbiCoder.encodeParameter('address', market);
|
|
941
|
+
const encodedUser = AbiCoder.encodeParameter('address', user);
|
|
942
|
+
return [encodedTargetRatio, encodedRatioState, encodedMarket, encodedUser];
|
|
943
|
+
},
|
|
944
|
+
decode(subData) {
|
|
945
|
+
const targetRatio = weiToRatioPercentage(String(AbiCoder.decodeParameter('uint256', subData[0])));
|
|
946
|
+
const ratioState = Number(AbiCoder.decodeParameter('uint8', subData[1]));
|
|
947
|
+
return { targetRatio, ratioState };
|
|
948
|
+
},
|
|
949
|
+
};
|
|
950
|
+
export const sparkGenericLiquidationProtectionSubData = sparkGenericLeverageManagementSubData;
|
|
936
951
|
export const sparkCloseGenericSubData = {
|
|
937
952
|
encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user) {
|
|
938
953
|
const encodedColl = AbiCoder.encodeParameter('address', collAsset);
|
|
@@ -989,6 +1004,33 @@ export const sparkLeverageManagementOnPriceSubData = {
|
|
|
989
1004
|
};
|
|
990
1005
|
},
|
|
991
1006
|
};
|
|
1007
|
+
export const sparkLeverageManagementOnPriceGenericSubData = {
|
|
1008
|
+
encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user) {
|
|
1009
|
+
const encodedColl = AbiCoder.encodeParameter('address', collAsset);
|
|
1010
|
+
const encodedCollId = AbiCoder.encodeParameter('uint16', collAssetId);
|
|
1011
|
+
const encodedDebt = AbiCoder.encodeParameter('address', debtAsset);
|
|
1012
|
+
const encodedDebtId = AbiCoder.encodeParameter('uint16', debtAssetId);
|
|
1013
|
+
const encodedMarket = AbiCoder.encodeParameter('address', marketAddr);
|
|
1014
|
+
const encodedTargetRatio = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
|
|
1015
|
+
const encodedUser = AbiCoder.encodeParameter('address', user);
|
|
1016
|
+
return [
|
|
1017
|
+
encodedColl, encodedCollId, encodedDebt, encodedDebtId,
|
|
1018
|
+
encodedMarket, encodedTargetRatio, encodedUser,
|
|
1019
|
+
];
|
|
1020
|
+
},
|
|
1021
|
+
decode(subData) {
|
|
1022
|
+
const collAsset = AbiCoder.decodeParameter('address', subData[0]);
|
|
1023
|
+
const collAssetId = Number(AbiCoder.decodeParameter('uint16', subData[1]));
|
|
1024
|
+
const debtAsset = AbiCoder.decodeParameter('address', subData[2]);
|
|
1025
|
+
const debtAssetId = Number(AbiCoder.decodeParameter('uint16', subData[3]));
|
|
1026
|
+
const marketAddr = AbiCoder.decodeParameter('address', subData[4]);
|
|
1027
|
+
const targetRatio = weiToRatioPercentage(String(AbiCoder.decodeParameter('uint256', subData[5])));
|
|
1028
|
+
const user = AbiCoder.decodeParameter('address', subData[6]);
|
|
1029
|
+
return {
|
|
1030
|
+
collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user,
|
|
1031
|
+
};
|
|
1032
|
+
},
|
|
1033
|
+
};
|
|
992
1034
|
export const sparkCollateralSwitchSubData = {
|
|
993
1035
|
encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, useOnBehalf = false) {
|
|
994
1036
|
const encodedFromAsset = AbiCoder.encodeParameter('address', fromAsset);
|
|
@@ -1020,6 +1062,38 @@ export const sparkCollateralSwitchSubData = {
|
|
|
1020
1062
|
};
|
|
1021
1063
|
},
|
|
1022
1064
|
};
|
|
1065
|
+
export const sparkGenericFLCollateralSwitchSubData = {
|
|
1066
|
+
encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user) {
|
|
1067
|
+
const encodedFromAsset = AbiCoder.encodeParameter('address', fromAsset);
|
|
1068
|
+
const encodedFromAssetId = AbiCoder.encodeParameter('uint16', fromAssetId);
|
|
1069
|
+
const encodedToAsset = AbiCoder.encodeParameter('address', toAsset);
|
|
1070
|
+
const encodedToAssetId = AbiCoder.encodeParameter('uint16', toAssetId);
|
|
1071
|
+
const encodedMarketAddr = AbiCoder.encodeParameter('address', marketAddr);
|
|
1072
|
+
const encodedAmountToSwitch = AbiCoder.encodeParameter('uint256', amountToSwitch);
|
|
1073
|
+
const encodedUser = AbiCoder.encodeParameter('address', user);
|
|
1074
|
+
return [
|
|
1075
|
+
encodedFromAsset,
|
|
1076
|
+
encodedFromAssetId,
|
|
1077
|
+
encodedToAsset,
|
|
1078
|
+
encodedToAssetId,
|
|
1079
|
+
encodedMarketAddr,
|
|
1080
|
+
encodedAmountToSwitch,
|
|
1081
|
+
encodedUser,
|
|
1082
|
+
];
|
|
1083
|
+
},
|
|
1084
|
+
decode(subData) {
|
|
1085
|
+
const fromAsset = AbiCoder.decodeParameter('address', subData[0]);
|
|
1086
|
+
const fromAssetId = Number(AbiCoder.decodeParameter('uint16', subData[1]));
|
|
1087
|
+
const toAsset = AbiCoder.decodeParameter('address', subData[2]);
|
|
1088
|
+
const toAssetId = Number(AbiCoder.decodeParameter('uint16', subData[3]));
|
|
1089
|
+
const marketAddr = AbiCoder.decodeParameter('address', subData[4]);
|
|
1090
|
+
const amountToSwitch = AbiCoder.decodeParameter('uint256', subData[5]);
|
|
1091
|
+
const user = AbiCoder.decodeParameter('address', subData[6]);
|
|
1092
|
+
return {
|
|
1093
|
+
fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user,
|
|
1094
|
+
};
|
|
1095
|
+
},
|
|
1096
|
+
};
|
|
1023
1097
|
/**
|
|
1024
1098
|
______ .______ ____ ____ __ __ _______. _______
|
|
1025
1099
|
/ || _ \ \ \ / / | | | | / || \
|