reserve.gno
0.59 Kb · 21 lines
1package lastcall
2
3// lockedUSD is tUSD the reserve holds on behalf of open positions and pending
4// limit orders. Payouts, spot sales and pool withdrawals may only spend the rest,
5// so a margin or an escrow can always be returned to its owner.
6var lockedUSD int64
7
8func lock(amount int64) { lockedUSD += amount }
9
10func unlock(amount int64) { lockedUSD -= amount }
11
12func freeReserve() int64 {
13 free := usd.BalanceOf(deskAddr) - lockedUSD
14 if free < 0 {
15 return 0
16 }
17 return free
18}
19
20// LockedUSD is the part of the reserve owed back as margin and limit escrow.
21func LockedUSD() int64 { return lockedUSD }