The vaultOwner() has the right to borrow from its own vaults,
provided they have enough collateral to do it.
Borrow will effectively mint EURO3, thus adding more circulating supply.
To get IVault interface, refer to Creating a vault
Here's an example of a simple borrowing interaction:
import"./IVaultFactory.sol";import"./IVault.sol";import"./ERC20.sol";// --- core contract logic ---IVaultFactory vaultFactory =IVaultFactory(0x.....0);address vaultAddress =0x...0;address destinationAddress = msg.sender;IVault myVault =IVault(vaultAddress);// get the maximum amount you can borrow(uint256 maxBorrowable, ) = myVault.borrowable();// borrowing can only be done from the VaultFactoryvaultFactory.borrow(vaultAddress, maxBorrowable, destinationAddress);// healthFactor is 18 decimals,// meaning 1e18 = 1.0 HFuint256 healthFactor = myVault.healthFactor(false);require(healthFactor >2**1e18,"borrowed too much!");
Repaying your loan
Repaying a loan requires enough EURO3 is approved to be spent by the VaultFactory
Here's an example implementation: