This repository has been archived by the owner on Jan 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
AccountFacet.sol
107 lines (93 loc) · 3.88 KB
/
AccountFacet.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "../../utils/Accessibility.sol";
import "../../utils/Pausable.sol";
import "./IAccountEvents.sol";
import "./AccountFacetImpl.sol";
import "../../storages/GlobalAppStorage.sol";
contract AccountFacet is Accessibility, Pausable, IAccountEvents {
//Party A
function deposit(uint256 amount) external whenNotAccountingPaused {
AccountFacetImpl.deposit(msg.sender, amount);
emit Deposit(msg.sender, msg.sender, amount);
}
function depositFor(address user, uint256 amount) external whenNotAccountingPaused {
AccountFacetImpl.deposit(user, amount);
emit Deposit(msg.sender, user, amount);
}
function withdraw(uint256 amount) external whenNotAccountingPaused notSuspended(msg.sender) {
AccountFacetImpl.withdraw(msg.sender, amount);
emit Withdraw(msg.sender, msg.sender, amount);
}
function withdrawTo(
address user,
uint256 amount
) external whenNotAccountingPaused notSuspended(msg.sender) {
AccountFacetImpl.withdraw(user, amount);
emit Withdraw(msg.sender, user, amount);
}
function allocate(
uint256 amount
) external whenNotAccountingPaused notLiquidatedPartyA(msg.sender) {
AccountFacetImpl.allocate(amount);
emit AllocatePartyA(msg.sender, amount);
}
function depositAndAllocate(
uint256 amount
) external whenNotAccountingPaused notLiquidatedPartyA(msg.sender) {
AccountFacetImpl.deposit(msg.sender, amount);
uint256 amountWith18Decimals = (amount * 1e18) /
(10 ** IERC20Metadata(GlobalAppStorage.layout().collateral).decimals());
AccountFacetImpl.allocate(amountWith18Decimals);
emit Deposit(msg.sender, msg.sender, amount);
emit AllocatePartyA(msg.sender, amountWith18Decimals);
}
function deallocate(
uint256 amount,
SingleUpnlSig memory upnlSig
) external whenNotAccountingPaused notLiquidatedPartyA(msg.sender) {
AccountFacetImpl.deallocate(amount, upnlSig);
emit DeallocatePartyA(msg.sender, amount);
}
// PartyB
function allocateForPartyB(
uint256 amount,
address partyA
) public whenNotPartyBActionsPaused notLiquidatedPartyB(msg.sender, partyA) onlyPartyB {
AccountFacetImpl.allocateForPartyB(amount, partyA, true);
emit AllocateForPartyB(msg.sender, partyA, amount);
}
function depositAndAllocateForPartyB(
uint256 amount,
address partyA
) external whenNotPartyBActionsPaused onlyPartyB {
AccountFacetImpl.depositForPartyB(amount);
AccountFacetImpl.allocateForPartyB(amount, partyA, true);
emit DepositForPartyB(msg.sender, amount);
emit AllocateForPartyB(msg.sender, partyA, amount);
}
function deallocateForPartyB(
uint256 amount,
address partyA,
SingleUpnlSig memory upnlSig
) external whenNotPartyBActionsPaused notLiquidatedPartyB(msg.sender, partyA) onlyPartyB {
AccountFacetImpl.deallocateForPartyB(amount, partyA, upnlSig);
emit DeallocateForPartyB(msg.sender, partyA, amount);
}
function depositForPartyB(uint256 amount) external whenNotPartyBActionsPaused onlyPartyB {
AccountFacetImpl.depositForPartyB(amount);
emit DepositForPartyB(msg.sender, amount);
}
function transferAllocation(
uint256 amount,
address origin,
address recipient,
SingleUpnlSig memory upnlSig
) external whenNotPartyBActionsPaused {
AccountFacetImpl.transferAllocation(amount, origin, recipient, upnlSig);
emit TransferAllocation(amount, origin, recipient);
}
}