Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/liquidations/liquidate.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local delegation = require ".supply.delegation"
local assertions = require ".utils.assertions"
local precision = require ".utils.precision"
local interest = require ".borrow.interest"
Expand Down Expand Up @@ -223,6 +224,9 @@ function mod.liquidatePosition(msg)
"The liquidation target owns less oTokens than the supplied quantity's worth"
)

-- run delegation
delegation.delegate(msg)

-- liquidate position by updating the oToken quantities, etc.
Balances[target] = tostring(balance - qtyValueInoToken)
Cash = tostring(availableTokens - quantity)
Expand Down
14 changes: 1 addition & 13 deletions src/process.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,7 @@ local function setup_handlers()
-- accrued AO distribution for actions that update oToken balances
Handlers.add(
"supply-delegate-ao",
function (msg)
local action = msg.Tags["X-Action"] or msg.Tags.Action

if action == "Delegate" then return true end
if
action == "Mint" or
action == "Redeem" or
action == "Liquidate-Position" or
action == "Transfer"
then return "continue" end

return false
end,
{ Action = "Delegate" },
delegation.delegate
)

Expand Down
4 changes: 4 additions & 0 deletions src/supply/mint.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local delegation = require ".supply.delegation"
local assertions = require ".utils.assertions"
local precision = require ".utils.precision"
local interest = require ".borrow.interest"
Expand Down Expand Up @@ -26,6 +27,9 @@ function mint.handler(msg)
"Mint quantity is above the allowed limit"
)

-- run delegation
delegation.delegate(msg)

-- transfer sender
local sender = msg.Tags.Sender

Expand Down
4 changes: 4 additions & 0 deletions src/supply/redeem.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local delegation = require ".supply.delegation"
local assertions = require ".utils.assertions"
local precision = require ".utils.precision"
local position = require ".borrow.position"
Expand Down Expand Up @@ -77,6 +78,9 @@ local function redeem(msg, _, oracle)
"Redeem value is too high and requires higher collateralization"
)

-- run delegation
delegation.delegate(msg)

-- update stored quantities (balance, available, total supply)
Balances[sender] = tostring(walletBalance - quantity)
Cash = tostring(availableTokens - rewardQtyScaled)
Expand Down
4 changes: 4 additions & 0 deletions src/token/transfer.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local delegation = require ".supply.delegation"
local assertions = require ".utils.assertions"
local precision = require ".utils.precision"
local position = require ".borrow.position"
Expand Down Expand Up @@ -53,6 +54,9 @@ local function transfer(msg, _, oracle)
"Transfer value is too high and requires higher collateralization"
)

-- run delegation
delegation.delegate(msg)

-- update balances
Balances[target] = tostring(bint(Balances[target] or 0) + quantity)
Balances[sender] = tostring(walletBalance - quantity)
Expand Down