-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathIBorrowing.sol
177 lines (158 loc) · 5 KB
/
IBorrowing.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
// SPDX-License-Identifier: MIT
import "../interface/IOptions.sol";
import "../interface/ITreasury.sol";
import "../interface/IGlobalVariables.sol";
import "../interface/CDSInterface.sol";
import "../interface/IUSDa.sol";
import "../interface/IAbond.sol";
pragma solidity 0.8.22;
interface IBorrowing {
error Borrow_DepositFailed();
error Borrow_GettingETHPriceFailed();
error Borrow_MintFailed();
error Borrow_USDaTransferFailed();
error Borrow_ETHTransferFailed();
error Borrow_BurnFailed();
error Borrow_EthTransferToCdsFailed();
error Borrow_RenewFailed();
error Borrow_TransferFailed();
error Borrow_CollateralAddressesAndPriceFeedIdsMustBeSameLength();
error Borrow_CallerIsNotAnAdmin();
error Borrow_OnlyTreasuryCancall();
error Borrow_Paused();
error Borrow_OnlyCoreContractsCancall();
error Borrow_CantBeEOAOrZeroAddress(address inputAddress);
error Borrow_RequiredApprovalsNotMetToSet();
error Borrow_CantBeContractOrZeroAddress(address inputAddress);
error Borrow_MustBeNonZeroAddress(address user);
error Borrow_CantLiquidateOwnAssets();
error Borrow_InvalidIndex();
error Borrow_NeedsMoreThanZero();
error Borrow_InsufficientBalance();
error Borrow_AlreadyWithdrewOrLiquidated();
error Borrow_DeadlinePassed();
error Borrow_BorrowHealthLow();
error Borrow_LTVIsZero();
error Borrow_NotEnoughFundInCDS();
error Borrow_AlreadyLiquidated();
error Borrow_AlreadyWithdrew();
error Borrow_NotSignedByEIP712Signer();
enum DownsideProtectionLimitValue {
// 0: deside Downside Protection limit by percentage of eth price in past 3 months
ETH_PRICE_VOLUME,
// 1: deside Downside Protection limit by CDS volume divided by borrower volume.
CDS_VOLUME_BY_BORROWER_VOLUME
}
enum AssetName {
DUMMY,
ETH,
WeETH,
WrsETH,
rsETH,
USDa,
ABOND,
TUSDT
}
enum LiquidationType {
DUMMY,
ONE,
TWO,
THREE
}
struct OmniChainBorrowingData {
uint256 normalizedAmount;
uint256 ethVaultValue;
uint256 cdsPoolValue;
uint256 totalCDSPool;
uint256 ethRemainingInWithdraw;
uint256 ethValueRemainingInWithdraw;
uint128 noOfLiquidations;
uint64 nonce;
}
struct BorrowDepositParams {
IOptions.StrikePrice strikePercent;
uint64 strikePrice;
uint256 volatility;
AssetName assetName;
uint256 depositingAmount;
}
struct BorrowLibDeposit_Params {
uint8 LTV;
uint8 APR;
uint256 lastCumulativeRate;
uint256 totalNormalizedAmount;
uint128 exchangeRate;
uint128 ethPrice;
uint128 lastEthprice;
}
struct BorrowDeposit_Result {
uint256 totalNormalizedAmount;
uint256 collateralRemainingInWithdraw;
uint256 collateralValueRemainingInWithdraw;
}
struct BorrowWithdraw_Params {
address toAddress;
uint64 index;
uint64 ethPrice;
uint128 exchangeRate;
uint64 withdrawTime;
uint256 lastCumulativeRate;
uint256 totalNormalizedAmount;
uint64 bondRatio;
uint256 collateralRemainingInWithdraw;
uint256 collateralValueRemainingInWithdraw;
}
struct BorrowWithdraw_Result {
uint128 downsideProtected;
uint256 totalNormalizedAmount;
uint256 collateralRemainingInWithdraw;
uint256 collateralValueRemainingInWithdraw;
}
struct CalculateCollateralToReturn_Param {
IOptions options;
ITreasury.DepositDetails depositDetail;
IGlobalVariables.OmniChainData omniChainData;
uint128 borrowingHealth;
uint64 ethPrice;
uint256 collateralRemainingInWithdraw;
uint256 collateralValueRemainingInWithdraw;
}
struct CalculateCollateralToReturn_Result {
uint128 collateralToReturn;
uint256 collateralRemainingInWithdraw;
uint256 collateralValueRemainingInWithdraw;
IGlobalVariables.OmniChainData omniChainData;
}
struct Interfaces {
ITreasury treasury;
IGlobalVariables globalVariables;
IUSDa usda;
IABONDToken abond;
CDSInterface cds;
IOptions options;
}
function getUSDValue(
address token
) external view returns (uint128, uint128);
function calculateRatio(
uint256 _amount,
uint128 currentEthPrice
) external returns (uint64);
function assetAddress(AssetName assetName) external view returns (address);
event Withdraw(
address user,
uint64 index,
uint256 withdrawTime,
uint128 withdrawAmount,
uint128 noOfAbond,
uint256 borrowDebt
);
event Liquidate(
uint64 index,
uint128 liquidationAmount,
uint128 profits,
uint128 ethAmount,
uint256 availableLiquidationAmount
);
event Renewed(address borrower, uint64 index, uint256 timestamp);
}