OmniTrust allows users to deposit any ERC20 or native asset of their choosing into Omnify. Upon creation of the deposit the creator can specify other owners who can modify any of the deposit's properties. Additionally, beneficiaries can be declared with or without daily allownces. More details are described below. Accessible from and
Interactions
Deposits and their properties
Before we dive in let's take a look at the createDeposit function, the Owner struct, and the Beneficiary struct.
function createDeposit(
string memory _id, // Deposit identifier, must not be a duplicate
uint256 _amount, // amount of the asset to be deposited (in Wei)
address _asset, // asset's contract address, use address(0) for the native token
bool _depositType, // Manages if the deposit is modifiable, true is modifiable
bool _liquidity, // Manage if deposit is retractable by any owner, true is retractable
bool _isActive, // Manage if deposit is active or not, true is active
Owner[] memory _owners, // Array of owner struct
Beneficiary[] memory _beneficiaries // Array of Beneficiary struct
) external payable;
Owner Struct
struct Owner {
address owner; // Owner's address
bool isOwner; // true is owner, this is used internally by the smart contract
}
Beneficiary Struct
struct Beneficiary {
address benef; // Beneficiary's address
uint256 allowance; // allowance/day if they are limited
bool isLimited; // controls if they should be limited by a daily allowance
uint256 dateLastWithdrawal; // date of last withdrawal, regulates daily allowance
}
Create a Deposit
1
Define an OmniTrust variable
ITrust99 public omnitrust = ITrust99(0xBdc066F91b9DB3b854e3Ec15b6816944896974CD);
2
Get Omnify's deposit & beneficiary fee and define msgVal variable
Omnify's deposit fee is charged when creating a deposit, or when depositing into an existing deposit. The beneficiary fee is charge per beneficiary when creating the deposit and when adding new beneficiaries while modifying the deposit.
uint256 public msgVal = 0;
uint256 public trustFee = omnitrust.depositFee();
uint256 public beneficiaryFee = omnitrust.beneficiaryFee(); // we will use this later
msgVal += trustFee;
3
Create the list of Beneficiaries and add them
In this example we defined 2 beneficiaries, one that withdraw without limits from the deposit, and one that is limited by a daily allowance.
uint256 public numOfBeneficiaries = 2;
ITrust99.Beneficiary[] memory beneficiaries = new ITrust99.Beneficiary[](numOfBeneficiaries)
ITrust99.Beneficiary public benef1 = ITrust99.Beneficiary(address(0x6BF6D002b5140b7CE0A0a4993621ecE52271e5f0), 0, false, 0); // unlimited beneficiary
ITrust99.Beneficiary public benef2 = ITrust99.Beneficiary(address(0x22c4D933bf8A882b065Bb5451d1Cf9991C817560), 1 * 10**15, true, 0); // beneficiary with an allowance
beneficiaries[0] = benef1;
beneficiaries[1] = benef2;
uint256 public beneficiaryCharge = beneficiaryFee * numOfBeneficiaries;
msgVal += beneficiaryCharge;
4
Create the list of Owners and add them
These addresses will have Owner privileges:
if the deposit is modifiable they can modify it.
if the deposit is retractable they can retract it.
they can activate and de-activate the deposit.
uint256 public numOfOwners = 1;
ITrust99.Owner[] memory owners = new ITrust99.Owner[](numOfOwners);
ITrust99.Owner public owner1 = Owner(address(0xd5Af3D1ec7f2E44A4F947B7c93B1bd983b9183fd), true);
owners[0] = owner1;
5
We can now call createDeposit with our parameters
address public asset = address(0);
amount = 1 * 10 ** 18;
if(asset == address(0)){
msgVal += amount; // add the deposit amount to msg.value if is native token deposit
}
omnitrust.createDeposit{value: msgVal}(
'id1', // Deposit identifier, must not be duplicate
amount, // amount of asset in Wei
asset, // token address, use address(0) for native token
true, // deposit IS modifiable
true, // deposit IS retractable by any of the owners
true, // deposit IS active
owners, // List of Owners
beneficiaries); // List of Beneficiaries and their restraints
WARNING: CREATING A NON-RETRACTABLE & NON-MODIFIABLE DEPOSIT WITHOUT ANY BENEFICIARIES WILL RESULT IN THE LOSS OF THE DEPOSITED ASSETS FOREVER REGARDLESS WHETHER YOUR ADDRESS IS ON THE LIST OF OWNERS OR NOT. OWNERS CANNOT WITHDRAW THE WHOLE DEPOSIT UNLESS ITS RETRACTABLE.
Activating and De-activating a deposit
To activate or de-activate a deposit any of the owners can simply call setDepositActiveVal with the parameters of deposit id, and active status as a boolean.
Activate
omnitrust.setDepositActiveVal('id1', true); // deposit is active and can be withdrawn or take deposits
De-Activate
omnitrust.setDepositActiveVal('id1', false); // deposit is inactive and cannot be withdrawn or take deposits
Withdraw from a deposit
An address has to be a beneficiary of a deposit to be able to withdraw from it. Additionally, if that beneficiary is limited by a daily allowance they can only withdraw their specified allowance once every 24 hours. To withdraw from a deposit a beneficiary should call withdrawFromDeposit and pass the deposit ID, and amount.
/*
To find out if the calling address is a beneficiary use "lookupDepositBeneficiaries"
and iterate over the returned array of "Beneficiary" to find all the
beneficiaries and their properties: isLimited, dateLastWithdrawal, allowance.
from there you can customize the call to "withdrawFromDeposit" according to those
properties.
*/
omnitrust.withdrawFromDeposit('id1', 1 * 10 ** 18);
Retracting all the deposit's funds
When any of the owners retract a deposit, all the funds contained within are transferred to their balance, and the deposit is de-activated until re-activated again. To Retract a deposit any of the owners should call retractDeposit and pass the id of the deposit.
omnitrust.retractDeposit('id1');
Deposit into existing deposit
Any modifiable deposit can accept deposits by anyone who has the id. The assets deposited should match the initial asset the deposit was created for. Just call depositIntoExistingDeposit and pass the id, asset address, and the amount in Wei.
uint256 public msgVal = 0; //msg.value
uint256 public depositFee = omnitrust.depositFee(); // Omnify's deposit fee
msgVal += depositFee;
address public asset = address(0); // token address, use address(0) for native token
uint256 public amount = 1 * 10 ** 18; // deposit amount in Wei
if(asset == address(0)){
msgVal += amount; // add the deposit amount to msg.value if is native token deposit
}
omnitrust.depositIntoExistingDeposit{value: msgVal}('id1', asset, amount);
We are now able to utilize OmniTrust's versatility. 🏦
OmniTrust contracts are very versatile and support many interactions. In this page we will cover creating deposits and their properties, activating and de-activating deposits, withdrawing from a deposit, retracting a deposit, and depositing funds into an existing deposit. You can find a list of all Omnify services' tiers and fees at .