@cashlab/moria
    Preparing search index...

    Class default

    Index

    Constructors

    • Parameters

      • __namedParameters: { oracle_owner_pubkey: Uint8Array; txfee_per_byte: bigint }

      Returns default

    Properties

    _context: CompilerContext
    _default_preferred_token_output_bch_amount: null | bigint
    _template_predefined_data: { [template_name: string]: any }

    Methods

    • Add collateral to an existing loan.

      Parameters

      • loan_utxo: UTXOWithNFT

        The current loan's utxo.

      • amount: bigint

        The amount to increase the collateral.

      • loan_private_key: Uint8Array

        The private key of the current loan.

      • input_coins: SpendableCoin[]

        A set of spendable coins to fund the refinance procedure.

      • payout_rules: PayoutRule[]

        A list of payout rules.

      Returns AddCollateralTxResult

      add collateral tx result

    • Get musd & oracle token id.

      Returns { musd_token_id: string; oracle_token_id: string }

    • Parameters

      • output: Output

      Returns null | bigint

    • Liquidate an under-water (collateral < 110%) loan. With MUSD tokens equivalent to the loan amount. The payout is the loan's collateral + the remainder of MUSD tokens if more MUSD is provided in inputs.

      Parameters

      • moria_utxo: UTXOWithNFT

        The moria's utxo.

      • oracle_utxo: UTXOWithNFT

        The oracle's utxo.

      • loan_utxo: UTXOWithNFT

        The current loan's utxo.

      • input_coins: SpendableCoin[]

        A set of spendable coins to fund the refinance procedure.

      • payout_rules: PayoutRule[]

        A list of payout rules. The payout rules is expected to not have more than two outputs.

      Returns moria0.MoriaTxResult

      A tx that pays out the collateral in exchange for MUSD

    • Mint a new loan. The collateral amount is taken from input_coins and the remaining - fees is in the payouts.

      Parameters

      • moria_utxo: UTXOWithNFT

        The moria's utxo.

      • oracle_utxo: UTXOWithNFT

        The oracle's utxo.

      • input_coins: SpendableCoin[]

        A set of spendable coins to fund the loan's collateral + fees

      • loan_amount: bigint

        The amount of MUSD to mint.

      • collateral_amount: bigint

        The collateral amount (sats)

      • borrower_pkh: Uint8Array

        borrower's public key's hash160, the pkh's format is equivalent to pkh used in p2pkh

      • token_payout_locking_bytecode: Uint8Array
      • payout_rules: PayoutRule[]

        A list of payout rules. The payout rules is expected to not have more than two outputs.

      Returns MintTxResult

      The mint tx result.

    • Redeem MUSD tokens equivalent to the loan amount with a BCH payout, The payout includes the remainder of MUSD tokens if more MUSD is provided in inputs.

      Parameters

      • moria_utxo: UTXOWithNFT

        The moria's utxo.

      • oracle_utxo: UTXOWithNFT

        The oracle's utxo.

      • loan_utxo: UTXOWithNFT

        The current loan's utxo.

      • sunset_datasig: Uint8Array

        A unique sig which will be revealed on the blockchain once the sunset event occurs.

      • input_coins: SpendableCoin[]

        A set of spendable coins to fund the refinance procedure.

      • payout_rules: PayoutRule[]

        A list of payout rules. The payout rules is expected to not have more than two outputs.

      Returns RedeemTxResult

      A tx that redeems MUSD with BCH payouts

    • Mint a new loan to pay back another loan in order to reduce or increase the size and/or add or decrease the collateral rate of the loan.

      Parameters

      • moria_utxo: UTXOWithNFT

        The moria's utxo.

      • oracle_utxo: UTXOWithNFT

        The oracle's utxo.

      • next_loan_amount: bigint

        the amount of the next loan

      • next_collateral_amount: bigint

        The collateral amount for the substitute loan

      • current_loan_utxo: UTXOWithNFT

        The current loan's utxo.

      • current_loan_private_key: Uint8Array

        The private key of the current loan.

      • next_loan_pkh: Uint8Array

        borrower's public key's hash160, the pkh's format is equivalent to pkh used in p2pkh.

      • input_coins: SpendableCoin[]

        A set of spendable coins to fund the refinance procedure.

      • payout_rules: PayoutRule[]

        A list of payout rules. The payout rules is expected to not have more than two outputs.

      Returns RefinanceLoanResult

      refinance tx chain with details

    • Repay a loan with MUSD tokens equivalent to the loan amount. The payout is the loan's collateral + the remainder of MUSD tokens if more MUSD is provided in inputs.

      Parameters

      • moria_utxo: UTXOWithNFT

        The moria's utxo.

      • oracle_utxo: UTXOWithNFT

        The oracle's utxo.

      • loan_utxo: UTXOWithNFT

        The current loan's utxo.

      • loan_private_key: Uint8Array

        The private key of the current loan.

      • input_coins: SpendableCoin[]

        A set of spendable coins to fund the refinance procedure.

      • payout_rules: PayoutRule[]

        A list of payout rules. The payout rules is expected to not have more than two outputs.

      Returns moria0.MoriaTxResult

      A tx that pays out the collateral in exchange for MUSD

    • Parameters

      • value: null | bigint

      Returns void

    • Verify the validity of a TxResult, Expecting the generated transaction should be valid.

      Parameters

      • tx_result: TxResult

        result of a generated transaction

      Returns void

      InvalidProgramState

    • Helper function for calculating the collateral amount for a target collateral rate at a given price.

      Parameters

      • loan_amount: bigint

        Loan amount.

      • rate: Fraction | "MIN"

        Collateral rate represented as a Fraction or literal string 'MIN' for minimum collateral amount possible.

      • oracle_price: bigint

        The token price from the oracle

      Returns bigint

      the collateral amount

    • Helper function for calculating the loan amount with the collateral_amount with a target collateral rate at a given price.

      Parameters

      • collateral_amount: bigint

        Collateral amount in sats.

      • rate: Fraction | "MIN"

        Collateral rate represented as a Fraction or literal string 'MIN' for minimum collateral amount possible.

      • oracle_price: bigint

        The token price from the oracle

      Returns bigint

      the loan amount

    • Parameters

      • getPredefinedData: () => {
            oracle_token: Uint8Array;
            sunset_message: Uint8Array;
            sunset_pubkey: Uint8Array;
        }

      Returns CompilerBch

    • Parameters

      • getPredefinedData: () => { owner_pubkey: Uint8Array }

      Returns CompilerBch