Skip to content

Commit 61196a6

Browse files
committed
restore lines
1 parent c0d7d58 commit 61196a6

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

cadence/contracts/TidalProtocol.cdc

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -904,14 +904,13 @@ access(all) contract TidalProtocol {
904904
log(" [CONTRACT] collateralTokenCount: \(collateralTokenCount)")
905905
log(" [CONTRACT] effectiveCollateralAfterDeposit: \(effectiveCollateral)")
906906

907-
// this code has been commented by llm, figure out why
908-
// // We can calculate the available debt increase that would bring us to the target health, unless the health
909-
// // after deposit is an edgecase, in which case getting to the target health is impossible.
910-
// var availableDebtIncrease = (healthAfterDeposit == UFix64.max ? effectiveCollateralAfterDeposit : effectiveCollateralAfterDeposit / targetHealth) - effectiveDebtAfterDeposit
911-
//
912-
// // var availableDebtIncrease = (effectiveCollateralAfterDeposit / targetHealth) - effectiveDebtAfterDeposit
913-
// let availableTokens = (availableDebtIncrease * self.borrowFactor[withdrawType]!) / self.priceOracle.price(ofToken: withdrawType)!
914-
// return availableTokens + collateralTokenCount
907+
// We can calculate the available debt increase that would bring us to the target health, unless the health
908+
// after deposit is an edgecase, in which case getting to the target health is impossible.
909+
var availableDebtIncrease = (healthAfterAdjustment == UFix64.max ? effectiveCollateral : effectiveCollateral / targetHealth) - effectiveDebt
910+
911+
// var availableDebtIncrease = (effectiveCollateralAfterDeposit / targetHealth) - effectiveDebtAfterDeposit
912+
let availableTokens = (availableDebtIncrease * self.borrowFactor[withdrawType]!) / self.priceOracle.price(ofToken: withdrawType)!
913+
return availableTokens + collateralTokenCount
915914
}
916915

917916
// At this point, we're either dealing with a position that didn't have a credit balance in the withdraw

0 commit comments

Comments
 (0)