1
+ pragma solidity 0.6.10 ;
2
+ pragma experimental ABIEncoderV2;
3
+
4
+ import { FlexibleLeverageStrategyExtension } from "../adapters/FlexibleLeverageStrategyExtension.sol " ;
5
+
6
+ // Mock contract for FlexibleLeverageStrategyExtension used to test FLIRebalanceViewer
7
+ contract FLIStrategyExtensionMock {
8
+
9
+ string [] internal shouldRebalanceNames;
10
+ FlexibleLeverageStrategyExtension.ShouldRebalance[] internal shouldRebalancesEnums;
11
+
12
+ uint256 [] internal chunkRebalanceSizes;
13
+ address internal chunkRebalanceSellAsset;
14
+ address internal chunkRebalanceBuyAsset;
15
+
16
+ FlexibleLeverageStrategyExtension.ContractSettings internal strategy;
17
+
18
+ mapping (string => FlexibleLeverageStrategyExtension.ExchangeSettings) internal exchangeSettings;
19
+
20
+
21
+ function shouldRebalanceWithBounds (
22
+ uint256 /* _customMinLeverageRatio */ ,
23
+ uint256 /* _customMaxLeverageRatio */
24
+ )
25
+ external
26
+ view
27
+ returns (string [] memory , FlexibleLeverageStrategyExtension.ShouldRebalance[] memory )
28
+ {
29
+ return (shouldRebalanceNames, shouldRebalancesEnums);
30
+ }
31
+
32
+ function getChunkRebalanceNotional (
33
+ string [] calldata /* _exchangeNames */
34
+ )
35
+ external
36
+ view
37
+ returns (uint256 [] memory sizes , address sellAsset , address buyAsset )
38
+ {
39
+ sizes = chunkRebalanceSizes;
40
+ sellAsset = chunkRebalanceSellAsset;
41
+ buyAsset = chunkRebalanceBuyAsset;
42
+ }
43
+
44
+ function getStrategy () external view returns (FlexibleLeverageStrategyExtension.ContractSettings memory ) {
45
+ return strategy;
46
+ }
47
+
48
+ function getExchangeSettings (string memory _exchangeName ) external view returns (FlexibleLeverageStrategyExtension.ExchangeSettings memory ) {
49
+ return exchangeSettings[_exchangeName];
50
+ }
51
+
52
+ function getEnabledExchanges () external view returns (string [] memory ) {
53
+ return shouldRebalanceNames;
54
+ }
55
+
56
+ /* =========== Functions for setting mock state =========== */
57
+
58
+ function setShouldRebalanceWithBounds (
59
+ string [] memory _shouldRebalanceNames ,
60
+ FlexibleLeverageStrategyExtension.ShouldRebalance[] memory _shouldRebalancesEnums
61
+ )
62
+ external
63
+ {
64
+ shouldRebalanceNames = _shouldRebalanceNames;
65
+ shouldRebalancesEnums = _shouldRebalancesEnums;
66
+ }
67
+
68
+ function setGetChunkRebalanceWithBounds (
69
+ uint256 [] memory _chunkRebalanceSizes ,
70
+ address _chunkRebalanceSellAsset ,
71
+ address _chunkRebalanceBuyAsset
72
+ )
73
+ external
74
+ {
75
+ chunkRebalanceSizes = _chunkRebalanceSizes;
76
+ chunkRebalanceSellAsset = _chunkRebalanceSellAsset;
77
+ chunkRebalanceBuyAsset = _chunkRebalanceBuyAsset;
78
+ }
79
+
80
+ function setStrategy (FlexibleLeverageStrategyExtension.ContractSettings memory _strategy ) external {
81
+ strategy = _strategy;
82
+ }
83
+
84
+ function setExchangeSettings (string memory _exchangeName , FlexibleLeverageStrategyExtension.ExchangeSettings memory _settings ) external {
85
+ exchangeSettings[_exchangeName] = _settings;
86
+ }
87
+ }
0 commit comments