Skip to content

Commit 7254d74

Browse files
committed
docs: update readme with details
1 parent 2644e53 commit 7254d74

1 file changed

Lines changed: 41 additions & 4 deletions

File tree

README.md

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,44 @@ time-lock vault functionality such as `deposit`, `withdraw` and `batchWithdraw`.
2222
## Custom Vaults
2323

2424
Alternatively, you can create your own Solidity vault contract by extending the `TimeLockVault`
25-
abstract contract and implementing your desired logic. Your contract can inherit additional
26-
functionalities such as premature withdrawal (refer to the `_prematureWithdraw` function) before the
27-
maturity date subject your specific condition, control over the depositor/recipient addresses, and
28-
other aspects.
25+
abstract contract and implementing your desired logic.
26+
27+
### Installation
28+
29+
```bash
30+
npm install @superical/time-lock-vault --save-dev
31+
```
32+
33+
### Usage
34+
35+
Note that the `TimeLockVault` is an upgradeable contract. If you don't plan on upgrading your vault
36+
contract, you should initialise it in your constructor.
37+
38+
```solidity
39+
import "@superical/time-lock-vault/contracts/TimeLockVault.sol";
40+
41+
contract MyCustomVault is TimeLockVault {
42+
constructor(string memory _name, string memory _symbol, address _asset) initializer {
43+
// Initialize the TimeLockVault contract
44+
__TimeLockVault_init(_name, _symbol, _asset);
45+
}
46+
47+
// Implement custom deposit logic
48+
function deposit(uint256 amount) external {
49+
// Custom deposit condition here...
50+
// Deposit from the sender to himself and to be locked for 1 day
51+
_deposit(_msgSender(), _msgSender(), amount, 86400);
52+
}
53+
54+
// Implement custom withdraw logic
55+
function withdraw(uint256 depositId) external {
56+
// Custom withdrawal condition here...
57+
// Withdraw deposit ID to sender
58+
_withdraw(depositId);
59+
}
60+
}
61+
```
62+
63+
Your contract will inherit additional functionalities such as premature withdrawal (refer to the
64+
`_prematureWithdraw` function) before the maturity date subject your specific condition, control
65+
over the depositor/recipient addresses, and other aspects.

0 commit comments

Comments
 (0)