A portfolio is a smart contract that can hold any asset and execute Defire's operations. Portfolios have owners and managers that can be added or removed.
Portfolios' owners are the only accounts to whom the assets can be withdrawn. There is a main owner who can add and remove other owners. Even though owners can execute operations, never use an owner account to operate. It is recommended to keep owners accounts secure, for example, in a hardware wallet, and to operate with managers.
Portfolios' managers can execute operations. There is a main manager who can add and remove other managers. It is recommended to keep main manager accounts secure so, in case another manager account is hacked, the main manager can remove it.
Portfolios are secure because even if any manager account (including main manager account) is hacked, the assets cannot be stolen because they can only be withdrawn to owner's accounts.
An action method to create a new portfolio.
const portfolio = await defire.actions.createPortfolio({owners: ["0xF335fD8CEE75f7759b2fb05a9B3B8A9c85bb1dA3"],managers: ["0xeA51f872dcaA7f4C3895092B95004a64AE680004"]});
Create object param fields |
owners List of portfolio's owners. There must be at least one owner. First owner will be the main owner. |
managers List of portfolio's managers. There must be at least one manager. First owner will be the main owner. |
whitelistedOps List of whitelisted operations addresses. The portfolio can execute only those operations. Default: list of official operations. |
whitelistedAssets List of whitelisted assets addresses. The portfolio can operate only those assets. Default: list of official assets. |
Returns |
This method returns a |
A query method to get an existing portfolio.
const portfolio = await defire.query.getPortfolio("0x3915185D3a079d841B6b6D8dAa7E9067e0A05380");
Method parameters |
address Smart contract address of the portfolio. |
Returns |
This method returns a |
It contains the information, query and action methods about a specific portfolio.
Object fields |
address string Smart contract address of the portfolio |
A query to get the list of assets that the portfolio holds.
const assets = await portfolio.query.getAssets();
Returns |
This method returns a |
A query to check portfolio balance of an asset.
const balance = await portfolio.query.balance(defire.Assets.DAI);
Method parameters |
address Smart contract address of the asset. |
Returns |
This method returns a |
A query method to check if a portfolio holds an asset.
const result = await portfolio.query.hasAsset(defire.Assets.DAI);
Method parameters |
address Smart contract address of the asset. |
Returns |
This method returns a |
An action method to execute one DeFi operation from the portfolio.
const result = await portfolio.actions.execute(operation);
Method parameters |
operation DeFi operation to be executed. |
Returns |
This method returns a |
An action method to execute many DeFi operations from the portfolio.
const result = await portfolio.actions.execute([operation1, operation2, operation3]);
Method parameters |
operations DeFi operations to be executed. |
Returns |
This method returns a |
An action method to withdraw portfolio assets to the owner.
const result = await portfolio.actions.withdraw("0xF335fD8CEE75f7759b2fb05a9B3B8A9c85bb1dA3",[{asset: defire.Assets.DAI,amount: "5000000000000000000" //5 DAI},{asset: defire.Assets.ETH,amount: "1500000000000000000" //1.5 ETH}]);
Method parameters |
to Address of an owner of the portfolio. |
assets
List of each asset and amounts that will be withdrawn |
Returns |
This method returns a |
An action method to execute multiple DeFi operations from the portfolio and then withdraw its assets to the owner.
const result = await portfolio.actions.operateAndWithdraw([operation1,operation2,operation3],to: "0xF335fD8CEE75f7759b2fb05a9B3B8A9c85bb1dA3",[{asset: defire.Assets.DAI,amount: "5000000000000000000" //5 DAI},{asset: defire.Assets.ETHamount: "1500000000000000000" //1.5 ETH}]);
Method parameters |
operations DeFi operations to be executed. |
to Address of an owner of the portfolio. |
assets
List of each asset and amounts that will be withdrawn |
Returns |
This method returns a |
An action method to add a new owner to the portfolio.
const result = await portfolio.actions.addOwner("0xe5eE35Aa75698eADdF5BAab64cf7C77Dd1111a4E");
Method parameters |
address New owner address. |
Returns |
This method returns a |
An action method to remove an owner from the portfolio.
const result = await portfolio.actions.removeOwner("0xe5eE35Aa75698eADdF5BAab64cf7C77Dd1111a4E");
Method parameters |
address Address of the owner to be removed. |
Returns |
This method returns a |
A query method that checks if the address is an owner of the portfolio.
const result = await portfolio.query.isOwner("0xe5eE35Aa75698eADdF5BAab64cf7C77Dd1111a4E");
Method parameters |
address Ethereum address to check if it is owner. |
Returns |
This method returns a |
A query method that checks if the address is the main owner of the portfolio.
const result = await portfolio.query.isMainOwner("0xe5eE35Aa75698eADdF5BAab64cf7C77Dd1111a4E");
Method parameters |
address Ethereum address to check if it is main owner. |
Returns |
This method returns a |
An action method to add a new manager to the portfolio.
const result = await portfolio.actions.addManager("0x9038afa398563815cc26b9ec5Ecd3b8069cd9507");
Method parameters |
address New manager address. |
Returns |
This method returns a |
An action method to remove an manager from the portfolio.
const result = await portfolio.actions.removeManager("0x9038afa398563815cc26b9ec5Ecd3b8069cd9507");
Method parameters |
address Address of the manager to be removed. |
Returns |
This method returns a |
A query method that checks if the address is an manager of the portfolio.
const result = await portfolio.query.isManager("0x9038afa398563815cc26b9ec5Ecd3b8069cd9507");
Method parameters |
address Ethereum address to check if it is manager. |
Returns |
This method returns a |
A query method that checks if the address is the main manager of the portfolio.
const result = await portfolio.query.isMainManager("0x9038afa398563815cc26b9ec5Ecd3b8069cd9507");
Method parameters |
address Ethereum address to check if it is main manager. |
Returns |
This method returns a |