This repository has been archived by the owner on Apr 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBorrower.sol
82 lines (65 loc) · 3.08 KB
/
Borrower.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
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
pragma experimental ABIEncoderV2;
import "lib/zivoe-core-foundry/lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
contract Borrower {
/************************/
/*** DIRECT FUNCTIONS ***/
/************************/
function transferByTrader(address token, address to, uint256 amount) external {
IERC20(token).transfer(to, amount);
}
/*********************/
/*** TRY FUNCTIONS ***/
/*********************/
function try_approveToken(address token, address to, uint256 amount) external returns (bool ok) {
string memory sig = "approve(address,uint256)";
(ok,) = address(token).call(abi.encodeWithSignature(sig, to, amount));
}
function try_createOffer(
address occ,
address borrower,
uint256 borrowAmount,
uint256 APR,
uint256 APRLateFee,
uint256 term,
uint256 paymentInterval,
uint256 gracePeriod,
int8 schedule
) external returns (bool ok) {
string memory sig = "createOffer(address,uint256,uint256,uint256,uint256,uint256,uint256,int8)";
(ok,) = address(occ).call(abi.encodeWithSignature(sig, borrower, borrowAmount, APR, APRLateFee, term, paymentInterval, gracePeriod, schedule));
}
function try_cancelOffer(address occ, uint256 id) external returns (bool ok) {
string memory sig = "cancelOffer(uint256)";
(ok,) = address(occ).call(abi.encodeWithSignature(sig, id));
}
function try_acceptOffer(address occ, uint256 id) external returns (bool ok) {
string memory sig = "acceptOffer(uint256)";
(ok,) = address(occ).call(abi.encodeWithSignature(sig, id));
}
function try_makePayment(address occ, uint256 id) external returns (bool ok) {
string memory sig = "makePayment(uint256)";
(ok,) = address(occ).call(abi.encodeWithSignature(sig, id));
}
function try_resolveDefault(address occ, uint256 id, uint256 amount) external returns (bool ok) {
string memory sig = "resolveDefault(uint256,uint256)";
(ok,) = address(occ).call(abi.encodeWithSignature(sig, id, amount));
}
function try_callLoan(address occ, uint256 id) external returns (bool ok) {
string memory sig = "callLoan(uint256)";
(ok,) = address(occ).call(abi.encodeWithSignature(sig, id));
}
function try_markDefault(address occ, uint256 id) external returns (bool ok) {
string memory sig = "markDefault(uint256)";
(ok,) = address(occ).call(abi.encodeWithSignature(sig, id));
}
function try_resolveInsolvency(address occ, uint256 id, uint256 amount) external returns (bool ok) {
string memory sig = "resolveInsolvency(uint256,uint256)";
(ok,) = address(occ).call(abi.encodeWithSignature(sig, id, amount));
}
function try_supplyInterest(address occ, uint256 id, uint256 excessAmount) external returns (bool ok) {
string memory sig = "supplyInterest(uint256,uint256)";
(ok,) = address(occ).call(abi.encodeWithSignature(sig, id, excessAmount));
}
}