@indigo-labs/indigo-sdk 0.3.8 → 0.3.10
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/dist/index.d.mts +192 -32
- package/dist/index.d.ts +192 -32
- package/dist/index.js +819 -242
- package/dist/index.mjs +707 -135
- package/package.json +1 -1
- package/src/contracts/cdp/helpers.ts +12 -0
- package/src/contracts/gov/transactions.ts +4 -4
- package/src/contracts/iasset/helpers.ts +1 -0
- package/src/contracts/price-oracle/types-new.ts +1 -1
- package/src/contracts/rob/helpers.ts +274 -196
- package/src/contracts/rob/transactions.ts +11 -5
- package/src/contracts/rob-leverage/helpers.ts +379 -371
- package/src/contracts/rob-leverage/transactions.ts +176 -104
- package/src/utils/utils.ts +0 -3
- package/tests/cdp/cdp-queries.ts +1 -1
- package/tests/endpoints/initialize.ts +14 -2
- package/tests/interest-collection/interest-collector-queries.ts +2 -1
- package/tests/queries/collector-queries.ts +2 -1
- package/tests/queries/poll-queries.ts +2 -1
- package/tests/queries/treasury-queries.ts +2 -1
- package/tests/rob/rob-leverage.test.ts +1646 -612
- package/tests/rob/rob.test.ts +35 -19
- package/tests/rob/transactions-mutated.ts +6 -4
|
@@ -50,8 +50,8 @@ import {
|
|
|
50
50
|
import {
|
|
51
51
|
buildRedemptionsTx,
|
|
52
52
|
isFullyRedeemed,
|
|
53
|
-
MIN_ROB_COLLATERAL_AMT
|
|
54
|
-
|
|
53
|
+
MIN_ROB_COLLATERAL_AMT,
|
|
54
|
+
robAmtToSpend,
|
|
55
55
|
} from './helpers';
|
|
56
56
|
import { match, P } from 'ts-pattern';
|
|
57
57
|
import { Rational } from '../../types/rational';
|
|
@@ -232,7 +232,9 @@ export async function redeemRob(
|
|
|
232
232
|
0n,
|
|
233
233
|
refInputIdxs[2],
|
|
234
234
|
refInputIdxs[1],
|
|
235
|
-
priceOracleOutRef !== undefined
|
|
235
|
+
priceOracleOutRef !== undefined
|
|
236
|
+
? { OracleRefInputIdx: refInputIdxs[3] }
|
|
237
|
+
: 'OracleVoid',
|
|
236
238
|
);
|
|
237
239
|
|
|
238
240
|
tx.readFrom(allRefInputs);
|
|
@@ -272,7 +274,10 @@ export async function adjustRob(
|
|
|
272
274
|
const robDatum = parseRobDatumOrThrow(getInlineDatumOrThrow(robUtxo));
|
|
273
275
|
|
|
274
276
|
// The claim case
|
|
275
|
-
if (
|
|
277
|
+
if (
|
|
278
|
+
adjustmentAmt === 0n &&
|
|
279
|
+
isFullyRedeemed(robUtxo, robDatum, sysParams.cdpParams.cdpAssetSymbol)
|
|
280
|
+
) {
|
|
276
281
|
throw new Error(
|
|
277
282
|
"When there's no more lovelaces to spend, use close instead of claim.",
|
|
278
283
|
);
|
|
@@ -281,7 +286,8 @@ export async function adjustRob(
|
|
|
281
286
|
// Negative adjust case
|
|
282
287
|
if (
|
|
283
288
|
adjustmentAmt < 0 &&
|
|
284
|
-
|
|
289
|
+
robAmtToSpend(robUtxo, robDatum, sysParams.cdpParams.cdpAssetSymbol) <=
|
|
290
|
+
-adjustmentAmt
|
|
285
291
|
) {
|
|
286
292
|
throw new Error(
|
|
287
293
|
"Can't adjust negatively by more than available. Also, for adjusting by exactly the amount deposited, a close action should be used instead.",
|