@0dotxyz/p0-ts-sdk 2.7.1 → 2.7.2
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 +9 -2
- package/dist/index.cjs +2118 -229
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +226 -6
- package/dist/index.d.ts +226 -6
- package/dist/index.js +2103 -230
- package/dist/index.js.map +1 -1
- package/dist/instructions.d.cts +1 -1
- package/dist/instructions.d.ts +1 -1
- package/dist/{types-Ctm1kvCr.d.ts → types-B5SGXpex.d.ts} +1 -1
- package/dist/{types-DzbVhEfo.d.cts → types-BFLi0Ozl.d.cts} +1 -1
- package/dist/vendor.cjs +2016 -645
- package/dist/vendor.cjs.map +1 -1
- package/dist/vendor.d.cts +1932 -834
- package/dist/vendor.d.ts +1932 -834
- package/dist/vendor.js +2016 -645
- package/dist/vendor.js.map +1 -1
- package/package.json +1 -1
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
|