@indigo-labs/indigo-sdk 0.2.10 → 0.2.12
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 +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +44 -0
- package/dist/index.mjs +39 -0
- package/package.json +1 -1
- package/src/contracts/stability-pool/transactions.ts +49 -1
- package/src/contracts/staking/helpers.ts +5 -2
- package/src/index.ts +1 -0
- package/src/utils/lucid-utils.ts +3 -1
- package/tests/stability-pool.test.ts +154 -0
package/dist/index.d.mts
CHANGED
|
@@ -1153,6 +1153,7 @@ declare function createSpAccount(asset: string, amount: bigint, params: SystemPa
|
|
|
1153
1153
|
declare function adjustSpAccount(asset: string, amount: bigint, accountUtxo: UTxO, params: SystemParams, lucid: LucidEvolution): Promise<TxBuilder>;
|
|
1154
1154
|
declare function closeSpAccount(accountUtxo: UTxO, params: SystemParams, lucid: LucidEvolution): Promise<TxBuilder>;
|
|
1155
1155
|
declare function processSpRequest(asset: string, stabilityPoolUtxo: UTxO, accountUtxo: UTxO, govUtxo: UTxO, iAssetUtxo: UTxO, newSnapshotUtxo: UTxO | undefined, params: SystemParams, lucid: LucidEvolution, collectorOref: OutRef): Promise<TxBuilder>;
|
|
1156
|
+
declare function annulRequest(accountUtxo: UTxO, params: SystemParams, lucid: LucidEvolution): Promise<TxBuilder>;
|
|
1156
1157
|
|
|
1157
1158
|
declare const SPIntegerSchema: Core.TSchema.Struct<{
|
|
1158
1159
|
value: Core.TSchema.Integer;
|
|
@@ -1612,6 +1613,14 @@ declare function feedInterestOracle(params: InterestOracleParams, newInterestRat
|
|
|
1612
1613
|
|
|
1613
1614
|
declare function mkInterestOracleValidator(params: InterestOracleParams): SpendingValidator;
|
|
1614
1615
|
|
|
1616
|
+
declare function calculateUnitaryInterest(timePeriod: bigint, interestRate: bigint): bigint;
|
|
1617
|
+
declare function calculateUnitaryInterestSinceOracleLastUpdated(now: bigint, oracleDatum: InterestOracleDatum): bigint;
|
|
1618
|
+
declare function calculateAccruedInterest(now: bigint, unitaryInterestSnapshot: bigint, mintedAmount: bigint, interestLastSettled: bigint, interestOracleDatum: InterestOracleDatum): bigint;
|
|
1619
|
+
/**
|
|
1620
|
+
* Calculate the amount of interest needed to achieve 100% collateral ratio.
|
|
1621
|
+
*/
|
|
1622
|
+
declare function computeInterestLovelacesFor100PercentCR(collateral: bigint, mintedAmt: bigint, price: OnChainDecimal): bigint;
|
|
1623
|
+
|
|
1615
1624
|
declare const VersionRecordTokenParamsSchema: _lucid_evolution_lucid.TObject<{
|
|
1616
1625
|
upgradeToken: _lucid_evolution_lucid.TObject<{
|
|
1617
1626
|
currencySymbol: _lucid_evolution_lucid.TUnsafe<string>;
|
|
@@ -2211,4 +2220,4 @@ declare function calculateCollateralRatioFromLeverage(iasset: string, leverage:
|
|
|
2211
2220
|
*/
|
|
2212
2221
|
declare function calculateLeverageFromCollateralRatio(iasset: string, collateralRatioPercentage: OnChainDecimal, baseCollateral: bigint, iassetPrice: OnChainDecimal, debtMintingFeePercentage: OnChainDecimal, redemptionReimbursementPercentage: OnChainDecimal, lrpParams: LrpParamsSP, allLrps: [UTxO, LRPDatum][]): number | undefined;
|
|
2213
2222
|
|
|
2214
|
-
export { type AccountAction, type AccountContent, AccountContentSchema, ActionReturnDatum, ActionReturnDatumSchema, type AddressCredential, type AddressCredentialOrDatum, AddressD, type AddressSP, AddressSchema, type Amount, type AssetClass, type AssetClassSP, AssetClassSchema, type AuthTokenPolicies, type CDPContent, CDPContentSchema, CDPCreatorParams, type CDPCreatorParamsSP, CDPCreatorRedeemer, type CDPDatum, CDPDatumSchema, type CDPFees, CDPFeesSchema, type CDPRedeemer, type CdpParams, type CdpParamsSP, type CollectorParamsSP, CredentialD, CredentialSchema, type CurrencySymbol, type DistributionParams, type EpochToScaleToSum, EpochToScaleToSumSchema, ExecuteDatum, ExecuteParams, type ExecuteParamsSP, type FeedInterestOracleRedeemer, FeedInterestOracleRedeemerSchema, type GovDatum, GovParams, type GovParamsSP, GovRedeemer, type IAssetContent, IAssetContentSchema, type IAssetOutput, IAssetPriceInfoSchema, type Input, type InterestOracleDatum, InterestOracleDatumSchema, type InterestOracleParams, InterestOracleParamsSchema, type LRPDatum, LRPDatumSchema, type LRPParams, LRPParamsSchema, type LRPRedeemer, LRPRedeemerSchema, type LrpOutput, type LrpParamsSP, MAX_REDEMPTIONS_WITH_CDP_OPEN, MIN_LRP_COLLATERAL_AMT, ONE_DAY, ONE_HOUR, ONE_SECOND, ONE_YEAR, type OracleAssetNft, OracleAssetNftSchema, type Output, type OutputReference, OutputReferenceSchema, PollManagerParams, type PollManagerParamsSP, PollManagerRedeemer, PollShardParams, type PollShardParamsSP, PollShardRedeemer, type PriceOracleDatum, PriceOracleDatumSchema, type PriceOracleParams, PriceOracleParamsSchema, type PriceOracleRedeemer, type PubKeyHash, 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 StabilityPoolSnapshot, StakeCredentialSchema, type StakingManager, type StakingManagerOutput, type StakingParamsSP, type StakingPosLockedAmt, type StakingPosition, type StakingPositionOutput, type StakingRedeemer, type StartTime, type SystemParams, type TokenName, type TreasuryParamsSP, type TreasuryWithdrawal, type TreasuryWithdrawalItem, TreasuryWithdrawalSchema, type ValidatorHashes, VerificationKeyHashSchema, type VersionRecordParams, VersionRecordTokenParams, type VoteOption, addrDetails, addressFromBech32, addressToBech32, adjust, adjustLrp, adjustSpAccount, adjustStakingPosition, adjustmentHelper, approximateLeverageRedemptions, assetClassToUnit, assetClassValueOf, balance, buildRedemptionsTx, burnCdp, calculateAdaReward, calculateCollateralRatioFromLeverage, calculateIAssetRedemptionAmt, calculateLeverageFromCollateralRatio, calculateMinCollateralCappedIAssetRedemptionAmt, calculateTotalAdaForRedemption, cancelLrp, castCDPCreatorParams, castCdpParams, castExecuteParams, castGovParams, castInterestOracleParams, castLrpParams, castPollManagerParams, castPollShardParams, castPriceOracleParams, castStabilityPoolParams, castStakingParams, castVersionRecordTokenParams, cdpCollateralRatioPercentage, claimLrp, closeCdp, closeSpAccount, closeStakingPosition, collectorFeeTx, createProposal, createScriptAddress, createShardsChunks, createSpAccount, depositCdp, distributeAda, distributeReward, endProposal, executeProposal, feedInterestOracle, findStakingManager, findStakingManagerByOutRef, findStakingPositionByOutRef, freezeCdp, fromSPInteger, fromSysParamsScriptCredential, fromSystemParamsAsset, fromSystemParamsScriptRef, getAccountFund, getAccountReward, getInlineDatumOrThrow, getRandomElement, getSumFromEpochToScaleToSum, initEpochToScaleToSumMap, initSpSnapshot, insertSorted, isAssetsZero, leverageCdpWithLrp, liquidateCdp, liquidationHelper, loadSystemParamsFromFile, loadSystemParamsFromUrl, lovelacesAmt, lrpRedeemableLovelacesInclReimb, matchSingle, mergeCdps, mergeShards, mintCdp, mkAssetsOf, mkCDPCreatorValidator, mkCDPCreatorValidatorFromSP, mkCdpValidatorFromSP, mkCollectorValidatorFromSP, mkExecuteValidator, mkExecuteValidatorFromSP, mkInterestOracleValidator, mkLovelacesOf, mkLrpValidator, mkLrpValidatorFromSP, mkPollManagerValidator, mkPollManagerValidatorFromSP, mkPollShardValidator, mkPollShardValidatorFromSP, mkSPInteger, mkTreasuryValidatorFromSP, mkVersionRecordTokenPolicy, mkVersionRegistryValidator, negateAssets, oneShotMintTx, openCdp, openLrp, openStakingPosition, parseAccountDatum, parseCdpDatum, parseCdpDatumOrThrow, parseExecuteDatum, parseExecuteDatumOrThrow, parseGovDatum, parseGovDatumOrThrow, parseIAssetDatum, parseIAssetDatumOrThrow, parseInterestOracleDatum, parseLrpDatum, parseLrpDatumOrThrow, parsePriceOracleDatum, parseSnapshotEpochToScaleToSumDatum, parseStabilityPoolDatum, parseStakingManagerDatum, parseStakingPosition, parseStakingPositionOrThrow, processSpRequest, randomLrpsSubsetSatisfyingTargetLovelaces, redeemCdp, redeemLrp, rewardSnapshotPrecision, runCreateScriptRefTx, runOneShotMintTx, scriptRef, serialiseCDPCreatorDatum, serialiseCDPCreatorRedeemer, serialiseCdpDatum, serialiseCdpRedeemer, serialiseExecuteDatum, serialiseFeedInterestOracleRedeemer, serialiseGovDatum, serialiseGovRedeemer, serialiseIAssetDatum, serialiseInterestOracleDatum, serialiseLrpDatum, serialiseLrpRedeemer, serialisePollManagerRedeemer, serialisePollShardRedeemer, serialisePriceOracleDatum, serialisePriceOracleRedeemer, serialiseStabilityPoolDatum, serialiseStabilityPoolRedeemer, serialiseStakingDatum, serialiseStakingRedeemer, setSumInEpochToScaleToSum, shuffle, spAdd, spDiv, spMul, spSub, startInterestOracle, summarizeActualLeverageRedemptions, toSystemParamsAsset, treasuryFeeTx, updatePoolSnapshotWithdrawalFee, updateStakingLockedAmount, vote, withdrawCdp };
|
|
2223
|
+
export { type AccountAction, type AccountContent, AccountContentSchema, ActionReturnDatum, ActionReturnDatumSchema, type AddressCredential, type AddressCredentialOrDatum, AddressD, type AddressSP, AddressSchema, type Amount, type AssetClass, type AssetClassSP, AssetClassSchema, type AuthTokenPolicies, type CDPContent, CDPContentSchema, CDPCreatorParams, type CDPCreatorParamsSP, CDPCreatorRedeemer, type CDPDatum, CDPDatumSchema, type CDPFees, CDPFeesSchema, type CDPRedeemer, type CdpParams, type CdpParamsSP, type CollectorParamsSP, CredentialD, CredentialSchema, type CurrencySymbol, type DistributionParams, type EpochToScaleToSum, EpochToScaleToSumSchema, ExecuteDatum, ExecuteParams, type ExecuteParamsSP, type FeedInterestOracleRedeemer, FeedInterestOracleRedeemerSchema, type GovDatum, GovParams, type GovParamsSP, GovRedeemer, type IAssetContent, IAssetContentSchema, type IAssetOutput, IAssetPriceInfoSchema, type Input, type InterestOracleDatum, InterestOracleDatumSchema, type InterestOracleParams, InterestOracleParamsSchema, type LRPDatum, LRPDatumSchema, type LRPParams, LRPParamsSchema, type LRPRedeemer, LRPRedeemerSchema, type LrpOutput, type LrpParamsSP, MAX_REDEMPTIONS_WITH_CDP_OPEN, MIN_LRP_COLLATERAL_AMT, ONE_DAY, ONE_HOUR, ONE_SECOND, ONE_YEAR, type OracleAssetNft, OracleAssetNftSchema, type Output, type OutputReference, OutputReferenceSchema, PollManagerParams, type PollManagerParamsSP, PollManagerRedeemer, PollShardParams, type PollShardParamsSP, PollShardRedeemer, type PriceOracleDatum, PriceOracleDatumSchema, type PriceOracleParams, PriceOracleParamsSchema, type PriceOracleRedeemer, type PubKeyHash, 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 StabilityPoolSnapshot, StakeCredentialSchema, type StakingManager, type StakingManagerOutput, type StakingParamsSP, type StakingPosLockedAmt, type StakingPosition, type StakingPositionOutput, type StakingRedeemer, type StartTime, type SystemParams, type TokenName, type TreasuryParamsSP, type TreasuryWithdrawal, type TreasuryWithdrawalItem, TreasuryWithdrawalSchema, type ValidatorHashes, VerificationKeyHashSchema, type VersionRecordParams, VersionRecordTokenParams, type VoteOption, addrDetails, addressFromBech32, addressToBech32, adjust, adjustLrp, adjustSpAccount, adjustStakingPosition, adjustmentHelper, annulRequest, approximateLeverageRedemptions, assetClassToUnit, assetClassValueOf, balance, buildRedemptionsTx, burnCdp, calculateAccruedInterest, calculateAdaReward, calculateCollateralRatioFromLeverage, calculateIAssetRedemptionAmt, calculateLeverageFromCollateralRatio, calculateMinCollateralCappedIAssetRedemptionAmt, calculateTotalAdaForRedemption, calculateUnitaryInterest, calculateUnitaryInterestSinceOracleLastUpdated, cancelLrp, castCDPCreatorParams, castCdpParams, castExecuteParams, castGovParams, castInterestOracleParams, castLrpParams, castPollManagerParams, castPollShardParams, castPriceOracleParams, castStabilityPoolParams, castStakingParams, castVersionRecordTokenParams, cdpCollateralRatioPercentage, claimLrp, closeCdp, closeSpAccount, closeStakingPosition, collectorFeeTx, computeInterestLovelacesFor100PercentCR, createProposal, createScriptAddress, createShardsChunks, createSpAccount, depositCdp, distributeAda, distributeReward, endProposal, executeProposal, feedInterestOracle, findStakingManager, findStakingManagerByOutRef, findStakingPositionByOutRef, freezeCdp, fromSPInteger, fromSysParamsScriptCredential, fromSystemParamsAsset, fromSystemParamsScriptRef, getAccountFund, getAccountReward, getInlineDatumOrThrow, getRandomElement, getSumFromEpochToScaleToSum, initEpochToScaleToSumMap, initSpSnapshot, insertSorted, isAssetsZero, leverageCdpWithLrp, liquidateCdp, liquidationHelper, loadSystemParamsFromFile, loadSystemParamsFromUrl, lovelacesAmt, lrpRedeemableLovelacesInclReimb, matchSingle, mergeCdps, mergeShards, mintCdp, mkAssetsOf, mkCDPCreatorValidator, mkCDPCreatorValidatorFromSP, mkCdpValidatorFromSP, mkCollectorValidatorFromSP, mkExecuteValidator, mkExecuteValidatorFromSP, mkInterestOracleValidator, mkLovelacesOf, mkLrpValidator, mkLrpValidatorFromSP, mkPollManagerValidator, mkPollManagerValidatorFromSP, mkPollShardValidator, mkPollShardValidatorFromSP, mkSPInteger, mkTreasuryValidatorFromSP, mkVersionRecordTokenPolicy, mkVersionRegistryValidator, negateAssets, oneShotMintTx, openCdp, openLrp, openStakingPosition, parseAccountDatum, parseCdpDatum, parseCdpDatumOrThrow, parseExecuteDatum, parseExecuteDatumOrThrow, parseGovDatum, parseGovDatumOrThrow, parseIAssetDatum, parseIAssetDatumOrThrow, parseInterestOracleDatum, parseLrpDatum, parseLrpDatumOrThrow, parsePriceOracleDatum, parseSnapshotEpochToScaleToSumDatum, parseStabilityPoolDatum, parseStakingManagerDatum, parseStakingPosition, parseStakingPositionOrThrow, processSpRequest, randomLrpsSubsetSatisfyingTargetLovelaces, redeemCdp, redeemLrp, rewardSnapshotPrecision, runCreateScriptRefTx, runOneShotMintTx, scriptRef, serialiseCDPCreatorDatum, serialiseCDPCreatorRedeemer, serialiseCdpDatum, serialiseCdpRedeemer, serialiseExecuteDatum, serialiseFeedInterestOracleRedeemer, serialiseGovDatum, serialiseGovRedeemer, serialiseIAssetDatum, serialiseInterestOracleDatum, serialiseLrpDatum, serialiseLrpRedeemer, serialisePollManagerRedeemer, serialisePollShardRedeemer, serialisePriceOracleDatum, serialisePriceOracleRedeemer, serialiseStabilityPoolDatum, serialiseStabilityPoolRedeemer, serialiseStakingDatum, serialiseStakingRedeemer, setSumInEpochToScaleToSum, shuffle, spAdd, spDiv, spMul, spSub, startInterestOracle, summarizeActualLeverageRedemptions, toSystemParamsAsset, treasuryFeeTx, updatePoolSnapshotWithdrawalFee, updateStakingLockedAmount, vote, withdrawCdp };
|
package/dist/index.d.ts
CHANGED
|
@@ -1153,6 +1153,7 @@ declare function createSpAccount(asset: string, amount: bigint, params: SystemPa
|
|
|
1153
1153
|
declare function adjustSpAccount(asset: string, amount: bigint, accountUtxo: UTxO, params: SystemParams, lucid: LucidEvolution): Promise<TxBuilder>;
|
|
1154
1154
|
declare function closeSpAccount(accountUtxo: UTxO, params: SystemParams, lucid: LucidEvolution): Promise<TxBuilder>;
|
|
1155
1155
|
declare function processSpRequest(asset: string, stabilityPoolUtxo: UTxO, accountUtxo: UTxO, govUtxo: UTxO, iAssetUtxo: UTxO, newSnapshotUtxo: UTxO | undefined, params: SystemParams, lucid: LucidEvolution, collectorOref: OutRef): Promise<TxBuilder>;
|
|
1156
|
+
declare function annulRequest(accountUtxo: UTxO, params: SystemParams, lucid: LucidEvolution): Promise<TxBuilder>;
|
|
1156
1157
|
|
|
1157
1158
|
declare const SPIntegerSchema: Core.TSchema.Struct<{
|
|
1158
1159
|
value: Core.TSchema.Integer;
|
|
@@ -1612,6 +1613,14 @@ declare function feedInterestOracle(params: InterestOracleParams, newInterestRat
|
|
|
1612
1613
|
|
|
1613
1614
|
declare function mkInterestOracleValidator(params: InterestOracleParams): SpendingValidator;
|
|
1614
1615
|
|
|
1616
|
+
declare function calculateUnitaryInterest(timePeriod: bigint, interestRate: bigint): bigint;
|
|
1617
|
+
declare function calculateUnitaryInterestSinceOracleLastUpdated(now: bigint, oracleDatum: InterestOracleDatum): bigint;
|
|
1618
|
+
declare function calculateAccruedInterest(now: bigint, unitaryInterestSnapshot: bigint, mintedAmount: bigint, interestLastSettled: bigint, interestOracleDatum: InterestOracleDatum): bigint;
|
|
1619
|
+
/**
|
|
1620
|
+
* Calculate the amount of interest needed to achieve 100% collateral ratio.
|
|
1621
|
+
*/
|
|
1622
|
+
declare function computeInterestLovelacesFor100PercentCR(collateral: bigint, mintedAmt: bigint, price: OnChainDecimal): bigint;
|
|
1623
|
+
|
|
1615
1624
|
declare const VersionRecordTokenParamsSchema: _lucid_evolution_lucid.TObject<{
|
|
1616
1625
|
upgradeToken: _lucid_evolution_lucid.TObject<{
|
|
1617
1626
|
currencySymbol: _lucid_evolution_lucid.TUnsafe<string>;
|
|
@@ -2211,4 +2220,4 @@ declare function calculateCollateralRatioFromLeverage(iasset: string, leverage:
|
|
|
2211
2220
|
*/
|
|
2212
2221
|
declare function calculateLeverageFromCollateralRatio(iasset: string, collateralRatioPercentage: OnChainDecimal, baseCollateral: bigint, iassetPrice: OnChainDecimal, debtMintingFeePercentage: OnChainDecimal, redemptionReimbursementPercentage: OnChainDecimal, lrpParams: LrpParamsSP, allLrps: [UTxO, LRPDatum][]): number | undefined;
|
|
2213
2222
|
|
|
2214
|
-
export { type AccountAction, type AccountContent, AccountContentSchema, ActionReturnDatum, ActionReturnDatumSchema, type AddressCredential, type AddressCredentialOrDatum, AddressD, type AddressSP, AddressSchema, type Amount, type AssetClass, type AssetClassSP, AssetClassSchema, type AuthTokenPolicies, type CDPContent, CDPContentSchema, CDPCreatorParams, type CDPCreatorParamsSP, CDPCreatorRedeemer, type CDPDatum, CDPDatumSchema, type CDPFees, CDPFeesSchema, type CDPRedeemer, type CdpParams, type CdpParamsSP, type CollectorParamsSP, CredentialD, CredentialSchema, type CurrencySymbol, type DistributionParams, type EpochToScaleToSum, EpochToScaleToSumSchema, ExecuteDatum, ExecuteParams, type ExecuteParamsSP, type FeedInterestOracleRedeemer, FeedInterestOracleRedeemerSchema, type GovDatum, GovParams, type GovParamsSP, GovRedeemer, type IAssetContent, IAssetContentSchema, type IAssetOutput, IAssetPriceInfoSchema, type Input, type InterestOracleDatum, InterestOracleDatumSchema, type InterestOracleParams, InterestOracleParamsSchema, type LRPDatum, LRPDatumSchema, type LRPParams, LRPParamsSchema, type LRPRedeemer, LRPRedeemerSchema, type LrpOutput, type LrpParamsSP, MAX_REDEMPTIONS_WITH_CDP_OPEN, MIN_LRP_COLLATERAL_AMT, ONE_DAY, ONE_HOUR, ONE_SECOND, ONE_YEAR, type OracleAssetNft, OracleAssetNftSchema, type Output, type OutputReference, OutputReferenceSchema, PollManagerParams, type PollManagerParamsSP, PollManagerRedeemer, PollShardParams, type PollShardParamsSP, PollShardRedeemer, type PriceOracleDatum, PriceOracleDatumSchema, type PriceOracleParams, PriceOracleParamsSchema, type PriceOracleRedeemer, type PubKeyHash, 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 StabilityPoolSnapshot, StakeCredentialSchema, type StakingManager, type StakingManagerOutput, type StakingParamsSP, type StakingPosLockedAmt, type StakingPosition, type StakingPositionOutput, type StakingRedeemer, type StartTime, type SystemParams, type TokenName, type TreasuryParamsSP, type TreasuryWithdrawal, type TreasuryWithdrawalItem, TreasuryWithdrawalSchema, type ValidatorHashes, VerificationKeyHashSchema, type VersionRecordParams, VersionRecordTokenParams, type VoteOption, addrDetails, addressFromBech32, addressToBech32, adjust, adjustLrp, adjustSpAccount, adjustStakingPosition, adjustmentHelper, approximateLeverageRedemptions, assetClassToUnit, assetClassValueOf, balance, buildRedemptionsTx, burnCdp, calculateAdaReward, calculateCollateralRatioFromLeverage, calculateIAssetRedemptionAmt, calculateLeverageFromCollateralRatio, calculateMinCollateralCappedIAssetRedemptionAmt, calculateTotalAdaForRedemption, cancelLrp, castCDPCreatorParams, castCdpParams, castExecuteParams, castGovParams, castInterestOracleParams, castLrpParams, castPollManagerParams, castPollShardParams, castPriceOracleParams, castStabilityPoolParams, castStakingParams, castVersionRecordTokenParams, cdpCollateralRatioPercentage, claimLrp, closeCdp, closeSpAccount, closeStakingPosition, collectorFeeTx, createProposal, createScriptAddress, createShardsChunks, createSpAccount, depositCdp, distributeAda, distributeReward, endProposal, executeProposal, feedInterestOracle, findStakingManager, findStakingManagerByOutRef, findStakingPositionByOutRef, freezeCdp, fromSPInteger, fromSysParamsScriptCredential, fromSystemParamsAsset, fromSystemParamsScriptRef, getAccountFund, getAccountReward, getInlineDatumOrThrow, getRandomElement, getSumFromEpochToScaleToSum, initEpochToScaleToSumMap, initSpSnapshot, insertSorted, isAssetsZero, leverageCdpWithLrp, liquidateCdp, liquidationHelper, loadSystemParamsFromFile, loadSystemParamsFromUrl, lovelacesAmt, lrpRedeemableLovelacesInclReimb, matchSingle, mergeCdps, mergeShards, mintCdp, mkAssetsOf, mkCDPCreatorValidator, mkCDPCreatorValidatorFromSP, mkCdpValidatorFromSP, mkCollectorValidatorFromSP, mkExecuteValidator, mkExecuteValidatorFromSP, mkInterestOracleValidator, mkLovelacesOf, mkLrpValidator, mkLrpValidatorFromSP, mkPollManagerValidator, mkPollManagerValidatorFromSP, mkPollShardValidator, mkPollShardValidatorFromSP, mkSPInteger, mkTreasuryValidatorFromSP, mkVersionRecordTokenPolicy, mkVersionRegistryValidator, negateAssets, oneShotMintTx, openCdp, openLrp, openStakingPosition, parseAccountDatum, parseCdpDatum, parseCdpDatumOrThrow, parseExecuteDatum, parseExecuteDatumOrThrow, parseGovDatum, parseGovDatumOrThrow, parseIAssetDatum, parseIAssetDatumOrThrow, parseInterestOracleDatum, parseLrpDatum, parseLrpDatumOrThrow, parsePriceOracleDatum, parseSnapshotEpochToScaleToSumDatum, parseStabilityPoolDatum, parseStakingManagerDatum, parseStakingPosition, parseStakingPositionOrThrow, processSpRequest, randomLrpsSubsetSatisfyingTargetLovelaces, redeemCdp, redeemLrp, rewardSnapshotPrecision, runCreateScriptRefTx, runOneShotMintTx, scriptRef, serialiseCDPCreatorDatum, serialiseCDPCreatorRedeemer, serialiseCdpDatum, serialiseCdpRedeemer, serialiseExecuteDatum, serialiseFeedInterestOracleRedeemer, serialiseGovDatum, serialiseGovRedeemer, serialiseIAssetDatum, serialiseInterestOracleDatum, serialiseLrpDatum, serialiseLrpRedeemer, serialisePollManagerRedeemer, serialisePollShardRedeemer, serialisePriceOracleDatum, serialisePriceOracleRedeemer, serialiseStabilityPoolDatum, serialiseStabilityPoolRedeemer, serialiseStakingDatum, serialiseStakingRedeemer, setSumInEpochToScaleToSum, shuffle, spAdd, spDiv, spMul, spSub, startInterestOracle, summarizeActualLeverageRedemptions, toSystemParamsAsset, treasuryFeeTx, updatePoolSnapshotWithdrawalFee, updateStakingLockedAmount, vote, withdrawCdp };
|
|
2223
|
+
export { type AccountAction, type AccountContent, AccountContentSchema, ActionReturnDatum, ActionReturnDatumSchema, type AddressCredential, type AddressCredentialOrDatum, AddressD, type AddressSP, AddressSchema, type Amount, type AssetClass, type AssetClassSP, AssetClassSchema, type AuthTokenPolicies, type CDPContent, CDPContentSchema, CDPCreatorParams, type CDPCreatorParamsSP, CDPCreatorRedeemer, type CDPDatum, CDPDatumSchema, type CDPFees, CDPFeesSchema, type CDPRedeemer, type CdpParams, type CdpParamsSP, type CollectorParamsSP, CredentialD, CredentialSchema, type CurrencySymbol, type DistributionParams, type EpochToScaleToSum, EpochToScaleToSumSchema, ExecuteDatum, ExecuteParams, type ExecuteParamsSP, type FeedInterestOracleRedeemer, FeedInterestOracleRedeemerSchema, type GovDatum, GovParams, type GovParamsSP, GovRedeemer, type IAssetContent, IAssetContentSchema, type IAssetOutput, IAssetPriceInfoSchema, type Input, type InterestOracleDatum, InterestOracleDatumSchema, type InterestOracleParams, InterestOracleParamsSchema, type LRPDatum, LRPDatumSchema, type LRPParams, LRPParamsSchema, type LRPRedeemer, LRPRedeemerSchema, type LrpOutput, type LrpParamsSP, MAX_REDEMPTIONS_WITH_CDP_OPEN, MIN_LRP_COLLATERAL_AMT, ONE_DAY, ONE_HOUR, ONE_SECOND, ONE_YEAR, type OracleAssetNft, OracleAssetNftSchema, type Output, type OutputReference, OutputReferenceSchema, PollManagerParams, type PollManagerParamsSP, PollManagerRedeemer, PollShardParams, type PollShardParamsSP, PollShardRedeemer, type PriceOracleDatum, PriceOracleDatumSchema, type PriceOracleParams, PriceOracleParamsSchema, type PriceOracleRedeemer, type PubKeyHash, 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 StabilityPoolSnapshot, StakeCredentialSchema, type StakingManager, type StakingManagerOutput, type StakingParamsSP, type StakingPosLockedAmt, type StakingPosition, type StakingPositionOutput, type StakingRedeemer, type StartTime, type SystemParams, type TokenName, type TreasuryParamsSP, type TreasuryWithdrawal, type TreasuryWithdrawalItem, TreasuryWithdrawalSchema, type ValidatorHashes, VerificationKeyHashSchema, type VersionRecordParams, VersionRecordTokenParams, type VoteOption, addrDetails, addressFromBech32, addressToBech32, adjust, adjustLrp, adjustSpAccount, adjustStakingPosition, adjustmentHelper, annulRequest, approximateLeverageRedemptions, assetClassToUnit, assetClassValueOf, balance, buildRedemptionsTx, burnCdp, calculateAccruedInterest, calculateAdaReward, calculateCollateralRatioFromLeverage, calculateIAssetRedemptionAmt, calculateLeverageFromCollateralRatio, calculateMinCollateralCappedIAssetRedemptionAmt, calculateTotalAdaForRedemption, calculateUnitaryInterest, calculateUnitaryInterestSinceOracleLastUpdated, cancelLrp, castCDPCreatorParams, castCdpParams, castExecuteParams, castGovParams, castInterestOracleParams, castLrpParams, castPollManagerParams, castPollShardParams, castPriceOracleParams, castStabilityPoolParams, castStakingParams, castVersionRecordTokenParams, cdpCollateralRatioPercentage, claimLrp, closeCdp, closeSpAccount, closeStakingPosition, collectorFeeTx, computeInterestLovelacesFor100PercentCR, createProposal, createScriptAddress, createShardsChunks, createSpAccount, depositCdp, distributeAda, distributeReward, endProposal, executeProposal, feedInterestOracle, findStakingManager, findStakingManagerByOutRef, findStakingPositionByOutRef, freezeCdp, fromSPInteger, fromSysParamsScriptCredential, fromSystemParamsAsset, fromSystemParamsScriptRef, getAccountFund, getAccountReward, getInlineDatumOrThrow, getRandomElement, getSumFromEpochToScaleToSum, initEpochToScaleToSumMap, initSpSnapshot, insertSorted, isAssetsZero, leverageCdpWithLrp, liquidateCdp, liquidationHelper, loadSystemParamsFromFile, loadSystemParamsFromUrl, lovelacesAmt, lrpRedeemableLovelacesInclReimb, matchSingle, mergeCdps, mergeShards, mintCdp, mkAssetsOf, mkCDPCreatorValidator, mkCDPCreatorValidatorFromSP, mkCdpValidatorFromSP, mkCollectorValidatorFromSP, mkExecuteValidator, mkExecuteValidatorFromSP, mkInterestOracleValidator, mkLovelacesOf, mkLrpValidator, mkLrpValidatorFromSP, mkPollManagerValidator, mkPollManagerValidatorFromSP, mkPollShardValidator, mkPollShardValidatorFromSP, mkSPInteger, mkTreasuryValidatorFromSP, mkVersionRecordTokenPolicy, mkVersionRegistryValidator, negateAssets, oneShotMintTx, openCdp, openLrp, openStakingPosition, parseAccountDatum, parseCdpDatum, parseCdpDatumOrThrow, parseExecuteDatum, parseExecuteDatumOrThrow, parseGovDatum, parseGovDatumOrThrow, parseIAssetDatum, parseIAssetDatumOrThrow, parseInterestOracleDatum, parseLrpDatum, parseLrpDatumOrThrow, parsePriceOracleDatum, parseSnapshotEpochToScaleToSumDatum, parseStabilityPoolDatum, parseStakingManagerDatum, parseStakingPosition, parseStakingPositionOrThrow, processSpRequest, randomLrpsSubsetSatisfyingTargetLovelaces, redeemCdp, redeemLrp, rewardSnapshotPrecision, runCreateScriptRefTx, runOneShotMintTx, scriptRef, serialiseCDPCreatorDatum, serialiseCDPCreatorRedeemer, serialiseCdpDatum, serialiseCdpRedeemer, serialiseExecuteDatum, serialiseFeedInterestOracleRedeemer, serialiseGovDatum, serialiseGovRedeemer, serialiseIAssetDatum, serialiseInterestOracleDatum, serialiseLrpDatum, serialiseLrpRedeemer, serialisePollManagerRedeemer, serialisePollShardRedeemer, serialisePriceOracleDatum, serialisePriceOracleRedeemer, serialiseStabilityPoolDatum, serialiseStabilityPoolRedeemer, serialiseStakingDatum, serialiseStakingRedeemer, setSumInEpochToScaleToSum, shuffle, spAdd, spDiv, spMul, spSub, startInterestOracle, summarizeActualLeverageRedemptions, toSystemParamsAsset, treasuryFeeTx, updatePoolSnapshotWithdrawalFee, updateStakingLockedAmount, vote, withdrawCdp };
|
package/dist/index.js
CHANGED
|
@@ -88,18 +88,22 @@ __export(index_exports, {
|
|
|
88
88
|
adjustSpAccount: () => adjustSpAccount,
|
|
89
89
|
adjustStakingPosition: () => adjustStakingPosition,
|
|
90
90
|
adjustmentHelper: () => adjustmentHelper,
|
|
91
|
+
annulRequest: () => annulRequest,
|
|
91
92
|
approximateLeverageRedemptions: () => approximateLeverageRedemptions,
|
|
92
93
|
assetClassToUnit: () => assetClassToUnit,
|
|
93
94
|
assetClassValueOf: () => assetClassValueOf,
|
|
94
95
|
balance: () => balance,
|
|
95
96
|
buildRedemptionsTx: () => buildRedemptionsTx,
|
|
96
97
|
burnCdp: () => burnCdp,
|
|
98
|
+
calculateAccruedInterest: () => calculateAccruedInterest,
|
|
97
99
|
calculateAdaReward: () => calculateAdaReward,
|
|
98
100
|
calculateCollateralRatioFromLeverage: () => calculateCollateralRatioFromLeverage,
|
|
99
101
|
calculateIAssetRedemptionAmt: () => calculateIAssetRedemptionAmt,
|
|
100
102
|
calculateLeverageFromCollateralRatio: () => calculateLeverageFromCollateralRatio,
|
|
101
103
|
calculateMinCollateralCappedIAssetRedemptionAmt: () => calculateMinCollateralCappedIAssetRedemptionAmt,
|
|
102
104
|
calculateTotalAdaForRedemption: () => calculateTotalAdaForRedemption,
|
|
105
|
+
calculateUnitaryInterest: () => calculateUnitaryInterest,
|
|
106
|
+
calculateUnitaryInterestSinceOracleLastUpdated: () => calculateUnitaryInterestSinceOracleLastUpdated,
|
|
103
107
|
cancelLrp: () => cancelLrp,
|
|
104
108
|
castCDPCreatorParams: () => castCDPCreatorParams,
|
|
105
109
|
castCdpParams: () => castCdpParams,
|
|
@@ -119,6 +123,7 @@ __export(index_exports, {
|
|
|
119
123
|
closeSpAccount: () => closeSpAccount,
|
|
120
124
|
closeStakingPosition: () => closeStakingPosition,
|
|
121
125
|
collectorFeeTx: () => collectorFeeTx,
|
|
126
|
+
computeInterestLovelacesFor100PercentCR: () => computeInterestLovelacesFor100PercentCR,
|
|
122
127
|
createProposal: () => createProposal,
|
|
123
128
|
createScriptAddress: () => createScriptAddress,
|
|
124
129
|
createShardsChunks: () => createShardsChunks,
|
|
@@ -4726,6 +4731,40 @@ async function processSpRequest(asset, stabilityPoolUtxo, accountUtxo, govUtxo,
|
|
|
4726
4731
|
}
|
|
4727
4732
|
return tx;
|
|
4728
4733
|
}
|
|
4734
|
+
async function annulRequest(accountUtxo, params, lucid) {
|
|
4735
|
+
const stabilityPoolScriptRef = await scriptRef(
|
|
4736
|
+
params.scriptReferences.stabilityPoolValidatorRef,
|
|
4737
|
+
lucid
|
|
4738
|
+
);
|
|
4739
|
+
const oldAccountDatum = parseAccountDatum(
|
|
4740
|
+
getInlineDatumOrThrow(accountUtxo)
|
|
4741
|
+
);
|
|
4742
|
+
const tx = lucid.newTx().readFrom([stabilityPoolScriptRef]).collectFrom([accountUtxo], serialiseStabilityPoolRedeemer("AnnulRequest")).addSignerKey((0, import_lucid34.toHex)(oldAccountDatum.owner));
|
|
4743
|
+
if (oldAccountDatum.request !== "Create") {
|
|
4744
|
+
tx.pay.ToContract(
|
|
4745
|
+
(0, import_lucid34.credentialToAddress)(lucid.config().network, {
|
|
4746
|
+
hash: (0, import_lucid34.validatorToScriptHash)(
|
|
4747
|
+
mkStabilityPoolValidatorFromSP(params.stabilityPoolParams)
|
|
4748
|
+
),
|
|
4749
|
+
type: "Script"
|
|
4750
|
+
}),
|
|
4751
|
+
{
|
|
4752
|
+
kind: "inline",
|
|
4753
|
+
value: serialiseStabilityPoolDatum({
|
|
4754
|
+
Account: {
|
|
4755
|
+
...oldAccountDatum,
|
|
4756
|
+
request: null
|
|
4757
|
+
}
|
|
4758
|
+
})
|
|
4759
|
+
},
|
|
4760
|
+
mkAssetsOf(
|
|
4761
|
+
fromSystemParamsAsset(params.stabilityPoolParams.accountToken),
|
|
4762
|
+
1n
|
|
4763
|
+
)
|
|
4764
|
+
);
|
|
4765
|
+
}
|
|
4766
|
+
return tx;
|
|
4767
|
+
}
|
|
4729
4768
|
|
|
4730
4769
|
// src/contracts/staking/transactions.ts
|
|
4731
4770
|
var import_lucid35 = require("@lucid-evolution/lucid");
|
|
@@ -6158,18 +6197,22 @@ async function leverageCdpWithLrp(leverage, baseCollateral, priceOracleOutRef, i
|
|
|
6158
6197
|
adjustSpAccount,
|
|
6159
6198
|
adjustStakingPosition,
|
|
6160
6199
|
adjustmentHelper,
|
|
6200
|
+
annulRequest,
|
|
6161
6201
|
approximateLeverageRedemptions,
|
|
6162
6202
|
assetClassToUnit,
|
|
6163
6203
|
assetClassValueOf,
|
|
6164
6204
|
balance,
|
|
6165
6205
|
buildRedemptionsTx,
|
|
6166
6206
|
burnCdp,
|
|
6207
|
+
calculateAccruedInterest,
|
|
6167
6208
|
calculateAdaReward,
|
|
6168
6209
|
calculateCollateralRatioFromLeverage,
|
|
6169
6210
|
calculateIAssetRedemptionAmt,
|
|
6170
6211
|
calculateLeverageFromCollateralRatio,
|
|
6171
6212
|
calculateMinCollateralCappedIAssetRedemptionAmt,
|
|
6172
6213
|
calculateTotalAdaForRedemption,
|
|
6214
|
+
calculateUnitaryInterest,
|
|
6215
|
+
calculateUnitaryInterestSinceOracleLastUpdated,
|
|
6173
6216
|
cancelLrp,
|
|
6174
6217
|
castCDPCreatorParams,
|
|
6175
6218
|
castCdpParams,
|
|
@@ -6189,6 +6232,7 @@ async function leverageCdpWithLrp(leverage, baseCollateral, priceOracleOutRef, i
|
|
|
6189
6232
|
closeSpAccount,
|
|
6190
6233
|
closeStakingPosition,
|
|
6191
6234
|
collectorFeeTx,
|
|
6235
|
+
computeInterestLovelacesFor100PercentCR,
|
|
6192
6236
|
createProposal,
|
|
6193
6237
|
createScriptAddress,
|
|
6194
6238
|
createShardsChunks,
|
package/dist/index.mjs
CHANGED
|
@@ -4536,6 +4536,40 @@ async function processSpRequest(asset, stabilityPoolUtxo, accountUtxo, govUtxo,
|
|
|
4536
4536
|
}
|
|
4537
4537
|
return tx;
|
|
4538
4538
|
}
|
|
4539
|
+
async function annulRequest(accountUtxo, params, lucid) {
|
|
4540
|
+
const stabilityPoolScriptRef = await scriptRef(
|
|
4541
|
+
params.scriptReferences.stabilityPoolValidatorRef,
|
|
4542
|
+
lucid
|
|
4543
|
+
);
|
|
4544
|
+
const oldAccountDatum = parseAccountDatum(
|
|
4545
|
+
getInlineDatumOrThrow(accountUtxo)
|
|
4546
|
+
);
|
|
4547
|
+
const tx = lucid.newTx().readFrom([stabilityPoolScriptRef]).collectFrom([accountUtxo], serialiseStabilityPoolRedeemer("AnnulRequest")).addSignerKey(toHex(oldAccountDatum.owner));
|
|
4548
|
+
if (oldAccountDatum.request !== "Create") {
|
|
4549
|
+
tx.pay.ToContract(
|
|
4550
|
+
credentialToAddress3(lucid.config().network, {
|
|
4551
|
+
hash: validatorToScriptHash2(
|
|
4552
|
+
mkStabilityPoolValidatorFromSP(params.stabilityPoolParams)
|
|
4553
|
+
),
|
|
4554
|
+
type: "Script"
|
|
4555
|
+
}),
|
|
4556
|
+
{
|
|
4557
|
+
kind: "inline",
|
|
4558
|
+
value: serialiseStabilityPoolDatum({
|
|
4559
|
+
Account: {
|
|
4560
|
+
...oldAccountDatum,
|
|
4561
|
+
request: null
|
|
4562
|
+
}
|
|
4563
|
+
})
|
|
4564
|
+
},
|
|
4565
|
+
mkAssetsOf(
|
|
4566
|
+
fromSystemParamsAsset(params.stabilityPoolParams.accountToken),
|
|
4567
|
+
1n
|
|
4568
|
+
)
|
|
4569
|
+
);
|
|
4570
|
+
}
|
|
4571
|
+
return tx;
|
|
4572
|
+
}
|
|
4539
4573
|
|
|
4540
4574
|
// src/contracts/staking/transactions.ts
|
|
4541
4575
|
import {
|
|
@@ -6010,18 +6044,22 @@ export {
|
|
|
6010
6044
|
adjustSpAccount,
|
|
6011
6045
|
adjustStakingPosition,
|
|
6012
6046
|
adjustmentHelper,
|
|
6047
|
+
annulRequest,
|
|
6013
6048
|
approximateLeverageRedemptions,
|
|
6014
6049
|
assetClassToUnit,
|
|
6015
6050
|
assetClassValueOf,
|
|
6016
6051
|
balance,
|
|
6017
6052
|
buildRedemptionsTx,
|
|
6018
6053
|
burnCdp,
|
|
6054
|
+
calculateAccruedInterest,
|
|
6019
6055
|
calculateAdaReward,
|
|
6020
6056
|
calculateCollateralRatioFromLeverage,
|
|
6021
6057
|
calculateIAssetRedemptionAmt,
|
|
6022
6058
|
calculateLeverageFromCollateralRatio,
|
|
6023
6059
|
calculateMinCollateralCappedIAssetRedemptionAmt,
|
|
6024
6060
|
calculateTotalAdaForRedemption,
|
|
6061
|
+
calculateUnitaryInterest,
|
|
6062
|
+
calculateUnitaryInterestSinceOracleLastUpdated,
|
|
6025
6063
|
cancelLrp,
|
|
6026
6064
|
castCDPCreatorParams,
|
|
6027
6065
|
castCdpParams,
|
|
@@ -6041,6 +6079,7 @@ export {
|
|
|
6041
6079
|
closeSpAccount,
|
|
6042
6080
|
closeStakingPosition,
|
|
6043
6081
|
collectorFeeTx,
|
|
6082
|
+
computeInterestLovelacesFor100PercentCR,
|
|
6044
6083
|
createProposal,
|
|
6045
6084
|
createScriptAddress,
|
|
6046
6085
|
createShardsChunks,
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
toHex,
|
|
13
13
|
} from '@lucid-evolution/lucid';
|
|
14
14
|
import { ActionReturnDatum } from './types';
|
|
15
|
-
import { SystemParams } from '../../types/system-params';
|
|
15
|
+
import { fromSystemParamsAsset, SystemParams } from '../../types/system-params';
|
|
16
16
|
import {
|
|
17
17
|
addrDetails,
|
|
18
18
|
getInlineDatumOrThrow,
|
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
StabilityPoolSnapshot,
|
|
50
50
|
} from './types-new';
|
|
51
51
|
import { collectorFeeTx } from '../collector/transactions';
|
|
52
|
+
import { mkAssetsOf } from '../../utils/value-helpers';
|
|
52
53
|
|
|
53
54
|
export async function createSpAccount(
|
|
54
55
|
asset: string,
|
|
@@ -670,3 +671,50 @@ export async function processSpRequest(
|
|
|
670
671
|
|
|
671
672
|
return tx;
|
|
672
673
|
}
|
|
674
|
+
|
|
675
|
+
export async function annulRequest(
|
|
676
|
+
accountUtxo: UTxO,
|
|
677
|
+
params: SystemParams,
|
|
678
|
+
lucid: LucidEvolution,
|
|
679
|
+
): Promise<TxBuilder> {
|
|
680
|
+
const stabilityPoolScriptRef = await scriptRef(
|
|
681
|
+
params.scriptReferences.stabilityPoolValidatorRef,
|
|
682
|
+
lucid,
|
|
683
|
+
);
|
|
684
|
+
|
|
685
|
+
const oldAccountDatum: AccountContent = parseAccountDatum(
|
|
686
|
+
getInlineDatumOrThrow(accountUtxo),
|
|
687
|
+
);
|
|
688
|
+
|
|
689
|
+
const tx = lucid
|
|
690
|
+
.newTx()
|
|
691
|
+
.readFrom([stabilityPoolScriptRef])
|
|
692
|
+
.collectFrom([accountUtxo], serialiseStabilityPoolRedeemer('AnnulRequest'))
|
|
693
|
+
.addSignerKey(toHex(oldAccountDatum.owner));
|
|
694
|
+
|
|
695
|
+
if (oldAccountDatum.request !== 'Create') {
|
|
696
|
+
tx.pay.ToContract(
|
|
697
|
+
credentialToAddress(lucid.config().network!, {
|
|
698
|
+
hash: validatorToScriptHash(
|
|
699
|
+
mkStabilityPoolValidatorFromSP(params.stabilityPoolParams),
|
|
700
|
+
),
|
|
701
|
+
type: 'Script',
|
|
702
|
+
}),
|
|
703
|
+
{
|
|
704
|
+
kind: 'inline',
|
|
705
|
+
value: serialiseStabilityPoolDatum({
|
|
706
|
+
Account: {
|
|
707
|
+
...oldAccountDatum,
|
|
708
|
+
request: null,
|
|
709
|
+
},
|
|
710
|
+
}),
|
|
711
|
+
},
|
|
712
|
+
mkAssetsOf(
|
|
713
|
+
fromSystemParamsAsset(params.stabilityPoolParams.accountToken),
|
|
714
|
+
1n,
|
|
715
|
+
),
|
|
716
|
+
);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
return tx;
|
|
720
|
+
}
|
|
@@ -131,5 +131,8 @@ export function calculateAdaReward(
|
|
|
131
131
|
oldSnapshotAda: bigint,
|
|
132
132
|
existingIndyAmount: bigint,
|
|
133
133
|
): bigint {
|
|
134
|
-
return (
|
|
135
|
-
|
|
134
|
+
return (
|
|
135
|
+
((currentSnapshotAda - oldSnapshotAda) * existingIndyAmount) /
|
|
136
|
+
rewardSnapshotPrecision
|
|
137
|
+
);
|
|
138
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ export * from './contracts/staking/types-new';
|
|
|
17
17
|
export * from './contracts/interest-oracle/transactions';
|
|
18
18
|
export * from './contracts/interest-oracle/types';
|
|
19
19
|
export * from './contracts/interest-oracle/scripts';
|
|
20
|
+
export * from './contracts/interest-oracle/helpers';
|
|
20
21
|
export * from './contracts/version-registry/types';
|
|
21
22
|
export * from './contracts/version-registry/scripts';
|
|
22
23
|
export * from './contracts/treasury/transactions';
|
package/src/utils/lucid-utils.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { init } from './endpoints/initialize';
|
|
|
7
7
|
import {
|
|
8
8
|
addrDetails,
|
|
9
9
|
adjustSpAccount,
|
|
10
|
+
annulRequest,
|
|
10
11
|
closeSpAccount,
|
|
11
12
|
createSpAccount,
|
|
12
13
|
fromSystemParamsAsset,
|
|
@@ -396,6 +397,159 @@ test<MyContext>('Stability Pool - Adjust Account', async ({
|
|
|
396
397
|
);
|
|
397
398
|
});
|
|
398
399
|
|
|
400
|
+
test<MyContext>('Stability Pool - Annul Request', async ({
|
|
401
|
+
lucid,
|
|
402
|
+
users,
|
|
403
|
+
emulator,
|
|
404
|
+
}: MyContext) => {
|
|
405
|
+
lucid.selectWallet.fromSeed(users.admin.seedPhrase);
|
|
406
|
+
const [systemParams, [iusdInfo]] = await init(lucid, [iusdInitialAssetCfg]);
|
|
407
|
+
lucid.selectWallet.fromSeed(users.user.seedPhrase);
|
|
408
|
+
const [pkh, _] = await addrDetails(lucid);
|
|
409
|
+
|
|
410
|
+
const iasset = await findIAsset(
|
|
411
|
+
lucid,
|
|
412
|
+
systemParams.validatorHashes.cdpHash,
|
|
413
|
+
fromSystemParamsAsset(systemParams.cdpParams.iAssetAuthToken),
|
|
414
|
+
iusdInfo.iassetTokenNameAscii,
|
|
415
|
+
);
|
|
416
|
+
|
|
417
|
+
await runAndAwaitTx(
|
|
418
|
+
lucid,
|
|
419
|
+
openCdp(
|
|
420
|
+
1_000_000_000n,
|
|
421
|
+
20n,
|
|
422
|
+
systemParams,
|
|
423
|
+
await findRandomCdpCreator(
|
|
424
|
+
lucid,
|
|
425
|
+
systemParams.validatorHashes.cdpCreatorHash,
|
|
426
|
+
fromSystemParamsAsset(systemParams.cdpCreatorParams.cdpCreatorNft),
|
|
427
|
+
),
|
|
428
|
+
iasset.utxo,
|
|
429
|
+
await findPriceOracle(
|
|
430
|
+
lucid,
|
|
431
|
+
match(iasset.datum.price)
|
|
432
|
+
.with({ Oracle: { content: P.select() } }, (oracleNft) => oracleNft)
|
|
433
|
+
.otherwise(() => {
|
|
434
|
+
throw new Error('Expected active oracle');
|
|
435
|
+
}),
|
|
436
|
+
),
|
|
437
|
+
await findInterestOracle(lucid, iasset.datum.interestOracleNft),
|
|
438
|
+
await findRandomCollector(
|
|
439
|
+
lucid,
|
|
440
|
+
systemParams.validatorHashes.collectorHash,
|
|
441
|
+
),
|
|
442
|
+
lucid,
|
|
443
|
+
emulator.slot,
|
|
444
|
+
),
|
|
445
|
+
);
|
|
446
|
+
|
|
447
|
+
await runAndAwaitTx(
|
|
448
|
+
lucid,
|
|
449
|
+
createSpAccount(iusdInfo.iassetTokenNameAscii, 10n, systemParams, lucid),
|
|
450
|
+
);
|
|
451
|
+
|
|
452
|
+
lucid.selectWallet.fromSeed(users.admin.seedPhrase);
|
|
453
|
+
|
|
454
|
+
let stabilityPoolUtxo = await findStabilityPool(
|
|
455
|
+
lucid,
|
|
456
|
+
systemParams.validatorHashes.stabilityPoolHash,
|
|
457
|
+
{
|
|
458
|
+
currencySymbol:
|
|
459
|
+
systemParams.stabilityPoolParams.stabilityPoolToken[0].unCurrencySymbol,
|
|
460
|
+
tokenName: fromText(
|
|
461
|
+
systemParams.stabilityPoolParams.stabilityPoolToken[1].unTokenName,
|
|
462
|
+
),
|
|
463
|
+
},
|
|
464
|
+
iusdInfo.iassetTokenNameAscii,
|
|
465
|
+
);
|
|
466
|
+
|
|
467
|
+
let accountUtxo = await findStabilityPoolAccount(
|
|
468
|
+
lucid,
|
|
469
|
+
systemParams.validatorHashes.stabilityPoolHash,
|
|
470
|
+
pkh.hash,
|
|
471
|
+
iusdInfo.iassetTokenNameAscii,
|
|
472
|
+
);
|
|
473
|
+
|
|
474
|
+
const assetUtxo = await findIAsset(
|
|
475
|
+
lucid,
|
|
476
|
+
systemParams.validatorHashes.cdpHash,
|
|
477
|
+
{
|
|
478
|
+
currencySymbol:
|
|
479
|
+
systemParams.cdpParams.iAssetAuthToken[0].unCurrencySymbol,
|
|
480
|
+
tokenName: fromText(
|
|
481
|
+
systemParams.cdpParams.iAssetAuthToken[1].unTokenName,
|
|
482
|
+
),
|
|
483
|
+
},
|
|
484
|
+
iusdInfo.iassetTokenNameAscii,
|
|
485
|
+
);
|
|
486
|
+
|
|
487
|
+
const govUtxo = await findGov(lucid, systemParams.validatorHashes.govHash, {
|
|
488
|
+
currencySymbol: systemParams.govParams.govNFT[0].unCurrencySymbol,
|
|
489
|
+
tokenName: fromText(systemParams.govParams.govNFT[1].unTokenName),
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
await runAndAwaitTx(
|
|
493
|
+
lucid,
|
|
494
|
+
processSpRequest(
|
|
495
|
+
iusdInfo.iassetTokenNameAscii,
|
|
496
|
+
stabilityPoolUtxo,
|
|
497
|
+
accountUtxo,
|
|
498
|
+
govUtxo.utxo,
|
|
499
|
+
assetUtxo.utxo,
|
|
500
|
+
undefined,
|
|
501
|
+
systemParams,
|
|
502
|
+
lucid,
|
|
503
|
+
await findRandomCollector(
|
|
504
|
+
lucid,
|
|
505
|
+
systemParams.validatorHashes.collectorHash,
|
|
506
|
+
),
|
|
507
|
+
),
|
|
508
|
+
);
|
|
509
|
+
|
|
510
|
+
lucid.selectWallet.fromSeed(users.user.seedPhrase);
|
|
511
|
+
|
|
512
|
+
stabilityPoolUtxo = await findStabilityPool(
|
|
513
|
+
lucid,
|
|
514
|
+
systemParams.validatorHashes.stabilityPoolHash,
|
|
515
|
+
{
|
|
516
|
+
currencySymbol:
|
|
517
|
+
systemParams.stabilityPoolParams.stabilityPoolToken[0].unCurrencySymbol,
|
|
518
|
+
tokenName: fromText(
|
|
519
|
+
systemParams.stabilityPoolParams.stabilityPoolToken[1].unTokenName,
|
|
520
|
+
),
|
|
521
|
+
},
|
|
522
|
+
iusdInfo.iassetTokenNameAscii,
|
|
523
|
+
);
|
|
524
|
+
|
|
525
|
+
accountUtxo = await findStabilityPoolAccount(
|
|
526
|
+
lucid,
|
|
527
|
+
systemParams.validatorHashes.stabilityPoolHash,
|
|
528
|
+
pkh.hash,
|
|
529
|
+
iusdInfo.iassetTokenNameAscii,
|
|
530
|
+
);
|
|
531
|
+
|
|
532
|
+
await runAndAwaitTx(
|
|
533
|
+
lucid,
|
|
534
|
+
adjustSpAccount(
|
|
535
|
+
iusdInfo.iassetTokenNameAscii,
|
|
536
|
+
10n,
|
|
537
|
+
accountUtxo,
|
|
538
|
+
systemParams,
|
|
539
|
+
lucid,
|
|
540
|
+
),
|
|
541
|
+
);
|
|
542
|
+
|
|
543
|
+
accountUtxo = await findStabilityPoolAccount(
|
|
544
|
+
lucid,
|
|
545
|
+
systemParams.validatorHashes.stabilityPoolHash,
|
|
546
|
+
pkh.hash,
|
|
547
|
+
iusdInfo.iassetTokenNameAscii,
|
|
548
|
+
);
|
|
549
|
+
|
|
550
|
+
await runAndAwaitTx(lucid, annulRequest(accountUtxo, systemParams, lucid));
|
|
551
|
+
});
|
|
552
|
+
|
|
399
553
|
test<MyContext>('Stability Pool - Close Account', async ({
|
|
400
554
|
lucid,
|
|
401
555
|
users,
|