@indigo-labs/indigo-sdk 0.5.14 → 0.5.15

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 CHANGED
@@ -831,6 +831,14 @@ declare function numberToRational(num: number, precision?: number): Rational;
831
831
  * Amount of iasset equal in value to the given number of collateral amount.
832
832
  */
833
833
  declare function iassetValueOfCollateral(collateralAmt: bigint, oraclePrice: Rational): bigint;
834
+ /**
835
+ * Resolves the effective debt and collateral of a CDP
836
+ * after applying all accrued interest and fees.
837
+ */
838
+ declare function computeEffectiveCdpState(now: bigint, cdpUtxoAssets: Assets, cdpContent: CDPContent, interestOracleDatum: InterestOracleDatum): {
839
+ mintedAmt: bigint;
840
+ collateralAmt: bigint;
841
+ };
834
842
  declare function cdpCollateralRatioPercentage(
835
843
  /**
836
844
  * Should be ideally the result of the following: lucid.slotToUnixTime(lucid.currentSlot()).
@@ -4723,6 +4731,16 @@ declare function summariseOrder(lucid: LucidEvolution, order: ParsedOutput<Stabl
4723
4731
  */
4724
4732
  declare function pickValidSatisfiableOrders(lucid: LucidEvolution, orders: ParsedOutput<StableswapOrderDatum>[], pool: ParsedOutput<StableswapPoolContent>, sysParams: SystemParams, psmProcessingConfig?: PSMProcessingConfig): ParsedOutput<StableswapOrderDatum>[];
4725
4733
 
4734
+ declare function findAllStableswapPools(lucid: LucidEvolution, sysParams: SystemParams): Promise<ParsedOutput<StableswapPoolContent>[]>;
4735
+ declare function findStableswapPool(lucid: LucidEvolution, sysParams: SystemParams, iassetName: string,
4736
+ /**
4737
+ * PSM pool's collateral
4738
+ */
4739
+ collateralAsset: AssetClass): Promise<{
4740
+ utxo: UTxO;
4741
+ datum: StableswapPoolContent;
4742
+ }>;
4743
+
4726
4744
  declare function createStableswapOrder(iasset: string, collateralAsset: AssetClass, amount: bigint, minting: boolean, poolDatum: StableswapPoolContent, params: SystemParams, lucid: LucidEvolution, destinationAddress?: Address, destinationInlineDatum?: Core.Data.Data, maxExecutionFee?: bigint, additionalLovelaces?: bigint, maxFeeRatio?: Rational): Promise<TxBuilder>;
4727
4745
  declare function cancelStableswapOrder(stableswapOrderOref: OutRef, sysParams: SystemParams, lucid: LucidEvolution): Promise<TxBuilder>;
4728
4746
  declare function batchProcessStableswapOrders(stableswapOrderOrefs: OutRef[], stableswapPoolOref: OutRef, treasuryOref: OutRef | undefined, sysParams: SystemParams, lucid: LucidEvolution, psmProcessingConfig?: PSMProcessingConfig): Promise<TxBuilder>;
@@ -4753,4 +4771,4 @@ declare function mkAuthTokenPolicy(ac: AssetClass, tn: string): MintingPolicy;
4753
4771
 
4754
4772
  declare const alwaysFailValidator: SpendingValidator;
4755
4773
 
4756
- export { type AccountAction, type AccountContent, AccountContentSchema, type ActionReturnDatum, type AddCollateralAsssetContent, type AddressCredential, type AddressCredentialOrDatum, type AddressSP, AikenIntervalIntervalBound, AikenIntervalIntervalBoundType, type Amount, type AssetClassD, type AssetClassSP, AssetClassSchema, type AssetInfo, type AssetSnapshot, type AssetState, type AuthTokenPolicies, BASE_MAX_EXECUTION_FEE, BASE_MAX_TX_FEE, BigIntOrd, type CDPContent, CDPCreatorParams, type CDPCreatorParamsSP, type CDPDatum, CardanoTransactionValidityRange, type CdpParams, type CdpParamsSP, type CdpRedeemParams, type CdpRedeemParamsSP, type CdpRedeemer, type CollateralAssetContent, type CollateralAssetInfo, type CollateralAssetOutput, type CollectorParamsSP, type CollectorRedeemer, CollectorRedeemerSchema, CredentialD, CredentialSchema, type CurrencySymbolSP, DEFAULT_INIT_OPTIONS, type DerivedPythPrice, type DerivedPythPriceSP, DerivedPythPriceSchema, type E2S2SIndex, type E2S2SIndicesPerAsset, type EpochToScaleKey, type EpochToScaleToSumEntry, type ExecuteDatum, ExecuteParams, type ExecuteParamsSP, type Feed, type FindE2S2SIdxResult, type GovDatum, GovParams, type GovParamsSP, type GovRedeemer, type IAssetContent, type IAssetDatum, type IAssetOutput, type IAssetParamsSP, type IAssetPriceInfo, IAssetPriceInfoSchema, type IAssetRedeemer, IAssetScriptParams, INIT_TOKEN_NAMES, type IndigoOracleNftParam, type InitialAssetParam, type InitialCollateralAssetParam, type InitialStablepoolParam, type InitializeOptions, type Input, type InterestCollectionDatum, type InterestCollectionParams, type InterestCollectionParamsSP, InterestCollectionParamsSchema, type InterestCollectionRedeemer, type InterestOracleDatum, InterestOracleDatumSchema, type InterestOracleParams, InterestOracleParamsSchema, type InterestOracleRedeemer, MAX_BUY_ROB_REDEMPTIONS_COUNT, MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET, MAX_E2S2S_ENTRIES_COUNT, MAX_REDEMPTIONS_WITH_CDP_OPEN, MAX_SELL_ROB_REDEMPTIONS_COUNT, MIN_ROB_COLLATERAL_AMT, type MarketSession, type ModifyStableswapPoolContent, ONE_DAY, ONE_HOUR, ONE_SECOND, ONE_YEAR, type OneShotParams, OneShotParamsSchema, type OracleIdx, OracleIdxSchema, type Output, PRICE_UPDATE_MAGIC, type PSMProcessingConfig, type ParsedOutput, type PollDatum, type PollManagerContent, PollManagerParams, type PollManagerParamsSP, type PollManagerRedeemer, type PollShardContent, PollShardParams, type PollShardParamsSP, type PollShardRedeemer, type PollStatus, type PriceOracleDatum, type PriceOracleParam, type PriceOracleParams, PriceOracleParamsSchema, type PriceOracleRedeemer, type PriceUpdate, type ProcessRequestAccountContent, type ProposalContent, ProposalContentSchema, type ProposeAssetContent, type ProposeStableswapPoolContent, type ProtocolParams, ProtocolParamsSchema, type PubKeyHash, type PythConfig, type PythConfiguration, type PythFeedConfig, type PythFeedParams, type PythFeedParamsSP, type PythFeedRedeemer, type PythMessageParts, type PythOracleParam, type PythPriceConfigurationSP, type PythStateDatum, type PythUpdatesRedeemer, type Rational, RationalSchema, type RedeemCdpWithdrawalRedeemer, type RobDatum, type RobOrderType, type RobOutput, type RobParams, type RobParamsSP, RobParamsSchema, type RobRedeemer, SOLANA_FORMAT_MAGIC, type SPInteger, SPIntegerSchema, type ScriptCredential, type ScriptOutput, type ScriptRef, type ScriptReference, type ScriptReferences, type SnapshotEpochToScaleToSumContent, SnapshotEpochToScaleToSumContentSchema, type StabilityPoolContent, StabilityPoolContentSchema, StabilityPoolDatumSchema, StabilityPoolParams, type StabilityPoolParamsSP, type StabilityPoolRedeemer, StabilityPoolRedeemerSchema, type StableswapInfo, type StableswapOrderDatum, StableswapOrderDatumSchema, type StableswapOrderInfo, type StableswapOrderRedeemer, type StableswapOutputDatum, type StableswapParamsSP, type StableswapPoolContent, StakeCredential, StakeCredentialSchema, type StakingManager, type StakingManagerOutput, type StakingParamsSP, type StakingPosLockedAmt, type StakingPosition, type StakingPositionOutput, type StakingRedeemer, type StartTime, type StateSnapshot, type SumSnapshot, type SystemParams, type TokenNameSP, type TreasuryParamsSP, type TreasuryWithdrawal, type TreasuryWithdrawalItem, TreasuryWithdrawalSchema, type UpgradePaths, type ValidatorHashes, VerificationKeyHashSchema, type VersionRecordParams, VersionRecordTokenParams, type VoteOption, addrDetails, adjustCdp, adjustPriceToDecimals, adjustRob, adjustStakingPosition, alwaysFailValidator, annulRequest, approximateLeverageRedemptions, attachOracle, balance, batchCollectInterest, batchProcessStableswapOrders, bigintMax, bigintMin, buildRedemptionsTx, burnCdp, calculateAccruedInterest, calculateAdaReward, calculateCollateralRatioFromLeverage, calculateIAssetRedemptionAmt, calculateLeverageFromCollateralRatio, calculateMinCollateralCappedIAssetRedemptionAmt, calculatePurchaseAmtWhenRobBuyOrder, calculatePurchaseAmtWhenRobSellOrder, calculateSpendAmtWhenRobBuyOrder, calculateSpendAmtWhenRobSellOrder, calculateTotalCollateralForRedemption, calculateUnitaryInterest, calculateUnitaryInterestSinceOracleLastUpdated, cancelRob, cancelStableswapOrder, castCDPCreatorParams, castCdpParams, castCdpRedeemParams, castExecuteParams, castGovParams, castInterestCollectionParams, castInterestOracleParams, castOneShotParams, castPollManagerParams, castPollShardParams, castPriceOracleParams, castRobParams, castStabilityPoolParams, castStakingParams, castVersionRecordTokenParams, cdpCollateralRatioPercentage, claimRob, closeCdp, closeStakingPosition, collectInterestTx, collectPriceFeedIds, collectorFeeTx, createDestinationDatum, createE2s2sSnapshots, createProcessRequestAccountRedeemer, createProposal, createScriptAddress, createShardsChunks, createStableswapOrder, decodePriceUpdate, decodePythMessage, depositCdp, deriveAuthToken, derivePythPrice, distributeAda, distributeInterest, distributeReward, divideOnChainCompatible, encodePriceUpdate, encodePythMessage, encodeSignedPythMessage, endProposal, estimateMinOrderOutputLovelaces, estimateUtxoMinLovelace, executeProposal, feedInterestOracle, feedPriceOracleTx, findAdminInterestCollectors, findAllInterestCollectors, findAllTreasuryUtxos, findAllTreasuryUtxosWithNonAdaAsset, findCollateralAsset, findE2s2sSnapshots, findIAsset, findInterestOracle, findRandomCdpCreator, findRandomNonAdminInterestCollector, findRandomTreasuryUtxo, findRandomTreasuryUtxoWithAsset, findRandomTreasuryUtxoWithOnlyAda, findRelevantE2s2sIdxs, findStabilityPool, findStabilityPoolAccount, findStakingManager, findStakingManagerByOutRef, findStakingPositionByOutRef, freezeCdp, fromDataDerivedPythPrice, fromDecimal, fromSPInteger, fromSysParamsCredential, fromSysParamsDerivedPythPrice, fromSysParamsPythFeedParams, fromSysParamsStakeCredential, fromSystemParamsAsset, fromSystemParamsAssetLucid, fromSystemParamsScriptRef, getAssetClassComparisonStr, getInlineDatumOrThrow, getPythFeedConfig, getUpdatedAccountDeposit, handleOracleForCollateralAsset, iassetValueOfCollateral, init, initCDPCreator, initCollector, initGovernance, initInterestCollector, initPythConfig, initScriptRef, initSpState, initStakingManager, initSumVal, initTreasury, initializeAsset, insertSorted, isBuyOrderFullyRedeemed, isFullyRedeemed, isSameEpochToScaleKey, leverageCdpWithRob, liquidateCdp, liquidationHelper, loadSystemParamsFromFile, loadSystemParamsFromUrl, matchSingle, mergeCdps, mergeShards, mintAuthTokenDirect, mintCdp, mintOneTimeAsset, mintOneTimeToken, mkAuthTokenPolicy, mkCDPCreatorValidator, mkCDPCreatorValidatorFromSP, mkCdpRedeemValidatorFromSP, mkCdpValidatorFromSP, mkCollectorValidatorFromSP, mkExecuteValidator, mkExecuteValidatorFromSP, mkGovValidator, mkGovValidatorFromSP, mkIAssetTokenPolicy, mkIAssetValidatorFromSP, mkInterestCollectionValidator, mkInterestCollectionValidatorFromSP, mkInterestOracleValidator, mkOneShotPolicy, mkPollManagerValidator, mkPollManagerValidatorFromSP, mkPollShardValidator, mkPollShardValidatorFromSP, mkPriceOracleValidator, mkPythFeedValidator, mkRobValidator, mkRobValidatorFromSP, mkSPInteger, mkStabilityPoolAddr, mkStabilityPoolValidator, mkStabilityPoolValidatorFromSP, mkStableswapValidator, mkStableswapValidatorFromSP, mkStakingValidatorFromSP, mkTreasuryAddr, mkTreasuryValidatorFromSP, mkVersionRecordTokenPolicy, mkVersionRegistryValidator, numberToRational, oneShotMintTx, openCdp, openRob, openStakingPosition, parseAccountDatum, parseAccountDatumOrThrow, parseCdpDatum, parseCdpDatumOrThrow, parseCdpRedeemer, parseCdpRedeemerOrThrow, parseCollateralAssetDatum, parseCollateralAssetDatumOrThrow, parseExecuteDatum, parseExecuteDatumOrThrow, parseGovDatum, parseGovDatumOrThrow, parseIAssetDatum, parseIAssetDatumOrThrow, parseInterestCollectionDatum, parseInterestOracleDatum, parsePollManager, parsePollManagerOrThrow, parsePollShard, parsePollShardOrThrow, parsePollShardRedeemer, parsePollShardRedeemerOrThrow, parsePriceOracleDatum, parsePythStateDatum, parseRobDatum, parseRobDatumOrThrow, parseRobRedeemer, parseRobRedeemerOrThrow, parseSnapshotEpochToScaleToSumDatum, parseSnapshotEpochToScaleToSumDatumOrThrow, parseStabilityPoolDatum, parseStabilityPoolDatumOrThrow, parseStabilityPoolRedeemer, parseStabilityPoolRedeemerOrThrow, parseStableswapOrderDatum, parseStableswapOrderDatumOrThrow, parseStableswapOrderRedeemer, parseStableswapOrderRedeemerOrThrow, parseStableswapPoolDatum, parseStableswapPoolDatumOrThrow, parseStakingManagerDatum, parseStakingPosition, parseStakingPositionOrThrow, parseStakingRedeemer, parseStakingRedeemerOrThrow, partitionEpochToScaleToSums, pickValidSatisfiableOrders, processSpRequest, psmOrderType, randomRobsSubsetSatisfyingTargetCollateral, rationalAdd, rationalCeil, rationalDiv, rationalFloor, rationalFromInt, rationalMul, rationalNegate, rationalSub, rationalToFloat, rationalZero, redeemCdp, redeemRob, repsertReadonlyArr, repsertWithReadonlyArr, requestSpAccountAdjustment, requestSpAccountClosure, requestSpAccountCreation, rewardSnapshotPrecision, rewardsPerAsset, robAmtToSpend, robBuyOrderFilledAssets, robBuyOrderSummary, robCollateralAmtToSpend, robIAssetAmtToSpend, robSellOrderFilledAssets, runCreateScriptRefTx, runOneShotMintTx, scriptRef, serialiseActionReturnDatum, serialiseCdpDatum, serialiseCdpRedeemer, serialiseCollectorRedeemer, serialiseExecuteDatum, serialiseFeedInterestOracleRedeemer, serialiseGovDatum, serialiseGovRedeemer, serialiseIAssetDatum, serialiseIAssetRedeemer, serialiseInterestCollectionDatum, serialiseInterestCollectionRedeemer, serialiseInterestOracleDatum, serialisePollDatum, serialisePollManagerRedeemer, serialisePollShardRedeemer, serialisePriceOracleDatum, serialisePriceOracleRedeemer, serialisePythFeedParams, serialisePythFeedRedeemer, serialisePythStateDatum, serialisePythUpdatesRedeemer, serialiseRedeemCdpWithdrawalRedeemer, serialiseRobDatum, serialiseRobRedeemer, serialiseStabilityPoolDatum, serialiseStabilityPoolRedeemer, serialiseStableswapOrderDatum, serialiseStableswapOrderRedeemer, serialiseStableswapOutputDatum, serialiseStableswapPoolDatum, serialiseStakingDatum, serialiseStakingRedeemer, shuffle, signersAllOf, spAdd, spDiv, spMul, spSub, spZeroNegatives, startInterestOracle, startPriceOracleTx, submitTx, sum, summariseOrder, summarizeActualLeverageRedemptions, toAssetClassFromLucid, toDataDerivedPythPrice, toSystemParamsAsset, treasuryCollect, treasuryFeeTx, treasuryMerge, treasuryPrepareWithdrawal, treasurySplit, updateAccount, updatePermissions, updatePoolStateWhenWithdrawalFee, updateStableswapPoolFees, updateStakingLockedAmount, vote, withdrawCdp, zeroNegatives };
4774
+ export { type AccountAction, type AccountContent, AccountContentSchema, type ActionReturnDatum, type AddCollateralAsssetContent, type AddressCredential, type AddressCredentialOrDatum, type AddressSP, AikenIntervalIntervalBound, AikenIntervalIntervalBoundType, type Amount, type AssetClassD, type AssetClassSP, AssetClassSchema, type AssetInfo, type AssetSnapshot, type AssetState, type AuthTokenPolicies, BASE_MAX_EXECUTION_FEE, BASE_MAX_TX_FEE, BigIntOrd, type CDPContent, CDPCreatorParams, type CDPCreatorParamsSP, type CDPDatum, CardanoTransactionValidityRange, type CdpParams, type CdpParamsSP, type CdpRedeemParams, type CdpRedeemParamsSP, type CdpRedeemer, type CollateralAssetContent, type CollateralAssetInfo, type CollateralAssetOutput, type CollectorParamsSP, type CollectorRedeemer, CollectorRedeemerSchema, CredentialD, CredentialSchema, type CurrencySymbolSP, DEFAULT_INIT_OPTIONS, type DerivedPythPrice, type DerivedPythPriceSP, DerivedPythPriceSchema, type E2S2SIndex, type E2S2SIndicesPerAsset, type EpochToScaleKey, type EpochToScaleToSumEntry, type ExecuteDatum, ExecuteParams, type ExecuteParamsSP, type Feed, type FindE2S2SIdxResult, type GovDatum, GovParams, type GovParamsSP, type GovRedeemer, type IAssetContent, type IAssetDatum, type IAssetOutput, type IAssetParamsSP, type IAssetPriceInfo, IAssetPriceInfoSchema, type IAssetRedeemer, IAssetScriptParams, INIT_TOKEN_NAMES, type IndigoOracleNftParam, type InitialAssetParam, type InitialCollateralAssetParam, type InitialStablepoolParam, type InitializeOptions, type Input, type InterestCollectionDatum, type InterestCollectionParams, type InterestCollectionParamsSP, InterestCollectionParamsSchema, type InterestCollectionRedeemer, type InterestOracleDatum, InterestOracleDatumSchema, type InterestOracleParams, InterestOracleParamsSchema, type InterestOracleRedeemer, MAX_BUY_ROB_REDEMPTIONS_COUNT, MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET, MAX_E2S2S_ENTRIES_COUNT, MAX_REDEMPTIONS_WITH_CDP_OPEN, MAX_SELL_ROB_REDEMPTIONS_COUNT, MIN_ROB_COLLATERAL_AMT, type MarketSession, type ModifyStableswapPoolContent, ONE_DAY, ONE_HOUR, ONE_SECOND, ONE_YEAR, type OneShotParams, OneShotParamsSchema, type OracleIdx, OracleIdxSchema, type Output, PRICE_UPDATE_MAGIC, type PSMProcessingConfig, type ParsedOutput, type PollDatum, type PollManagerContent, PollManagerParams, type PollManagerParamsSP, type PollManagerRedeemer, type PollShardContent, PollShardParams, type PollShardParamsSP, type PollShardRedeemer, type PollStatus, type PriceOracleDatum, type PriceOracleParam, type PriceOracleParams, PriceOracleParamsSchema, type PriceOracleRedeemer, type PriceUpdate, type ProcessRequestAccountContent, type ProposalContent, ProposalContentSchema, type ProposeAssetContent, type ProposeStableswapPoolContent, type ProtocolParams, ProtocolParamsSchema, type PubKeyHash, type PythConfig, type PythConfiguration, type PythFeedConfig, type PythFeedParams, type PythFeedParamsSP, type PythFeedRedeemer, type PythMessageParts, type PythOracleParam, type PythPriceConfigurationSP, type PythStateDatum, type PythUpdatesRedeemer, type Rational, RationalSchema, type RedeemCdpWithdrawalRedeemer, type RobDatum, type RobOrderType, type RobOutput, type RobParams, type RobParamsSP, RobParamsSchema, type RobRedeemer, SOLANA_FORMAT_MAGIC, type SPInteger, SPIntegerSchema, type ScriptCredential, type ScriptOutput, type ScriptRef, type ScriptReference, type ScriptReferences, type SnapshotEpochToScaleToSumContent, SnapshotEpochToScaleToSumContentSchema, type StabilityPoolContent, StabilityPoolContentSchema, StabilityPoolDatumSchema, StabilityPoolParams, type StabilityPoolParamsSP, type StabilityPoolRedeemer, StabilityPoolRedeemerSchema, type StableswapInfo, type StableswapOrderDatum, StableswapOrderDatumSchema, type StableswapOrderInfo, type StableswapOrderRedeemer, type StableswapOutputDatum, type StableswapParamsSP, type StableswapPoolContent, StakeCredential, StakeCredentialSchema, type StakingManager, type StakingManagerOutput, type StakingParamsSP, type StakingPosLockedAmt, type StakingPosition, type StakingPositionOutput, type StakingRedeemer, type StartTime, type StateSnapshot, type SumSnapshot, type SystemParams, type TokenNameSP, type TreasuryParamsSP, type TreasuryWithdrawal, type TreasuryWithdrawalItem, TreasuryWithdrawalSchema, type UpgradePaths, type ValidatorHashes, VerificationKeyHashSchema, type VersionRecordParams, VersionRecordTokenParams, type VoteOption, addrDetails, adjustCdp, adjustPriceToDecimals, adjustRob, adjustStakingPosition, alwaysFailValidator, annulRequest, approximateLeverageRedemptions, attachOracle, balance, batchCollectInterest, batchProcessStableswapOrders, bigintMax, bigintMin, buildRedemptionsTx, burnCdp, calculateAccruedInterest, calculateAdaReward, calculateCollateralRatioFromLeverage, calculateIAssetRedemptionAmt, calculateLeverageFromCollateralRatio, calculateMinCollateralCappedIAssetRedemptionAmt, calculatePurchaseAmtWhenRobBuyOrder, calculatePurchaseAmtWhenRobSellOrder, calculateSpendAmtWhenRobBuyOrder, calculateSpendAmtWhenRobSellOrder, calculateTotalCollateralForRedemption, calculateUnitaryInterest, calculateUnitaryInterestSinceOracleLastUpdated, cancelRob, cancelStableswapOrder, castCDPCreatorParams, castCdpParams, castCdpRedeemParams, castExecuteParams, castGovParams, castInterestCollectionParams, castInterestOracleParams, castOneShotParams, castPollManagerParams, castPollShardParams, castPriceOracleParams, castRobParams, castStabilityPoolParams, castStakingParams, castVersionRecordTokenParams, cdpCollateralRatioPercentage, claimRob, closeCdp, closeStakingPosition, collectInterestTx, collectPriceFeedIds, collectorFeeTx, computeEffectiveCdpState, createDestinationDatum, createE2s2sSnapshots, createProcessRequestAccountRedeemer, createProposal, createScriptAddress, createShardsChunks, createStableswapOrder, decodePriceUpdate, decodePythMessage, depositCdp, deriveAuthToken, derivePythPrice, distributeAda, distributeInterest, distributeReward, divideOnChainCompatible, encodePriceUpdate, encodePythMessage, encodeSignedPythMessage, endProposal, estimateMinOrderOutputLovelaces, estimateUtxoMinLovelace, executeProposal, feedInterestOracle, feedPriceOracleTx, findAdminInterestCollectors, findAllInterestCollectors, findAllStableswapPools, findAllTreasuryUtxos, findAllTreasuryUtxosWithNonAdaAsset, findCollateralAsset, findE2s2sSnapshots, findIAsset, findInterestOracle, findRandomCdpCreator, findRandomNonAdminInterestCollector, findRandomTreasuryUtxo, findRandomTreasuryUtxoWithAsset, findRandomTreasuryUtxoWithOnlyAda, findRelevantE2s2sIdxs, findStabilityPool, findStabilityPoolAccount, findStableswapPool, findStakingManager, findStakingManagerByOutRef, findStakingPositionByOutRef, freezeCdp, fromDataDerivedPythPrice, fromDecimal, fromSPInteger, fromSysParamsCredential, fromSysParamsDerivedPythPrice, fromSysParamsPythFeedParams, fromSysParamsStakeCredential, fromSystemParamsAsset, fromSystemParamsAssetLucid, fromSystemParamsScriptRef, getAssetClassComparisonStr, getInlineDatumOrThrow, getPythFeedConfig, getUpdatedAccountDeposit, handleOracleForCollateralAsset, iassetValueOfCollateral, init, initCDPCreator, initCollector, initGovernance, initInterestCollector, initPythConfig, initScriptRef, initSpState, initStakingManager, initSumVal, initTreasury, initializeAsset, insertSorted, isBuyOrderFullyRedeemed, isFullyRedeemed, isSameEpochToScaleKey, leverageCdpWithRob, liquidateCdp, liquidationHelper, loadSystemParamsFromFile, loadSystemParamsFromUrl, matchSingle, mergeCdps, mergeShards, mintAuthTokenDirect, mintCdp, mintOneTimeAsset, mintOneTimeToken, mkAuthTokenPolicy, mkCDPCreatorValidator, mkCDPCreatorValidatorFromSP, mkCdpRedeemValidatorFromSP, mkCdpValidatorFromSP, mkCollectorValidatorFromSP, mkExecuteValidator, mkExecuteValidatorFromSP, mkGovValidator, mkGovValidatorFromSP, mkIAssetTokenPolicy, mkIAssetValidatorFromSP, mkInterestCollectionValidator, mkInterestCollectionValidatorFromSP, mkInterestOracleValidator, mkOneShotPolicy, mkPollManagerValidator, mkPollManagerValidatorFromSP, mkPollShardValidator, mkPollShardValidatorFromSP, mkPriceOracleValidator, mkPythFeedValidator, mkRobValidator, mkRobValidatorFromSP, mkSPInteger, mkStabilityPoolAddr, mkStabilityPoolValidator, mkStabilityPoolValidatorFromSP, mkStableswapValidator, mkStableswapValidatorFromSP, mkStakingValidatorFromSP, mkTreasuryAddr, mkTreasuryValidatorFromSP, mkVersionRecordTokenPolicy, mkVersionRegistryValidator, numberToRational, oneShotMintTx, openCdp, openRob, openStakingPosition, parseAccountDatum, parseAccountDatumOrThrow, parseCdpDatum, parseCdpDatumOrThrow, parseCdpRedeemer, parseCdpRedeemerOrThrow, parseCollateralAssetDatum, parseCollateralAssetDatumOrThrow, parseExecuteDatum, parseExecuteDatumOrThrow, parseGovDatum, parseGovDatumOrThrow, parseIAssetDatum, parseIAssetDatumOrThrow, parseInterestCollectionDatum, parseInterestOracleDatum, parsePollManager, parsePollManagerOrThrow, parsePollShard, parsePollShardOrThrow, parsePollShardRedeemer, parsePollShardRedeemerOrThrow, parsePriceOracleDatum, parsePythStateDatum, parseRobDatum, parseRobDatumOrThrow, parseRobRedeemer, parseRobRedeemerOrThrow, parseSnapshotEpochToScaleToSumDatum, parseSnapshotEpochToScaleToSumDatumOrThrow, parseStabilityPoolDatum, parseStabilityPoolDatumOrThrow, parseStabilityPoolRedeemer, parseStabilityPoolRedeemerOrThrow, parseStableswapOrderDatum, parseStableswapOrderDatumOrThrow, parseStableswapOrderRedeemer, parseStableswapOrderRedeemerOrThrow, parseStableswapPoolDatum, parseStableswapPoolDatumOrThrow, parseStakingManagerDatum, parseStakingPosition, parseStakingPositionOrThrow, parseStakingRedeemer, parseStakingRedeemerOrThrow, partitionEpochToScaleToSums, pickValidSatisfiableOrders, processSpRequest, psmOrderType, randomRobsSubsetSatisfyingTargetCollateral, rationalAdd, rationalCeil, rationalDiv, rationalFloor, rationalFromInt, rationalMul, rationalNegate, rationalSub, rationalToFloat, rationalZero, redeemCdp, redeemRob, repsertReadonlyArr, repsertWithReadonlyArr, requestSpAccountAdjustment, requestSpAccountClosure, requestSpAccountCreation, rewardSnapshotPrecision, rewardsPerAsset, robAmtToSpend, robBuyOrderFilledAssets, robBuyOrderSummary, robCollateralAmtToSpend, robIAssetAmtToSpend, robSellOrderFilledAssets, runCreateScriptRefTx, runOneShotMintTx, scriptRef, serialiseActionReturnDatum, serialiseCdpDatum, serialiseCdpRedeemer, serialiseCollectorRedeemer, serialiseExecuteDatum, serialiseFeedInterestOracleRedeemer, serialiseGovDatum, serialiseGovRedeemer, serialiseIAssetDatum, serialiseIAssetRedeemer, serialiseInterestCollectionDatum, serialiseInterestCollectionRedeemer, serialiseInterestOracleDatum, serialisePollDatum, serialisePollManagerRedeemer, serialisePollShardRedeemer, serialisePriceOracleDatum, serialisePriceOracleRedeemer, serialisePythFeedParams, serialisePythFeedRedeemer, serialisePythStateDatum, serialisePythUpdatesRedeemer, serialiseRedeemCdpWithdrawalRedeemer, serialiseRobDatum, serialiseRobRedeemer, serialiseStabilityPoolDatum, serialiseStabilityPoolRedeemer, serialiseStableswapOrderDatum, serialiseStableswapOrderRedeemer, serialiseStableswapOutputDatum, serialiseStableswapPoolDatum, serialiseStakingDatum, serialiseStakingRedeemer, shuffle, signersAllOf, spAdd, spDiv, spMul, spSub, spZeroNegatives, startInterestOracle, startPriceOracleTx, submitTx, sum, summariseOrder, summarizeActualLeverageRedemptions, toAssetClassFromLucid, toDataDerivedPythPrice, toSystemParamsAsset, treasuryCollect, treasuryFeeTx, treasuryMerge, treasuryPrepareWithdrawal, treasurySplit, updateAccount, updatePermissions, updatePoolStateWhenWithdrawalFee, updateStableswapPoolFees, updateStakingLockedAmount, vote, withdrawCdp, zeroNegatives };
package/dist/index.d.ts CHANGED
@@ -831,6 +831,14 @@ declare function numberToRational(num: number, precision?: number): Rational;
831
831
  * Amount of iasset equal in value to the given number of collateral amount.
832
832
  */
833
833
  declare function iassetValueOfCollateral(collateralAmt: bigint, oraclePrice: Rational): bigint;
834
+ /**
835
+ * Resolves the effective debt and collateral of a CDP
836
+ * after applying all accrued interest and fees.
837
+ */
838
+ declare function computeEffectiveCdpState(now: bigint, cdpUtxoAssets: Assets, cdpContent: CDPContent, interestOracleDatum: InterestOracleDatum): {
839
+ mintedAmt: bigint;
840
+ collateralAmt: bigint;
841
+ };
834
842
  declare function cdpCollateralRatioPercentage(
835
843
  /**
836
844
  * Should be ideally the result of the following: lucid.slotToUnixTime(lucid.currentSlot()).
@@ -4723,6 +4731,16 @@ declare function summariseOrder(lucid: LucidEvolution, order: ParsedOutput<Stabl
4723
4731
  */
4724
4732
  declare function pickValidSatisfiableOrders(lucid: LucidEvolution, orders: ParsedOutput<StableswapOrderDatum>[], pool: ParsedOutput<StableswapPoolContent>, sysParams: SystemParams, psmProcessingConfig?: PSMProcessingConfig): ParsedOutput<StableswapOrderDatum>[];
4725
4733
 
4734
+ declare function findAllStableswapPools(lucid: LucidEvolution, sysParams: SystemParams): Promise<ParsedOutput<StableswapPoolContent>[]>;
4735
+ declare function findStableswapPool(lucid: LucidEvolution, sysParams: SystemParams, iassetName: string,
4736
+ /**
4737
+ * PSM pool's collateral
4738
+ */
4739
+ collateralAsset: AssetClass): Promise<{
4740
+ utxo: UTxO;
4741
+ datum: StableswapPoolContent;
4742
+ }>;
4743
+
4726
4744
  declare function createStableswapOrder(iasset: string, collateralAsset: AssetClass, amount: bigint, minting: boolean, poolDatum: StableswapPoolContent, params: SystemParams, lucid: LucidEvolution, destinationAddress?: Address, destinationInlineDatum?: Core.Data.Data, maxExecutionFee?: bigint, additionalLovelaces?: bigint, maxFeeRatio?: Rational): Promise<TxBuilder>;
4727
4745
  declare function cancelStableswapOrder(stableswapOrderOref: OutRef, sysParams: SystemParams, lucid: LucidEvolution): Promise<TxBuilder>;
4728
4746
  declare function batchProcessStableswapOrders(stableswapOrderOrefs: OutRef[], stableswapPoolOref: OutRef, treasuryOref: OutRef | undefined, sysParams: SystemParams, lucid: LucidEvolution, psmProcessingConfig?: PSMProcessingConfig): Promise<TxBuilder>;
@@ -4753,4 +4771,4 @@ declare function mkAuthTokenPolicy(ac: AssetClass, tn: string): MintingPolicy;
4753
4771
 
4754
4772
  declare const alwaysFailValidator: SpendingValidator;
4755
4773
 
4756
- export { type AccountAction, type AccountContent, AccountContentSchema, type ActionReturnDatum, type AddCollateralAsssetContent, type AddressCredential, type AddressCredentialOrDatum, type AddressSP, AikenIntervalIntervalBound, AikenIntervalIntervalBoundType, type Amount, type AssetClassD, type AssetClassSP, AssetClassSchema, type AssetInfo, type AssetSnapshot, type AssetState, type AuthTokenPolicies, BASE_MAX_EXECUTION_FEE, BASE_MAX_TX_FEE, BigIntOrd, type CDPContent, CDPCreatorParams, type CDPCreatorParamsSP, type CDPDatum, CardanoTransactionValidityRange, type CdpParams, type CdpParamsSP, type CdpRedeemParams, type CdpRedeemParamsSP, type CdpRedeemer, type CollateralAssetContent, type CollateralAssetInfo, type CollateralAssetOutput, type CollectorParamsSP, type CollectorRedeemer, CollectorRedeemerSchema, CredentialD, CredentialSchema, type CurrencySymbolSP, DEFAULT_INIT_OPTIONS, type DerivedPythPrice, type DerivedPythPriceSP, DerivedPythPriceSchema, type E2S2SIndex, type E2S2SIndicesPerAsset, type EpochToScaleKey, type EpochToScaleToSumEntry, type ExecuteDatum, ExecuteParams, type ExecuteParamsSP, type Feed, type FindE2S2SIdxResult, type GovDatum, GovParams, type GovParamsSP, type GovRedeemer, type IAssetContent, type IAssetDatum, type IAssetOutput, type IAssetParamsSP, type IAssetPriceInfo, IAssetPriceInfoSchema, type IAssetRedeemer, IAssetScriptParams, INIT_TOKEN_NAMES, type IndigoOracleNftParam, type InitialAssetParam, type InitialCollateralAssetParam, type InitialStablepoolParam, type InitializeOptions, type Input, type InterestCollectionDatum, type InterestCollectionParams, type InterestCollectionParamsSP, InterestCollectionParamsSchema, type InterestCollectionRedeemer, type InterestOracleDatum, InterestOracleDatumSchema, type InterestOracleParams, InterestOracleParamsSchema, type InterestOracleRedeemer, MAX_BUY_ROB_REDEMPTIONS_COUNT, MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET, MAX_E2S2S_ENTRIES_COUNT, MAX_REDEMPTIONS_WITH_CDP_OPEN, MAX_SELL_ROB_REDEMPTIONS_COUNT, MIN_ROB_COLLATERAL_AMT, type MarketSession, type ModifyStableswapPoolContent, ONE_DAY, ONE_HOUR, ONE_SECOND, ONE_YEAR, type OneShotParams, OneShotParamsSchema, type OracleIdx, OracleIdxSchema, type Output, PRICE_UPDATE_MAGIC, type PSMProcessingConfig, type ParsedOutput, type PollDatum, type PollManagerContent, PollManagerParams, type PollManagerParamsSP, type PollManagerRedeemer, type PollShardContent, PollShardParams, type PollShardParamsSP, type PollShardRedeemer, type PollStatus, type PriceOracleDatum, type PriceOracleParam, type PriceOracleParams, PriceOracleParamsSchema, type PriceOracleRedeemer, type PriceUpdate, type ProcessRequestAccountContent, type ProposalContent, ProposalContentSchema, type ProposeAssetContent, type ProposeStableswapPoolContent, type ProtocolParams, ProtocolParamsSchema, type PubKeyHash, type PythConfig, type PythConfiguration, type PythFeedConfig, type PythFeedParams, type PythFeedParamsSP, type PythFeedRedeemer, type PythMessageParts, type PythOracleParam, type PythPriceConfigurationSP, type PythStateDatum, type PythUpdatesRedeemer, type Rational, RationalSchema, type RedeemCdpWithdrawalRedeemer, type RobDatum, type RobOrderType, type RobOutput, type RobParams, type RobParamsSP, RobParamsSchema, type RobRedeemer, SOLANA_FORMAT_MAGIC, type SPInteger, SPIntegerSchema, type ScriptCredential, type ScriptOutput, type ScriptRef, type ScriptReference, type ScriptReferences, type SnapshotEpochToScaleToSumContent, SnapshotEpochToScaleToSumContentSchema, type StabilityPoolContent, StabilityPoolContentSchema, StabilityPoolDatumSchema, StabilityPoolParams, type StabilityPoolParamsSP, type StabilityPoolRedeemer, StabilityPoolRedeemerSchema, type StableswapInfo, type StableswapOrderDatum, StableswapOrderDatumSchema, type StableswapOrderInfo, type StableswapOrderRedeemer, type StableswapOutputDatum, type StableswapParamsSP, type StableswapPoolContent, StakeCredential, StakeCredentialSchema, type StakingManager, type StakingManagerOutput, type StakingParamsSP, type StakingPosLockedAmt, type StakingPosition, type StakingPositionOutput, type StakingRedeemer, type StartTime, type StateSnapshot, type SumSnapshot, type SystemParams, type TokenNameSP, type TreasuryParamsSP, type TreasuryWithdrawal, type TreasuryWithdrawalItem, TreasuryWithdrawalSchema, type UpgradePaths, type ValidatorHashes, VerificationKeyHashSchema, type VersionRecordParams, VersionRecordTokenParams, type VoteOption, addrDetails, adjustCdp, adjustPriceToDecimals, adjustRob, adjustStakingPosition, alwaysFailValidator, annulRequest, approximateLeverageRedemptions, attachOracle, balance, batchCollectInterest, batchProcessStableswapOrders, bigintMax, bigintMin, buildRedemptionsTx, burnCdp, calculateAccruedInterest, calculateAdaReward, calculateCollateralRatioFromLeverage, calculateIAssetRedemptionAmt, calculateLeverageFromCollateralRatio, calculateMinCollateralCappedIAssetRedemptionAmt, calculatePurchaseAmtWhenRobBuyOrder, calculatePurchaseAmtWhenRobSellOrder, calculateSpendAmtWhenRobBuyOrder, calculateSpendAmtWhenRobSellOrder, calculateTotalCollateralForRedemption, calculateUnitaryInterest, calculateUnitaryInterestSinceOracleLastUpdated, cancelRob, cancelStableswapOrder, castCDPCreatorParams, castCdpParams, castCdpRedeemParams, castExecuteParams, castGovParams, castInterestCollectionParams, castInterestOracleParams, castOneShotParams, castPollManagerParams, castPollShardParams, castPriceOracleParams, castRobParams, castStabilityPoolParams, castStakingParams, castVersionRecordTokenParams, cdpCollateralRatioPercentage, claimRob, closeCdp, closeStakingPosition, collectInterestTx, collectPriceFeedIds, collectorFeeTx, createDestinationDatum, createE2s2sSnapshots, createProcessRequestAccountRedeemer, createProposal, createScriptAddress, createShardsChunks, createStableswapOrder, decodePriceUpdate, decodePythMessage, depositCdp, deriveAuthToken, derivePythPrice, distributeAda, distributeInterest, distributeReward, divideOnChainCompatible, encodePriceUpdate, encodePythMessage, encodeSignedPythMessage, endProposal, estimateMinOrderOutputLovelaces, estimateUtxoMinLovelace, executeProposal, feedInterestOracle, feedPriceOracleTx, findAdminInterestCollectors, findAllInterestCollectors, findAllTreasuryUtxos, findAllTreasuryUtxosWithNonAdaAsset, findCollateralAsset, findE2s2sSnapshots, findIAsset, findInterestOracle, findRandomCdpCreator, findRandomNonAdminInterestCollector, findRandomTreasuryUtxo, findRandomTreasuryUtxoWithAsset, findRandomTreasuryUtxoWithOnlyAda, findRelevantE2s2sIdxs, findStabilityPool, findStabilityPoolAccount, findStakingManager, findStakingManagerByOutRef, findStakingPositionByOutRef, freezeCdp, fromDataDerivedPythPrice, fromDecimal, fromSPInteger, fromSysParamsCredential, fromSysParamsDerivedPythPrice, fromSysParamsPythFeedParams, fromSysParamsStakeCredential, fromSystemParamsAsset, fromSystemParamsAssetLucid, fromSystemParamsScriptRef, getAssetClassComparisonStr, getInlineDatumOrThrow, getPythFeedConfig, getUpdatedAccountDeposit, handleOracleForCollateralAsset, iassetValueOfCollateral, init, initCDPCreator, initCollector, initGovernance, initInterestCollector, initPythConfig, initScriptRef, initSpState, initStakingManager, initSumVal, initTreasury, initializeAsset, insertSorted, isBuyOrderFullyRedeemed, isFullyRedeemed, isSameEpochToScaleKey, leverageCdpWithRob, liquidateCdp, liquidationHelper, loadSystemParamsFromFile, loadSystemParamsFromUrl, matchSingle, mergeCdps, mergeShards, mintAuthTokenDirect, mintCdp, mintOneTimeAsset, mintOneTimeToken, mkAuthTokenPolicy, mkCDPCreatorValidator, mkCDPCreatorValidatorFromSP, mkCdpRedeemValidatorFromSP, mkCdpValidatorFromSP, mkCollectorValidatorFromSP, mkExecuteValidator, mkExecuteValidatorFromSP, mkGovValidator, mkGovValidatorFromSP, mkIAssetTokenPolicy, mkIAssetValidatorFromSP, mkInterestCollectionValidator, mkInterestCollectionValidatorFromSP, mkInterestOracleValidator, mkOneShotPolicy, mkPollManagerValidator, mkPollManagerValidatorFromSP, mkPollShardValidator, mkPollShardValidatorFromSP, mkPriceOracleValidator, mkPythFeedValidator, mkRobValidator, mkRobValidatorFromSP, mkSPInteger, mkStabilityPoolAddr, mkStabilityPoolValidator, mkStabilityPoolValidatorFromSP, mkStableswapValidator, mkStableswapValidatorFromSP, mkStakingValidatorFromSP, mkTreasuryAddr, mkTreasuryValidatorFromSP, mkVersionRecordTokenPolicy, mkVersionRegistryValidator, numberToRational, oneShotMintTx, openCdp, openRob, openStakingPosition, parseAccountDatum, parseAccountDatumOrThrow, parseCdpDatum, parseCdpDatumOrThrow, parseCdpRedeemer, parseCdpRedeemerOrThrow, parseCollateralAssetDatum, parseCollateralAssetDatumOrThrow, parseExecuteDatum, parseExecuteDatumOrThrow, parseGovDatum, parseGovDatumOrThrow, parseIAssetDatum, parseIAssetDatumOrThrow, parseInterestCollectionDatum, parseInterestOracleDatum, parsePollManager, parsePollManagerOrThrow, parsePollShard, parsePollShardOrThrow, parsePollShardRedeemer, parsePollShardRedeemerOrThrow, parsePriceOracleDatum, parsePythStateDatum, parseRobDatum, parseRobDatumOrThrow, parseRobRedeemer, parseRobRedeemerOrThrow, parseSnapshotEpochToScaleToSumDatum, parseSnapshotEpochToScaleToSumDatumOrThrow, parseStabilityPoolDatum, parseStabilityPoolDatumOrThrow, parseStabilityPoolRedeemer, parseStabilityPoolRedeemerOrThrow, parseStableswapOrderDatum, parseStableswapOrderDatumOrThrow, parseStableswapOrderRedeemer, parseStableswapOrderRedeemerOrThrow, parseStableswapPoolDatum, parseStableswapPoolDatumOrThrow, parseStakingManagerDatum, parseStakingPosition, parseStakingPositionOrThrow, parseStakingRedeemer, parseStakingRedeemerOrThrow, partitionEpochToScaleToSums, pickValidSatisfiableOrders, processSpRequest, psmOrderType, randomRobsSubsetSatisfyingTargetCollateral, rationalAdd, rationalCeil, rationalDiv, rationalFloor, rationalFromInt, rationalMul, rationalNegate, rationalSub, rationalToFloat, rationalZero, redeemCdp, redeemRob, repsertReadonlyArr, repsertWithReadonlyArr, requestSpAccountAdjustment, requestSpAccountClosure, requestSpAccountCreation, rewardSnapshotPrecision, rewardsPerAsset, robAmtToSpend, robBuyOrderFilledAssets, robBuyOrderSummary, robCollateralAmtToSpend, robIAssetAmtToSpend, robSellOrderFilledAssets, runCreateScriptRefTx, runOneShotMintTx, scriptRef, serialiseActionReturnDatum, serialiseCdpDatum, serialiseCdpRedeemer, serialiseCollectorRedeemer, serialiseExecuteDatum, serialiseFeedInterestOracleRedeemer, serialiseGovDatum, serialiseGovRedeemer, serialiseIAssetDatum, serialiseIAssetRedeemer, serialiseInterestCollectionDatum, serialiseInterestCollectionRedeemer, serialiseInterestOracleDatum, serialisePollDatum, serialisePollManagerRedeemer, serialisePollShardRedeemer, serialisePriceOracleDatum, serialisePriceOracleRedeemer, serialisePythFeedParams, serialisePythFeedRedeemer, serialisePythStateDatum, serialisePythUpdatesRedeemer, serialiseRedeemCdpWithdrawalRedeemer, serialiseRobDatum, serialiseRobRedeemer, serialiseStabilityPoolDatum, serialiseStabilityPoolRedeemer, serialiseStableswapOrderDatum, serialiseStableswapOrderRedeemer, serialiseStableswapOutputDatum, serialiseStableswapPoolDatum, serialiseStakingDatum, serialiseStakingRedeemer, shuffle, signersAllOf, spAdd, spDiv, spMul, spSub, spZeroNegatives, startInterestOracle, startPriceOracleTx, submitTx, sum, summariseOrder, summarizeActualLeverageRedemptions, toAssetClassFromLucid, toDataDerivedPythPrice, toSystemParamsAsset, treasuryCollect, treasuryFeeTx, treasuryMerge, treasuryPrepareWithdrawal, treasurySplit, updateAccount, updatePermissions, updatePoolStateWhenWithdrawalFee, updateStableswapPoolFees, updateStakingLockedAmount, vote, withdrawCdp, zeroNegatives };
4774
+ export { type AccountAction, type AccountContent, AccountContentSchema, type ActionReturnDatum, type AddCollateralAsssetContent, type AddressCredential, type AddressCredentialOrDatum, type AddressSP, AikenIntervalIntervalBound, AikenIntervalIntervalBoundType, type Amount, type AssetClassD, type AssetClassSP, AssetClassSchema, type AssetInfo, type AssetSnapshot, type AssetState, type AuthTokenPolicies, BASE_MAX_EXECUTION_FEE, BASE_MAX_TX_FEE, BigIntOrd, type CDPContent, CDPCreatorParams, type CDPCreatorParamsSP, type CDPDatum, CardanoTransactionValidityRange, type CdpParams, type CdpParamsSP, type CdpRedeemParams, type CdpRedeemParamsSP, type CdpRedeemer, type CollateralAssetContent, type CollateralAssetInfo, type CollateralAssetOutput, type CollectorParamsSP, type CollectorRedeemer, CollectorRedeemerSchema, CredentialD, CredentialSchema, type CurrencySymbolSP, DEFAULT_INIT_OPTIONS, type DerivedPythPrice, type DerivedPythPriceSP, DerivedPythPriceSchema, type E2S2SIndex, type E2S2SIndicesPerAsset, type EpochToScaleKey, type EpochToScaleToSumEntry, type ExecuteDatum, ExecuteParams, type ExecuteParamsSP, type Feed, type FindE2S2SIdxResult, type GovDatum, GovParams, type GovParamsSP, type GovRedeemer, type IAssetContent, type IAssetDatum, type IAssetOutput, type IAssetParamsSP, type IAssetPriceInfo, IAssetPriceInfoSchema, type IAssetRedeemer, IAssetScriptParams, INIT_TOKEN_NAMES, type IndigoOracleNftParam, type InitialAssetParam, type InitialCollateralAssetParam, type InitialStablepoolParam, type InitializeOptions, type Input, type InterestCollectionDatum, type InterestCollectionParams, type InterestCollectionParamsSP, InterestCollectionParamsSchema, type InterestCollectionRedeemer, type InterestOracleDatum, InterestOracleDatumSchema, type InterestOracleParams, InterestOracleParamsSchema, type InterestOracleRedeemer, MAX_BUY_ROB_REDEMPTIONS_COUNT, MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET, MAX_E2S2S_ENTRIES_COUNT, MAX_REDEMPTIONS_WITH_CDP_OPEN, MAX_SELL_ROB_REDEMPTIONS_COUNT, MIN_ROB_COLLATERAL_AMT, type MarketSession, type ModifyStableswapPoolContent, ONE_DAY, ONE_HOUR, ONE_SECOND, ONE_YEAR, type OneShotParams, OneShotParamsSchema, type OracleIdx, OracleIdxSchema, type Output, PRICE_UPDATE_MAGIC, type PSMProcessingConfig, type ParsedOutput, type PollDatum, type PollManagerContent, PollManagerParams, type PollManagerParamsSP, type PollManagerRedeemer, type PollShardContent, PollShardParams, type PollShardParamsSP, type PollShardRedeemer, type PollStatus, type PriceOracleDatum, type PriceOracleParam, type PriceOracleParams, PriceOracleParamsSchema, type PriceOracleRedeemer, type PriceUpdate, type ProcessRequestAccountContent, type ProposalContent, ProposalContentSchema, type ProposeAssetContent, type ProposeStableswapPoolContent, type ProtocolParams, ProtocolParamsSchema, type PubKeyHash, type PythConfig, type PythConfiguration, type PythFeedConfig, type PythFeedParams, type PythFeedParamsSP, type PythFeedRedeemer, type PythMessageParts, type PythOracleParam, type PythPriceConfigurationSP, type PythStateDatum, type PythUpdatesRedeemer, type Rational, RationalSchema, type RedeemCdpWithdrawalRedeemer, type RobDatum, type RobOrderType, type RobOutput, type RobParams, type RobParamsSP, RobParamsSchema, type RobRedeemer, SOLANA_FORMAT_MAGIC, type SPInteger, SPIntegerSchema, type ScriptCredential, type ScriptOutput, type ScriptRef, type ScriptReference, type ScriptReferences, type SnapshotEpochToScaleToSumContent, SnapshotEpochToScaleToSumContentSchema, type StabilityPoolContent, StabilityPoolContentSchema, StabilityPoolDatumSchema, StabilityPoolParams, type StabilityPoolParamsSP, type StabilityPoolRedeemer, StabilityPoolRedeemerSchema, type StableswapInfo, type StableswapOrderDatum, StableswapOrderDatumSchema, type StableswapOrderInfo, type StableswapOrderRedeemer, type StableswapOutputDatum, type StableswapParamsSP, type StableswapPoolContent, StakeCredential, StakeCredentialSchema, type StakingManager, type StakingManagerOutput, type StakingParamsSP, type StakingPosLockedAmt, type StakingPosition, type StakingPositionOutput, type StakingRedeemer, type StartTime, type StateSnapshot, type SumSnapshot, type SystemParams, type TokenNameSP, type TreasuryParamsSP, type TreasuryWithdrawal, type TreasuryWithdrawalItem, TreasuryWithdrawalSchema, type UpgradePaths, type ValidatorHashes, VerificationKeyHashSchema, type VersionRecordParams, VersionRecordTokenParams, type VoteOption, addrDetails, adjustCdp, adjustPriceToDecimals, adjustRob, adjustStakingPosition, alwaysFailValidator, annulRequest, approximateLeverageRedemptions, attachOracle, balance, batchCollectInterest, batchProcessStableswapOrders, bigintMax, bigintMin, buildRedemptionsTx, burnCdp, calculateAccruedInterest, calculateAdaReward, calculateCollateralRatioFromLeverage, calculateIAssetRedemptionAmt, calculateLeverageFromCollateralRatio, calculateMinCollateralCappedIAssetRedemptionAmt, calculatePurchaseAmtWhenRobBuyOrder, calculatePurchaseAmtWhenRobSellOrder, calculateSpendAmtWhenRobBuyOrder, calculateSpendAmtWhenRobSellOrder, calculateTotalCollateralForRedemption, calculateUnitaryInterest, calculateUnitaryInterestSinceOracleLastUpdated, cancelRob, cancelStableswapOrder, castCDPCreatorParams, castCdpParams, castCdpRedeemParams, castExecuteParams, castGovParams, castInterestCollectionParams, castInterestOracleParams, castOneShotParams, castPollManagerParams, castPollShardParams, castPriceOracleParams, castRobParams, castStabilityPoolParams, castStakingParams, castVersionRecordTokenParams, cdpCollateralRatioPercentage, claimRob, closeCdp, closeStakingPosition, collectInterestTx, collectPriceFeedIds, collectorFeeTx, computeEffectiveCdpState, createDestinationDatum, createE2s2sSnapshots, createProcessRequestAccountRedeemer, createProposal, createScriptAddress, createShardsChunks, createStableswapOrder, decodePriceUpdate, decodePythMessage, depositCdp, deriveAuthToken, derivePythPrice, distributeAda, distributeInterest, distributeReward, divideOnChainCompatible, encodePriceUpdate, encodePythMessage, encodeSignedPythMessage, endProposal, estimateMinOrderOutputLovelaces, estimateUtxoMinLovelace, executeProposal, feedInterestOracle, feedPriceOracleTx, findAdminInterestCollectors, findAllInterestCollectors, findAllStableswapPools, findAllTreasuryUtxos, findAllTreasuryUtxosWithNonAdaAsset, findCollateralAsset, findE2s2sSnapshots, findIAsset, findInterestOracle, findRandomCdpCreator, findRandomNonAdminInterestCollector, findRandomTreasuryUtxo, findRandomTreasuryUtxoWithAsset, findRandomTreasuryUtxoWithOnlyAda, findRelevantE2s2sIdxs, findStabilityPool, findStabilityPoolAccount, findStableswapPool, findStakingManager, findStakingManagerByOutRef, findStakingPositionByOutRef, freezeCdp, fromDataDerivedPythPrice, fromDecimal, fromSPInteger, fromSysParamsCredential, fromSysParamsDerivedPythPrice, fromSysParamsPythFeedParams, fromSysParamsStakeCredential, fromSystemParamsAsset, fromSystemParamsAssetLucid, fromSystemParamsScriptRef, getAssetClassComparisonStr, getInlineDatumOrThrow, getPythFeedConfig, getUpdatedAccountDeposit, handleOracleForCollateralAsset, iassetValueOfCollateral, init, initCDPCreator, initCollector, initGovernance, initInterestCollector, initPythConfig, initScriptRef, initSpState, initStakingManager, initSumVal, initTreasury, initializeAsset, insertSorted, isBuyOrderFullyRedeemed, isFullyRedeemed, isSameEpochToScaleKey, leverageCdpWithRob, liquidateCdp, liquidationHelper, loadSystemParamsFromFile, loadSystemParamsFromUrl, matchSingle, mergeCdps, mergeShards, mintAuthTokenDirect, mintCdp, mintOneTimeAsset, mintOneTimeToken, mkAuthTokenPolicy, mkCDPCreatorValidator, mkCDPCreatorValidatorFromSP, mkCdpRedeemValidatorFromSP, mkCdpValidatorFromSP, mkCollectorValidatorFromSP, mkExecuteValidator, mkExecuteValidatorFromSP, mkGovValidator, mkGovValidatorFromSP, mkIAssetTokenPolicy, mkIAssetValidatorFromSP, mkInterestCollectionValidator, mkInterestCollectionValidatorFromSP, mkInterestOracleValidator, mkOneShotPolicy, mkPollManagerValidator, mkPollManagerValidatorFromSP, mkPollShardValidator, mkPollShardValidatorFromSP, mkPriceOracleValidator, mkPythFeedValidator, mkRobValidator, mkRobValidatorFromSP, mkSPInteger, mkStabilityPoolAddr, mkStabilityPoolValidator, mkStabilityPoolValidatorFromSP, mkStableswapValidator, mkStableswapValidatorFromSP, mkStakingValidatorFromSP, mkTreasuryAddr, mkTreasuryValidatorFromSP, mkVersionRecordTokenPolicy, mkVersionRegistryValidator, numberToRational, oneShotMintTx, openCdp, openRob, openStakingPosition, parseAccountDatum, parseAccountDatumOrThrow, parseCdpDatum, parseCdpDatumOrThrow, parseCdpRedeemer, parseCdpRedeemerOrThrow, parseCollateralAssetDatum, parseCollateralAssetDatumOrThrow, parseExecuteDatum, parseExecuteDatumOrThrow, parseGovDatum, parseGovDatumOrThrow, parseIAssetDatum, parseIAssetDatumOrThrow, parseInterestCollectionDatum, parseInterestOracleDatum, parsePollManager, parsePollManagerOrThrow, parsePollShard, parsePollShardOrThrow, parsePollShardRedeemer, parsePollShardRedeemerOrThrow, parsePriceOracleDatum, parsePythStateDatum, parseRobDatum, parseRobDatumOrThrow, parseRobRedeemer, parseRobRedeemerOrThrow, parseSnapshotEpochToScaleToSumDatum, parseSnapshotEpochToScaleToSumDatumOrThrow, parseStabilityPoolDatum, parseStabilityPoolDatumOrThrow, parseStabilityPoolRedeemer, parseStabilityPoolRedeemerOrThrow, parseStableswapOrderDatum, parseStableswapOrderDatumOrThrow, parseStableswapOrderRedeemer, parseStableswapOrderRedeemerOrThrow, parseStableswapPoolDatum, parseStableswapPoolDatumOrThrow, parseStakingManagerDatum, parseStakingPosition, parseStakingPositionOrThrow, parseStakingRedeemer, parseStakingRedeemerOrThrow, partitionEpochToScaleToSums, pickValidSatisfiableOrders, processSpRequest, psmOrderType, randomRobsSubsetSatisfyingTargetCollateral, rationalAdd, rationalCeil, rationalDiv, rationalFloor, rationalFromInt, rationalMul, rationalNegate, rationalSub, rationalToFloat, rationalZero, redeemCdp, redeemRob, repsertReadonlyArr, repsertWithReadonlyArr, requestSpAccountAdjustment, requestSpAccountClosure, requestSpAccountCreation, rewardSnapshotPrecision, rewardsPerAsset, robAmtToSpend, robBuyOrderFilledAssets, robBuyOrderSummary, robCollateralAmtToSpend, robIAssetAmtToSpend, robSellOrderFilledAssets, runCreateScriptRefTx, runOneShotMintTx, scriptRef, serialiseActionReturnDatum, serialiseCdpDatum, serialiseCdpRedeemer, serialiseCollectorRedeemer, serialiseExecuteDatum, serialiseFeedInterestOracleRedeemer, serialiseGovDatum, serialiseGovRedeemer, serialiseIAssetDatum, serialiseIAssetRedeemer, serialiseInterestCollectionDatum, serialiseInterestCollectionRedeemer, serialiseInterestOracleDatum, serialisePollDatum, serialisePollManagerRedeemer, serialisePollShardRedeemer, serialisePriceOracleDatum, serialisePriceOracleRedeemer, serialisePythFeedParams, serialisePythFeedRedeemer, serialisePythStateDatum, serialisePythUpdatesRedeemer, serialiseRedeemCdpWithdrawalRedeemer, serialiseRobDatum, serialiseRobRedeemer, serialiseStabilityPoolDatum, serialiseStabilityPoolRedeemer, serialiseStableswapOrderDatum, serialiseStableswapOrderRedeemer, serialiseStableswapOutputDatum, serialiseStableswapPoolDatum, serialiseStakingDatum, serialiseStakingRedeemer, shuffle, signersAllOf, spAdd, spDiv, spMul, spSub, spZeroNegatives, startInterestOracle, startPriceOracleTx, submitTx, sum, summariseOrder, summarizeActualLeverageRedemptions, toAssetClassFromLucid, toDataDerivedPythPrice, toSystemParamsAsset, treasuryCollect, treasuryFeeTx, treasuryMerge, treasuryPrepareWithdrawal, treasurySplit, updateAccount, updatePermissions, updatePoolStateWhenWithdrawalFee, updateStableswapPoolFees, updateStakingLockedAmount, vote, withdrawCdp, zeroNegatives };
package/dist/index.js CHANGED
@@ -141,6 +141,7 @@ __export(index_exports, {
141
141
  collectInterestTx: () => collectInterestTx,
142
142
  collectPriceFeedIds: () => collectPriceFeedIds,
143
143
  collectorFeeTx: () => collectorFeeTx,
144
+ computeEffectiveCdpState: () => computeEffectiveCdpState,
144
145
  createDestinationDatum: () => createDestinationDatum,
145
146
  createE2s2sSnapshots: () => createE2s2sSnapshots,
146
147
  createProcessRequestAccountRedeemer: () => createProcessRequestAccountRedeemer,
@@ -168,6 +169,7 @@ __export(index_exports, {
168
169
  feedPriceOracleTx: () => feedPriceOracleTx,
169
170
  findAdminInterestCollectors: () => findAdminInterestCollectors,
170
171
  findAllInterestCollectors: () => findAllInterestCollectors,
172
+ findAllStableswapPools: () => findAllStableswapPools,
171
173
  findAllTreasuryUtxos: () => findAllTreasuryUtxos,
172
174
  findAllTreasuryUtxosWithNonAdaAsset: () => findAllTreasuryUtxosWithNonAdaAsset,
173
175
  findCollateralAsset: () => findCollateralAsset,
@@ -182,6 +184,7 @@ __export(index_exports, {
182
184
  findRelevantE2s2sIdxs: () => findRelevantE2s2sIdxs,
183
185
  findStabilityPool: () => findStabilityPool,
184
186
  findStabilityPoolAccount: () => findStabilityPoolAccount,
187
+ findStableswapPool: () => findStableswapPool,
185
188
  findStakingManager: () => findStakingManager,
186
189
  findStakingManagerByOutRef: () => findStakingManagerByOutRef,
187
190
  findStakingPositionByOutRef: () => findStakingPositionByOutRef,
@@ -867,28 +870,41 @@ function iassetValueOfCollateral(collateralAmt, oraclePrice) {
867
870
  rationalDiv(rationalFromInt(collateralAmt), oraclePrice)
868
871
  );
869
872
  }
870
- function cdpCollateralRatioPercentage(now, iassetPrice, cdpUtxoAssets, cdpContent, interestOracleDatum) {
871
- return (0, import_ts_pattern5.match)(cdpContent.cdpFees).with({ ActiveCDPInterestTracking: import_ts_pattern5.P.select() }, (interest) => {
872
- const interestAmt = calculateAccruedInterest(
873
+ function computeEffectiveCdpState(now, cdpUtxoAssets, cdpContent, interestOracleDatum) {
874
+ const interestAmt = (0, import_ts_pattern5.match)(cdpContent.cdpFees).with(
875
+ { ActiveCDPInterestTracking: import_ts_pattern5.P.select() },
876
+ (interest) => calculateAccruedInterest(
873
877
  now,
874
878
  interest.unitaryInterestSnapshot,
875
879
  cdpContent.mintedAmt,
876
880
  interest.lastSettled,
877
881
  interestOracleDatum
878
- );
879
- const collateral = (0, import_cardano_offchain_common.assetClassValueOf)(
880
- cdpUtxoAssets,
881
- cdpContent.collateralAsset
882
- );
883
- const ratio = rationalDiv(
884
- rationalFromInt(collateral),
885
- rationalMul(
886
- rationalFromInt(cdpContent.mintedAmt + interestAmt),
887
- iassetPrice
888
- )
889
- );
890
- return Number(ratio.numerator) * 100 / Number(ratio.denominator);
891
- }).with({ FrozenCDPAccumulatedFees: import_ts_pattern5.P.any }, () => 0).exhaustive();
882
+ )
883
+ ).with(
884
+ { FrozenCDPAccumulatedFees: import_ts_pattern5.P.select() },
885
+ (fees) => fees.iassetInterest
886
+ ).exhaustive();
887
+ const collateralAmt = (0, import_cardano_offchain_common.assetClassValueOf)(
888
+ cdpUtxoAssets,
889
+ cdpContent.collateralAsset
890
+ );
891
+ return {
892
+ mintedAmt: cdpContent.mintedAmt + interestAmt,
893
+ collateralAmt
894
+ };
895
+ }
896
+ function cdpCollateralRatioPercentage(now, iassetPrice, cdpUtxoAssets, cdpContent, interestOracleDatum) {
897
+ const cdpState = computeEffectiveCdpState(
898
+ now,
899
+ cdpUtxoAssets,
900
+ cdpContent,
901
+ interestOracleDatum
902
+ );
903
+ const ratio = rationalDiv(
904
+ rationalFromInt(cdpState.collateralAmt),
905
+ rationalMul(rationalFromInt(cdpState.mintedAmt), iassetPrice)
906
+ );
907
+ return Number(ratio.numerator) * 100 / Number(ratio.denominator);
892
908
  }
893
909
  function calculateIAssetRedemptionAmt(collateralAmt, mintedAmt, price, rmr) {
894
910
  return rationalCeil(
@@ -11783,35 +11799,78 @@ function pickValidSatisfiableOrders(lucid, orders, pool, sysParams, psmProcessin
11783
11799
  return [...mintingOrders, ...selected].map((o) => o.order);
11784
11800
  }
11785
11801
 
11786
- // src/contracts/stableswap/transactions.ts
11802
+ // src/contracts/stableswap/queries.ts
11787
11803
  var import_lucid67 = require("@lucid-evolution/lucid");
11788
11804
  var import_cardano_offchain_common36 = require("@indigo-labs/cardano-offchain-common");
11789
11805
  var import_fp_ts30 = require("fp-ts");
11806
+ async function findAllStableswapPools(lucid, sysParams) {
11807
+ const cdpUtxos = await lucid.utxosAtWithUnit(
11808
+ createScriptAddress(
11809
+ lucid.config().network,
11810
+ sysParams.validatorHashes.cdpHash
11811
+ ),
11812
+ (0, import_cardano_offchain_common36.assetClassToUnit)(
11813
+ fromSystemParamsAsset(sysParams.stableswapParams.cdpToken)
11814
+ )
11815
+ );
11816
+ return import_fp_ts30.function.pipe(
11817
+ cdpUtxos.map(
11818
+ (utxo) => import_fp_ts30.function.pipe(
11819
+ import_fp_ts30.option.fromNullable(utxo.datum),
11820
+ import_fp_ts30.option.flatMap(parseStableswapPoolDatum),
11821
+ import_fp_ts30.option.map((datum) => ({ utxo, datum }))
11822
+ )
11823
+ ),
11824
+ import_fp_ts30.array.compact
11825
+ );
11826
+ }
11827
+ async function findStableswapPool(lucid, sysParams, iassetName, collateralAsset) {
11828
+ const stableswapPools = await findAllStableswapPools(lucid, sysParams);
11829
+ return (0, import_cardano_offchain_common36.matchSingle)(
11830
+ import_fp_ts30.function.pipe(
11831
+ stableswapPools.map((pool) => {
11832
+ if ((0, import_lucid67.toHex)(pool.datum.iasset) === iassetName && (0, import_cardano_offchain_common36.isSameAssetClass)(pool.datum.collateralAsset, collateralAsset)) {
11833
+ return import_fp_ts30.option.some(pool);
11834
+ }
11835
+ return import_fp_ts30.option.none;
11836
+ }),
11837
+ import_fp_ts30.array.compact
11838
+ ),
11839
+ (res) => new Error(
11840
+ "Expected a single stableswap pool UTXO.: " + JSON.stringify(res)
11841
+ )
11842
+ );
11843
+ }
11844
+
11845
+ // src/contracts/stableswap/transactions.ts
11846
+ var import_lucid68 = require("@lucid-evolution/lucid");
11847
+ var import_cardano_offchain_common37 = require("@indigo-labs/cardano-offchain-common");
11848
+ var import_fp_ts31 = require("fp-ts");
11790
11849
  async function createStableswapOrder(iasset, collateralAsset, amount, minting, poolDatum, params, lucid, destinationAddress, destinationInlineDatum, maxExecutionFee = BASE_MAX_EXECUTION_FEE, additionalLovelaces = 0n, maxFeeRatio) {
11791
11850
  const myAddress = await lucid.wallet().address();
11792
- const pkh = (0, import_lucid67.paymentCredentialOf)(myAddress);
11851
+ const pkh = (0, import_lucid68.paymentCredentialOf)(myAddress);
11793
11852
  const datum = {
11794
- iasset: (0, import_lucid67.fromHex)((0, import_lucid67.fromText)(iasset)),
11853
+ iasset: (0, import_lucid68.fromHex)((0, import_lucid68.fromText)(iasset)),
11795
11854
  collateralAsset,
11796
- owner: (0, import_lucid67.fromHex)(pkh.hash),
11797
- destination: (0, import_cardano_offchain_common36.addressFromBech32)(destinationAddress ?? myAddress),
11855
+ owner: (0, import_lucid68.fromHex)(pkh.hash),
11856
+ destination: (0, import_cardano_offchain_common37.addressFromBech32)(destinationAddress ?? myAddress),
11798
11857
  destinationInlineDatum: destinationInlineDatum ?? null,
11799
11858
  maxExecutionFee,
11800
11859
  maxFeeRatio: maxFeeRatio ?? (minting ? poolDatum.mintingFeeRatio : poolDatum.redemptionFeeRatio)
11801
11860
  };
11802
- const assetsToSwap = minting ? (0, import_cardano_offchain_common36.mkAssetsOf)(collateralAsset, amount) : (0, import_cardano_offchain_common36.mkAssetsOf)(
11861
+ const assetsToSwap = minting ? (0, import_cardano_offchain_common37.mkAssetsOf)(collateralAsset, amount) : (0, import_cardano_offchain_common37.mkAssetsOf)(
11803
11862
  {
11804
- currencySymbol: (0, import_lucid67.fromHex)(
11863
+ currencySymbol: (0, import_lucid68.fromHex)(
11805
11864
  params.stableswapParams.iassetSymbol.unCurrencySymbol
11806
11865
  ),
11807
- tokenName: (0, import_lucid67.fromHex)((0, import_lucid67.fromText)(iasset))
11866
+ tokenName: (0, import_lucid68.fromHex)((0, import_lucid68.fromText)(iasset))
11808
11867
  },
11809
11868
  amount
11810
11869
  );
11811
- const orderAssetsPlusFees = (0, import_lucid67.addAssets)(
11870
+ const orderAssetsPlusFees = (0, import_lucid68.addAssets)(
11812
11871
  assetsToSwap,
11813
- (0, import_cardano_offchain_common36.mkLovelacesOf)(maxExecutionFee),
11814
- (0, import_cardano_offchain_common36.mkLovelacesOf)(additionalLovelaces)
11872
+ (0, import_cardano_offchain_common37.mkLovelacesOf)(maxExecutionFee),
11873
+ (0, import_cardano_offchain_common37.mkLovelacesOf)(additionalLovelaces)
11815
11874
  );
11816
11875
  const expectedMinOutputLovelaces = estimateMinOrderOutputLovelaces(
11817
11876
  lucid,
@@ -11819,7 +11878,7 @@ async function createStableswapOrder(iasset, collateralAsset, amount, minting, p
11819
11878
  orderAssetsPlusFees
11820
11879
  );
11821
11880
  return lucid.newTx().pay.ToContract(
11822
- (0, import_lucid67.credentialToAddress)(lucid.config().network, {
11881
+ (0, import_lucid68.credentialToAddress)(lucid.config().network, {
11823
11882
  hash: params.validatorHashes.stableswapHash,
11824
11883
  type: "Script"
11825
11884
  }),
@@ -11827,11 +11886,11 @@ async function createStableswapOrder(iasset, collateralAsset, amount, minting, p
11827
11886
  kind: "inline",
11828
11887
  value: serialiseStableswapOrderDatum(datum)
11829
11888
  },
11830
- (0, import_lucid67.addAssets)(orderAssetsPlusFees, (0, import_cardano_offchain_common36.mkLovelacesOf)(expectedMinOutputLovelaces))
11889
+ (0, import_lucid68.addAssets)(orderAssetsPlusFees, (0, import_cardano_offchain_common37.mkLovelacesOf)(expectedMinOutputLovelaces))
11831
11890
  );
11832
11891
  }
11833
11892
  async function cancelStableswapOrder(stableswapOrderOref, sysParams, lucid) {
11834
- const stableswapScriptRefUtxo = (0, import_cardano_offchain_common36.matchSingle)(
11893
+ const stableswapScriptRefUtxo = (0, import_cardano_offchain_common37.matchSingle)(
11835
11894
  await lucid.utxosByOutRef([
11836
11895
  fromSystemParamsScriptRef(
11837
11896
  sysParams.scriptReferences.stableswapValidatorRef
@@ -11839,20 +11898,20 @@ async function cancelStableswapOrder(stableswapOrderOref, sysParams, lucid) {
11839
11898
  ]),
11840
11899
  (_) => new Error("Expected a single Stableswap Ref Script UTXO")
11841
11900
  );
11842
- const stableswapOrderUtxo = (0, import_cardano_offchain_common36.matchSingle)(
11901
+ const stableswapOrderUtxo = (0, import_cardano_offchain_common37.matchSingle)(
11843
11902
  await lucid.utxosByOutRef([stableswapOrderOref]),
11844
11903
  (_) => new Error("Expected a single Stableswap Order UTXO.")
11845
11904
  );
11846
11905
  const stableswapOrderDatum = parseStableswapOrderDatumOrThrow(
11847
- (0, import_cardano_offchain_common36.getInlineDatumOrThrow)(stableswapOrderUtxo)
11906
+ (0, import_cardano_offchain_common37.getInlineDatumOrThrow)(stableswapOrderUtxo)
11848
11907
  );
11849
11908
  return lucid.newTx().readFrom([stableswapScriptRefUtxo]).collectFrom(
11850
11909
  [stableswapOrderUtxo],
11851
11910
  serialiseStableswapOrderRedeemer("CancelStableswapOrder")
11852
- ).addSignerKey((0, import_lucid67.toHex)(stableswapOrderDatum.owner));
11911
+ ).addSignerKey((0, import_lucid68.toHex)(stableswapOrderDatum.owner));
11853
11912
  }
11854
11913
  async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPoolOref, treasuryOref, sysParams, lucid, psmProcessingConfig) {
11855
- const stableswapScriptRefUtxo = (0, import_cardano_offchain_common36.matchSingle)(
11914
+ const stableswapScriptRefUtxo = (0, import_cardano_offchain_common37.matchSingle)(
11856
11915
  await lucid.utxosByOutRef([
11857
11916
  fromSystemParamsScriptRef(
11858
11917
  sysParams.scriptReferences.stableswapValidatorRef
@@ -11860,13 +11919,13 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11860
11919
  ]),
11861
11920
  (_) => new Error("Expected a single Stableswap Ref Script UTXO")
11862
11921
  );
11863
- const cdpScriptRefUtxo = (0, import_cardano_offchain_common36.matchSingle)(
11922
+ const cdpScriptRefUtxo = (0, import_cardano_offchain_common37.matchSingle)(
11864
11923
  await lucid.utxosByOutRef([
11865
11924
  fromSystemParamsScriptRef(sysParams.scriptReferences.cdpValidatorRef)
11866
11925
  ]),
11867
11926
  (_) => new Error("Expected a single CDP Ref Script UTXO")
11868
11927
  );
11869
- const iAssetTokenPolicyRefScriptUtxo = (0, import_cardano_offchain_common36.matchSingle)(
11928
+ const iAssetTokenPolicyRefScriptUtxo = (0, import_cardano_offchain_common37.matchSingle)(
11870
11929
  await lucid.utxosByOutRef([
11871
11930
  fromSystemParamsScriptRef(
11872
11931
  sysParams.scriptReferences.iAssetTokenPolicyRef
@@ -11874,11 +11933,11 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11874
11933
  ]),
11875
11934
  (_) => new Error("Expected a single iasset token policy Ref Script UTXO")
11876
11935
  );
11877
- if (import_fp_ts30.array.isEmpty(stableswapOrderOrefs)) {
11936
+ if (import_fp_ts31.array.isEmpty(stableswapOrderOrefs)) {
11878
11937
  throw new Error("At least one order must be provided.");
11879
11938
  }
11880
11939
  const stableswapOrderUtxos = await lucid.utxosByOutRef(stableswapOrderOrefs);
11881
- const sortedStableswapOrderUtxos = (0, import_lucid67.sortUTxOs)(
11940
+ const sortedStableswapOrderUtxos = (0, import_lucid68.sortUTxOs)(
11882
11941
  stableswapOrderUtxos,
11883
11942
  "Canonical"
11884
11943
  );
@@ -11887,26 +11946,26 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11887
11946
  }
11888
11947
  const mainOrderUtxo = sortedStableswapOrderUtxos[0];
11889
11948
  const mainOrderDatum = parseStableswapOrderDatumOrThrow(
11890
- (0, import_cardano_offchain_common36.getInlineDatumOrThrow)(mainOrderUtxo)
11949
+ (0, import_cardano_offchain_common37.getInlineDatumOrThrow)(mainOrderUtxo)
11891
11950
  );
11892
11951
  const iassetAc = {
11893
- currencySymbol: (0, import_lucid67.fromHex)(
11952
+ currencySymbol: (0, import_lucid68.fromHex)(
11894
11953
  sysParams.stableswapParams.iassetSymbol.unCurrencySymbol
11895
11954
  ),
11896
11955
  tokenName: mainOrderDatum.iasset
11897
11956
  };
11898
11957
  const collateralAc = mainOrderDatum.collateralAsset;
11899
- const stableswapPoolUtxo = (0, import_cardano_offchain_common36.matchSingle)(
11958
+ const stableswapPoolUtxo = (0, import_cardano_offchain_common37.matchSingle)(
11900
11959
  await lucid.utxosByOutRef([stableswapPoolOref]),
11901
11960
  (_) => new Error("Expected a single cdp UTXO")
11902
11961
  );
11903
11962
  const stableswapPoolDatum = parseStableswapPoolDatumOrThrow(
11904
- (0, import_cardano_offchain_common36.getInlineDatumOrThrow)(stableswapPoolUtxo)
11963
+ (0, import_cardano_offchain_common37.getInlineDatumOrThrow)(stableswapPoolUtxo)
11905
11964
  );
11906
11965
  const ordersInfo = sortedStableswapOrderUtxos.map(
11907
11966
  (orderUtxo) => {
11908
11967
  const orderDatum = parseStableswapOrderDatumOrThrow(
11909
- (0, import_cardano_offchain_common36.getInlineDatumOrThrow)(orderUtxo)
11968
+ (0, import_cardano_offchain_common37.getInlineDatumOrThrow)(orderUtxo)
11910
11969
  );
11911
11970
  const res = summariseOrder(
11912
11971
  lucid,
@@ -11921,9 +11980,9 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11921
11980
  return res.result;
11922
11981
  }
11923
11982
  );
11924
- const totalSwapInfo = import_fp_ts30.function.pipe(
11983
+ const totalSwapInfo = import_fp_ts31.function.pipe(
11925
11984
  ordersInfo,
11926
- import_fp_ts30.array.reduce(
11985
+ import_fp_ts31.array.reduce(
11927
11986
  {
11928
11987
  suppliedCollateralAsset: 0n,
11929
11988
  suppliedIasset: 0n,
@@ -11945,11 +12004,11 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11945
12004
  )
11946
12005
  );
11947
12006
  const collateralAmtChangePool = totalSwapInfo.suppliedCollateralAsset - totalSwapInfo.owedCollateralAsset;
11948
- const newPsmPoolValue = (0, import_lucid67.addAssets)(
12007
+ const newPsmPoolValue = (0, import_lucid68.addAssets)(
11949
12008
  stableswapPoolUtxo.assets,
11950
- (0, import_cardano_offchain_common36.mkAssetsOf)(collateralAc, collateralAmtChangePool)
12009
+ (0, import_cardano_offchain_common37.mkAssetsOf)(collateralAc, collateralAmtChangePool)
11951
12010
  );
11952
- if ((0, import_cardano_offchain_common36.assetClassValueOf)(newPsmPoolValue, collateralAc) < 0n) {
12011
+ if ((0, import_cardano_offchain_common37.assetClassValueOf)(newPsmPoolValue, collateralAc) < 0n) {
11953
12012
  throw new Error("Cannot batch more than liquidity allows");
11954
12013
  }
11955
12014
  const amountToMint = totalSwapInfo.owedIasset - totalSwapInfo.suppliedIasset + totalSwapInfo.mintingFee;
@@ -11975,14 +12034,14 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11975
12034
  newPsmPoolValue
11976
12035
  ).setMinFee(stableswapOrderOrefs.length > 1 ? 1498875n : 1030000n);
11977
12036
  if (amountToMint !== 0n) {
11978
- tx.mintAssets((0, import_cardano_offchain_common36.mkAssetsOf)(iassetAc, amountToMint), import_lucid67.Data.void());
12037
+ tx.mintAssets((0, import_cardano_offchain_common37.mkAssetsOf)(iassetAc, amountToMint), import_lucid68.Data.void());
11979
12038
  }
11980
- import_fp_ts30.function.pipe(
12039
+ import_fp_ts31.function.pipe(
11981
12040
  ordersInfo,
11982
- import_fp_ts30.array.reduce(tx, (acc, orderInfo) => {
12041
+ import_fp_ts31.array.reduce(tx, (acc, orderInfo) => {
11983
12042
  return acc.collectFrom(
11984
12043
  [orderInfo.order.utxo],
11985
- (0, import_cardano_offchain_common36.isSameOutRef)(orderInfo.order.utxo, mainOrderUtxo) ? serialiseStableswapOrderRedeemer("BatchProcessStableswapOrders") : {
12044
+ (0, import_cardano_offchain_common37.isSameOutRef)(orderInfo.order.utxo, mainOrderUtxo) ? serialiseStableswapOrderRedeemer("BatchProcessStableswapOrders") : {
11986
12045
  kind: "selected",
11987
12046
  makeRedeemer: (inputIndices) => {
11988
12047
  return serialiseStableswapOrderRedeemer({
@@ -11995,7 +12054,7 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11995
12054
  inputs: [orderInfo.order.utxo, mainOrderUtxo]
11996
12055
  }
11997
12056
  ).pay.ToAddressWithData(
11998
- (0, import_cardano_offchain_common36.addressToBech32)(
12057
+ (0, import_cardano_offchain_common37.addressToBech32)(
11999
12058
  orderInfo.order.datum.destination,
12000
12059
  lucid.config().network
12001
12060
  ),
@@ -12006,13 +12065,13 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
12006
12065
  orderInfo.order.utxo
12007
12066
  )
12008
12067
  },
12009
- (0, import_lucid67.addAssets)(
12068
+ (0, import_lucid68.addAssets)(
12010
12069
  // NOTICE: Currently, we always take the max execution fee from the order utxo.
12011
12070
  // This can be improved so that we take the actual execution fee.
12012
- (0, import_cardano_offchain_common36.mkLovelacesOf)(
12013
- (0, import_cardano_offchain_common36.lovelacesAmt)(orderInfo.order.utxo.assets) - orderInfo.order.datum.maxExecutionFee
12071
+ (0, import_cardano_offchain_common37.mkLovelacesOf)(
12072
+ (0, import_cardano_offchain_common37.lovelacesAmt)(orderInfo.order.utxo.assets) - orderInfo.order.datum.maxExecutionFee
12014
12073
  ),
12015
- orderInfo.orderType === "MINTING" ? (0, import_cardano_offchain_common36.mkAssetsOf)(iassetAc, orderInfo.swapInfo.owedIasset) : (0, import_cardano_offchain_common36.mkAssetsOf)(
12074
+ orderInfo.orderType === "MINTING" ? (0, import_cardano_offchain_common37.mkAssetsOf)(iassetAc, orderInfo.swapInfo.owedIasset) : (0, import_cardano_offchain_common37.mkAssetsOf)(
12016
12075
  collateralAc,
12017
12076
  orderInfo.swapInfo.owedCollateralAsset
12018
12077
  )
@@ -12035,7 +12094,7 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
12035
12094
  return tx;
12036
12095
  }
12037
12096
  async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRef, newMintingFeeRatio, newRedemptionFeeRatio, sysParams, lucid) {
12038
- const stableswapScriptRefUtxo = (0, import_cardano_offchain_common36.matchSingle)(
12097
+ const stableswapScriptRefUtxo = (0, import_cardano_offchain_common37.matchSingle)(
12039
12098
  await lucid.utxosByOutRef([
12040
12099
  fromSystemParamsScriptRef(
12041
12100
  sysParams.scriptReferences.stableswapValidatorRef
@@ -12043,22 +12102,22 @@ async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRe
12043
12102
  ]),
12044
12103
  (_) => new Error("Expected a single Stableswap Ref Script UTXO")
12045
12104
  );
12046
- const cdpScriptRefUtxo = (0, import_cardano_offchain_common36.matchSingle)(
12105
+ const cdpScriptRefUtxo = (0, import_cardano_offchain_common37.matchSingle)(
12047
12106
  await lucid.utxosByOutRef([
12048
12107
  fromSystemParamsScriptRef(sysParams.scriptReferences.cdpValidatorRef)
12049
12108
  ]),
12050
12109
  (_) => new Error("Expected a single CDP Ref Script UTXO")
12051
12110
  );
12052
- const stableswapPool = (0, import_cardano_offchain_common36.matchSingle)(
12111
+ const stableswapPool = (0, import_cardano_offchain_common37.matchSingle)(
12053
12112
  await lucid.utxosByOutRef([stableswapPoolOutRef]),
12054
12113
  (_) => new Error("Expected a single Stableswap Pool UTXO.")
12055
12114
  );
12056
- const stableswapFeeUtxo = (0, import_cardano_offchain_common36.matchSingle)(
12115
+ const stableswapFeeUtxo = (0, import_cardano_offchain_common37.matchSingle)(
12057
12116
  await lucid.utxosByOutRef([stableswapFeeOutRef]),
12058
12117
  (_) => new Error("Expected a single Stableswap Fee UTXO.")
12059
12118
  );
12060
12119
  const stableswapPoolDatum = parseStableswapPoolDatumOrThrow(
12061
- (0, import_cardano_offchain_common36.getInlineDatumOrThrow)(stableswapPool)
12120
+ (0, import_cardano_offchain_common37.getInlineDatumOrThrow)(stableswapPool)
12062
12121
  );
12063
12122
  const newStableswapPoolDatum = {
12064
12123
  ...stableswapPoolDatum,
@@ -12086,7 +12145,7 @@ async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRe
12086
12145
  value: serialiseStableswapPoolDatum(newStableswapPoolDatum)
12087
12146
  },
12088
12147
  stableswapPool.assets
12089
- ).addSignerKey((0, import_lucid67.toHex)(stableswapPoolDatum.feeManager)).setMinFee(1038402n);
12148
+ ).addSignerKey((0, import_lucid68.toHex)(stableswapPoolDatum.feeManager)).setMinFee(1038402n);
12090
12149
  }
12091
12150
  // Annotate the CommonJS export names for ESM import in node:
12092
12151
  0 && (module.exports = {
@@ -12201,6 +12260,7 @@ async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRe
12201
12260
  collectInterestTx,
12202
12261
  collectPriceFeedIds,
12203
12262
  collectorFeeTx,
12263
+ computeEffectiveCdpState,
12204
12264
  createDestinationDatum,
12205
12265
  createE2s2sSnapshots,
12206
12266
  createProcessRequestAccountRedeemer,
@@ -12228,6 +12288,7 @@ async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRe
12228
12288
  feedPriceOracleTx,
12229
12289
  findAdminInterestCollectors,
12230
12290
  findAllInterestCollectors,
12291
+ findAllStableswapPools,
12231
12292
  findAllTreasuryUtxos,
12232
12293
  findAllTreasuryUtxosWithNonAdaAsset,
12233
12294
  findCollateralAsset,
@@ -12242,6 +12303,7 @@ async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRe
12242
12303
  findRelevantE2s2sIdxs,
12243
12304
  findStabilityPool,
12244
12305
  findStabilityPoolAccount,
12306
+ findStableswapPool,
12245
12307
  findStakingManager,
12246
12308
  findStakingManagerByOutRef,
12247
12309
  findStakingPositionByOutRef,
package/dist/index.mjs CHANGED
@@ -475,28 +475,41 @@ function iassetValueOfCollateral(collateralAmt, oraclePrice) {
475
475
  rationalDiv(rationalFromInt(collateralAmt), oraclePrice)
476
476
  );
477
477
  }
478
- function cdpCollateralRatioPercentage(now, iassetPrice, cdpUtxoAssets, cdpContent, interestOracleDatum) {
479
- return match4(cdpContent.cdpFees).with({ ActiveCDPInterestTracking: P4.select() }, (interest) => {
480
- const interestAmt = calculateAccruedInterest(
478
+ function computeEffectiveCdpState(now, cdpUtxoAssets, cdpContent, interestOracleDatum) {
479
+ const interestAmt = match4(cdpContent.cdpFees).with(
480
+ { ActiveCDPInterestTracking: P4.select() },
481
+ (interest) => calculateAccruedInterest(
481
482
  now,
482
483
  interest.unitaryInterestSnapshot,
483
484
  cdpContent.mintedAmt,
484
485
  interest.lastSettled,
485
486
  interestOracleDatum
486
- );
487
- const collateral = assetClassValueOf(
488
- cdpUtxoAssets,
489
- cdpContent.collateralAsset
490
- );
491
- const ratio = rationalDiv(
492
- rationalFromInt(collateral),
493
- rationalMul(
494
- rationalFromInt(cdpContent.mintedAmt + interestAmt),
495
- iassetPrice
496
- )
497
- );
498
- return Number(ratio.numerator) * 100 / Number(ratio.denominator);
499
- }).with({ FrozenCDPAccumulatedFees: P4.any }, () => 0).exhaustive();
487
+ )
488
+ ).with(
489
+ { FrozenCDPAccumulatedFees: P4.select() },
490
+ (fees) => fees.iassetInterest
491
+ ).exhaustive();
492
+ const collateralAmt = assetClassValueOf(
493
+ cdpUtxoAssets,
494
+ cdpContent.collateralAsset
495
+ );
496
+ return {
497
+ mintedAmt: cdpContent.mintedAmt + interestAmt,
498
+ collateralAmt
499
+ };
500
+ }
501
+ function cdpCollateralRatioPercentage(now, iassetPrice, cdpUtxoAssets, cdpContent, interestOracleDatum) {
502
+ const cdpState = computeEffectiveCdpState(
503
+ now,
504
+ cdpUtxoAssets,
505
+ cdpContent,
506
+ interestOracleDatum
507
+ );
508
+ const ratio = rationalDiv(
509
+ rationalFromInt(cdpState.collateralAmt),
510
+ rationalMul(rationalFromInt(cdpState.mintedAmt), iassetPrice)
511
+ );
512
+ return Number(ratio.numerator) * 100 / Number(ratio.denominator);
500
513
  }
501
514
  function calculateIAssetRedemptionAmt(collateralAmt, mintedAmt, price, rmr) {
502
515
  return rationalCeil(
@@ -11677,6 +11690,53 @@ function pickValidSatisfiableOrders(lucid, orders, pool, sysParams, psmProcessin
11677
11690
  return [...mintingOrders, ...selected].map((o) => o.order);
11678
11691
  }
11679
11692
 
11693
+ // src/contracts/stableswap/queries.ts
11694
+ import { toHex as toHex20 } from "@lucid-evolution/lucid";
11695
+ import {
11696
+ assetClassToUnit as assetClassToUnit8,
11697
+ isSameAssetClass as isSameAssetClass6,
11698
+ matchSingle as matchSingle7
11699
+ } from "@indigo-labs/cardano-offchain-common";
11700
+ import { array as A18, function as F28, option as O23 } from "fp-ts";
11701
+ async function findAllStableswapPools(lucid, sysParams) {
11702
+ const cdpUtxos = await lucid.utxosAtWithUnit(
11703
+ createScriptAddress(
11704
+ lucid.config().network,
11705
+ sysParams.validatorHashes.cdpHash
11706
+ ),
11707
+ assetClassToUnit8(
11708
+ fromSystemParamsAsset(sysParams.stableswapParams.cdpToken)
11709
+ )
11710
+ );
11711
+ return F28.pipe(
11712
+ cdpUtxos.map(
11713
+ (utxo) => F28.pipe(
11714
+ O23.fromNullable(utxo.datum),
11715
+ O23.flatMap(parseStableswapPoolDatum),
11716
+ O23.map((datum) => ({ utxo, datum }))
11717
+ )
11718
+ ),
11719
+ A18.compact
11720
+ );
11721
+ }
11722
+ async function findStableswapPool(lucid, sysParams, iassetName, collateralAsset) {
11723
+ const stableswapPools = await findAllStableswapPools(lucid, sysParams);
11724
+ return matchSingle7(
11725
+ F28.pipe(
11726
+ stableswapPools.map((pool) => {
11727
+ if (toHex20(pool.datum.iasset) === iassetName && isSameAssetClass6(pool.datum.collateralAsset, collateralAsset)) {
11728
+ return O23.some(pool);
11729
+ }
11730
+ return O23.none;
11731
+ }),
11732
+ A18.compact
11733
+ ),
11734
+ (res) => new Error(
11735
+ "Expected a single stableswap pool UTXO.: " + JSON.stringify(res)
11736
+ )
11737
+ );
11738
+ }
11739
+
11680
11740
  // src/contracts/stableswap/transactions.ts
11681
11741
  import {
11682
11742
  addAssets as addAssets18,
@@ -11686,20 +11746,20 @@ import {
11686
11746
  fromText as fromText15,
11687
11747
  paymentCredentialOf as paymentCredentialOf3,
11688
11748
  sortUTxOs as sortUTxOs2,
11689
- toHex as toHex20
11749
+ toHex as toHex21
11690
11750
  } from "@lucid-evolution/lucid";
11691
11751
  import {
11692
11752
  addressFromBech32 as addressFromBech323,
11693
11753
  addressToBech32 as addressToBech324,
11694
11754
  getInlineDatumOrThrow as getInlineDatumOrThrow6,
11695
- matchSingle as matchSingle7,
11755
+ matchSingle as matchSingle8,
11696
11756
  mkAssetsOf as mkAssetsOf16,
11697
11757
  mkLovelacesOf as mkLovelacesOf9,
11698
11758
  lovelacesAmt as lovelacesAmt6,
11699
11759
  isSameOutRef as isSameOutRef2,
11700
11760
  assetClassValueOf as assetClassValueOf13
11701
11761
  } from "@indigo-labs/cardano-offchain-common";
11702
- import { array as A18, function as F28 } from "fp-ts";
11762
+ import { array as A19, function as F29 } from "fp-ts";
11703
11763
  async function createStableswapOrder(iasset, collateralAsset, amount, minting, poolDatum, params, lucid, destinationAddress, destinationInlineDatum, maxExecutionFee = BASE_MAX_EXECUTION_FEE, additionalLovelaces = 0n, maxFeeRatio) {
11704
11764
  const myAddress = await lucid.wallet().address();
11705
11765
  const pkh = paymentCredentialOf3(myAddress);
@@ -11744,7 +11804,7 @@ async function createStableswapOrder(iasset, collateralAsset, amount, minting, p
11744
11804
  );
11745
11805
  }
11746
11806
  async function cancelStableswapOrder(stableswapOrderOref, sysParams, lucid) {
11747
- const stableswapScriptRefUtxo = matchSingle7(
11807
+ const stableswapScriptRefUtxo = matchSingle8(
11748
11808
  await lucid.utxosByOutRef([
11749
11809
  fromSystemParamsScriptRef(
11750
11810
  sysParams.scriptReferences.stableswapValidatorRef
@@ -11752,7 +11812,7 @@ async function cancelStableswapOrder(stableswapOrderOref, sysParams, lucid) {
11752
11812
  ]),
11753
11813
  (_) => new Error("Expected a single Stableswap Ref Script UTXO")
11754
11814
  );
11755
- const stableswapOrderUtxo = matchSingle7(
11815
+ const stableswapOrderUtxo = matchSingle8(
11756
11816
  await lucid.utxosByOutRef([stableswapOrderOref]),
11757
11817
  (_) => new Error("Expected a single Stableswap Order UTXO.")
11758
11818
  );
@@ -11762,10 +11822,10 @@ async function cancelStableswapOrder(stableswapOrderOref, sysParams, lucid) {
11762
11822
  return lucid.newTx().readFrom([stableswapScriptRefUtxo]).collectFrom(
11763
11823
  [stableswapOrderUtxo],
11764
11824
  serialiseStableswapOrderRedeemer("CancelStableswapOrder")
11765
- ).addSignerKey(toHex20(stableswapOrderDatum.owner));
11825
+ ).addSignerKey(toHex21(stableswapOrderDatum.owner));
11766
11826
  }
11767
11827
  async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPoolOref, treasuryOref, sysParams, lucid, psmProcessingConfig) {
11768
- const stableswapScriptRefUtxo = matchSingle7(
11828
+ const stableswapScriptRefUtxo = matchSingle8(
11769
11829
  await lucid.utxosByOutRef([
11770
11830
  fromSystemParamsScriptRef(
11771
11831
  sysParams.scriptReferences.stableswapValidatorRef
@@ -11773,13 +11833,13 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11773
11833
  ]),
11774
11834
  (_) => new Error("Expected a single Stableswap Ref Script UTXO")
11775
11835
  );
11776
- const cdpScriptRefUtxo = matchSingle7(
11836
+ const cdpScriptRefUtxo = matchSingle8(
11777
11837
  await lucid.utxosByOutRef([
11778
11838
  fromSystemParamsScriptRef(sysParams.scriptReferences.cdpValidatorRef)
11779
11839
  ]),
11780
11840
  (_) => new Error("Expected a single CDP Ref Script UTXO")
11781
11841
  );
11782
- const iAssetTokenPolicyRefScriptUtxo = matchSingle7(
11842
+ const iAssetTokenPolicyRefScriptUtxo = matchSingle8(
11783
11843
  await lucid.utxosByOutRef([
11784
11844
  fromSystemParamsScriptRef(
11785
11845
  sysParams.scriptReferences.iAssetTokenPolicyRef
@@ -11787,7 +11847,7 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11787
11847
  ]),
11788
11848
  (_) => new Error("Expected a single iasset token policy Ref Script UTXO")
11789
11849
  );
11790
- if (A18.isEmpty(stableswapOrderOrefs)) {
11850
+ if (A19.isEmpty(stableswapOrderOrefs)) {
11791
11851
  throw new Error("At least one order must be provided.");
11792
11852
  }
11793
11853
  const stableswapOrderUtxos = await lucid.utxosByOutRef(stableswapOrderOrefs);
@@ -11809,7 +11869,7 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11809
11869
  tokenName: mainOrderDatum.iasset
11810
11870
  };
11811
11871
  const collateralAc = mainOrderDatum.collateralAsset;
11812
- const stableswapPoolUtxo = matchSingle7(
11872
+ const stableswapPoolUtxo = matchSingle8(
11813
11873
  await lucid.utxosByOutRef([stableswapPoolOref]),
11814
11874
  (_) => new Error("Expected a single cdp UTXO")
11815
11875
  );
@@ -11834,9 +11894,9 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11834
11894
  return res.result;
11835
11895
  }
11836
11896
  );
11837
- const totalSwapInfo = F28.pipe(
11897
+ const totalSwapInfo = F29.pipe(
11838
11898
  ordersInfo,
11839
- A18.reduce(
11899
+ A19.reduce(
11840
11900
  {
11841
11901
  suppliedCollateralAsset: 0n,
11842
11902
  suppliedIasset: 0n,
@@ -11890,9 +11950,9 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11890
11950
  if (amountToMint !== 0n) {
11891
11951
  tx.mintAssets(mkAssetsOf16(iassetAc, amountToMint), Data53.void());
11892
11952
  }
11893
- F28.pipe(
11953
+ F29.pipe(
11894
11954
  ordersInfo,
11895
- A18.reduce(tx, (acc, orderInfo) => {
11955
+ A19.reduce(tx, (acc, orderInfo) => {
11896
11956
  return acc.collectFrom(
11897
11957
  [orderInfo.order.utxo],
11898
11958
  isSameOutRef2(orderInfo.order.utxo, mainOrderUtxo) ? serialiseStableswapOrderRedeemer("BatchProcessStableswapOrders") : {
@@ -11948,7 +12008,7 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11948
12008
  return tx;
11949
12009
  }
11950
12010
  async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRef, newMintingFeeRatio, newRedemptionFeeRatio, sysParams, lucid) {
11951
- const stableswapScriptRefUtxo = matchSingle7(
12011
+ const stableswapScriptRefUtxo = matchSingle8(
11952
12012
  await lucid.utxosByOutRef([
11953
12013
  fromSystemParamsScriptRef(
11954
12014
  sysParams.scriptReferences.stableswapValidatorRef
@@ -11956,17 +12016,17 @@ async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRe
11956
12016
  ]),
11957
12017
  (_) => new Error("Expected a single Stableswap Ref Script UTXO")
11958
12018
  );
11959
- const cdpScriptRefUtxo = matchSingle7(
12019
+ const cdpScriptRefUtxo = matchSingle8(
11960
12020
  await lucid.utxosByOutRef([
11961
12021
  fromSystemParamsScriptRef(sysParams.scriptReferences.cdpValidatorRef)
11962
12022
  ]),
11963
12023
  (_) => new Error("Expected a single CDP Ref Script UTXO")
11964
12024
  );
11965
- const stableswapPool = matchSingle7(
12025
+ const stableswapPool = matchSingle8(
11966
12026
  await lucid.utxosByOutRef([stableswapPoolOutRef]),
11967
12027
  (_) => new Error("Expected a single Stableswap Pool UTXO.")
11968
12028
  );
11969
- const stableswapFeeUtxo = matchSingle7(
12029
+ const stableswapFeeUtxo = matchSingle8(
11970
12030
  await lucid.utxosByOutRef([stableswapFeeOutRef]),
11971
12031
  (_) => new Error("Expected a single Stableswap Fee UTXO.")
11972
12032
  );
@@ -11999,7 +12059,7 @@ async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRe
11999
12059
  value: serialiseStableswapPoolDatum(newStableswapPoolDatum)
12000
12060
  },
12001
12061
  stableswapPool.assets
12002
- ).addSignerKey(toHex20(stableswapPoolDatum.feeManager)).setMinFee(1038402n);
12062
+ ).addSignerKey(toHex21(stableswapPoolDatum.feeManager)).setMinFee(1038402n);
12003
12063
  }
12004
12064
  export {
12005
12065
  AccountContentSchema,
@@ -12113,6 +12173,7 @@ export {
12113
12173
  collectInterestTx,
12114
12174
  collectPriceFeedIds,
12115
12175
  collectorFeeTx,
12176
+ computeEffectiveCdpState,
12116
12177
  createDestinationDatum,
12117
12178
  createE2s2sSnapshots,
12118
12179
  createProcessRequestAccountRedeemer,
@@ -12140,6 +12201,7 @@ export {
12140
12201
  feedPriceOracleTx,
12141
12202
  findAdminInterestCollectors,
12142
12203
  findAllInterestCollectors,
12204
+ findAllStableswapPools,
12143
12205
  findAllTreasuryUtxos,
12144
12206
  findAllTreasuryUtxosWithNonAdaAsset,
12145
12207
  findCollateralAsset,
@@ -12154,6 +12216,7 @@ export {
12154
12216
  findRelevantE2s2sIdxs,
12155
12217
  findStabilityPool,
12156
12218
  findStabilityPoolAccount,
12219
+ findStableswapPool,
12157
12220
  findStakingManager,
12158
12221
  findStakingManagerByOutRef,
12159
12222
  findStakingPositionByOutRef,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indigo-labs/indigo-sdk",
3
- "version": "0.5.14",
3
+ "version": "0.5.15",
4
4
  "description": "Indigo SDK for interacting with Indigo endpoints via lucid-evolution",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",