Skip to content

Commit d7b0c6b

Browse files
committed
Restructure docs generation around mkdocs
1 parent 59c0081 commit d7b0c6b

23 files changed

+361
-526
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/**/spa/**/style.css
33

44
docs/build
5+
docs/md-build
56

67
# Created by https://www.toptal.com/developers/gitignore/api/python,solidity,visualstudiocode,react
78
# Edit at https://www.toptal.com/developers/gitignore?templates=python,solidity,visualstudiocode,react

CONTRIBUTING.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Contributing guidelines
2+
3+
## Table of Contents
4+
5+
- [Table of Contents](#table-of-contents)
6+
- [Coding Style](#coding-style)
7+
- [Solidity](#solidity)
8+
- [JavaScript](#javascript)
9+
- [Python](#python)
10+
- [Documentation](#documentation)
11+
- [mkdocs](#mkdocs)
12+
13+
## Coding Style
14+
15+
### Solidity
16+
17+
* Solidity portions of the codebase adhere follow the official [Solidity Styleguide]
18+
19+
### JavaScript
20+
21+
### Python
22+
23+
* Python portions of the codebase follow standard PEP8 best practices.
24+
* Python code must be formatted using the Black formatter using the provided settings.
25+
26+
## Documentation
27+
28+
New addition to the codebase must be fully documented.
29+
30+
- JavaScript portions of the code should be annotated using JSDoc style docstrings.
31+
- Solidity portions of the code should be fully annotated using [NatSpec] and [Solidity Domain for Sphinx].
32+
33+
Documentation is generated using [solidity-docgen] and rendered via [mkdocs].
34+
[solidity-docgen] parses NatSpec and outputs `.md` files inside `docs/md-build` according
35+
to an Handlebars template located at `docs/solidity-docgen-templates/contract.hbs`.
36+
37+
**NOTE:** Each `.sol` file should contain only one `Interface` or `Contract`.
38+
39+
To build the documentation:
40+
41+
```console
42+
yarn build docs
43+
```
44+
45+
To serve the documentation
46+
47+
```console
48+
yarn build docs
49+
```
50+
51+
### mkdocs
52+
53+
To install [mkdocs] Python must be installed in the system.
54+
55+
```
56+
pip install docs/requirements.in
57+
```
58+
59+
**NOTE:** Working inside a virtual environment is highly recommended!
60+
61+
---
62+
63+
[Solidity Styleguide]: https://solidity.readthedocs.io/en/v0.7.0/style-guide.html
64+
[NatSpec]: https://solidity.readthedocs.io/en/v0.7.0/style-guide.html#natspec
65+
[Write the Docs!]: docs/source/write_the_docs.rst
66+
[solidity-docgen]: https://github.com/OpenZeppelin/solidity-docgen
67+
[mkdocs]: https://www.mkdocs.org/

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# unifi
2+
3+
A DFO protocol powered DeFi set of tools built on top of Uniswap.

contracts/stableCoin/MintNewVotingTokensForStableCoinFunctionality.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
pragma solidity ^0.6.0;
44

55
/**
6-
* @title Mint Voting Tokens (unifi) by burning Stable Coin (uSD) // DOCUMENT
6+
* @title Mint Voting Tokens ($unifi) by burning Stable Coin ($uSD) // DOCUMENT
7+
* @dev This contract define the logic that is used
78
*/
89
contract MintNewVotingTokensForStableCoinFunctionality {
910
function onStart(address, address) public {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pragma solidity ^0.6.0;
2+
3+
// DOCUMENT
4+
interface IDoubleProxy {
5+
function proxy() external view returns (address);
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pragma solidity ^0.6.0;
2+
3+
// DOCUMENT
4+
interface IMVDFunctionalitiesManager {
5+
function isAuthorizedFunctionality(address functionality) external view returns (bool);
6+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pragma solidity ^0.6.0;
2+
3+
// DOCUMENT
4+
interface IMVDProxy {
5+
function getToken() external view returns (address);
6+
7+
function getMVDFunctionalitiesManagerAddress() external view returns (address);
8+
9+
function getMVDWalletAddress() external view returns (address);
10+
11+
function getStateHolderAddress() external view returns (address);
12+
13+
function submit(string calldata codeName, bytes calldata data)
14+
external
15+
payable
16+
returns (bytes memory returnData);
17+
}

contracts/stableCoin/standalone/IStableCoin.sol

Lines changed: 6 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ interface IStableCoin {
156156
) external returns (uint256 amountA, uint256 amountB);
157157

158158
/**
159-
* @dev Rebalance by Credit is triggered when the total amount of source tokens is greater
159+
* @dev Rebalance by Credit is triggered when the total amount of source tokens' value is greater
160160
* than uSD circulating supply. Rebalancing is done by withdrawing the excess from the pool.
161161
*
162162
* =====
@@ -172,183 +172,13 @@ interface IStableCoin {
172172
) external returns (uint256 redeemed);
173173

174174
/**
175-
* @dev // DOCUMENT
176-
*/
177-
function rebalanceByDebt(uint256 amount) external returns (uint256);
178-
}
179-
180-
// -----------------------------------------------------------------------------------------------|
181-
182-
// DOCUMENT
183-
interface IDoubleProxy {
184-
function proxy() external view returns (address);
185-
}
186-
187-
// -----------------------------------------------------------------------------------------------|
188-
189-
// DOCUMENT
190-
interface IMVDProxy {
191-
function getToken() external view returns (address);
192-
193-
function getMVDFunctionalitiesManagerAddress() external view returns (address);
194-
195-
function getMVDWalletAddress() external view returns (address);
196-
197-
function getStateHolderAddress() external view returns (address);
198-
199-
function submit(string calldata codeName, bytes calldata data)
200-
external
201-
payable
202-
returns (bytes memory returnData);
203-
}
204-
205-
// -----------------------------------------------------------------------------------------------|
206-
207-
// DOCUMENT
208-
interface IMVDFunctionalitiesManager {
209-
function isAuthorizedFunctionality(address functionality) external view returns (bool);
210-
}
211-
212-
// -----------------------------------------------------------------------------------------------|
213-
214-
// DOCUMENT
215-
interface IStateHolder {
216-
function getBool(string calldata varName) external view returns (bool);
217-
218-
function getUint256(string calldata varName) external view returns (uint256);
219-
}
220-
221-
// -----------------------------------------------------------------------------------------------|
222-
223-
/**
224-
* @title Uniswap V2 Router
225-
* @dev Route liquidity back and forth an Uniswap Liquidity Pool.
226-
* For more information see: https://uniswap.org/docs/v2/smart-contracts/router02/
227-
*
228-
*/
229-
interface IUniswapV2Router {
230-
/**
231-
* https://uniswap.org/docs/v2/smart-contracts/library#getamountsout
232-
* Given an input asset amount and an array of token addresses, calculates all subsequent maximum
233-
* output token amounts by calling getReserves for each pair of token addresses in the path in
234-
* turn, and using these to call getAmountOut. Useful for calculating optimal token amounts
235-
* before calling swap.
236-
*/
237-
function getAmountsOut(uint256 amountIn, address[] calldata path)
238-
external
239-
view
240-
returns (uint256[] memory amounts);
241-
242-
/**
243-
* @dev Removes liquidity from an ERC-20⇄ERC-20 pool
244-
*
245-
* https://uniswap.org/docs/v2/smart-contracts/router02/#addliquidity
246-
*
247-
* =====
248-
*
249-
* @param tokenA A pool token
250-
* @param tokenB A pool token
251-
* @param liquidity The amount of liquidity tokens to remove
252-
* @param amountAMin The minimum amount of tokenA that must be received for the transaction not to revert
253-
* @param amountBMin The minimum amount of tokenB that must be received for the transaction not to revert
254-
* @param to Recipient of the underlying assets
255-
* @param deadline Unix timestamp after which the transaction will revert
256-
*
257-
* =====
258-
*
259-
* @return amountA The amount of tokenA received
260-
* @return amountB The amount of tokenB received
261-
*
262-
*/
263-
function removeLiquidity(
264-
address tokenA,
265-
address tokenB,
266-
uint256 liquidity,
267-
uint256 amountAMin,
268-
uint256 amountBMin,
269-
address to,
270-
uint256 deadline
271-
) external returns (uint256 amountA, uint256 amountB);
272-
273-
/**
274-
* @dev Add Liquidity to an ERC-20⇄ERC-20 pool
275-
*
276-
* - To cover all possible scenarios, msg.sender should have already given the router an allowance
277-
* of at least amountADesired/amountBDesired on tokenA/tokenB.
278-
* - Always adds assets at the ideal ratio, according to the price when the transaction is executed.
279-
* - If a pool for the passed tokens does not exists, one is created automatically, and exactly
280-
* amountADesired/amountBDesired tokens are added.
281-
*
282-
* https://uniswap.org/docs/v2/smart-contracts/router02/#addliquidity
283-
*
284-
* =====
285-
*
286-
* @param tokenA A pool token
287-
* @param tokenB A pool token
288-
* @param liquidity The amount of liquidity tokens to remove
289-
* @param amountADesired The amount of tokenA to add as liquidity if the B/A price is <=
290-
* amountBDesired/amountADesired (A depreciates).
291-
* @param amountBDesired The amount of tokenB to add as liquidity if the A/B price is <=
292-
* amountADesired/amountBDesired (B depreciates).
293-
* @param amountAMin Bounds the extent to which the B/A price can go up before the transaction reverts. Must be <= amountADesired.
294-
* @param amountBMin Bounds the extent to which the A/B price can go up before the transaction reverts. Must be <= amountBDesired.
295-
* @param to Recipient of the underlying assets
296-
* @param deadline Unix timestamp after which the transaction will revert
175+
* @dev Rebalance by Credit is triggered when the total amount of source tokens' value is greater
176+
* than uSD circulating supply. Rebalancing is done by withdrawing the excess from the pool.
297177
*
298178
* =====
299179
*
300-
* @return amountA The amount of tokenA sent to the pool
301-
* @return amountB The amount of tokenB sent to the pool
302-
* @return liquidity The amount of liquidity tokens minted
303-
*
180+
* @notice Positive imbalances can be caused by the accrual of liquidity provider fee. Withdrawn tokens
181+
* are stored inside the Unifi DFO as a source of long-term value
304182
*/
305-
function addLiquidity(
306-
address tokenA,
307-
address tokenB,
308-
uint256 amountADesired,
309-
uint256 amountBDesired,
310-
uint256 amountAMin,
311-
uint256 amountBMin,
312-
address to,
313-
uint256 deadline
314-
)
315-
external
316-
returns (
317-
uint256 amountA,
318-
uint256 amountB,
319-
uint256 liquidity
320-
);
321-
}
322-
323-
// -----------------------------------------------------------------------------------------------|
324-
325-
// DOCUMENT
326-
/**
327-
* @title Uniswap V2 Pair
328-
*/
329-
interface IUniswapV2Pair {
330-
// DOCUMENT
331-
function decimals() external pure returns (uint8);
332-
333-
// DOCUMENT
334-
function totalSupply() external view returns (uint256);
335-
336-
// DOCUMENT
337-
function token0() external view returns (address);
338-
339-
// DOCUMENT
340-
function token1() external view returns (address);
341-
342-
// DOCUMENT
343-
function balanceOf(address account) external view returns (uint256);
344-
345-
// DOCUMENT
346-
function getReserves()
347-
external
348-
view
349-
returns (
350-
uint112 reserve0,
351-
uint112 reserve1,
352-
uint32 blockTimestampLast
353-
);
183+
function rebalanceByDebt(uint256 amount) external returns (uint256);
354184
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pragma solidity ^0.6.0;
2+
3+
// DOCUMENT
4+
interface IStateHolder {
5+
function getBool(string calldata varName) external view returns (bool);
6+
7+
function getUint256(string calldata varName) external view returns (uint256);
8+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
pragma solidity ^0.6.0;
2+
3+
// DOCUMENT
4+
/**
5+
* @title Uniswap V2 Pair
6+
*/
7+
interface IUniswapV2Pair {
8+
// DOCUMENT
9+
function decimals() external pure returns (uint8);
10+
11+
// DOCUMENT
12+
function totalSupply() external view returns (uint256);
13+
14+
// DOCUMENT
15+
function token0() external view returns (address);
16+
17+
// DOCUMENT
18+
function token1() external view returns (address);
19+
20+
// DOCUMENT
21+
function balanceOf(address account) external view returns (uint256);
22+
23+
// DOCUMENT
24+
function getReserves()
25+
external
26+
view
27+
returns (
28+
uint112 reserve0,
29+
uint112 reserve1,
30+
uint32 blockTimestampLast
31+
);
32+
}

0 commit comments

Comments
 (0)