|
2 | 2 |
|
3 | 3 | <img src={require("/static/img/docs/solarity.png").default} alt=""/>
|
4 | 4 |
|
5 |
| -## Solidity Library for Savvies by Distributed Lab |
6 |
| - |
7 |
| -The library consists of modules and utilities that are built leveraging [Openzeppelin Contracts](https://github.com/OpenZeppelin/openzeppelin-contracts) (4.9.6) and **go far beyond mediocre solidity**. |
| 5 | +## Solarity Solidity Library |
| 6 | + |
| 7 | +Solidity contracts and utilities that **go far beyond mediocre solidity**. |
| 8 | + |
| 9 | +### Contracts |
| 10 | + |
| 11 | +```ml |
| 12 | +contracts |
| 13 | +├── access |
| 14 | +│ ├── AMerkleWhitelisted — "Whitelists via Merkle proofs" |
| 15 | +│ ├── AMultiOwnable — "Multiple owners with the equal access level" |
| 16 | +│ ├── ARBAC — "A powerful implementation of a true RBAC" |
| 17 | +│ └── extensions |
| 18 | +│ └── ARBACGroupable — "Groupable extension of ARBAC" |
| 19 | +├── contracts—registry |
| 20 | +│ ├── AContractsRegistry — "Reference registry implementation of ERC-6224 pattern" |
| 21 | +│ ├── ADependant — "Reference dependant implementation of ERC-6224 pattern" |
| 22 | +│ └── pools |
| 23 | +│ ├── APoolContractsRegistry — "Adaptation of ERC-6224 for factory-like contracts" |
| 24 | +│ └── APoolFactory — "Factory implementation for a pooled registry" |
| 25 | +├── diamond |
| 26 | +│ ├── ADiamondStorage — "The storage part of ERC-2535 diamond" |
| 27 | +│ ├── Diamond — "Revised ERC-2535 diamond implementation" |
| 28 | +│ └── utils |
| 29 | +│ ├── AInitializableStorage — "Initializable logic for diamond facets" |
| 30 | +│ └── DiamondERC165 — "ERC-165 introspection for diamond facets" |
| 31 | +├── finance |
| 32 | +│ ├── compound—rate—keeper |
| 33 | +│ │ └── ACompoundRateKeeper — "Complex percentage calculator used in lending protocols" |
| 34 | +│ ├── staking |
| 35 | +│ │ ├── AStaking — "Flexible rewards staking implementation" |
| 36 | +│ │ └── AValueDistributor — "Efficient distribution algorithm implementation" |
| 37 | +│ └── vesting |
| 38 | +│ └── AVesting — "Linear and exponential vesting implementation" |
| 39 | +├── libs |
| 40 | +│ ├── arrays |
| 41 | +│ │ ├── ArrayHelper — "Common functions to work with arrays" |
| 42 | +│ │ ├── Paginator — "Return array slices from view function" |
| 43 | +│ │ └── SetHelper — "Array abstraction over sets" |
| 44 | +│ ├── bn |
| 45 | +│ │ └── U512 — "A hyperoptimized uint512 implementation" |
| 46 | +│ ├── crypto |
| 47 | +│ │ ├── ECDSA256 — "ECDSA verification over any 256-bit curves" |
| 48 | +│ │ ├── ECDSA384 — "ECDSA verification over any 384-bit curves" |
| 49 | +│ │ ├── ECDSA512 — "ECDSA verification over any 512-bit curves" |
| 50 | +│ │ └── RSASSAPSS — "RSASSA-PSS verification with MGF1" |
| 51 | +│ ├── data—structures |
| 52 | +│ │ ├── AvlTree — "AVL tree implementation with an iterator traversal" |
| 53 | +│ │ ├── CartesianMerkleTree — "CMT reference implementation" |
| 54 | +│ │ ├── DynamicSet — "Set for strings and bytes" |
| 55 | +│ │ ├── IncrementalMerkleTree — "IMT implementation with flexible tree height" |
| 56 | +│ │ ├── PriorityQueue — "Max queue heap implementation" |
| 57 | +│ │ ├── SparseMerkleTree — "SMT optimized implementation" |
| 58 | +│ │ └── memory |
| 59 | +│ │ └── Vector — "A pushable memory array" |
| 60 | +│ ├── utils |
| 61 | +│ │ ├── DecimalsConverter — "Simplify interaction with ERC-20 decimals" |
| 62 | +│ │ ├── MemoryUtils — "Functions for memory manipulation" |
| 63 | +│ │ ├── ReturnDataProxy — "Bypass extra returndata copy when returning data" |
| 64 | +│ │ └── Typecaster — "Cast between various Solidity types" |
| 65 | +│ └── zkp |
| 66 | +│ ├── Groth16VerifierHelper — "Simplify integration with Groth16 proofs" |
| 67 | +│ └── PlonkVerifierHelper — "Simplify integration with Plonk proofs" |
| 68 | +├── oracles |
| 69 | +│ ├── AUniswapV2Oracle — "Uniswap V2 oracle with custom TWAP" |
| 70 | +│ └── UniswapV3Oracle — "Uniswap V3 oracle with a clean interface" |
| 71 | +├── proxy |
| 72 | +│ └── adminable |
| 73 | +│ ├── AdminableProxy — "A slight modification of a transparent proxy" |
| 74 | +│ └── AdminableProxyUpgrader — "A slight modification of a proxy admin" |
| 75 | +├── tokens |
| 76 | +│ └── ASBT — "A minimal implementation of an SBT" |
| 77 | +├── utils |
| 78 | +│ ├── ABlockGuard — "Protect against flashloans" |
| 79 | +│ └── Globals — "Some commonly used constants" |
| 80 | +├── presets — "Presets for the library contracts" |
| 81 | +├── interfaces — "Interfaces for the library contracts" |
| 82 | +└── mock — "Mocks for testing purposes" |
| 83 | +``` |
8 | 84 |
|
9 |
| -* Implementation of the [**Contracts Registry**](https://eips.ethereum.org/EIPS/eip-6224) pattern |
10 |
| -* State-of-the-art cryptography primitives (**ECDSA over 256-bit and 384-bit curves**, **RSASSA-PSS**) |
11 |
| -* Advanced data structures (**Vector**, **DynamicSet**, **PriorityQueue**, **AVLTree**) |
12 |
| -* ZK-friendly [**Sparse Merkle Tree**](https://docs.iden3.io/publications/pdfs/Merkle-Tree.pdf) and [**Incremental Merkle Tree**](https://github.com/runtimeverification/deposit-contract-verification/blob/master/deposit-contract-verification.pdf) implementations |
13 |
| -* Versatile **RBAC** and **MultiOwnable** smart contracts |
14 |
| -* Enhanced and simplified [**Diamond**](https://eips.ethereum.org/EIPS/eip-2535) pattern |
15 |
| -* Flexible finance instruments (**Staking**, **Vesting**) |
16 |
| -* Novel **ReturnDataProxy** contract |
17 |
| -* Robust UniswapV2 and UniswapV3 oracles |
18 |
| -* Lightweight **SBT** implementation |
19 |
| -* Utilities to ease work with memory, types, ERC20 decimals, arrays, sets, and ZK proofs |
| 85 | +Built with courage and aspiration to perfection. |
20 | 86 |
|
21 |
| -Checkout guides section for detailed explanations with usage examples for each module. |
| 87 | +> The library is designed to work cohesively with [hardhat-zkit](https://github.com/dl-solarity/hardhat-zkit) and [circom-lib](https://github.com/dl-solarity/circom-lib) packages. |
22 | 88 |
|
23 | 89 | ### Installation
|
24 | 90 |
|
25 | 91 | ```bash
|
26 |
| -$ npm install @solarity/solidity-lib |
| 92 | +npm install @solarity/solidity-lib |
27 | 93 | ```
|
28 | 94 |
|
29 | 95 | The latest stable version is always in the `master` branch.
|
30 | 96 |
|
31 |
| -### Usage |
32 |
| - |
33 |
| -You will find the smart contracts in the `contracts` directory. Feel free to play around and check the source code, it is rather descriptive. |
34 |
| - |
35 |
| -Once the [npm package](https://www.npmjs.com/package/@solarity/solidity-lib) is installed, one can use the library just like that: |
36 |
| - |
37 |
| -```solidity |
38 |
| -pragma solidity ^0.8.4; |
39 |
| -
|
40 |
| -import "@solarity/solidity-lib/contracts-registry/presets/OwnableContractsRegistry.sol"; |
41 |
| -
|
42 |
| -contract ContractsRegistry is OwnableContractsRegistry { |
43 |
| - . . . |
44 |
| -} |
45 |
| -``` |
46 |
| - |
47 |
| -> It is important to use the library as it is shipped and not copy-paste the code from untrusted sources. |
48 |
| -
|
49 | 97 | ### Contribution
|
50 | 98 |
|
51 |
| -We are open to contributions to our [solidity-lib](https://github.com/dl-solarity/solidity-lib/tree/master) repository. If you're interested in contributing, please visit the [How to contribute](./contribution/how-to-contribute.md) section. |
| 99 | +We are open to any mind-blowing ideas! Please take a look at our [contribution guidelines](https://docs.solarity.dev/docs/getting-started/contribution/how-to-contribute) to get involved. |
52 | 100 |
|
53 | 101 | ### License
|
54 | 102 |
|
|
0 commit comments