@0dotxyz/p0-ts-sdk 2.7.1 → 2.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -98,7 +98,7 @@ console.log(`Compute units: ${simulation.value.unitsConsumed}`);
98
98
  ### 5. Borrow Against Collateral
99
99
 
100
100
  ```typescript
101
- // Check how much you can borrow
101
+ // Check how much you can borrow (account health + bank borrow cap + bank liquidity)
102
102
  const maxBorrow = wrappedAccount.computeMaxBorrowForBank(usdcBank.address);
103
103
  console.log(`Max borrow: $${maxBorrow.toString()}`);
104
104
 
@@ -289,9 +289,16 @@ const health = wrapped.computeHealthComponents(
289
289
  MarginRequirementType.Initial // or Maintenance
290
290
  );
291
291
 
292
- // Max amounts
292
+ // Max amounts — bank-aware:
293
+ // borrow = min(health-based, remaining borrow cap, available bank liquidity, rate-limit headroom)
294
+ // withdraw = min(health-based, available bank liquidity, rate-limit headroom)
295
+ // deposit = remaining deposit cap (optionally min'd with your wallet balance)
296
+ // (rate-limit headroom = bank net-outflow limiter in tokens + group USD limiter, if enabled)
293
297
  const maxBorrow = wrapped.computeMaxBorrowForBank(bankAddress);
294
298
  const maxWithdraw = wrapped.computeMaxWithdrawForBank(bankAddress);
299
+ const maxDeposit = wrapped.computeMaxDepositForBank(bankAddress, { walletBalance: 1_000 });
300
+
301
+ // Pass { ignoreBankLimits: true } to get the purely health-based borrow/withdraw amount
295
302
  ```
296
303
 
297
304
  ## 🧪 Testing