Skip to content
Closed
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
6 changes: 6 additions & 0 deletions cadence/contracts/FlowALPv0.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ access(all) contract FlowALPv0 {
remainingCapacity: UFix64
)

access(all) event PositionHealthUpdated(
pid: UInt64,
health: UFix128
)

//// Emitted each time the insurance rate is updated for a specific token in a specific pool.
//// The insurance rate is an annual percentage; for example a value of 0.001 indicates 0.1%.
access(all) event InsuranceRateUpdated(
Expand Down Expand Up @@ -3958,6 +3963,7 @@ access(all) contract FlowALPv0 {
}

let positionHealth = self.positionHealth(pid: pid)
emit PositionHealthUpdated(pid: pid, health: positionHealth)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how do we ensure that we've captured all the cases where the position health is updated. Note, this function has a few returns that skips this emit.

And is it possible the position health will be updated outside of this function?

This function only queues the update, asyncUpdatePosition is actually the function updating the position. Should we emit event there instead?

And this is when the position is updated from internally. What about externally? For instance, since position health depends on the price oracle, so the position health is changed as soon as the price oracle updates the price.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your concerns are valid and discussed in this PR. This PR is to be closed. We're going to gather position health factors via a script.


if positionHealth < position.minHealth || positionHealth > position.maxHealth {
// This position is outside the configured health bounds, we queue it for an update
Expand Down