Skip to content

Commit 39debd5

Browse files
committed
debug debt
1 parent 415d9e2 commit 39debd5

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

cadence/contracts/TidalProtocol.cdc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ access(all) contract TidalProtocol {
451451
let sourceType = topUpSource.getSourceType()
452452
let sourceAmount = topUpSource.minimumAvailable()
453453
log("sourceAmount")
454+
log(sourceType)
454455
log(sourceAmount)
455456

456457
return self.fundsAvailableAboveTargetHealthAfterDepositing(
@@ -735,6 +736,8 @@ access(all) contract TidalProtocol {
735736
interestIndex: depositTokenState.debitInterestIndex
736737
)
737738

739+
log("trueDebt, \(trueDebt)")
740+
738741
if trueDebt >= depositAmount {
739742
// This deposit will pay down some debt, but won't result in net collateral, we
740743
// just need to account for the debt decrease.
@@ -759,6 +762,8 @@ access(all) contract TidalProtocol {
759762
effectiveDebt: effectiveDebtAfterDeposit
760763
)
761764

765+
log("healthAfterDeposit, \(healthAfterDeposit)")
766+
762767

763768
if healthAfterDeposit <= targetHealth {
764769
// The position is already at or below the target health, so we can't withdraw anything.
@@ -1354,8 +1359,13 @@ access(all) contract TidalProtocol {
13541359
let trueBalance = TidalProtocol.scaledBalanceToTrueBalance(scaledBalance: balance.scaledBalance,
13551360
interestIndex: tokenState.creditInterestIndex)
13561361

1362+
log("trueBalance")
1363+
log(trueBalance)
1364+
log(type)
1365+
13571366
let value = priceOracle.price(ofToken: type)! * trueBalance
13581367

1368+
log(value)
13591369
effectiveCollateral = effectiveCollateral + (value * self.collateralFactor[type]!)
13601370
} else {
13611371
let trueBalance = TidalProtocol.scaledBalanceToTrueBalance(scaledBalance: balance.scaledBalance,
@@ -1636,6 +1646,8 @@ access(all) contract TidalProtocol {
16361646
return 0.0
16371647
}
16381648
let pool = self.pool.borrow()!
1649+
log("pool")
1650+
log(pool)
16391651
return pool.availableBalance(pid: self.positionID, type: self.type, pullFromTopUpSource: self.pullFromTopUpSource)
16401652
}
16411653
/// Withdraws up to the max amount as the sourceType Vault

0 commit comments

Comments
 (0)