@indigo-labs/indigo-sdk 0.1.5 → 0.1.7
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 +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.js +66 -6
- package/dist/index.mjs +64 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1235,6 +1235,11 @@ declare const LRPDatumSchema: _lucid_evolution_lucid.TObject<{
|
|
|
1235
1235
|
maxPrice: _lucid_evolution_lucid.TObject<{
|
|
1236
1236
|
getOnChainInt: _lucid_evolution_lucid.TUnsafe<bigint>;
|
|
1237
1237
|
}>;
|
|
1238
|
+
/**
|
|
1239
|
+
* The amount of lovelaces that is available to be spent.
|
|
1240
|
+
* This doesn't correspond to the lovelaces in UTXO's value,
|
|
1241
|
+
* since that can contain fees, too.
|
|
1242
|
+
*/
|
|
1238
1243
|
lovelacesToSpend: _lucid_evolution_lucid.TUnsafe<bigint>;
|
|
1239
1244
|
}>;
|
|
1240
1245
|
type LRPDatum = Data.Static<typeof LRPDatumSchema>;
|
|
@@ -1273,7 +1278,22 @@ type OnChainDecimal = Data.Static<typeof OnChainDecimalSchema>;
|
|
|
1273
1278
|
|
|
1274
1279
|
declare function openLrp(assetTokenName: string, lovelacesAmt: bigint, maxPrice: OnChainDecimal, lucid: LucidEvolution, lrpScriptHash: ScriptHash, network: Network, lrpStakeCredential?: Credential$1): Promise<TxBuilder>;
|
|
1275
1280
|
declare function cancelLrp(lrpOutRef: OutRef, lrpRefScriptOutRef: OutRef, lucid: LucidEvolution): Promise<TxBuilder>;
|
|
1276
|
-
declare function redeemLrp(
|
|
1281
|
+
declare function redeemLrp(
|
|
1282
|
+
/** The tuple represents the LRP outref and the amount of iAssets to redeem against it. */
|
|
1283
|
+
redemptionLrpsData: [OutRef, bigint][], lrpRefScriptOutRef: OutRef, priceOracleOutRef: OutRef, iassetOutRef: OutRef, lucid: LucidEvolution, lrpParams: LRPParams, priceOracleParams: PriceOracleParams, network: Network, currentSlot: number): Promise<TxBuilder>;
|
|
1284
|
+
/**
|
|
1285
|
+
* Create Tx adjusting the LRP and claiming the received iAssets
|
|
1286
|
+
*/
|
|
1287
|
+
declare function adjustLrp(lucid: LucidEvolution, lrpOutRef: OutRef,
|
|
1288
|
+
/**
|
|
1289
|
+
* A positive amount increases the lovelaces in the LRP,
|
|
1290
|
+
* and a negative amount takes lovelaces from the LRP.
|
|
1291
|
+
*/
|
|
1292
|
+
lovelacesAdjustAmt: bigint, lrpRefScriptOutRef: OutRef, lrpParams: LRPParams): Promise<TxBuilder>;
|
|
1293
|
+
/**
|
|
1294
|
+
* Create Tx claiming the received iAssets.
|
|
1295
|
+
*/
|
|
1296
|
+
declare function claimLrp(lucid: LucidEvolution, lrpOutRef: OutRef, lrpRefScriptOutRef: OutRef, lrpParams: LRPParams): Promise<TxBuilder>;
|
|
1277
1297
|
|
|
1278
1298
|
declare const mkLrpValidator: (params: LRPParams) => SpendingValidator;
|
|
1279
1299
|
|
|
@@ -1297,4 +1317,4 @@ type OneShotParams = Data.Static<typeof OneShotParamsSchema>;
|
|
|
1297
1317
|
declare function oneShotMintTx(lucid: LucidEvolution, params: OneShotParams): Promise<[TxBuilder, PolicyId]>;
|
|
1298
1318
|
declare function runOneShotMintTx(lucid: LucidEvolution, params: OneShotParams): Promise<PolicyId>;
|
|
1299
1319
|
|
|
1300
|
-
export { AccountAction, AccountActionSchema, AccountContent, AccountContentSchema, ActionReturnDatum, ActionReturnDatumSchema, Address, type AddressCredential, type AddressCredentialOrDatum, type AddressSP, AddressSchema, type Amount, type AssetClass, type AssetClassSP, AssetClassSchema, type AuthTokenPolicies, type CDPContent, CDPContentSchema, CDPContract, type CDPCreatorParamsSP, type CDPDatum, CDPDatumSchema, type CDPFees, CDPFeesSchema, type CdpParams, CollectorContract, type CollectorParams, Credential, CredentialSchema, type CurrencySymbol, type DistributionParams, EpochToScaleToSum, EpochToScaleToSumSchema, ExecuteParams, type ExecuteParamsSP, type FeedInterestOracleRedeemer, FeedInterestOracleRedeemerSchema, GovContract, type GovDatum, GovParams, type GovParamsSP, type IAssetContent, IAssetContentSchema, IAssetHelpers, type IAssetOutput, type Input, InterestOracleContract, type InterestOracleDatum, InterestOracleDatumSchema, type InterestOracleParams, InterestOracleParamsSchema, type LRPDatum, LRPDatumSchema, type LRPParams, LRPParamsSchema, type LRPRedeemer, LRPRedeemerSchema, ONE_SECOND, type OracleAssetNft, OracleAssetNftSchema, type Output, type OutputReference, OutputReferenceSchema, PollManagerParams, type PollManagerParamsSP, PollShardParams, type PollShardParamsSP, type PriceOracleDatum, PriceOracleDatumSchema, type PriceOracleParams, PriceOracleParamsSchema, type PubKeyHash, SPInteger, SPIntegerSchema, type ScriptCredential, type ScriptOutput, type ScriptRef, type ScriptReference, type ScriptReferences, SnapshotEpochToScaleToSumContent, SnapshotEpochToScaleToSumContentSchema, StabilityPoolContent, StabilityPoolContentSchema, StabilityPoolContract, StabilityPoolDatum, StabilityPoolDatumSchema, StabilityPoolParams, type StabilityPoolParamsSP, StabilityPoolRedeemer, StabilityPoolRedeemerSchema, StabilityPoolSnapshot, StakingContract, type StakingParams, type StartTime, type SystemParams, type TokenName, TreasuryContract, type TreasuryParams, type ValidatorHashes, VerificationKeyHashSchema, type VersionRecordParams, _cdpValidator, _collectorValidator, _treasuryValidator, addrDetails, addressFromBech32, addressToBech32, balance, calculateFeeFromPercentage, cancelLrp, castExecuteParams, castGovParams, castInterestOracleParams, castLrpParams, castPollManagerParams, castPollShardParams, castPriceOracleParams, castStabilityPoolParams, cdpCreatorValidator, createScriptAddress, fromSPInteger, fromSystemParamsAsset, getInlineDatumOrThrow, getRandomElement, loadSystemParamsFromFile, loadSystemParamsFromUrl, matchSingle, mkCDPCreatorValidator, mkCDPCreatorValidatorFromSP, mkInterestOracleValidator, mkLrpValidator, mkPollManagerValidator, mkPollManagerValidatorFromSP, mkPollShardValidator, mkPollShardValidatorFromSP, mkSPInteger, oneDay, oneHour, oneShotMintTx, oneYear, openLrp, parseAccountDatum, parseCDPDatum, parseGovDatum, parseIAssetDatum, parseInterestOracleDatum, parseLrpDatum, parsePriceOracleDatum, parseSnapshotEpochToScaleToSumDatum, parseStabilityPoolDatum, redeemLrp, runCreateScriptRefTx, runOneShotMintTx, scriptRef, serialiseCDPDatum, serialiseFeedInterestOracleRedeemer, serialiseGovDatum, serialiseIAssetDatum, serialiseInterestOracleDatum, serialiseLrpDatum, serialiseLrpRedeemer, serialisePriceOracleDatum, serialiseStabilityPoolDatum, serialiseStabilityPoolRedeemer, spAdd, spDiv, spMul, spSub, toSystemParamsAsset };
|
|
1320
|
+
export { AccountAction, AccountActionSchema, AccountContent, AccountContentSchema, ActionReturnDatum, ActionReturnDatumSchema, Address, type AddressCredential, type AddressCredentialOrDatum, type AddressSP, AddressSchema, type Amount, type AssetClass, type AssetClassSP, AssetClassSchema, type AuthTokenPolicies, type CDPContent, CDPContentSchema, CDPContract, type CDPCreatorParamsSP, type CDPDatum, CDPDatumSchema, type CDPFees, CDPFeesSchema, type CdpParams, CollectorContract, type CollectorParams, Credential, CredentialSchema, type CurrencySymbol, type DistributionParams, EpochToScaleToSum, EpochToScaleToSumSchema, ExecuteParams, type ExecuteParamsSP, type FeedInterestOracleRedeemer, FeedInterestOracleRedeemerSchema, GovContract, type GovDatum, GovParams, type GovParamsSP, type IAssetContent, IAssetContentSchema, IAssetHelpers, type IAssetOutput, type Input, InterestOracleContract, type InterestOracleDatum, InterestOracleDatumSchema, type InterestOracleParams, InterestOracleParamsSchema, type LRPDatum, LRPDatumSchema, type LRPParams, LRPParamsSchema, type LRPRedeemer, LRPRedeemerSchema, ONE_SECOND, type OracleAssetNft, OracleAssetNftSchema, type Output, type OutputReference, OutputReferenceSchema, PollManagerParams, type PollManagerParamsSP, PollShardParams, type PollShardParamsSP, type PriceOracleDatum, PriceOracleDatumSchema, type PriceOracleParams, PriceOracleParamsSchema, type PubKeyHash, SPInteger, SPIntegerSchema, type ScriptCredential, type ScriptOutput, type ScriptRef, type ScriptReference, type ScriptReferences, SnapshotEpochToScaleToSumContent, SnapshotEpochToScaleToSumContentSchema, StabilityPoolContent, StabilityPoolContentSchema, StabilityPoolContract, StabilityPoolDatum, StabilityPoolDatumSchema, StabilityPoolParams, type StabilityPoolParamsSP, StabilityPoolRedeemer, StabilityPoolRedeemerSchema, StabilityPoolSnapshot, StakingContract, type StakingParams, type StartTime, type SystemParams, type TokenName, TreasuryContract, type TreasuryParams, type ValidatorHashes, VerificationKeyHashSchema, type VersionRecordParams, _cdpValidator, _collectorValidator, _treasuryValidator, addrDetails, addressFromBech32, addressToBech32, adjustLrp, balance, calculateFeeFromPercentage, cancelLrp, castExecuteParams, castGovParams, castInterestOracleParams, castLrpParams, castPollManagerParams, castPollShardParams, castPriceOracleParams, castStabilityPoolParams, cdpCreatorValidator, claimLrp, createScriptAddress, fromSPInteger, fromSystemParamsAsset, getInlineDatumOrThrow, getRandomElement, loadSystemParamsFromFile, loadSystemParamsFromUrl, matchSingle, mkCDPCreatorValidator, mkCDPCreatorValidatorFromSP, mkInterestOracleValidator, mkLrpValidator, mkPollManagerValidator, mkPollManagerValidatorFromSP, mkPollShardValidator, mkPollShardValidatorFromSP, mkSPInteger, oneDay, oneHour, oneShotMintTx, oneYear, openLrp, parseAccountDatum, parseCDPDatum, parseGovDatum, parseIAssetDatum, parseInterestOracleDatum, parseLrpDatum, parsePriceOracleDatum, parseSnapshotEpochToScaleToSumDatum, parseStabilityPoolDatum, redeemLrp, runCreateScriptRefTx, runOneShotMintTx, scriptRef, serialiseCDPDatum, serialiseFeedInterestOracleRedeemer, serialiseGovDatum, serialiseIAssetDatum, serialiseInterestOracleDatum, serialiseLrpDatum, serialiseLrpRedeemer, serialisePriceOracleDatum, serialiseStabilityPoolDatum, serialiseStabilityPoolRedeemer, spAdd, spDiv, spMul, spSub, toSystemParamsAsset };
|
package/dist/index.d.ts
CHANGED
|
@@ -1235,6 +1235,11 @@ declare const LRPDatumSchema: _lucid_evolution_lucid.TObject<{
|
|
|
1235
1235
|
maxPrice: _lucid_evolution_lucid.TObject<{
|
|
1236
1236
|
getOnChainInt: _lucid_evolution_lucid.TUnsafe<bigint>;
|
|
1237
1237
|
}>;
|
|
1238
|
+
/**
|
|
1239
|
+
* The amount of lovelaces that is available to be spent.
|
|
1240
|
+
* This doesn't correspond to the lovelaces in UTXO's value,
|
|
1241
|
+
* since that can contain fees, too.
|
|
1242
|
+
*/
|
|
1238
1243
|
lovelacesToSpend: _lucid_evolution_lucid.TUnsafe<bigint>;
|
|
1239
1244
|
}>;
|
|
1240
1245
|
type LRPDatum = Data.Static<typeof LRPDatumSchema>;
|
|
@@ -1273,7 +1278,22 @@ type OnChainDecimal = Data.Static<typeof OnChainDecimalSchema>;
|
|
|
1273
1278
|
|
|
1274
1279
|
declare function openLrp(assetTokenName: string, lovelacesAmt: bigint, maxPrice: OnChainDecimal, lucid: LucidEvolution, lrpScriptHash: ScriptHash, network: Network, lrpStakeCredential?: Credential$1): Promise<TxBuilder>;
|
|
1275
1280
|
declare function cancelLrp(lrpOutRef: OutRef, lrpRefScriptOutRef: OutRef, lucid: LucidEvolution): Promise<TxBuilder>;
|
|
1276
|
-
declare function redeemLrp(
|
|
1281
|
+
declare function redeemLrp(
|
|
1282
|
+
/** The tuple represents the LRP outref and the amount of iAssets to redeem against it. */
|
|
1283
|
+
redemptionLrpsData: [OutRef, bigint][], lrpRefScriptOutRef: OutRef, priceOracleOutRef: OutRef, iassetOutRef: OutRef, lucid: LucidEvolution, lrpParams: LRPParams, priceOracleParams: PriceOracleParams, network: Network, currentSlot: number): Promise<TxBuilder>;
|
|
1284
|
+
/**
|
|
1285
|
+
* Create Tx adjusting the LRP and claiming the received iAssets
|
|
1286
|
+
*/
|
|
1287
|
+
declare function adjustLrp(lucid: LucidEvolution, lrpOutRef: OutRef,
|
|
1288
|
+
/**
|
|
1289
|
+
* A positive amount increases the lovelaces in the LRP,
|
|
1290
|
+
* and a negative amount takes lovelaces from the LRP.
|
|
1291
|
+
*/
|
|
1292
|
+
lovelacesAdjustAmt: bigint, lrpRefScriptOutRef: OutRef, lrpParams: LRPParams): Promise<TxBuilder>;
|
|
1293
|
+
/**
|
|
1294
|
+
* Create Tx claiming the received iAssets.
|
|
1295
|
+
*/
|
|
1296
|
+
declare function claimLrp(lucid: LucidEvolution, lrpOutRef: OutRef, lrpRefScriptOutRef: OutRef, lrpParams: LRPParams): Promise<TxBuilder>;
|
|
1277
1297
|
|
|
1278
1298
|
declare const mkLrpValidator: (params: LRPParams) => SpendingValidator;
|
|
1279
1299
|
|
|
@@ -1297,4 +1317,4 @@ type OneShotParams = Data.Static<typeof OneShotParamsSchema>;
|
|
|
1297
1317
|
declare function oneShotMintTx(lucid: LucidEvolution, params: OneShotParams): Promise<[TxBuilder, PolicyId]>;
|
|
1298
1318
|
declare function runOneShotMintTx(lucid: LucidEvolution, params: OneShotParams): Promise<PolicyId>;
|
|
1299
1319
|
|
|
1300
|
-
export { AccountAction, AccountActionSchema, AccountContent, AccountContentSchema, ActionReturnDatum, ActionReturnDatumSchema, Address, type AddressCredential, type AddressCredentialOrDatum, type AddressSP, AddressSchema, type Amount, type AssetClass, type AssetClassSP, AssetClassSchema, type AuthTokenPolicies, type CDPContent, CDPContentSchema, CDPContract, type CDPCreatorParamsSP, type CDPDatum, CDPDatumSchema, type CDPFees, CDPFeesSchema, type CdpParams, CollectorContract, type CollectorParams, Credential, CredentialSchema, type CurrencySymbol, type DistributionParams, EpochToScaleToSum, EpochToScaleToSumSchema, ExecuteParams, type ExecuteParamsSP, type FeedInterestOracleRedeemer, FeedInterestOracleRedeemerSchema, GovContract, type GovDatum, GovParams, type GovParamsSP, type IAssetContent, IAssetContentSchema, IAssetHelpers, type IAssetOutput, type Input, InterestOracleContract, type InterestOracleDatum, InterestOracleDatumSchema, type InterestOracleParams, InterestOracleParamsSchema, type LRPDatum, LRPDatumSchema, type LRPParams, LRPParamsSchema, type LRPRedeemer, LRPRedeemerSchema, ONE_SECOND, type OracleAssetNft, OracleAssetNftSchema, type Output, type OutputReference, OutputReferenceSchema, PollManagerParams, type PollManagerParamsSP, PollShardParams, type PollShardParamsSP, type PriceOracleDatum, PriceOracleDatumSchema, type PriceOracleParams, PriceOracleParamsSchema, type PubKeyHash, SPInteger, SPIntegerSchema, type ScriptCredential, type ScriptOutput, type ScriptRef, type ScriptReference, type ScriptReferences, SnapshotEpochToScaleToSumContent, SnapshotEpochToScaleToSumContentSchema, StabilityPoolContent, StabilityPoolContentSchema, StabilityPoolContract, StabilityPoolDatum, StabilityPoolDatumSchema, StabilityPoolParams, type StabilityPoolParamsSP, StabilityPoolRedeemer, StabilityPoolRedeemerSchema, StabilityPoolSnapshot, StakingContract, type StakingParams, type StartTime, type SystemParams, type TokenName, TreasuryContract, type TreasuryParams, type ValidatorHashes, VerificationKeyHashSchema, type VersionRecordParams, _cdpValidator, _collectorValidator, _treasuryValidator, addrDetails, addressFromBech32, addressToBech32, balance, calculateFeeFromPercentage, cancelLrp, castExecuteParams, castGovParams, castInterestOracleParams, castLrpParams, castPollManagerParams, castPollShardParams, castPriceOracleParams, castStabilityPoolParams, cdpCreatorValidator, createScriptAddress, fromSPInteger, fromSystemParamsAsset, getInlineDatumOrThrow, getRandomElement, loadSystemParamsFromFile, loadSystemParamsFromUrl, matchSingle, mkCDPCreatorValidator, mkCDPCreatorValidatorFromSP, mkInterestOracleValidator, mkLrpValidator, mkPollManagerValidator, mkPollManagerValidatorFromSP, mkPollShardValidator, mkPollShardValidatorFromSP, mkSPInteger, oneDay, oneHour, oneShotMintTx, oneYear, openLrp, parseAccountDatum, parseCDPDatum, parseGovDatum, parseIAssetDatum, parseInterestOracleDatum, parseLrpDatum, parsePriceOracleDatum, parseSnapshotEpochToScaleToSumDatum, parseStabilityPoolDatum, redeemLrp, runCreateScriptRefTx, runOneShotMintTx, scriptRef, serialiseCDPDatum, serialiseFeedInterestOracleRedeemer, serialiseGovDatum, serialiseIAssetDatum, serialiseInterestOracleDatum, serialiseLrpDatum, serialiseLrpRedeemer, serialisePriceOracleDatum, serialiseStabilityPoolDatum, serialiseStabilityPoolRedeemer, spAdd, spDiv, spMul, spSub, toSystemParamsAsset };
|
|
1320
|
+
export { AccountAction, AccountActionSchema, AccountContent, AccountContentSchema, ActionReturnDatum, ActionReturnDatumSchema, Address, type AddressCredential, type AddressCredentialOrDatum, type AddressSP, AddressSchema, type Amount, type AssetClass, type AssetClassSP, AssetClassSchema, type AuthTokenPolicies, type CDPContent, CDPContentSchema, CDPContract, type CDPCreatorParamsSP, type CDPDatum, CDPDatumSchema, type CDPFees, CDPFeesSchema, type CdpParams, CollectorContract, type CollectorParams, Credential, CredentialSchema, type CurrencySymbol, type DistributionParams, EpochToScaleToSum, EpochToScaleToSumSchema, ExecuteParams, type ExecuteParamsSP, type FeedInterestOracleRedeemer, FeedInterestOracleRedeemerSchema, GovContract, type GovDatum, GovParams, type GovParamsSP, type IAssetContent, IAssetContentSchema, IAssetHelpers, type IAssetOutput, type Input, InterestOracleContract, type InterestOracleDatum, InterestOracleDatumSchema, type InterestOracleParams, InterestOracleParamsSchema, type LRPDatum, LRPDatumSchema, type LRPParams, LRPParamsSchema, type LRPRedeemer, LRPRedeemerSchema, ONE_SECOND, type OracleAssetNft, OracleAssetNftSchema, type Output, type OutputReference, OutputReferenceSchema, PollManagerParams, type PollManagerParamsSP, PollShardParams, type PollShardParamsSP, type PriceOracleDatum, PriceOracleDatumSchema, type PriceOracleParams, PriceOracleParamsSchema, type PubKeyHash, SPInteger, SPIntegerSchema, type ScriptCredential, type ScriptOutput, type ScriptRef, type ScriptReference, type ScriptReferences, SnapshotEpochToScaleToSumContent, SnapshotEpochToScaleToSumContentSchema, StabilityPoolContent, StabilityPoolContentSchema, StabilityPoolContract, StabilityPoolDatum, StabilityPoolDatumSchema, StabilityPoolParams, type StabilityPoolParamsSP, StabilityPoolRedeemer, StabilityPoolRedeemerSchema, StabilityPoolSnapshot, StakingContract, type StakingParams, type StartTime, type SystemParams, type TokenName, TreasuryContract, type TreasuryParams, type ValidatorHashes, VerificationKeyHashSchema, type VersionRecordParams, _cdpValidator, _collectorValidator, _treasuryValidator, addrDetails, addressFromBech32, addressToBech32, adjustLrp, balance, calculateFeeFromPercentage, cancelLrp, castExecuteParams, castGovParams, castInterestOracleParams, castLrpParams, castPollManagerParams, castPollShardParams, castPriceOracleParams, castStabilityPoolParams, cdpCreatorValidator, claimLrp, createScriptAddress, fromSPInteger, fromSystemParamsAsset, getInlineDatumOrThrow, getRandomElement, loadSystemParamsFromFile, loadSystemParamsFromUrl, matchSingle, mkCDPCreatorValidator, mkCDPCreatorValidatorFromSP, mkInterestOracleValidator, mkLrpValidator, mkPollManagerValidator, mkPollManagerValidatorFromSP, mkPollShardValidator, mkPollShardValidatorFromSP, mkSPInteger, oneDay, oneHour, oneShotMintTx, oneYear, openLrp, parseAccountDatum, parseCDPDatum, parseGovDatum, parseIAssetDatum, parseInterestOracleDatum, parseLrpDatum, parsePriceOracleDatum, parseSnapshotEpochToScaleToSumDatum, parseStabilityPoolDatum, redeemLrp, runCreateScriptRefTx, runOneShotMintTx, scriptRef, serialiseCDPDatum, serialiseFeedInterestOracleRedeemer, serialiseGovDatum, serialiseIAssetDatum, serialiseInterestOracleDatum, serialiseLrpDatum, serialiseLrpRedeemer, serialisePriceOracleDatum, serialiseStabilityPoolDatum, serialiseStabilityPoolRedeemer, spAdd, spDiv, spMul, spSub, toSystemParamsAsset };
|
package/dist/index.js
CHANGED
|
@@ -88,6 +88,7 @@ __export(index_exports, {
|
|
|
88
88
|
addrDetails: () => addrDetails,
|
|
89
89
|
addressFromBech32: () => addressFromBech32,
|
|
90
90
|
addressToBech32: () => addressToBech32,
|
|
91
|
+
adjustLrp: () => adjustLrp,
|
|
91
92
|
balance: () => balance,
|
|
92
93
|
calculateFeeFromPercentage: () => calculateFeeFromPercentage,
|
|
93
94
|
cancelLrp: () => cancelLrp,
|
|
@@ -100,6 +101,7 @@ __export(index_exports, {
|
|
|
100
101
|
castPriceOracleParams: () => castPriceOracleParams,
|
|
101
102
|
castStabilityPoolParams: () => castStabilityPoolParams,
|
|
102
103
|
cdpCreatorValidator: () => cdpCreatorValidator,
|
|
104
|
+
claimLrp: () => claimLrp,
|
|
103
105
|
createScriptAddress: () => createScriptAddress,
|
|
104
106
|
fromSPInteger: () => fromSPInteger,
|
|
105
107
|
fromSystemParamsAsset: () => fromSystemParamsAsset,
|
|
@@ -2471,6 +2473,9 @@ function mkAssetsOf(assetClass, amount) {
|
|
|
2471
2473
|
[assetClassToUnit(assetClass)]: amount
|
|
2472
2474
|
};
|
|
2473
2475
|
}
|
|
2476
|
+
function assetClassValueOf(assets, assetClass) {
|
|
2477
|
+
return assets[assetClassToUnit(assetClass)] ?? 0n;
|
|
2478
|
+
}
|
|
2474
2479
|
|
|
2475
2480
|
// tests/queries/interest-oracle-queries.ts
|
|
2476
2481
|
async function findInterestOracle(lucid, interestNft) {
|
|
@@ -2741,6 +2746,11 @@ var LRPDatumSchema = import_lucid32.Data.Object({
|
|
|
2741
2746
|
owner: import_lucid32.Data.Bytes(),
|
|
2742
2747
|
iasset: import_lucid32.Data.Bytes(),
|
|
2743
2748
|
maxPrice: OnChainDecimalSchema,
|
|
2749
|
+
/**
|
|
2750
|
+
* The amount of lovelaces that is available to be spent.
|
|
2751
|
+
* This doesn't correspond to the lovelaces in UTXO's value,
|
|
2752
|
+
* since that can contain fees, too.
|
|
2753
|
+
*/
|
|
2744
2754
|
lovelacesToSpend: import_lucid32.Data.Integer()
|
|
2745
2755
|
});
|
|
2746
2756
|
var LRPDatum = LRPDatumSchema;
|
|
@@ -2825,7 +2835,7 @@ async function cancelLrp(lrpOutRef, lrpRefScriptOutRef, lucid) {
|
|
|
2825
2835
|
);
|
|
2826
2836
|
return lucid.newTx().readFrom([lrpScriptRefUtxo]).collectFrom([lrpUtxo], serialiseLrpRedeemer("Cancel")).addSigner(ownAddr);
|
|
2827
2837
|
}
|
|
2828
|
-
async function redeemLrp(redemptionLrpsData, lrpRefScriptOutRef, priceOracleOutRef, iassetOutRef, lucid, lrpParams, priceOracleParams, network) {
|
|
2838
|
+
async function redeemLrp(redemptionLrpsData, lrpRefScriptOutRef, priceOracleOutRef, iassetOutRef, lucid, lrpParams, priceOracleParams, network, currentSlot) {
|
|
2829
2839
|
const lrpScriptRefUtxo = matchSingle(
|
|
2830
2840
|
await lucid.utxosByOutRef([lrpRefScriptOutRef]),
|
|
2831
2841
|
(_2) => new Error("Expected a single LRP Ref Script UTXO")
|
|
@@ -2844,9 +2854,12 @@ async function redeemLrp(redemptionLrpsData, lrpRefScriptOutRef, priceOracleOutR
|
|
|
2844
2854
|
getInlineDatumOrThrow(priceOracleUtxo)
|
|
2845
2855
|
);
|
|
2846
2856
|
const redemptionLrps = await lucid.utxosByOutRef(lrpsToRedeemOutRefs).then((val) => (0, import_Array2.zip)(val, lrpRedemptionIAssetAmt));
|
|
2847
|
-
const [[mainLrpUtxo,
|
|
2857
|
+
const [[mainLrpUtxo, _], __] = (0, import_ts_pattern5.match)(redemptionLrps).with(
|
|
2848
2858
|
[import_ts_pattern5.P._, ...import_ts_pattern5.P.array()],
|
|
2849
|
-
([[firstLrp,
|
|
2859
|
+
([[firstLrp, _2], ...rest]) => [
|
|
2860
|
+
[firstLrp, _2],
|
|
2861
|
+
rest
|
|
2862
|
+
]
|
|
2850
2863
|
).otherwise(() => {
|
|
2851
2864
|
throw new Error("Expects at least 1 UTXO to redeem.");
|
|
2852
2865
|
});
|
|
@@ -2856,7 +2869,7 @@ async function redeemLrp(redemptionLrpsData, lrpRefScriptOutRef, priceOracleOutR
|
|
|
2856
2869
|
(idx, acc, [lrpUtxo, redeemIAssetAmt]) => {
|
|
2857
2870
|
const lovelacesForRedemption = ocdMul(
|
|
2858
2871
|
{
|
|
2859
|
-
getOnChainInt:
|
|
2872
|
+
getOnChainInt: redeemIAssetAmt
|
|
2860
2873
|
},
|
|
2861
2874
|
priceOracleDatum.price
|
|
2862
2875
|
).getOnChainInt;
|
|
@@ -2905,12 +2918,57 @@ async function redeemLrp(redemptionLrpsData, lrpRefScriptOutRef, priceOracleOutR
|
|
|
2905
2918
|
}
|
|
2906
2919
|
)(redemptionLrps);
|
|
2907
2920
|
const txValidity = oracleExpirationAwareValidity(
|
|
2908
|
-
|
|
2921
|
+
currentSlot,
|
|
2909
2922
|
Number(priceOracleParams.biasTime),
|
|
2910
2923
|
Number(priceOracleDatum.expiration),
|
|
2911
2924
|
network
|
|
2912
2925
|
);
|
|
2913
|
-
return lucid.newTx().validTo(txValidity.validTo).readFrom([lrpScriptRefUtxo]).readFrom([iassetUtxo, priceOracleUtxo]).compose(tx);
|
|
2926
|
+
return lucid.newTx().validFrom(txValidity.validFrom).validTo(txValidity.validTo).readFrom([lrpScriptRefUtxo]).readFrom([iassetUtxo, priceOracleUtxo]).compose(tx);
|
|
2927
|
+
}
|
|
2928
|
+
async function adjustLrp(lucid, lrpOutRef, lovelacesAdjustAmt, lrpRefScriptOutRef, lrpParams) {
|
|
2929
|
+
const ownAddr = await lucid.wallet().address();
|
|
2930
|
+
const lrpScriptRefUtxo = matchSingle(
|
|
2931
|
+
await lucid.utxosByOutRef([lrpRefScriptOutRef]),
|
|
2932
|
+
(_) => new Error("Expected a single LRP Ref Script UTXO")
|
|
2933
|
+
);
|
|
2934
|
+
const lrpUtxo = matchSingle(
|
|
2935
|
+
await lucid.utxosByOutRef([lrpOutRef]),
|
|
2936
|
+
(_) => new Error("Expected a single LRP UTXO.")
|
|
2937
|
+
);
|
|
2938
|
+
const lrpDatum = parseLrpDatum(getInlineDatumOrThrow(lrpUtxo));
|
|
2939
|
+
const rewardAssetClass = {
|
|
2940
|
+
currencySymbol: lrpParams.iassetPolicyId,
|
|
2941
|
+
tokenName: lrpDatum.iasset
|
|
2942
|
+
};
|
|
2943
|
+
const rewardAssetsAmt = assetClassValueOf(lrpUtxo.assets, rewardAssetClass);
|
|
2944
|
+
if (lovelacesAdjustAmt === 0n && lrpDatum.lovelacesToSpend === 0n) {
|
|
2945
|
+
throw new Error(
|
|
2946
|
+
"When there's no more lovelaces to spend, use close instead of claim."
|
|
2947
|
+
);
|
|
2948
|
+
}
|
|
2949
|
+
if (lovelacesAdjustAmt < 0 && lrpDatum.lovelacesToSpend <= lovelacesAdjustAmt) {
|
|
2950
|
+
throw new Error(
|
|
2951
|
+
"Can't adjust negatively by more than available. Also, for adjusting by exactly the amount deposited, a close action should be used instead."
|
|
2952
|
+
);
|
|
2953
|
+
}
|
|
2954
|
+
return lucid.newTx().readFrom([lrpScriptRefUtxo]).collectFrom([lrpUtxo], serialiseLrpRedeemer("Cancel")).pay.ToContract(
|
|
2955
|
+
lrpUtxo.address,
|
|
2956
|
+
{
|
|
2957
|
+
kind: "inline",
|
|
2958
|
+
value: serialiseLrpDatum({
|
|
2959
|
+
...lrpDatum,
|
|
2960
|
+
lovelacesToSpend: lrpDatum.lovelacesToSpend + lovelacesAdjustAmt
|
|
2961
|
+
})
|
|
2962
|
+
},
|
|
2963
|
+
(0, import_lucid34.addAssets)(
|
|
2964
|
+
lrpUtxo.assets,
|
|
2965
|
+
mkAssetsOf(rewardAssetClass, -rewardAssetsAmt),
|
|
2966
|
+
mkLovelacesOf(lovelacesAdjustAmt)
|
|
2967
|
+
)
|
|
2968
|
+
).addSigner(ownAddr);
|
|
2969
|
+
}
|
|
2970
|
+
async function claimLrp(lucid, lrpOutRef, lrpRefScriptOutRef, lrpParams) {
|
|
2971
|
+
return adjustLrp(lucid, lrpOutRef, 0n, lrpRefScriptOutRef, lrpParams);
|
|
2914
2972
|
}
|
|
2915
2973
|
|
|
2916
2974
|
// src/scripts/lrp-validator.ts
|
|
@@ -3006,6 +3064,7 @@ async function runCreateScriptRefTx(lucid, scriptRefValidator, network) {
|
|
|
3006
3064
|
addrDetails,
|
|
3007
3065
|
addressFromBech32,
|
|
3008
3066
|
addressToBech32,
|
|
3067
|
+
adjustLrp,
|
|
3009
3068
|
balance,
|
|
3010
3069
|
calculateFeeFromPercentage,
|
|
3011
3070
|
cancelLrp,
|
|
@@ -3018,6 +3077,7 @@ async function runCreateScriptRefTx(lucid, scriptRefValidator, network) {
|
|
|
3018
3077
|
castPriceOracleParams,
|
|
3019
3078
|
castStabilityPoolParams,
|
|
3020
3079
|
cdpCreatorValidator,
|
|
3080
|
+
claimLrp,
|
|
3021
3081
|
createScriptAddress,
|
|
3022
3082
|
fromSPInteger,
|
|
3023
3083
|
fromSystemParamsAsset,
|
package/dist/index.mjs
CHANGED
|
@@ -2375,6 +2375,9 @@ function mkAssetsOf(assetClass, amount) {
|
|
|
2375
2375
|
[assetClassToUnit(assetClass)]: amount
|
|
2376
2376
|
};
|
|
2377
2377
|
}
|
|
2378
|
+
function assetClassValueOf(assets, assetClass) {
|
|
2379
|
+
return assets[assetClassToUnit(assetClass)] ?? 0n;
|
|
2380
|
+
}
|
|
2378
2381
|
|
|
2379
2382
|
// tests/queries/interest-oracle-queries.ts
|
|
2380
2383
|
async function findInterestOracle(lucid, interestNft) {
|
|
@@ -2651,6 +2654,11 @@ var LRPDatumSchema = Data20.Object({
|
|
|
2651
2654
|
owner: Data20.Bytes(),
|
|
2652
2655
|
iasset: Data20.Bytes(),
|
|
2653
2656
|
maxPrice: OnChainDecimalSchema,
|
|
2657
|
+
/**
|
|
2658
|
+
* The amount of lovelaces that is available to be spent.
|
|
2659
|
+
* This doesn't correspond to the lovelaces in UTXO's value,
|
|
2660
|
+
* since that can contain fees, too.
|
|
2661
|
+
*/
|
|
2654
2662
|
lovelacesToSpend: Data20.Integer()
|
|
2655
2663
|
});
|
|
2656
2664
|
var LRPDatum = LRPDatumSchema;
|
|
@@ -2740,7 +2748,7 @@ async function cancelLrp(lrpOutRef, lrpRefScriptOutRef, lucid) {
|
|
|
2740
2748
|
);
|
|
2741
2749
|
return lucid.newTx().readFrom([lrpScriptRefUtxo]).collectFrom([lrpUtxo], serialiseLrpRedeemer("Cancel")).addSigner(ownAddr);
|
|
2742
2750
|
}
|
|
2743
|
-
async function redeemLrp(redemptionLrpsData, lrpRefScriptOutRef, priceOracleOutRef, iassetOutRef, lucid, lrpParams, priceOracleParams, network) {
|
|
2751
|
+
async function redeemLrp(redemptionLrpsData, lrpRefScriptOutRef, priceOracleOutRef, iassetOutRef, lucid, lrpParams, priceOracleParams, network, currentSlot) {
|
|
2744
2752
|
const lrpScriptRefUtxo = matchSingle(
|
|
2745
2753
|
await lucid.utxosByOutRef([lrpRefScriptOutRef]),
|
|
2746
2754
|
(_2) => new Error("Expected a single LRP Ref Script UTXO")
|
|
@@ -2759,9 +2767,12 @@ async function redeemLrp(redemptionLrpsData, lrpRefScriptOutRef, priceOracleOutR
|
|
|
2759
2767
|
getInlineDatumOrThrow(priceOracleUtxo)
|
|
2760
2768
|
);
|
|
2761
2769
|
const redemptionLrps = await lucid.utxosByOutRef(lrpsToRedeemOutRefs).then((val) => zip(val, lrpRedemptionIAssetAmt));
|
|
2762
|
-
const [[mainLrpUtxo,
|
|
2770
|
+
const [[mainLrpUtxo, _], __] = match5(redemptionLrps).with(
|
|
2763
2771
|
[P5._, ...P5.array()],
|
|
2764
|
-
([[firstLrp,
|
|
2772
|
+
([[firstLrp, _2], ...rest]) => [
|
|
2773
|
+
[firstLrp, _2],
|
|
2774
|
+
rest
|
|
2775
|
+
]
|
|
2765
2776
|
).otherwise(() => {
|
|
2766
2777
|
throw new Error("Expects at least 1 UTXO to redeem.");
|
|
2767
2778
|
});
|
|
@@ -2771,7 +2782,7 @@ async function redeemLrp(redemptionLrpsData, lrpRefScriptOutRef, priceOracleOutR
|
|
|
2771
2782
|
(idx, acc, [lrpUtxo, redeemIAssetAmt]) => {
|
|
2772
2783
|
const lovelacesForRedemption = ocdMul(
|
|
2773
2784
|
{
|
|
2774
|
-
getOnChainInt:
|
|
2785
|
+
getOnChainInt: redeemIAssetAmt
|
|
2775
2786
|
},
|
|
2776
2787
|
priceOracleDatum.price
|
|
2777
2788
|
).getOnChainInt;
|
|
@@ -2820,12 +2831,57 @@ async function redeemLrp(redemptionLrpsData, lrpRefScriptOutRef, priceOracleOutR
|
|
|
2820
2831
|
}
|
|
2821
2832
|
)(redemptionLrps);
|
|
2822
2833
|
const txValidity = oracleExpirationAwareValidity(
|
|
2823
|
-
|
|
2834
|
+
currentSlot,
|
|
2824
2835
|
Number(priceOracleParams.biasTime),
|
|
2825
2836
|
Number(priceOracleDatum.expiration),
|
|
2826
2837
|
network
|
|
2827
2838
|
);
|
|
2828
|
-
return lucid.newTx().validTo(txValidity.validTo).readFrom([lrpScriptRefUtxo]).readFrom([iassetUtxo, priceOracleUtxo]).compose(tx);
|
|
2839
|
+
return lucid.newTx().validFrom(txValidity.validFrom).validTo(txValidity.validTo).readFrom([lrpScriptRefUtxo]).readFrom([iassetUtxo, priceOracleUtxo]).compose(tx);
|
|
2840
|
+
}
|
|
2841
|
+
async function adjustLrp(lucid, lrpOutRef, lovelacesAdjustAmt, lrpRefScriptOutRef, lrpParams) {
|
|
2842
|
+
const ownAddr = await lucid.wallet().address();
|
|
2843
|
+
const lrpScriptRefUtxo = matchSingle(
|
|
2844
|
+
await lucid.utxosByOutRef([lrpRefScriptOutRef]),
|
|
2845
|
+
(_) => new Error("Expected a single LRP Ref Script UTXO")
|
|
2846
|
+
);
|
|
2847
|
+
const lrpUtxo = matchSingle(
|
|
2848
|
+
await lucid.utxosByOutRef([lrpOutRef]),
|
|
2849
|
+
(_) => new Error("Expected a single LRP UTXO.")
|
|
2850
|
+
);
|
|
2851
|
+
const lrpDatum = parseLrpDatum(getInlineDatumOrThrow(lrpUtxo));
|
|
2852
|
+
const rewardAssetClass = {
|
|
2853
|
+
currencySymbol: lrpParams.iassetPolicyId,
|
|
2854
|
+
tokenName: lrpDatum.iasset
|
|
2855
|
+
};
|
|
2856
|
+
const rewardAssetsAmt = assetClassValueOf(lrpUtxo.assets, rewardAssetClass);
|
|
2857
|
+
if (lovelacesAdjustAmt === 0n && lrpDatum.lovelacesToSpend === 0n) {
|
|
2858
|
+
throw new Error(
|
|
2859
|
+
"When there's no more lovelaces to spend, use close instead of claim."
|
|
2860
|
+
);
|
|
2861
|
+
}
|
|
2862
|
+
if (lovelacesAdjustAmt < 0 && lrpDatum.lovelacesToSpend <= lovelacesAdjustAmt) {
|
|
2863
|
+
throw new Error(
|
|
2864
|
+
"Can't adjust negatively by more than available. Also, for adjusting by exactly the amount deposited, a close action should be used instead."
|
|
2865
|
+
);
|
|
2866
|
+
}
|
|
2867
|
+
return lucid.newTx().readFrom([lrpScriptRefUtxo]).collectFrom([lrpUtxo], serialiseLrpRedeemer("Cancel")).pay.ToContract(
|
|
2868
|
+
lrpUtxo.address,
|
|
2869
|
+
{
|
|
2870
|
+
kind: "inline",
|
|
2871
|
+
value: serialiseLrpDatum({
|
|
2872
|
+
...lrpDatum,
|
|
2873
|
+
lovelacesToSpend: lrpDatum.lovelacesToSpend + lovelacesAdjustAmt
|
|
2874
|
+
})
|
|
2875
|
+
},
|
|
2876
|
+
addAssets3(
|
|
2877
|
+
lrpUtxo.assets,
|
|
2878
|
+
mkAssetsOf(rewardAssetClass, -rewardAssetsAmt),
|
|
2879
|
+
mkLovelacesOf(lovelacesAdjustAmt)
|
|
2880
|
+
)
|
|
2881
|
+
).addSigner(ownAddr);
|
|
2882
|
+
}
|
|
2883
|
+
async function claimLrp(lucid, lrpOutRef, lrpRefScriptOutRef, lrpParams) {
|
|
2884
|
+
return adjustLrp(lucid, lrpOutRef, 0n, lrpRefScriptOutRef, lrpParams);
|
|
2829
2885
|
}
|
|
2830
2886
|
|
|
2831
2887
|
// src/scripts/lrp-validator.ts
|
|
@@ -2924,6 +2980,7 @@ export {
|
|
|
2924
2980
|
addrDetails,
|
|
2925
2981
|
addressFromBech32,
|
|
2926
2982
|
addressToBech32,
|
|
2983
|
+
adjustLrp,
|
|
2927
2984
|
balance,
|
|
2928
2985
|
calculateFeeFromPercentage,
|
|
2929
2986
|
cancelLrp,
|
|
@@ -2936,6 +2993,7 @@ export {
|
|
|
2936
2993
|
castPriceOracleParams,
|
|
2937
2994
|
castStabilityPoolParams,
|
|
2938
2995
|
cdpCreatorValidator,
|
|
2996
|
+
claimLrp,
|
|
2939
2997
|
createScriptAddress,
|
|
2940
2998
|
fromSPInteger,
|
|
2941
2999
|
fromSystemParamsAsset,
|