File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments