Skip to content

Commit 49d74ad

Browse files
committed
fix conditions
1 parent 74b508a commit 49d74ad

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

cadence/contracts/TidalProtocol.cdc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ access(all) contract TidalProtocol {
610610
let uintWithdrawBorrowFactor = TidalProtocolUtils.ufix64ToUInt256(self.borrowFactor[withdrawType]!, decimals: TidalProtocolUtils.decimals)
611611

612612
let maybeBalance = position.balances[withdrawType]
613-
if maybeBalance?.direction == BalanceDirection.Debit {
613+
if maybeBalance == nil || maybeBalance!.direction == BalanceDirection.Debit {
614614
// If the position doesn't have any collateral for the withdrawn token, we can just compute how much
615615
// additional effective debt the withdrawal will create.
616616
effectiveDebtAfterWithdrawal = balanceSheet.effectiveDebt +
@@ -831,7 +831,7 @@ access(all) contract TidalProtocol {
831831
let uintDepositBorrowFactor = TidalProtocolUtils.ufix64ToUInt256(self.borrowFactor[depositType]!, decimals: TidalProtocolUtils.decimals)
832832
let uintDepositCollateralFactor = TidalProtocolUtils.ufix64ToUInt256(self.collateralFactor[depositType]!, decimals: TidalProtocolUtils.decimals)
833833
let maybeBalance = position.balances[depositType]
834-
if maybeBalance?.direction == BalanceDirection.Credit {
834+
if maybeBalance == nil || maybeBalance!.direction == BalanceDirection.Credit {
835835
// If there's no debt for the deposit token, we can just compute how much additional effective collateral the deposit will create.
836836
effectiveCollateralAfterDeposit = balanceSheet.effectiveCollateral +
837837
TidalProtocolUtils.mul(TidalProtocolUtils.mul(uintDepositAmount, uintDepositPrice), uintDepositCollateralFactor)

0 commit comments

Comments
 (0)