Skip to content

Refactor fund available#27

Closed
nialexsan wants to merge 11 commits intomainfrom
refactor-fund-available
Closed

Refactor fund available#27
nialexsan wants to merge 11 commits intomainfrom
refactor-fund-available

Conversation

@nialexsan
Copy link
Copy Markdown
Contributor

@nialexsan nialexsan commented Jul 14, 2025

refactored available funds functions to make it more maintainable

Comment thread cadence/contracts/TidalProtocol.cdc Outdated
Comment on lines -816 to -823
// We can calculate the available debt increase that would bring us to the target health, unless the health
// after deposit is an edgecase, in which case getting to the target health is impossible.
var availableDebtIncrease = (healthAfterDeposit == UFix64.max ? effectiveCollateralAfterDeposit : effectiveCollateralAfterDeposit / targetHealth) - effectiveDebtAfterDeposit

// var availableDebtIncrease = (effectiveCollateralAfterDeposit / targetHealth) - effectiveDebtAfterDeposit
let availableTokens = (availableDebtIncrease * self.borrowFactor[withdrawType]!) / self.priceOracle.price(ofToken: withdrawType)!
return availableTokens + collateralTokenCount
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

after refactoring this code duplicates calculation below

This reverts commit c0d7d58.
@nialexsan nialexsan marked this pull request as ready for review July 14, 2025 18:55
@nialexsan nialexsan requested review from Kay-Zee and kgrgpg July 14, 2025 18:56
Base automatically changed from tracer-bullet to main July 15, 2025 18:15
@sisyphusSmiling sisyphusSmiling mentioned this pull request Jul 16, 2025
@nialexsan nialexsan closed this Jul 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant