Skip to content

Commit 23f2dd9

Browse files
committed
small fixes
1 parent 39405cf commit 23f2dd9

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

cadence/contracts/TidalProtocol.cdc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -797,15 +797,11 @@ access(all) contract TidalProtocol {
797797
depositAmount: depositAmount
798798
)
799799

800-
let effectiveCollateralAfterDeposit = adjusted.collateral
801-
let effectiveDebtAfterDeposit = adjusted.debt
802-
log(" [CONTRACT] effectiveCollateralAfterDeposit: \(effectiveCollateralAfterDeposit)")
803-
log(" [CONTRACT] effectiveDebtAfterDeposit: \(effectiveDebtAfterDeposit)")
804800
return self.computeAvailableWithdrawal(
805801
position: position,
806802
withdrawType: withdrawType,
807-
effectiveCollateral: effectiveCollateralAfterDeposit,
808-
effectiveDebt: effectiveDebtAfterDeposit,
803+
effectiveCollateral: adjusted.collateral,
804+
effectiveDebt: adjusted.debt,
809805
targetHealth: targetHealth
810806
)
811807
}
@@ -911,6 +907,7 @@ access(all) contract TidalProtocol {
911907

912908
// Check what the new health would be if we took out all of this collateral
913909
let potentialHealth = TidalProtocol.healthComputation(
910+
effectiveCollateral: effectiveCollateralAfterDeposit - collateralEffectiveValue, // ??? - why subtract?
914911
effectiveDebt: effectiveDebtAfterDeposit
915912
)
916913

@@ -921,7 +918,7 @@ access(all) contract TidalProtocol {
921918
// compute how many units of the token would bring the position down to the target health.
922919
let availableHealth = (healthAfterDeposit == UFix64.max) ? UFix64.max : healthAfterDeposit - targetHealth
923920
let uintAvailableHealth = TidalProtocolUtils.ufix64ToUInt256(availableHealth, decimals: TidalProtocolUtils.decimals)
924-
let availableEffectiveValue = (effectiveDebt == 0.0 || availableHealth == UFix64.max)
921+
let availableEffectiveValue = (effectiveDebtAfterDepositlet potentialHealth = TidalProtocol.healthComputation( == 0.0 || availableHealth == UFix64.max)
925922
? effectiveCollateralAfterDeposit
926923
: TidalProtocolUtils.mul(uintAvailableHealth, effectiveDebtAfterDeposit)
927924
log(" [CONTRACT] availableHealth: \(availableHealth)")

0 commit comments

Comments
 (0)