2025-01-13 12:04:03 +01:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
pragma solidity 0.8.28;
|
|
|
|
|
2025-01-28 10:31:39 +01:00
|
|
|
import "./vault/VaultBase.sol";
|
2025-01-13 12:04:03 +01:00
|
|
|
|
2025-01-22 11:32:22 +01:00
|
|
|
contract Vault is VaultBase {
|
|
|
|
// solhint-disable-next-line no-empty-blocks
|
|
|
|
constructor(IERC20 token) VaultBase(token) {}
|
2025-01-13 12:04:03 +01:00
|
|
|
|
2025-01-28 10:22:17 +01:00
|
|
|
function getBalance(
|
2025-02-04 09:53:31 +01:00
|
|
|
Fund fund,
|
2025-01-14 12:09:48 +01:00
|
|
|
Recipient recipient
|
2025-01-28 10:31:39 +01:00
|
|
|
) public view returns (uint128) {
|
2025-01-14 12:09:48 +01:00
|
|
|
Controller controller = Controller.wrap(msg.sender);
|
2025-02-05 15:13:49 +01:00
|
|
|
Balance memory balance = _getBalance(controller, fund, recipient);
|
|
|
|
return balance.available + balance.designated;
|
2025-01-15 11:43:18 +01:00
|
|
|
}
|
|
|
|
|
2025-01-28 10:22:17 +01:00
|
|
|
function getDesignatedBalance(
|
2025-02-04 09:53:31 +01:00
|
|
|
Fund fund,
|
2025-01-15 11:43:18 +01:00
|
|
|
Recipient recipient
|
2025-01-28 10:31:39 +01:00
|
|
|
) public view returns (uint128) {
|
2025-01-15 11:43:18 +01:00
|
|
|
Controller controller = Controller.wrap(msg.sender);
|
2025-02-05 15:13:49 +01:00
|
|
|
Balance memory balance = _getBalance(controller, fund, recipient);
|
|
|
|
return balance.designated;
|
2025-01-13 12:04:03 +01:00
|
|
|
}
|
|
|
|
|
2025-02-04 09:53:31 +01:00
|
|
|
function getLock(Fund fund) public view returns (Lock memory) {
|
2025-01-15 14:51:53 +01:00
|
|
|
Controller controller = Controller.wrap(msg.sender);
|
2025-02-04 09:53:31 +01:00
|
|
|
return _getLock(controller, fund);
|
2025-01-15 14:51:53 +01:00
|
|
|
}
|
|
|
|
|
2025-02-04 09:53:31 +01:00
|
|
|
function lock(Fund fund, Timestamp expiry, Timestamp maximum) public {
|
2025-01-14 12:09:48 +01:00
|
|
|
Controller controller = Controller.wrap(msg.sender);
|
2025-02-04 09:53:31 +01:00
|
|
|
_lock(controller, fund, expiry, maximum);
|
2025-01-13 12:04:03 +01:00
|
|
|
}
|
|
|
|
|
2025-02-04 09:53:31 +01:00
|
|
|
function extendLock(Fund fund, Timestamp expiry) public {
|
2025-01-14 12:09:48 +01:00
|
|
|
Controller controller = Controller.wrap(msg.sender);
|
2025-02-04 09:53:31 +01:00
|
|
|
_extendLock(controller, fund, expiry);
|
2025-01-15 11:43:18 +01:00
|
|
|
}
|
|
|
|
|
2025-02-04 09:53:31 +01:00
|
|
|
function deposit(Fund fund, address from, uint128 amount) public {
|
2025-02-03 16:45:30 +01:00
|
|
|
Controller controller = Controller.wrap(msg.sender);
|
2025-02-04 09:53:31 +01:00
|
|
|
_deposit(controller, fund, from, amount);
|
2025-01-13 12:04:03 +01:00
|
|
|
}
|
2025-01-14 14:11:53 +01:00
|
|
|
|
2025-02-03 16:45:30 +01:00
|
|
|
function designate(
|
2025-02-04 09:53:31 +01:00
|
|
|
Fund fund,
|
2025-02-03 16:45:30 +01:00
|
|
|
Recipient recipient,
|
|
|
|
uint128 amount
|
|
|
|
) public {
|
2025-01-22 11:32:22 +01:00
|
|
|
Controller controller = Controller.wrap(msg.sender);
|
2025-02-04 09:53:31 +01:00
|
|
|
_designate(controller, fund, recipient, amount);
|
2025-01-14 14:11:53 +01:00
|
|
|
}
|
2025-01-15 10:08:10 +01:00
|
|
|
|
|
|
|
function transfer(
|
2025-02-04 09:53:31 +01:00
|
|
|
Fund fund,
|
2025-01-15 10:08:10 +01:00
|
|
|
Recipient from,
|
|
|
|
Recipient to,
|
2025-01-28 10:31:39 +01:00
|
|
|
uint128 amount
|
2025-01-15 10:08:10 +01:00
|
|
|
) public {
|
|
|
|
Controller controller = Controller.wrap(msg.sender);
|
2025-02-04 09:53:31 +01:00
|
|
|
_transfer(controller, fund, from, to, amount);
|
2025-01-15 10:08:10 +01:00
|
|
|
}
|
|
|
|
|
2025-02-03 16:45:30 +01:00
|
|
|
function flow(
|
2025-02-04 09:53:31 +01:00
|
|
|
Fund fund,
|
2025-02-03 16:45:30 +01:00
|
|
|
Recipient from,
|
|
|
|
Recipient to,
|
|
|
|
TokensPerSecond rate
|
2025-01-15 11:43:18 +01:00
|
|
|
) public {
|
|
|
|
Controller controller = Controller.wrap(msg.sender);
|
2025-02-04 09:53:31 +01:00
|
|
|
_flow(controller, fund, from, to, rate);
|
2025-01-15 11:43:18 +01:00
|
|
|
}
|
|
|
|
|
2025-02-04 09:53:31 +01:00
|
|
|
function burn(Fund fund, Recipient recipient) public {
|
2025-01-15 14:51:53 +01:00
|
|
|
Controller controller = Controller.wrap(msg.sender);
|
2025-02-04 09:53:31 +01:00
|
|
|
_burn(controller, fund, recipient);
|
2025-01-15 14:51:53 +01:00
|
|
|
}
|
|
|
|
|
2025-02-04 09:53:31 +01:00
|
|
|
function withdraw(Fund fund, Recipient recipient) public {
|
2025-01-15 14:51:53 +01:00
|
|
|
Controller controller = Controller.wrap(msg.sender);
|
2025-02-04 09:53:31 +01:00
|
|
|
_withdraw(controller, fund, recipient);
|
2025-01-15 14:51:53 +01:00
|
|
|
}
|
2025-01-22 15:07:51 +01:00
|
|
|
|
2025-02-04 09:53:31 +01:00
|
|
|
function withdrawByRecipient(Controller controller, Fund fund) public {
|
2025-02-03 16:45:30 +01:00
|
|
|
Recipient recipient = Recipient.wrap(msg.sender);
|
2025-02-04 09:53:31 +01:00
|
|
|
_withdraw(controller, fund, recipient);
|
2025-01-22 15:07:51 +01:00
|
|
|
}
|
2025-01-13 12:04:03 +01:00
|
|
|
}
|