Skip to content

Commit 68b5ed6

Browse files
committed
filled in the blanks
Signed-off-by: Alexander Diemand <[email protected]>
1 parent 54befaa commit 68b5ed6

File tree

1 file changed

+53
-7
lines changed

1 file changed

+53
-7
lines changed

doc/Contracts.md

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Smart contracts
22

3-
## BCA_ERC20_nf.sol
3+
## Contract: BCAServiceToken
44

55
This contract implements an ERC20 token following the definitions from OpenZeppelin:
66

77
Source file: [BCA_ERC20_nf.sol](../bca-token-solidity/contracts/BCA_ERC20_nf.sol)
88

9+
Implements interfaces:
910
- `import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"`
1011
- the `constructor(string memory setName, string memory setSymbol, address setMinter, address setBurner)`
1112

@@ -19,12 +20,16 @@ The contract has public fields:
1920
- `address public minterAddress`
2021
- `address public burnerAddress`
2122

22-
## BCA_ServiceManager.sol
23+
## Contract: BCAServiceManager
2324

2425
The service manager contract is at the top of the hierarchy of contracts and serves as an entry point. It is parameterized by the ERC20 or stable-coin address that is used throughout the dependent contracts. It stores the addresses of provider controller contracts.
2526

2627
Source file: [BCA_ServiceManager.sol](../bca-token-solidity/contracts/BCA_ServiceManager.sol)
2728

29+
Implements interfaces:
30+
- [IServiceManager](../bca-token-solidity/contracts/Iface_ServiceManager.sol)
31+
- [ReentrancyGuard](https://docs.openzeppelin.com/contracts/4.x/api/security#ReentrancyGuard)
32+
2833
The contract has public fields:
2934
- `IERC20 public immutable tokToken`
3035
* address of the ERC20 token as stable-coin
@@ -52,13 +57,17 @@ The contract has public methods:
5257
- `function countServiceControllers() public view returns (uint)`
5358
* returns the number of known controllers by this service manager
5459
55-
## BCA_ServiceController.sol
60+
## Contract: BCAServiceController
5661
5762
The service controller contract is deployed for every provider.
5863
It keeps a list of addresses for the services that the provider offers.
5964
6065
Source file: [BCA_ServiceController.sol](../bca-token-solidity/contracts/BCA_ServiceController.sol)
6166
67+
Implements interfaces:
68+
- [IServiceController](../bca-token-solidity/contracts/Iface_ServiceController.sol)
69+
- [ReentrancyGuard](https://docs.openzeppelin.com/contracts/4.x/api/security#ReentrancyGuard)
70+
6271
The contract has public fields:
6372
- `IERC20 public immutable tokToken`
6473
* the common ERC20 or stable-coin
@@ -74,12 +83,16 @@ The contract has public methods:
7483
- `function countServiceContracts() public view returns (uint)`
7584
* returns the number of services in the array, necessary to enumerate the array entries
7685
77-
## BCA_Service.sol
86+
## Contract: BCAService
7887
7988
A service references a provider and the common ERC20/stable-coin and is parameterized with the maximal number of instances and the price of the service per day.
8089
8190
Source file: [BCA_Service.sol](../bca-token-solidity/contracts/BCA_Service.sol)
8291
92+
Implements interfaces:
93+
- [IService](../bca-token-solidity/contracts/Iface_Service.sol)
94+
- [ReentrancyGuard](https://docs.openzeppelin.com/contracts/4.x/api/security#ReentrancyGuard)
95+
8396
The contract has public fields:
8497
- `IERC20 public immutable tokToken`
8598
- `uint256 public immutable dayPrice`
@@ -93,47 +106,80 @@ The contract has public methods:
93106
- `function newInstance(address userAddress) external nonReentrant returns (address)`
94107
- `function countServiceInstances() public view returns (uint)`
95108
96-
## BCA_ServiceInstance.sol
109+
## Contract: BCAServiceInstance
110+
111+
This contract is at the heart of the market and represents a service instance. A user subscribes to a service with a first deposit of funds. This sets the start time of the contract from which the balances are calculated.
97112
98113
Source file: [BCA_ServiceInstance.sol](../bca-token-solidity/contracts/BCA_ServiceInstance.sol)
99114
115+
Implements interfaces:
116+
- [IServiceInstance](../bca-token-solidity/contracts/Iface_ServiceInstance.sol)
117+
- [ReentrancyGuard](https://docs.openzeppelin.com/contracts/4.x/api/security#ReentrancyGuard)
118+
100119
The contract has public fields:
101120
- `IERC20 public immutable tokToken`
121+
* the common ERC20/stable-coin
102122
- `uint256 public immutable dayPrice`
123+
* the price of the service for 24 hours; minimizes rounding errors
103124
- `address public immutable providerAddress`
125+
* the address of the provider
104126
- `address public immutable userAddress`
127+
* the address of the user
105128
- `uint256 public deposit`
129+
* the amount of deposits made by the user
106130
- `uint256 public retracted`
131+
* the amount of withdrawals made by the provider
107132
- `uint256 public startTime`
133+
* when the contract has been started
108134
- `uint256 public endTime`
135+
* when it has been stopped
109136
110137
The contract has public methods:
111138
- `constructor(address setProviderAddress, address tokAddress,
112139
address setUserAddress,
113140
uint256 setDayPrice)`
114141
- `function makeDeposit(uint256 amount) external nonReentrant`
142+
* deposits can only be made from the user's address
115143
- `function stop() external nonReentrant`
144+
* both parties may call stop() at any time
116145
- `function balanceUser() public view returns (uint256)`
146+
* calculates the user's balance
117147
- `function balanceProvider() public view returns (uint256)`
148+
* calculates the provider's balance
118149
- `function withdrawUser(uint256 amount) external nonReentrant`
150+
* the user may withdraw from his balance; this will affect the deposit
119151
- `function withdrawProvider(uint256 amount) external nonReentrant`
152+
* the provider may withdraw up to his calculated balance
153+
120154
155+
## Contract: BCAServiceFunding24
121156
122-
## BCA_Funding24.sol
157+
This contract automates the funding of a service contract by transferring the required funds to run the service every 24 hours. The contract is guaranteed to only transfer the said amount at most every 24 hours. It requires an external transaction to `deposit()` which is sent from a bot.
123158
124159
Source file: [BCA_Funding24.sol](../bca-token-solidity/contracts/BCA_Funding24.sol)
125160
161+
Implements interfaces:
162+
- [IFunding24](../bca-token-solidity/contracts/Iface_Funding24.sol)
163+
- [Ownable](https://docs.openzeppelin.com/contracts/4.x/api/access#Ownable)
164+
126165
The contract has public fields:
127166
- `address public immutable targetContract`
167+
* the target contract
128168
- `uint256 public immutable dailyAmount`
169+
* the amount to deposit every 24 hours
129170
- `IERC20 public immutable token`
171+
* the common ERC20/stable-coin
130172
- `uint256 public lastDepositTime`
173+
* remembers the last time a deposit was made
131174
132175
The contract has public methods:
133176
- `constructor(
134177
address initialOwner,
135178
address setTargetContract,
136179
address setToken,
137180
uint256 setDailyAmount`
181+
* the parameterization of the contract is done in the constructor. The owner is set to the service user.
138182
- `function deposit() external`
139-
- `function canDeposit() external view returns (bool)`
183+
* this method triggers the transfer of funds and makes the deposit to the service contract
184+
- `function canDeposit() external view returns (bool)`
185+
* returns true if a deposit can be make

0 commit comments

Comments
 (0)