@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
package/tests/rob/rob.test.ts
CHANGED
|
@@ -28,7 +28,8 @@ import {
|
|
|
28
28
|
createProposal,
|
|
29
29
|
fromSystemParamsAsset,
|
|
30
30
|
MIN_ROB_COLLATERAL_AMT,
|
|
31
|
-
|
|
31
|
+
robAmtToSpend,
|
|
32
|
+
robCollateralAmtToSpend,
|
|
32
33
|
} from '../../src';
|
|
33
34
|
import { strictEqual } from 'assert';
|
|
34
35
|
import {
|
|
@@ -1124,10 +1125,9 @@ describe('ROB', () => {
|
|
|
1124
1125
|
ownPkh,
|
|
1125
1126
|
);
|
|
1126
1127
|
|
|
1127
|
-
const amtToSpendBefore =
|
|
1128
|
+
const amtToSpendBefore = robCollateralAmtToSpend(
|
|
1128
1129
|
robBefore.utxo,
|
|
1129
1130
|
robBefore.datum,
|
|
1130
|
-
sysParams,
|
|
1131
1131
|
);
|
|
1132
1132
|
|
|
1133
1133
|
await runAndAwaitTx(
|
|
@@ -1148,10 +1148,9 @@ describe('ROB', () => {
|
|
|
1148
1148
|
ownPkh,
|
|
1149
1149
|
);
|
|
1150
1150
|
|
|
1151
|
-
const amtToSpendAfter =
|
|
1151
|
+
const amtToSpendAfter = robCollateralAmtToSpend(
|
|
1152
1152
|
adjustedUtxo1.utxo,
|
|
1153
1153
|
adjustedUtxo1.datum,
|
|
1154
|
-
sysParams,
|
|
1155
1154
|
);
|
|
1156
1155
|
|
|
1157
1156
|
assert(amtToSpendBefore - amtToSpendAfter === 1_000_000n);
|
|
@@ -1170,10 +1169,9 @@ describe('ROB', () => {
|
|
|
1170
1169
|
ownPkh,
|
|
1171
1170
|
);
|
|
1172
1171
|
|
|
1173
|
-
const amtToSpendBefore =
|
|
1172
|
+
const amtToSpendBefore = robCollateralAmtToSpend(
|
|
1174
1173
|
robBefore.utxo,
|
|
1175
1174
|
robBefore.datum,
|
|
1176
|
-
sysParams,
|
|
1177
1175
|
);
|
|
1178
1176
|
|
|
1179
1177
|
await runAndAwaitTx(
|
|
@@ -1194,10 +1192,9 @@ describe('ROB', () => {
|
|
|
1194
1192
|
ownPkh,
|
|
1195
1193
|
);
|
|
1196
1194
|
|
|
1197
|
-
const amtToSpendAfter =
|
|
1195
|
+
const amtToSpendAfter = robCollateralAmtToSpend(
|
|
1198
1196
|
adjustedUtxo2.utxo,
|
|
1199
1197
|
adjustedUtxo2.datum,
|
|
1200
|
-
sysParams,
|
|
1201
1198
|
);
|
|
1202
1199
|
|
|
1203
1200
|
strictEqual(amtToSpendAfter - amtToSpendBefore, 5_000_000n);
|
|
@@ -1274,13 +1271,21 @@ describe('ROB', () => {
|
|
|
1274
1271
|
};
|
|
1275
1272
|
|
|
1276
1273
|
assert(
|
|
1277
|
-
|
|
1274
|
+
robAmtToSpend(
|
|
1275
|
+
adjustedUtxo1.utxo,
|
|
1276
|
+
adjustedUtxo1.datum,
|
|
1277
|
+
sysParams.cdpParams.cdpAssetSymbol,
|
|
1278
|
+
) ===
|
|
1278
1279
|
20_000_000n - 1_000_000n,
|
|
1279
1280
|
);
|
|
1280
1281
|
|
|
1281
1282
|
expect(
|
|
1282
1283
|
assetClassValueOf(adjustedUtxo1.utxo.assets, iassetAc) ===
|
|
1283
|
-
|
|
1284
|
+
robAmtToSpend(
|
|
1285
|
+
adjustedUtxo1.utxo,
|
|
1286
|
+
adjustedUtxo1.datum,
|
|
1287
|
+
sysParams.cdpParams.cdpAssetSymbol,
|
|
1288
|
+
),
|
|
1284
1289
|
'IAssets to spend has to equal iassets in UTXO',
|
|
1285
1290
|
).toBeTruthy();
|
|
1286
1291
|
|
|
@@ -1305,13 +1310,21 @@ describe('ROB', () => {
|
|
|
1305
1310
|
const expectedResultAdaAmt = 20_000_000n - 1_000_000n + 5_000_000n;
|
|
1306
1311
|
|
|
1307
1312
|
strictEqual(
|
|
1308
|
-
|
|
1313
|
+
robAmtToSpend(
|
|
1314
|
+
adjustedUtxo2.utxo,
|
|
1315
|
+
adjustedUtxo2.datum,
|
|
1316
|
+
sysParams.cdpParams.cdpAssetSymbol,
|
|
1317
|
+
),
|
|
1309
1318
|
expectedResultAdaAmt,
|
|
1310
1319
|
);
|
|
1311
1320
|
|
|
1312
1321
|
expect(
|
|
1313
1322
|
assetClassValueOf(adjustedUtxo2.utxo.assets, iassetAc) >=
|
|
1314
|
-
|
|
1323
|
+
robAmtToSpend(
|
|
1324
|
+
adjustedUtxo2.utxo,
|
|
1325
|
+
adjustedUtxo2.datum,
|
|
1326
|
+
sysParams.cdpParams.cdpAssetSymbol,
|
|
1327
|
+
),
|
|
1315
1328
|
'IAssets to spend has to equal iassets in UTXO',
|
|
1316
1329
|
).toBeTruthy();
|
|
1317
1330
|
});
|
|
@@ -1376,10 +1389,9 @@ describe('ROB', () => {
|
|
|
1376
1389
|
|
|
1377
1390
|
const redemptionIAssetAmt = 11_000_000n;
|
|
1378
1391
|
|
|
1379
|
-
const amtToSpendBefore =
|
|
1392
|
+
const amtToSpendBefore = robCollateralAmtToSpend(
|
|
1380
1393
|
robUtxo.utxo,
|
|
1381
1394
|
robUtxo.datum,
|
|
1382
|
-
sysParams,
|
|
1383
1395
|
);
|
|
1384
1396
|
|
|
1385
1397
|
await runAndAwaitTx(
|
|
@@ -1408,7 +1420,7 @@ describe('ROB', () => {
|
|
|
1408
1420
|
|
|
1409
1421
|
expect(
|
|
1410
1422
|
amtToSpendBefore -
|
|
1411
|
-
|
|
1423
|
+
robCollateralAmtToSpend(redeemedRob.utxo, redeemedRob.datum),
|
|
1412
1424
|
'ROB has wrong number redeemed',
|
|
1413
1425
|
).toEqual(
|
|
1414
1426
|
// Since price is 1
|
|
@@ -1553,7 +1565,7 @@ describe('ROB', () => {
|
|
|
1553
1565
|
);
|
|
1554
1566
|
|
|
1555
1567
|
expect(
|
|
1556
|
-
|
|
1568
|
+
robCollateralAmtToSpend(redeemedRob.utxo, redeemedRob.datum),
|
|
1557
1569
|
'Wrong amt to spend in datum',
|
|
1558
1570
|
).toEqual(initialDeposit - expectedRedeemedAmt);
|
|
1559
1571
|
|
|
@@ -1701,7 +1713,11 @@ describe('ROB', () => {
|
|
|
1701
1713
|
);
|
|
1702
1714
|
|
|
1703
1715
|
expect(
|
|
1704
|
-
|
|
1716
|
+
robAmtToSpend(
|
|
1717
|
+
redeemedRob.utxo,
|
|
1718
|
+
redeemedRob.datum,
|
|
1719
|
+
sysParams.cdpParams.cdpAssetSymbol,
|
|
1720
|
+
),
|
|
1705
1721
|
'Wrong amt to spend in datum',
|
|
1706
1722
|
).toEqual(initialDeposit - expectedRedemptionAmt);
|
|
1707
1723
|
|
|
@@ -2274,7 +2290,7 @@ describe('ROB', () => {
|
|
|
2274
2290
|
|
|
2275
2291
|
// Since price is 1
|
|
2276
2292
|
expect(
|
|
2277
|
-
|
|
2293
|
+
robCollateralAmtToSpend(adjustedRob.utxo, adjustedRob.datum),
|
|
2278
2294
|
).toEqual(
|
|
2279
2295
|
// 20mil start, -1mil adjusted, rest redeemed
|
|
2280
2296
|
20_000_000n -
|
|
@@ -124,7 +124,9 @@ export async function testRedeemRob(
|
|
|
124
124
|
0n,
|
|
125
125
|
refInputIdxs[2],
|
|
126
126
|
refInputIdxs[1],
|
|
127
|
-
|
|
127
|
+
priceOracleOutRef !== undefined
|
|
128
|
+
? { OracleRefInputIdx: refInputIdxs[3] }
|
|
129
|
+
: 'OracleVoid',
|
|
128
130
|
);
|
|
129
131
|
|
|
130
132
|
const transaction = lucid
|
|
@@ -295,7 +297,7 @@ export async function redeemWithCdpCreate(
|
|
|
295
297
|
0n,
|
|
296
298
|
refInputIdxs[0],
|
|
297
299
|
refInputIdxs[1],
|
|
298
|
-
refInputIdxs[2],
|
|
300
|
+
{ OracleRefInputIdx: refInputIdxs[2] },
|
|
299
301
|
);
|
|
300
302
|
|
|
301
303
|
const txValidity = oracleExpirationAwareValidity(
|
|
@@ -534,7 +536,7 @@ export async function redeemWithCdpClose(
|
|
|
534
536
|
0n,
|
|
535
537
|
refInputIdxs[0],
|
|
536
538
|
refInputIdxs[1],
|
|
537
|
-
refInputIdxs[2],
|
|
539
|
+
{ OracleRefInputIdx: refInputIdxs[2] },
|
|
538
540
|
);
|
|
539
541
|
|
|
540
542
|
const validateFrom = slotToUnixTime(network, currentSlot - 1);
|
|
@@ -758,7 +760,7 @@ export async function redeemWithCdpAdjust(
|
|
|
758
760
|
0n,
|
|
759
761
|
refInputIdxs[0],
|
|
760
762
|
refInputIdxs[1],
|
|
761
|
-
refInputIdxs[2],
|
|
763
|
+
{ OracleRefInputIdx: refInputIdxs[2] },
|
|
762
764
|
);
|
|
763
765
|
|
|
764
766
|
const txValidity = oracleExpirationAwareValidity(
|