@poolzfinance/vault-manager
v1.0.1
Published
Vault Manager is a smart contract project that helps other contracts manage ERC20 tokens and maintain whitelists for each token.
Downloads
9
Keywords
Readme
Vault Manager
Description
Vault Manager is a smart contract project that helps other contracts manage ERC20 tokens and maintain whitelists for each token.
Features
- Management of ERC20 tokens
- Whitelisting functionalities
- Owner-based actions
Prerequisites
Installation
- Clone the repository:
git clone https://github.com/The-Poolz/VaultManager.git
- Install the dependencies:
npm install
- Run the Hardhat test:
npx hardhat test
Usage
After deploying the contracts, the owner (the deployer) can perform various operations.
From an External Contract
Deposit
To deposit tokens into a vault, the external contract should call depositByToken
from VaultManager.sol
. Make sure that msg.sender
is set to the _from
address.
Withdraw
To withdraw tokens, the external contract calls the
withdraw` function.
Owner Functionalities
If you are the owner of the deployed contracts, you have the following additional functionalities:
In VaultManager.sol
- Set Trustee: Must be called to finish the setup and can only be called once. After that, use
updateTrustee
to change the trustee. - Set Trade Start Time: Can be used to change the trade start time initially set during vault creation with
createNewVault
. - Set Vault Royalty: Can be used to change the royalty details initially set during vault creation with
createNewVault
. - Create New Vault: This function has multiple overloads, allowing you to create new vaults with different configurations.
- Update Trustee: You can update the trustee address using
updateTrustee
.
In Vault.sol
The Vault is an internal contract that is managed solely by its creator, the VaultManager contract. No one else can interact with it directly. It serves as a small internal part responsible for specific functionalities like withdraw
.
- Withdraw: The Vault Manager, which is the entity that creates the vault, has the ability to withdraw tokens to a specified address using the
withdraw
function.
Role of the Trustee
Only the trustee can use the tokens stored in the vaults, not the owner.
Code Overview
Solidity Contracts
- IVault.sol: Defines the interface for Vault contract.
- Vault.sol: Implements the Vault functionalities.
- IVaultManager.sol: Defines the interface for Vault Manager.
- VaultManager.sol: Implements the Vault Manager functionalities.
- VaultManagerEvents.sol: Contains events for Vault Manager.
Tests
- 1_Vault.ts: Test cases for Vault.
- 2_VaultManager.ts: Test cases for Vault Manager.
- 3_VaultManagerFail.ts: Negative test cases for Vault Manager.
Contributing
Feel free to open an issue or submit a pull request.
License
This project is licensed under the MIT License.