Skip to content

Commit b070da3

Browse files
committed
feat: add checks for disabled/enabled functions
1 parent 91f0cf9 commit b070da3

6 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/borrow/borrow.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ local function borrow(msg, _, oracle)
1717
-- get position data
1818
local pos = position.globalPosition(account, oracle)
1919

20+
-- check if the interaction is enabled
21+
assert(EnabledInteractions.borrow, "Borrowing is currently disabled")
22+
2023
-- amount of tokens to borrow
2124
local rawQuantity = bint(msg.Tags.Quantity)
2225
local quantity = precision.toInternalPrecision(rawQuantity)

src/borrow/repay.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ local repay = {}
88

99
---@type HandlerFunction
1010
function repay.handler(msg)
11+
-- check if the interaction is enabled
12+
assert(EnabledInteractions.repay, "Repaying is currently disabled")
13+
1114
assert(
1215
assertions.isTokenQuantity(msg.Tags.Quantity),
1316
"Invalid incoming transfer quantity"

src/liquidations/liquidate.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ local mod = {}
1111
-- (similar functionality to repaying)
1212
---@type HandlerFunction
1313
function mod.liquidateBorrow(msg)
14+
-- check if the interaction is enabled
15+
assert(EnabledInteractions.liquidation, "Borrow liquidation is currently disabled")
16+
1417
assert(
1518
assertions.isTokenQuantity(msg.Tags.Quantity),
1619
"Invalid incoming transfer quantity"
@@ -150,6 +153,9 @@ end
150153
-- (reverse redeem)
151154
---@type HandlerFunction
152155
function mod.liquidatePosition(msg)
156+
-- check if the interaction is enabled
157+
assert(EnabledInteractions.liquidation, "Position liquidation is currently disabled")
158+
153159
-- check if the message is coming from a friend process
154160
assert(
155161
assertions.isFriend(msg.From) or msg.From == ao.id,

src/supply/mint.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ local mint = {}
88

99
---@type HandlerFunction
1010
function mint.handler(msg)
11+
-- check if the interaction is enabled
12+
assert(EnabledInteractions.mint, "Minting is currently disabled")
13+
1114
assert(
1215
assertions.isTokenQuantity(msg.Tags.Quantity),
1316
"Invalid incoming transfer quantity"

src/supply/redeem.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ local rate = require ".supply.rate"
66

77
---@type HandlerWithOracle
88
local function redeem(msg, _, oracle)
9+
-- check if the interaction is enabled
10+
assert(EnabledInteractions.redeem, "Redeeming is currently disabled")
11+
912
-- the wallet that is burning the tokens
1013
local sender = msg.From
1114

src/token/transfer.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ local function transfer(msg, _, oracle)
1313
-- get position data
1414
local pos = position.globalPosition(sender, oracle)
1515

16+
-- check if the interaction is enabled
17+
assert(EnabledInteractions.transfer, "Transferring is currently disabled")
18+
1619
-- validate target and quantity
1720
assert(assertions.isAddress(target), "Invalid address")
1821
assert(target ~= sender, "Target cannot be the sender")

0 commit comments

Comments
 (0)