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-01-14 12:09:48 +01:00
|
|
|
Context context,
|
|
|
|
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-01-22 15:58:34 +01:00
|
|
|
Balance memory b = _getBalance(controller, context, recipient);
|
|
|
|
return b.available + b.designated;
|
2025-01-15 11:43:18 +01:00
|
|
|
}
|
|
|
|
|
2025-01-28 10:22:17 +01:00
|
|
|
function getDesignatedBalance(
|
2025-01-15 11:43:18 +01:00
|
|
|
Context context,
|
|
|
|
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-01-22 15:58:34 +01:00
|
|
|
Balance memory b = _getBalance(controller, context, recipient);
|
|
|
|
return b.designated;
|
2025-01-13 12:04:03 +01:00
|
|
|
}
|
|
|
|
|
2025-01-28 10:22:17 +01:00
|
|
|
function getLock(Context context) public view returns (Lock memory) {
|
2025-01-15 14:51:53 +01:00
|
|
|
Controller controller = Controller.wrap(msg.sender);
|
2025-01-22 11:32:22 +01:00
|
|
|
return _getLock(controller, context);
|
2025-01-15 14:51:53 +01:00
|
|
|
}
|
|
|
|
|
2025-01-28 10:31:39 +01:00
|
|
|
function deposit(Context context, address from, uint128 amount) public {
|
2025-01-14 12:09:48 +01:00
|
|
|
Controller controller = Controller.wrap(msg.sender);
|
2025-01-22 11:32:22 +01:00
|
|
|
_deposit(controller, context, from, amount);
|
2025-01-13 12:04:03 +01:00
|
|
|
}
|
|
|
|
|
2025-01-22 11:32:22 +01:00
|
|
|
function withdraw(Context context, Recipient recipient) public {
|
2025-01-14 12:09:48 +01:00
|
|
|
Controller controller = Controller.wrap(msg.sender);
|
2025-01-22 11:32:22 +01:00
|
|
|
_withdraw(controller, context, recipient);
|
2025-01-15 11:43:18 +01:00
|
|
|
}
|
|
|
|
|
2025-01-22 11:32:22 +01:00
|
|
|
function withdrawByRecipient(Controller controller, Context context) public {
|
|
|
|
Recipient recipient = Recipient.wrap(msg.sender);
|
|
|
|
_withdraw(controller, context, recipient);
|
2025-01-13 12:04:03 +01:00
|
|
|
}
|
2025-01-14 14:11:53 +01:00
|
|
|
|
|
|
|
function burn(Context context, Recipient recipient) public {
|
2025-01-22 11:32:22 +01:00
|
|
|
Controller controller = Controller.wrap(msg.sender);
|
|
|
|
_burn(controller, context, recipient);
|
2025-01-14 14:11:53 +01:00
|
|
|
}
|
2025-01-15 10:08:10 +01:00
|
|
|
|
|
|
|
function transfer(
|
|
|
|
Context context,
|
|
|
|
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-01-22 11:32:22 +01:00
|
|
|
_transfer(controller, context, from, to, amount);
|
2025-01-15 10:08:10 +01:00
|
|
|
}
|
|
|
|
|
2025-01-15 11:43:18 +01:00
|
|
|
function designate(
|
|
|
|
Context context,
|
|
|
|
Recipient recipient,
|
2025-01-28 10:31:39 +01:00
|
|
|
uint128 amount
|
2025-01-15 11:43:18 +01:00
|
|
|
) public {
|
|
|
|
Controller controller = Controller.wrap(msg.sender);
|
2025-01-22 11:32:22 +01:00
|
|
|
_designate(controller, context, recipient, amount);
|
2025-01-15 11:43:18 +01:00
|
|
|
}
|
|
|
|
|
2025-01-28 10:22:17 +01:00
|
|
|
function lock(Context context, Timestamp expiry, Timestamp maximum) public {
|
2025-01-15 14:51:53 +01:00
|
|
|
Controller controller = Controller.wrap(msg.sender);
|
2025-01-22 11:32:22 +01:00
|
|
|
_lockup(controller, context, expiry, maximum);
|
2025-01-15 14:51:53 +01:00
|
|
|
}
|
|
|
|
|
2025-01-28 10:22:17 +01:00
|
|
|
function extendLock(Context context, Timestamp expiry) public {
|
2025-01-15 14:51:53 +01:00
|
|
|
Controller controller = Controller.wrap(msg.sender);
|
2025-01-22 11:32:22 +01:00
|
|
|
_extendLock(controller, context, expiry);
|
2025-01-15 14:51:53 +01:00
|
|
|
}
|
2025-01-22 15:07:51 +01:00
|
|
|
|
|
|
|
function flow(
|
|
|
|
Context context,
|
|
|
|
Recipient from,
|
|
|
|
Recipient to,
|
|
|
|
TokensPerSecond rate
|
|
|
|
) public {
|
|
|
|
Controller controller = Controller.wrap(msg.sender);
|
|
|
|
_flow(controller, context, from, to, rate);
|
|
|
|
}
|
2025-01-13 12:04:03 +01:00
|
|
|
}
|