@morpho-org/morpho-sdk 10.1.0-next.0 → 10.2.0
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/README.md +6 -2
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +1 -5
- package/lib/cjs/actions/blue/borrow.d.ts +13 -4
- package/lib/cjs/actions/blue/borrow.internal.d.ts +13 -0
- package/lib/cjs/actions/blue/borrow.internal.js +36 -0
- package/lib/cjs/actions/blue/borrow.js +12 -18
- package/lib/cjs/actions/blue/common.d.ts +53 -28
- package/lib/cjs/actions/blue/common.js +36 -35
- package/lib/cjs/actions/blue/encode.d.ts +23 -0
- package/lib/cjs/actions/blue/encode.js +171 -0
- package/lib/cjs/actions/blue/refinance.d.ts +14 -5
- package/lib/cjs/actions/blue/refinance.internal.d.ts +42 -0
- package/lib/cjs/actions/blue/refinance.internal.js +65 -0
- package/lib/cjs/actions/blue/refinance.js +13 -65
- package/lib/cjs/actions/blue/refinanceValidation.d.ts +6 -6
- package/lib/cjs/actions/blue/refinanceValidation.js +10 -8
- package/lib/cjs/actions/blue/repay.d.ts +5 -4
- package/lib/cjs/actions/blue/repay.internal.d.ts +13 -0
- package/lib/cjs/actions/blue/repay.internal.js +38 -0
- package/lib/cjs/actions/blue/repay.js +5 -19
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +6 -5
- package/lib/cjs/actions/blue/repayWithdrawCollateral.internal.d.ts +61 -0
- package/lib/cjs/actions/blue/repayWithdrawCollateral.internal.js +112 -0
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +6 -118
- package/lib/cjs/actions/blue/signatures.d.ts +30 -0
- package/lib/cjs/actions/blue/signatures.js +90 -0
- package/lib/cjs/actions/blue/supply.d.ts +6 -4
- package/lib/cjs/actions/blue/supply.internal.d.ts +32 -0
- package/lib/cjs/actions/blue/supply.internal.js +101 -0
- package/lib/cjs/actions/blue/supply.js +6 -69
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +5 -4
- package/lib/cjs/actions/blue/supplyCollateral.internal.d.ts +13 -0
- package/lib/cjs/actions/blue/supplyCollateral.internal.js +37 -0
- package/lib/cjs/actions/blue/supplyCollateral.js +5 -19
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +15 -6
- package/lib/cjs/actions/blue/supplyCollateralBorrow.internal.d.ts +65 -0
- package/lib/cjs/actions/blue/supplyCollateralBorrow.internal.js +98 -0
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +13 -108
- package/lib/cjs/actions/blue/withdraw.d.ts +15 -6
- package/lib/cjs/actions/blue/withdraw.internal.d.ts +56 -0
- package/lib/cjs/actions/blue/withdraw.internal.js +87 -0
- package/lib/cjs/actions/blue/withdraw.js +13 -80
- package/lib/cjs/actions/blue/withdrawBuyCallback.d.ts +2 -2
- package/lib/cjs/actions/blue/withdrawBuyCallback.internal.d.ts +20 -0
- package/lib/cjs/actions/blue/withdrawBuyCallback.internal.js +58 -0
- package/lib/cjs/actions/blue/withdrawBuyCallback.js +2 -39
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +4 -3
- package/lib/cjs/actions/blue/withdrawCollateral.internal.d.ts +16 -0
- package/lib/cjs/actions/blue/withdrawCollateral.internal.js +39 -0
- package/lib/cjs/actions/blue/withdrawCollateral.js +5 -19
- package/lib/cjs/actions/bundles/common.d.ts +9 -0
- package/lib/cjs/actions/bundles/common.js +18 -6
- package/lib/cjs/actions/bundles/index.d.ts +1 -1
- package/lib/cjs/actions/bundles/index.js +3 -16
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +14 -0
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +59 -60
- package/lib/cjs/actions/midnight/cancelAndMake.d.ts +22 -1
- package/lib/cjs/actions/midnight/cancelAndMake.js +46 -87
- package/lib/cjs/actions/midnight/cancelOffers.d.ts +11 -0
- package/lib/cjs/actions/midnight/cancelOffers.js +22 -4
- package/lib/cjs/actions/midnight/encode.d.ts +36 -0
- package/lib/cjs/actions/midnight/encode.js +554 -0
- package/lib/cjs/actions/midnight/index.d.ts +14 -13
- package/lib/cjs/actions/midnight/index.js +29 -13
- package/lib/cjs/actions/midnight/parse.d.ts +35 -0
- package/lib/cjs/actions/midnight/parse.js +73 -0
- package/lib/cjs/actions/midnight/parseCollateralBatch.d.ts +58 -0
- package/lib/cjs/actions/midnight/parseCollateralBatch.js +216 -0
- package/lib/cjs/actions/midnight/redeem.d.ts +16 -3
- package/lib/cjs/actions/midnight/redeem.js +22 -51
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +13 -0
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +42 -67
- package/lib/cjs/actions/midnight/supplyCollateral.d.ts +40 -5
- package/lib/cjs/actions/midnight/supplyCollateral.js +60 -54
- package/lib/cjs/actions/midnight/supplyCollateralBatch.d.ts +3 -3
- package/lib/cjs/actions/midnight/supplyCollateralBatch.js +3 -62
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +24 -0
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +39 -67
- package/lib/cjs/actions/midnight/supplyCollateralWithNative.d.ts +77 -0
- package/lib/cjs/actions/midnight/supplyCollateralWithNative.js +142 -0
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +17 -2
- package/lib/cjs/actions/midnight/takeBorrow.js +25 -56
- package/lib/cjs/actions/midnight/takeLend.d.ts +21 -1
- package/lib/cjs/actions/midnight/takeLend.js +30 -58
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -2
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +34 -62
- package/lib/cjs/actions/midnight/takeWithdraw.d.ts +17 -2
- package/lib/cjs/actions/midnight/takeWithdraw.js +77 -115
- package/lib/cjs/actions/midnight/withdrawCollateral.d.ts +16 -3
- package/lib/cjs/actions/midnight/withdrawCollateral.js +25 -56
- package/lib/cjs/actions/midnight/withdrawCollateralBatch.d.ts +3 -3
- package/lib/cjs/actions/midnight/withdrawCollateralBatch.js +3 -71
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +13 -0
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +39 -19
- package/lib/cjs/actions/requirements/blue/index.d.ts +1 -1
- package/lib/cjs/actions/requirements/blue/index.js +3 -15
- package/lib/cjs/actions/requirements/chainCheck.d.ts +5 -0
- package/lib/cjs/actions/requirements/chainCheck.js +10 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +40 -27
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +11 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +36 -17
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +14 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +44 -9
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +10 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +61 -24
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +10 -0
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +25 -4
- package/lib/cjs/actions/requirements/encode/index.d.ts +5 -5
- package/lib/cjs/actions/requirements/encode/index.js +11 -19
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +26 -11
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +40 -12
- package/lib/cjs/actions/requirements/index.d.ts +1 -1
- package/lib/cjs/actions/requirements/index.js +3 -1
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +11 -0
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +34 -19
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -0
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +26 -12
- package/lib/cjs/actions/requirements/midnight/index.d.ts +2 -2
- package/lib/cjs/actions/requirements/midnight/index.js +5 -16
- package/lib/cjs/actions/vaultV1/deposit.d.ts +23 -1
- package/lib/cjs/actions/vaultV1/deposit.js +48 -11
- package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +18 -1
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +36 -16
- package/lib/cjs/actions/vaultV1/index.d.ts +5 -5
- package/lib/cjs/actions/vaultV1/index.js +11 -19
- package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +24 -2
- package/lib/cjs/actions/vaultV1/migrateToV2.js +51 -12
- package/lib/cjs/actions/vaultV1/redeem.d.ts +22 -2
- package/lib/cjs/actions/vaultV1/redeem.js +30 -8
- package/lib/cjs/actions/vaultV1/withdraw.d.ts +21 -1
- package/lib/cjs/actions/vaultV1/withdraw.js +30 -8
- package/lib/cjs/actions/vaultV2/deposit.d.ts +23 -1
- package/lib/cjs/actions/vaultV2/deposit.js +48 -11
- package/lib/cjs/actions/vaultV2/forceRedeem.d.ts +20 -2
- package/lib/cjs/actions/vaultV2/forceRedeem.js +39 -8
- package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +25 -2
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +38 -15
- package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +18 -1
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +35 -15
- package/lib/cjs/actions/vaultV2/index.d.ts +6 -6
- package/lib/cjs/actions/vaultV2/index.js +13 -20
- package/lib/cjs/actions/vaultV2/redeem.d.ts +22 -2
- package/lib/cjs/actions/vaultV2/redeem.js +30 -8
- package/lib/cjs/actions/vaultV2/withdraw.d.ts +21 -1
- package/lib/cjs/actions/vaultV2/withdraw.js +30 -8
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +1 -5
- package/lib/cjs/blue/entities.d.ts +4 -4
- package/lib/cjs/blue/entities.js +1 -3
- package/lib/cjs/blue/errors.d.ts +2 -2
- package/lib/cjs/blue/errors.js +1 -5
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +1 -3
- package/lib/cjs/blue/utils.d.ts +1 -1
- package/lib/cjs/blue/utils.js +1 -2
- package/lib/cjs/constants.d.ts +1 -1
- package/lib/cjs/constants.js +2 -0
- package/lib/cjs/entities/blue/blue.d.ts +118 -28
- package/lib/cjs/entities/blue/blue.js +503 -416
- package/lib/cjs/entities/index.d.ts +4 -4
- package/lib/cjs/entities/index.js +1 -3
- package/lib/cjs/entities/midnight/midnight.d.ts +117 -41
- package/lib/cjs/entities/midnight/midnight.js +472 -843
- package/lib/cjs/entities/midnight/parse.d.ts +74 -0
- package/lib/cjs/entities/midnight/parse.js +336 -0
- package/lib/cjs/entities/midnight/prepare.d.ts +47 -0
- package/lib/cjs/entities/midnight/prepare.js +293 -0
- package/lib/cjs/entities/midnight/publication.d.ts +7 -3
- package/lib/cjs/entities/midnight/publication.js +10 -7
- package/lib/cjs/entities/midnight/types.d.ts +7 -0
- package/lib/cjs/entities/requirements/assertContractCode.d.ts +10 -5
- package/lib/cjs/entities/requirements/assertContractCode.js +24 -15
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +15 -0
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +59 -51
- package/lib/cjs/entities/requirements/getErc2612Permit.d.ts +7 -3
- package/lib/cjs/entities/requirements/getErc2612Permit.js +20 -4
- package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.d.ts +15 -0
- package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.js +24 -7
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +14 -0
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +27 -7
- package/lib/cjs/entities/requirements/getVaultV1InKindRedeemRequirements.js +4 -3
- package/lib/cjs/entities/requirements/getVaultV2ForceWithdrawRequirements.js +4 -3
- package/lib/cjs/entities/requirements/getVaultV2InKindRedeemRequirements.js +4 -3
- package/lib/cjs/entities/requirements/index.d.ts +2 -2
- package/lib/cjs/entities/requirements/index.js +5 -16
- package/lib/cjs/entities/requirements/validateNativeRequirements.d.ts +21 -0
- package/lib/cjs/entities/requirements/validateNativeRequirements.js +37 -0
- package/lib/cjs/entities/vaultV1/inKindRedeemQuote.d.ts +2 -2
- package/lib/cjs/entities/vaultV1/inKindRedeemQuote.js +1 -7
- package/lib/cjs/entities/vaultV1/migrateToV2Quote.d.ts +2 -0
- package/lib/cjs/entities/vaultV1/migrateToV2Quote.js +5 -0
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +29 -46
- package/lib/cjs/entities/vaultV1/vaultV1.js +234 -159
- package/lib/cjs/entities/vaultV2/forceWithdrawQuote.d.ts +4 -0
- package/lib/cjs/entities/vaultV2/forceWithdrawQuote.js +9 -4
- package/lib/cjs/entities/vaultV2/inKindRedeemQuote.d.ts +2 -2
- package/lib/cjs/entities/vaultV2/inKindRedeemQuote.js +1 -7
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +40 -92
- package/lib/cjs/entities/vaultV2/vaultV2.js +230 -188
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +13 -5
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +21 -27
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +5 -7
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +1 -3
- package/lib/cjs/helpers/constant.d.ts +2 -0
- package/lib/cjs/helpers/constant.js +3 -1
- package/lib/cjs/helpers/deadShares.js +0 -3
- package/lib/cjs/helpers/getBlueBundlesV1QuoteTimestamp.d.ts +10 -0
- package/lib/cjs/helpers/getBlueBundlesV1QuoteTimestamp.js +18 -0
- package/lib/cjs/helpers/index.d.ts +1 -1
- package/lib/cjs/helpers/index.js +2 -1
- package/lib/cjs/helpers/parse.d.ts +33 -0
- package/lib/cjs/helpers/parse.js +71 -0
- package/lib/cjs/helpers/parseMidnight.d.ts +48 -0
- package/lib/cjs/helpers/parseMidnight.js +95 -0
- package/lib/cjs/helpers/parseMidnightMaker.d.ts +44 -0
- package/lib/cjs/helpers/parseMidnightMaker.js +154 -0
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.d.ts +3 -3
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +4 -5
- package/lib/cjs/helpers/quoteBlueRepay.d.ts +7 -3
- package/lib/cjs/helpers/quoteBlueRepay.js +20 -7
- package/lib/cjs/helpers/reallocationPenalty.d.ts +10 -0
- package/lib/cjs/helpers/reallocationPenalty.js +32 -0
- package/lib/cjs/helpers/referralFee.d.ts +2 -1
- package/lib/cjs/helpers/referralFee.js +5 -1
- package/lib/cjs/helpers/validate.d.ts +34 -6
- package/lib/cjs/helpers/validate.js +52 -9
- package/lib/cjs/helpers/validateMidnightBounds.d.ts +1 -2
- package/lib/cjs/helpers/validateMidnightBounds.js +1 -2
- package/lib/cjs/helpers/validateMidnightCancelAndMakePublication.d.ts +8 -0
- package/lib/cjs/helpers/validateMidnightCancelAndMakePublication.js +4 -4
- package/lib/cjs/helpers/validateMidnightPublication.d.ts +17 -1
- package/lib/cjs/helpers/validateMidnightTakeFeasibility.d.ts +2 -2
- package/lib/cjs/helpers/validateMidnightTakeFeasibility.js +1 -1
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/midnight/errors.d.ts +1 -2
- package/lib/cjs/midnight/errors.js +4 -5
- package/lib/cjs/transactionPlan/blue/borrow.d.ts +11 -5
- package/lib/cjs/transactionPlan/blue/borrow.js +26 -8
- package/lib/cjs/transactionPlan/blue/refinance.d.ts +9 -2
- package/lib/cjs/transactionPlan/blue/refinance.js +36 -11
- package/lib/cjs/transactionPlan/blue/repay.d.ts +1 -2
- package/lib/cjs/transactionPlan/blue/repay.js +3 -3
- package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.d.ts +4 -3
- package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.js +35 -7
- package/lib/cjs/transactionPlan/blue/supply.d.ts +1 -2
- package/lib/cjs/transactionPlan/blue/supply.js +1 -2
- package/lib/cjs/transactionPlan/blue/supplyCollateral.d.ts +2 -3
- package/lib/cjs/transactionPlan/blue/supplyCollateral.js +2 -3
- package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.d.ts +10 -4
- package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.js +25 -8
- package/lib/cjs/transactionPlan/blue/withdraw.d.ts +17 -7
- package/lib/cjs/transactionPlan/blue/withdraw.js +28 -9
- package/lib/cjs/transactionPlan/blue/withdrawCollateral.d.ts +5 -5
- package/lib/cjs/transactionPlan/blue/withdrawCollateral.js +17 -9
- package/lib/cjs/transactionPlan/deposit.js +4 -0
- package/lib/cjs/transactionPlan/intent.d.ts +1 -1
- package/lib/cjs/transactionPlan/intent.js +4 -2
- package/lib/cjs/transactionPlan/plan.d.ts +8 -4
- package/lib/cjs/transactionPlan/plan.js +8 -4
- package/lib/cjs/transactionPlan/types.d.ts +6 -0
- package/lib/cjs/transactionPlan/validation.d.ts +1 -1
- package/lib/cjs/transactionPlan/validation.js +3 -0
- package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +5 -5
- package/lib/cjs/transactionPlan/vaultv1/deposit.js +5 -5
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.d.ts +3 -3
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.js +7 -3
- package/lib/cjs/transactionPlan/vaultv1/redeem.d.ts +1 -2
- package/lib/cjs/transactionPlan/vaultv1/redeem.js +1 -2
- package/lib/cjs/transactionPlan/vaultv1/withdraw.d.ts +2 -3
- package/lib/cjs/transactionPlan/vaultv1/withdraw.js +2 -3
- package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +3 -3
- package/lib/cjs/transactionPlan/vaultv2/deposit.js +3 -3
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.d.ts +3 -3
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.js +3 -3
- package/lib/cjs/transactionPlan/vaultv2/redeem.d.ts +2 -3
- package/lib/cjs/transactionPlan/vaultv2/redeem.js +2 -3
- package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +2 -3
- package/lib/cjs/transactionPlan/vaultv2/withdraw.js +2 -3
- package/lib/cjs/types/action.d.ts +13 -2
- package/lib/cjs/types/error.d.ts +27 -8
- package/lib/cjs/types/error.js +42 -12
- package/lib/cjs/types/sharedLiquidity.d.ts +7 -2
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +2 -4
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- package/lib/esm/actions/blue/borrow.d.ts +13 -4
- package/lib/esm/actions/blue/borrow.internal.d.ts +13 -0
- package/lib/esm/actions/blue/borrow.internal.js +31 -0
- package/lib/esm/actions/blue/borrow.js +12 -18
- package/lib/esm/actions/blue/common.d.ts +53 -28
- package/lib/esm/actions/blue/common.js +36 -34
- package/lib/esm/actions/blue/encode.d.ts +23 -0
- package/lib/esm/actions/blue/encode.js +164 -0
- package/lib/esm/actions/blue/refinance.d.ts +14 -5
- package/lib/esm/actions/blue/refinance.internal.d.ts +42 -0
- package/lib/esm/actions/blue/refinance.internal.js +59 -0
- package/lib/esm/actions/blue/refinance.js +13 -65
- package/lib/esm/actions/blue/refinanceValidation.d.ts +6 -6
- package/lib/esm/actions/blue/refinanceValidation.js +11 -9
- package/lib/esm/actions/blue/repay.d.ts +5 -4
- package/lib/esm/actions/blue/repay.internal.d.ts +13 -0
- package/lib/esm/actions/blue/repay.internal.js +33 -0
- package/lib/esm/actions/blue/repay.js +5 -19
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +6 -5
- package/lib/esm/actions/blue/repayWithdrawCollateral.internal.d.ts +61 -0
- package/lib/esm/actions/blue/repayWithdrawCollateral.internal.js +104 -0
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +6 -118
- package/lib/esm/actions/blue/signatures.d.ts +30 -0
- package/lib/esm/actions/blue/signatures.js +82 -0
- package/lib/esm/actions/blue/supply.d.ts +6 -4
- package/lib/esm/actions/blue/supply.internal.d.ts +32 -0
- package/lib/esm/actions/blue/supply.internal.js +95 -0
- package/lib/esm/actions/blue/supply.js +6 -69
- package/lib/esm/actions/blue/supplyCollateral.d.ts +5 -4
- package/lib/esm/actions/blue/supplyCollateral.internal.d.ts +13 -0
- package/lib/esm/actions/blue/supplyCollateral.internal.js +32 -0
- package/lib/esm/actions/blue/supplyCollateral.js +5 -19
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +15 -6
- package/lib/esm/actions/blue/supplyCollateralBorrow.internal.d.ts +65 -0
- package/lib/esm/actions/blue/supplyCollateralBorrow.internal.js +91 -0
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +13 -108
- package/lib/esm/actions/blue/withdraw.d.ts +15 -6
- package/lib/esm/actions/blue/withdraw.internal.d.ts +56 -0
- package/lib/esm/actions/blue/withdraw.internal.js +80 -0
- package/lib/esm/actions/blue/withdraw.js +13 -80
- package/lib/esm/actions/blue/withdrawBuyCallback.d.ts +2 -2
- package/lib/esm/actions/blue/withdrawBuyCallback.internal.d.ts +20 -0
- package/lib/esm/actions/blue/withdrawBuyCallback.internal.js +53 -0
- package/lib/esm/actions/blue/withdrawBuyCallback.js +2 -39
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +4 -3
- package/lib/esm/actions/blue/withdrawCollateral.internal.d.ts +16 -0
- package/lib/esm/actions/blue/withdrawCollateral.internal.js +34 -0
- package/lib/esm/actions/blue/withdrawCollateral.js +5 -19
- package/lib/esm/actions/bundles/common.d.ts +9 -0
- package/lib/esm/actions/bundles/common.js +15 -4
- package/lib/esm/actions/bundles/index.d.ts +1 -1
- package/lib/esm/actions/bundles/index.js +1 -1
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +14 -0
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +58 -61
- package/lib/esm/actions/midnight/cancelAndMake.d.ts +22 -1
- package/lib/esm/actions/midnight/cancelAndMake.js +43 -85
- package/lib/esm/actions/midnight/cancelOffers.d.ts +11 -0
- package/lib/esm/actions/midnight/cancelOffers.js +18 -2
- package/lib/esm/actions/midnight/encode.d.ts +36 -0
- package/lib/esm/actions/midnight/encode.js +539 -0
- package/lib/esm/actions/midnight/index.d.ts +14 -13
- package/lib/esm/actions/midnight/index.js +14 -13
- package/lib/esm/actions/midnight/parse.d.ts +35 -0
- package/lib/esm/actions/midnight/parse.js +68 -0
- package/lib/esm/actions/midnight/parseCollateralBatch.d.ts +58 -0
- package/lib/esm/actions/midnight/parseCollateralBatch.js +209 -0
- package/lib/esm/actions/midnight/redeem.d.ts +16 -3
- package/lib/esm/actions/midnight/redeem.js +20 -50
- package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +13 -0
- package/lib/esm/actions/midnight/repayWithdrawCollateral.js +38 -64
- package/lib/esm/actions/midnight/supplyCollateral.d.ts +40 -5
- package/lib/esm/actions/midnight/supplyCollateral.js +57 -53
- package/lib/esm/actions/midnight/supplyCollateralBatch.d.ts +3 -3
- package/lib/esm/actions/midnight/supplyCollateralBatch.js +3 -62
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +24 -0
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +34 -63
- package/lib/esm/actions/midnight/supplyCollateralWithNative.d.ts +77 -0
- package/lib/esm/actions/midnight/supplyCollateralWithNative.js +137 -0
- package/lib/esm/actions/midnight/takeBorrow.d.ts +17 -2
- package/lib/esm/actions/midnight/takeBorrow.js +21 -53
- package/lib/esm/actions/midnight/takeLend.d.ts +21 -1
- package/lib/esm/actions/midnight/takeLend.js +27 -56
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -2
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +31 -60
- package/lib/esm/actions/midnight/takeWithdraw.d.ts +17 -2
- package/lib/esm/actions/midnight/takeWithdraw.js +76 -115
- package/lib/esm/actions/midnight/withdrawCollateral.d.ts +16 -3
- package/lib/esm/actions/midnight/withdrawCollateral.js +23 -55
- package/lib/esm/actions/midnight/withdrawCollateralBatch.d.ts +3 -3
- package/lib/esm/actions/midnight/withdrawCollateralBatch.js +3 -71
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +13 -0
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +36 -18
- package/lib/esm/actions/requirements/blue/index.d.ts +1 -1
- package/lib/esm/actions/requirements/blue/index.js +1 -1
- package/lib/esm/actions/requirements/chainCheck.d.ts +5 -0
- package/lib/esm/actions/requirements/chainCheck.js +6 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +36 -25
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +11 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +33 -16
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +14 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +41 -8
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +10 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +59 -24
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +10 -0
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +21 -2
- package/lib/esm/actions/requirements/encode/index.d.ts +5 -5
- package/lib/esm/actions/requirements/encode/index.js +5 -5
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +26 -11
- package/lib/esm/actions/requirements/getRequirementsApproval.js +38 -12
- package/lib/esm/actions/requirements/index.d.ts +1 -1
- package/lib/esm/actions/requirements/index.js +1 -1
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +11 -0
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +31 -18
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -0
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +22 -10
- package/lib/esm/actions/requirements/midnight/index.d.ts +2 -2
- package/lib/esm/actions/requirements/midnight/index.js +2 -2
- package/lib/esm/actions/vaultV1/deposit.d.ts +23 -1
- package/lib/esm/actions/vaultV1/deposit.js +45 -10
- package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +18 -1
- package/lib/esm/actions/vaultV1/inKindRedeem.js +33 -15
- package/lib/esm/actions/vaultV1/index.d.ts +5 -5
- package/lib/esm/actions/vaultV1/index.js +5 -5
- package/lib/esm/actions/vaultV1/migrateToV2.d.ts +24 -2
- package/lib/esm/actions/vaultV1/migrateToV2.js +49 -12
- package/lib/esm/actions/vaultV1/redeem.d.ts +22 -2
- package/lib/esm/actions/vaultV1/redeem.js +28 -8
- package/lib/esm/actions/vaultV1/withdraw.d.ts +21 -1
- package/lib/esm/actions/vaultV1/withdraw.js +28 -8
- package/lib/esm/actions/vaultV2/deposit.d.ts +23 -1
- package/lib/esm/actions/vaultV2/deposit.js +45 -10
- package/lib/esm/actions/vaultV2/forceRedeem.d.ts +20 -2
- package/lib/esm/actions/vaultV2/forceRedeem.js +35 -6
- package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +25 -2
- package/lib/esm/actions/vaultV2/forceWithdraw.js +35 -14
- package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +18 -1
- package/lib/esm/actions/vaultV2/inKindRedeem.js +32 -14
- package/lib/esm/actions/vaultV2/index.d.ts +6 -6
- package/lib/esm/actions/vaultV2/index.js +6 -6
- package/lib/esm/actions/vaultV2/redeem.d.ts +22 -2
- package/lib/esm/actions/vaultV2/redeem.js +28 -8
- package/lib/esm/actions/vaultV2/withdraw.d.ts +21 -1
- package/lib/esm/actions/vaultV2/withdraw.js +28 -8
- package/lib/esm/blue/abis.d.ts +1 -1
- package/lib/esm/blue/abis.js +1 -1
- package/lib/esm/blue/entities.d.ts +4 -4
- package/lib/esm/blue/entities.js +2 -2
- package/lib/esm/blue/errors.d.ts +2 -2
- package/lib/esm/blue/errors.js +2 -2
- package/lib/esm/blue/fetch.d.ts +2 -2
- package/lib/esm/blue/fetch.js +2 -2
- package/lib/esm/blue/utils.d.ts +1 -1
- package/lib/esm/blue/utils.js +1 -1
- package/lib/esm/constants.d.ts +1 -1
- package/lib/esm/constants.js +1 -1
- package/lib/esm/entities/blue/blue.d.ts +118 -28
- package/lib/esm/entities/blue/blue.js +485 -398
- package/lib/esm/entities/index.d.ts +4 -4
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/midnight/midnight.d.ts +117 -41
- package/lib/esm/entities/midnight/midnight.js +455 -826
- package/lib/esm/entities/midnight/parse.d.ts +74 -0
- package/lib/esm/entities/midnight/parse.js +320 -0
- package/lib/esm/entities/midnight/prepare.d.ts +47 -0
- package/lib/esm/entities/midnight/prepare.js +282 -0
- package/lib/esm/entities/midnight/publication.d.ts +7 -3
- package/lib/esm/entities/midnight/publication.js +7 -3
- package/lib/esm/entities/midnight/types.d.ts +7 -0
- package/lib/esm/entities/requirements/assertContractCode.d.ts +10 -5
- package/lib/esm/entities/requirements/assertContractCode.js +24 -15
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +15 -0
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +53 -47
- package/lib/esm/entities/requirements/getErc2612Permit.d.ts +7 -3
- package/lib/esm/entities/requirements/getErc2612Permit.js +19 -4
- package/lib/esm/entities/requirements/getUnusedPermit2Nonce.d.ts +15 -0
- package/lib/esm/entities/requirements/getUnusedPermit2Nonce.js +20 -5
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +14 -0
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +23 -5
- package/lib/esm/entities/requirements/getVaultV1InKindRedeemRequirements.js +4 -3
- package/lib/esm/entities/requirements/getVaultV2ForceWithdrawRequirements.js +4 -3
- package/lib/esm/entities/requirements/getVaultV2InKindRedeemRequirements.js +4 -3
- package/lib/esm/entities/requirements/index.d.ts +2 -2
- package/lib/esm/entities/requirements/index.js +2 -2
- package/lib/esm/entities/requirements/validateNativeRequirements.d.ts +21 -0
- package/lib/esm/entities/requirements/validateNativeRequirements.js +33 -0
- package/lib/esm/entities/vaultV1/inKindRedeemQuote.d.ts +2 -2
- package/lib/esm/entities/vaultV1/inKindRedeemQuote.js +1 -7
- package/lib/esm/entities/vaultV1/migrateToV2Quote.d.ts +2 -0
- package/lib/esm/entities/vaultV1/migrateToV2Quote.js +5 -0
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +29 -46
- package/lib/esm/entities/vaultV1/vaultV1.js +214 -139
- package/lib/esm/entities/vaultV2/forceWithdrawQuote.d.ts +4 -0
- package/lib/esm/entities/vaultV2/forceWithdrawQuote.js +10 -5
- package/lib/esm/entities/vaultV2/inKindRedeemQuote.d.ts +2 -2
- package/lib/esm/entities/vaultV2/inKindRedeemQuote.js +1 -7
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +40 -92
- package/lib/esm/entities/vaultV2/vaultV2.js +214 -172
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +13 -5
- package/lib/esm/entities/vaultV2BlueReallocationData.js +19 -25
- package/lib/esm/errors.d.ts +4 -4
- package/lib/esm/errors.js +4 -4
- package/lib/esm/fetch.d.ts +2 -2
- package/lib/esm/fetch.js +2 -2
- package/lib/esm/helpers/constant.d.ts +2 -0
- package/lib/esm/helpers/constant.js +2 -0
- package/lib/esm/helpers/deadShares.js +1 -4
- package/lib/esm/helpers/getBlueBundlesV1QuoteTimestamp.d.ts +10 -0
- package/lib/esm/helpers/getBlueBundlesV1QuoteTimestamp.js +15 -0
- package/lib/esm/helpers/index.d.ts +1 -1
- package/lib/esm/helpers/index.js +1 -1
- package/lib/esm/helpers/parse.d.ts +33 -0
- package/lib/esm/helpers/parse.js +61 -0
- package/lib/esm/helpers/parseMidnight.d.ts +48 -0
- package/lib/esm/helpers/parseMidnight.js +80 -0
- package/lib/esm/helpers/parseMidnightMaker.d.ts +44 -0
- package/lib/esm/helpers/parseMidnightMaker.js +147 -0
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.d.ts +3 -3
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +4 -5
- package/lib/esm/helpers/quoteBlueRepay.d.ts +7 -3
- package/lib/esm/helpers/quoteBlueRepay.js +21 -8
- package/lib/esm/helpers/reallocationPenalty.d.ts +10 -0
- package/lib/esm/helpers/reallocationPenalty.js +28 -0
- package/lib/esm/helpers/referralFee.d.ts +2 -1
- package/lib/esm/helpers/referralFee.js +5 -1
- package/lib/esm/helpers/validate.d.ts +34 -6
- package/lib/esm/helpers/validate.js +52 -11
- package/lib/esm/helpers/validateMidnightBounds.d.ts +1 -2
- package/lib/esm/helpers/validateMidnightBounds.js +1 -2
- package/lib/esm/helpers/validateMidnightCancelAndMakePublication.d.ts +8 -0
- package/lib/esm/helpers/validateMidnightCancelAndMakePublication.js +2 -2
- package/lib/esm/helpers/validateMidnightPublication.d.ts +17 -1
- package/lib/esm/helpers/validateMidnightTakeFeasibility.d.ts +2 -2
- package/lib/esm/helpers/validateMidnightTakeFeasibility.js +1 -1
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/midnight/errors.d.ts +1 -2
- package/lib/esm/midnight/errors.js +1 -2
- package/lib/esm/transactionPlan/blue/borrow.d.ts +11 -5
- package/lib/esm/transactionPlan/blue/borrow.js +27 -9
- package/lib/esm/transactionPlan/blue/refinance.d.ts +9 -2
- package/lib/esm/transactionPlan/blue/refinance.js +37 -12
- package/lib/esm/transactionPlan/blue/repay.d.ts +1 -2
- package/lib/esm/transactionPlan/blue/repay.js +4 -4
- package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.d.ts +4 -3
- package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.js +36 -8
- package/lib/esm/transactionPlan/blue/supply.d.ts +1 -2
- package/lib/esm/transactionPlan/blue/supply.js +1 -2
- package/lib/esm/transactionPlan/blue/supplyCollateral.d.ts +2 -3
- package/lib/esm/transactionPlan/blue/supplyCollateral.js +2 -3
- package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.d.ts +10 -4
- package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.js +25 -8
- package/lib/esm/transactionPlan/blue/withdraw.d.ts +17 -7
- package/lib/esm/transactionPlan/blue/withdraw.js +28 -9
- package/lib/esm/transactionPlan/blue/withdrawCollateral.d.ts +5 -5
- package/lib/esm/transactionPlan/blue/withdrawCollateral.js +17 -9
- package/lib/esm/transactionPlan/deposit.js +5 -1
- package/lib/esm/transactionPlan/intent.d.ts +1 -1
- package/lib/esm/transactionPlan/intent.js +4 -2
- package/lib/esm/transactionPlan/plan.d.ts +8 -4
- package/lib/esm/transactionPlan/plan.js +8 -4
- package/lib/esm/transactionPlan/types.d.ts +6 -0
- package/lib/esm/transactionPlan/validation.d.ts +1 -1
- package/lib/esm/transactionPlan/validation.js +3 -0
- package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +5 -5
- package/lib/esm/transactionPlan/vaultv1/deposit.js +5 -5
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.d.ts +3 -3
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.js +8 -4
- package/lib/esm/transactionPlan/vaultv1/redeem.d.ts +1 -2
- package/lib/esm/transactionPlan/vaultv1/redeem.js +1 -2
- package/lib/esm/transactionPlan/vaultv1/withdraw.d.ts +2 -3
- package/lib/esm/transactionPlan/vaultv1/withdraw.js +2 -3
- package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +3 -3
- package/lib/esm/transactionPlan/vaultv2/deposit.js +3 -3
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.d.ts +3 -3
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.js +3 -3
- package/lib/esm/transactionPlan/vaultv2/redeem.d.ts +2 -3
- package/lib/esm/transactionPlan/vaultv2/redeem.js +2 -3
- package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +2 -3
- package/lib/esm/transactionPlan/vaultv2/withdraw.js +2 -3
- package/lib/esm/types/action.d.ts +13 -2
- package/lib/esm/types/error.d.ts +27 -8
- package/lib/esm/types/error.js +38 -10
- package/lib/esm/types/sharedLiquidity.d.ts +7 -2
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/package.json +7 -7
|
@@ -1,24 +1,14 @@
|
|
|
1
1
|
import { MarketUtils, midnightBundlesV2Abi } from "@morpho-org/midnight-sdk";
|
|
2
|
-
import { deepFreeze
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { deepFreeze } from "@morpho-org/morpho-ts";
|
|
3
|
+
import { encodeAbiParameters, getAbiItem, zeroHash, } from "viem";
|
|
4
|
+
import { wrapMidnightEncoding } from "../../helpers/encodeMidnightCalldata.js";
|
|
5
|
+
import { parseDeadline } from "../../helpers/parse.js";
|
|
6
|
+
import { parseMidnightNativeFunding } from "../../helpers/parseMidnight.js";
|
|
7
7
|
import { validateMidnightUint128Field } from "../../helpers/validateMidnightBounds.js";
|
|
8
8
|
import { normalizeMidnightCancelAndMakePublication, validateMidnightCancelAndMakePublication, } from "../../helpers/validateMidnightCancelAndMakePublication.js";
|
|
9
9
|
import { snapshotMidnightCancelAndMakeParams, validateMidnightPublication, } from "../../helpers/validateMidnightPublication.js";
|
|
10
10
|
import { DuplicateMidnightGroupCancellationError, EmptyMidnightGroupCancellationsError, } from "../../types/index.js";
|
|
11
|
-
|
|
12
|
-
const emptyMidnightMarket = {
|
|
13
|
-
chainId: 0n,
|
|
14
|
-
midnight: zeroAddress,
|
|
15
|
-
loanToken: zeroAddress,
|
|
16
|
-
collateralParams: [],
|
|
17
|
-
maturity: 0n,
|
|
18
|
-
rcfThreshold: 0n,
|
|
19
|
-
enterGate: zeroAddress,
|
|
20
|
-
liquidatorGate: zeroAddress,
|
|
21
|
-
};
|
|
11
|
+
import { encodeMidnightCancelAndMake } from "./encode.js";
|
|
22
12
|
/**
|
|
23
13
|
* Encodes `MidnightBundlesV2.midnightBundlesV2CancelAndMake` for `msg.sender`: cancel previous
|
|
24
14
|
* groups under consumption guards, optionally park loan assets on Morpho Blue for the maker's
|
|
@@ -84,11 +74,12 @@ const emptyMidnightMarket = {
|
|
|
84
74
|
* @throws {NonPositiveInputError} when `deadline` is not positive.
|
|
85
75
|
* @throws {NegativeInputError} when a `maxConsumed` ceiling or `nativeAmount` is negative.
|
|
86
76
|
* @throws {InputExceedsMaxError} when a `maxConsumed` ceiling, collateral supply amount, collateral supply sum, or Blue supply amount exceeds `uint128`, `deadline` exceeds `uint256`, or `nativeAmount` exceeds the maximum wNative pull, including zero when no wNative is pulled.
|
|
77
|
+
* @throws {InvalidMidnightNativeAmountTypeError} when `nativeAmount` is supplied as a non-bigint.
|
|
87
78
|
* @throws {ChainWNativeMissingError} when wNative is not configured for the chain.
|
|
88
79
|
* @throws {NativeAmountOnNonWNativeAssetError} when configured token pulls contain no wNative token.
|
|
89
80
|
* @throws {ChainIdMismatchError} when the collateral market targets another chain.
|
|
90
81
|
* @throws {MidnightMarketAddressMismatchError} when the collateral market targets another Midnight deployment.
|
|
91
|
-
* @throws {UnknownCollateralIndexError} when a
|
|
82
|
+
* @throws {UnknownCollateralIndexError} when a supply targets an unconfigured collateral index.
|
|
92
83
|
* @throws {NonPositiveInputError} when a collateral supply amount is non-positive.
|
|
93
84
|
* @throws {NonPositiveInputError} when `blueSupply.assets` is non-positive.
|
|
94
85
|
* @throws {MidnightCalldataEncodingError} when another input cannot be ABI-encoded, such as an
|
|
@@ -117,16 +108,18 @@ const emptyMidnightMarket = {
|
|
|
117
108
|
* });
|
|
118
109
|
* ```
|
|
119
110
|
*/
|
|
120
|
-
export const midnightCancelAndMake = (params) =>
|
|
111
|
+
export const midnightCancelAndMake = (params) => encodeMidnightCancelAndMake(parseMidnightCancelAndMake(params));
|
|
112
|
+
const parsedCancelAndMake = Symbol();
|
|
113
|
+
/** Parses the complete maker bundle using upstream publication guards before ABI signature bounds. @internal */
|
|
114
|
+
export const parseMidnightCancelAndMake = (params) => {
|
|
121
115
|
const snapshot = snapshotMidnightCancelAndMakeParams(params);
|
|
122
116
|
// Throws on malformed or oversized hex; validation only.
|
|
123
117
|
validateMidnightPublication(snapshot);
|
|
124
|
-
|
|
118
|
+
const deadline = parseDeadline(snapshot.deadline);
|
|
125
119
|
const cancelledGroups = new Set();
|
|
126
120
|
for (const [index, { group, maxConsumed },] of snapshot.cancellations.entries()) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
validateMidnightUint128Field(field, maxConsumed);
|
|
121
|
+
// Validation only; preserves the upstream cancellation ceiling range and error labels.
|
|
122
|
+
validateMidnightUint128Field(`cancellations[${index}].maxConsumed`, maxConsumed);
|
|
130
123
|
const key = group.toLowerCase();
|
|
131
124
|
if (cancelledGroups.has(key)) {
|
|
132
125
|
throw new DuplicateMidnightGroupCancellationError({ index, group });
|
|
@@ -140,7 +133,7 @@ export const midnightCancelAndMake = (params) => {
|
|
|
140
133
|
}
|
|
141
134
|
}
|
|
142
135
|
else {
|
|
143
|
-
// Validation only;
|
|
136
|
+
// Validation only; use main's canonical publication and collateral guards, without duplicating them.
|
|
144
137
|
validateMidnightCancelAndMakePublication({
|
|
145
138
|
publication,
|
|
146
139
|
chainId: snapshot.chainId,
|
|
@@ -148,13 +141,11 @@ export const midnightCancelAndMake = (params) => {
|
|
|
148
141
|
});
|
|
149
142
|
}
|
|
150
143
|
const collateral = publication?.collateral;
|
|
151
|
-
const collateralPulls = collateral
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}));
|
|
157
|
-
const nativeFunding = validateMidnightNativeAmount({
|
|
144
|
+
const collateralPulls = collateral?.supplies.map(({ collateralIndex, assets }) => ({
|
|
145
|
+
token: MarketUtils.getCollateralByIndex(collateral.market, collateralIndex).token,
|
|
146
|
+
assets,
|
|
147
|
+
})) ?? [];
|
|
148
|
+
const nativeFunding = parseMidnightNativeFunding({
|
|
158
149
|
chainId: snapshot.chainId,
|
|
159
150
|
nativeAmount: snapshot.nativeAmount,
|
|
160
151
|
pulls: [
|
|
@@ -169,63 +160,30 @@ export const midnightCancelAndMake = (params) => {
|
|
|
169
160
|
...collateralPulls,
|
|
170
161
|
],
|
|
171
162
|
});
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const normalized = normalizeMidnightCancelAndMakePublication(publication);
|
|
177
|
-
const { supplies, blueSupply, signature } = normalized;
|
|
178
|
-
let tx = {
|
|
179
|
-
to: getChainAddress(snapshot.chainId, "midnightBundlesV2"),
|
|
180
|
-
value: nativeFunding.value,
|
|
181
|
-
data: encodeMidnightCalldata({
|
|
163
|
+
const signature = publication?.rootSignature;
|
|
164
|
+
// Bound delegated activation fields against the entrypoint ABI, after native coverage as before.
|
|
165
|
+
if (signature != null) {
|
|
166
|
+
wrapMidnightEncoding("midnightBundlesV2CancelAndMake", () => encodeAbiParameters(getAbiItem({
|
|
182
167
|
abi: midnightBundlesV2Abi,
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
normalized.ratifier, // ratifier
|
|
193
|
-
normalized.root, // newRoot
|
|
194
|
-
signature.height, // signatureHeight
|
|
195
|
-
signature.nonce, // signatureNonce
|
|
196
|
-
signature.deadline, // signatureDeadline
|
|
197
|
-
signature.v, // v
|
|
198
|
-
signature.r, // r
|
|
199
|
-
signature.s, // s
|
|
200
|
-
cancellations, // groupsToCancel
|
|
201
|
-
normalized.payload, // payload
|
|
202
|
-
snapshot.deadline, // deadline
|
|
203
|
-
nativeFunding.wrappedNative, // wrappedNative
|
|
204
|
-
],
|
|
205
|
-
}),
|
|
206
|
-
};
|
|
207
|
-
if (snapshot.metadata) {
|
|
208
|
-
tx = addTransactionMetadata(tx, snapshot.metadata);
|
|
168
|
+
name: "midnightBundlesV2CancelAndMake",
|
|
169
|
+
}).inputs.slice(7, 13), [
|
|
170
|
+
signature.height,
|
|
171
|
+
signature.nonce,
|
|
172
|
+
signature.deadline,
|
|
173
|
+
signature.v,
|
|
174
|
+
signature.r,
|
|
175
|
+
signature.s,
|
|
176
|
+
]));
|
|
209
177
|
}
|
|
210
178
|
return deepFreeze({
|
|
211
|
-
...
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
groups: normalized.groups,
|
|
221
|
-
cancellations,
|
|
222
|
-
collateralSupplies: supplies,
|
|
223
|
-
...(blueSupply && { blueSupply }),
|
|
224
|
-
...(nativeFunding.value > 0n
|
|
225
|
-
? { nativeAmount: nativeFunding.value }
|
|
226
|
-
: {}),
|
|
227
|
-
deadline: snapshot.deadline,
|
|
228
|
-
},
|
|
229
|
-
},
|
|
179
|
+
...snapshot,
|
|
180
|
+
publicationData: normalizeMidnightCancelAndMakePublication(publication),
|
|
181
|
+
deadline,
|
|
182
|
+
nativeFunding,
|
|
183
|
+
collateralPulls,
|
|
184
|
+
marketId: collateral == null
|
|
185
|
+
? zeroHash
|
|
186
|
+
: wrapMidnightEncoding("midnightBundlesV2CancelAndMake", () => MarketUtils.toId(collateral.market)),
|
|
187
|
+
[parsedCancelAndMake]: true,
|
|
230
188
|
});
|
|
231
189
|
};
|
|
@@ -52,3 +52,14 @@ export interface MidnightCancelOffersParams {
|
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
54
|
export declare const midnightCancelOffers: (params: MidnightCancelOffersParams) => Readonly<Transaction<MidnightCancelOffersAction>>;
|
|
55
|
+
declare const parsedCancelOffers: unique symbol;
|
|
56
|
+
/** Complete owned direct-cancellation constraints; no chain state or authorization proof. @internal */
|
|
57
|
+
export interface ParsedMidnightCancelOffers extends MidnightCancelOffersParams {
|
|
58
|
+
readonly midnight: Address;
|
|
59
|
+
readonly [parsedCancelOffers]: true;
|
|
60
|
+
}
|
|
61
|
+
/** Constructs the complete direct cancellation in the standalone builder's established order. @internal */
|
|
62
|
+
export declare const parseMidnightCancelOffers: (params: MidnightCancelOffersParams) => ParsedMidnightCancelOffers;
|
|
63
|
+
/** Encodes a complete direct cancellation without re-entering a public builder. @internal */
|
|
64
|
+
export declare const encodeMidnightCancelOffers: (params: ParsedMidnightCancelOffers) => Readonly<Transaction<MidnightCancelOffersAction>>;
|
|
65
|
+
export {};
|
|
@@ -6,6 +6,7 @@ import { addTransactionMetadata } from "../../helpers/index.js";
|
|
|
6
6
|
import { validateMidnightAddress } from "../../helpers/validateMidnightAccount.js";
|
|
7
7
|
import { validateMidnightBytes32 } from "../../helpers/validateMidnightPublication.js";
|
|
8
8
|
import { DuplicateMidnightGroupCancellationError, EmptyMidnightGroupCancellationsError, MidnightZeroOnBehalfError, } from "../../types/index.js";
|
|
9
|
+
import { snapshotMidnightMetadata } from "./parse.js";
|
|
9
10
|
/**
|
|
10
11
|
* Encodes a full cancellation of one or more offer groups as a direct call to Midnight.
|
|
11
12
|
*
|
|
@@ -50,8 +51,11 @@ import { DuplicateMidnightGroupCancellationError, EmptyMidnightGroupCancellation
|
|
|
50
51
|
* // tx.action => { type: "midnightCancelOffers", args: { groups: [group], onBehalf: maker } }
|
|
51
52
|
* ```
|
|
52
53
|
*/
|
|
53
|
-
export const midnightCancelOffers = (params) =>
|
|
54
|
-
|
|
54
|
+
export const midnightCancelOffers = (params) => encodeMidnightCancelOffers(parseMidnightCancelOffers(params));
|
|
55
|
+
const parsedCancelOffers = Symbol();
|
|
56
|
+
/** Constructs the complete direct cancellation in the standalone builder's established order. @internal */
|
|
57
|
+
export const parseMidnightCancelOffers = (params) => {
|
|
58
|
+
const { chainId, onBehalf } = params;
|
|
55
59
|
// Copy the list so validation and encoding read one snapshot and the caller's array stays unfrozen.
|
|
56
60
|
const groups = [...params.groups];
|
|
57
61
|
// Reject a malformed account before comparing it with the zero address.
|
|
@@ -73,6 +77,18 @@ export const midnightCancelOffers = (params) => {
|
|
|
73
77
|
seen.add(key);
|
|
74
78
|
}
|
|
75
79
|
const midnight = getChainAddress(chainId, "midnight");
|
|
80
|
+
return deepFreeze({
|
|
81
|
+
chainId,
|
|
82
|
+
onBehalf,
|
|
83
|
+
groups,
|
|
84
|
+
midnight,
|
|
85
|
+
metadata: snapshotMidnightMetadata(params.metadata),
|
|
86
|
+
[parsedCancelOffers]: true,
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
/** Encodes a complete direct cancellation without re-entering a public builder. @internal */
|
|
90
|
+
export const encodeMidnightCancelOffers = (params) => {
|
|
91
|
+
const { groups, onBehalf, metadata, midnight } = params;
|
|
76
92
|
const calls = groups.map((group) => encodeMidnightCalldata({
|
|
77
93
|
abi: midnightAbi,
|
|
78
94
|
functionName: "setConsumed",
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { MidnightCancelAndMakeAction, MidnightRedeemAction, MidnightRepayWithdrawCollateralAction, MidnightSupplyCollateralAction, MidnightSupplyCollateralBatchAction, MidnightSupplyCollateralTakeBorrowAction, MidnightTakeBorrowAction, MidnightTakeLendAction, MidnightTakeRepayWithdrawCollateralAction, MidnightTakeWithdrawAction, MidnightWithdrawCollateralAction, MidnightWithdrawCollateralBatchAction, Transaction } from "../../types/index.js";
|
|
2
|
+
import type { ParsedMidnightCancelAndMake } from "./cancelAndMake.js";
|
|
3
|
+
import type { ParsedMidnightSupplyCollateralBatch, ParsedMidnightWithdrawCollateralBatch } from "./parseCollateralBatch.js";
|
|
4
|
+
import type { ParsedMidnightRedeem } from "./redeem.js";
|
|
5
|
+
import type { ParsedMidnightRepayWithdrawCollateral } from "./repayWithdrawCollateral.js";
|
|
6
|
+
import type { ParsedMidnightSupplyCollateral } from "./supplyCollateral.js";
|
|
7
|
+
import type { ParsedMidnightSupplyCollateralTakeBorrow } from "./supplyCollateralTakeBorrow.js";
|
|
8
|
+
import type { ParsedMidnightTakeBorrow } from "./takeBorrow.js";
|
|
9
|
+
import type { ParsedMidnightTakeLend } from "./takeLend.js";
|
|
10
|
+
import type { ParsedMidnightTakeRepayWithdrawCollateral } from "./takeRepayWithdrawCollateral.js";
|
|
11
|
+
import type { ParsedMidnightTakeWithdraw } from "./takeWithdraw.js";
|
|
12
|
+
import type { ParsedMidnightWithdrawCollateral } from "./withdrawCollateral.js";
|
|
13
|
+
/** Encodes an owned collateral supply batch without repeating static validation. @internal */
|
|
14
|
+
export declare const encodeMidnightSupplyCollateralBatch: (params: ParsedMidnightSupplyCollateralBatch) => Readonly<Transaction<MidnightSupplyCollateralBatchAction>>;
|
|
15
|
+
/** Encodes an owned collateral withdrawal batch without repeating static validation. @internal */
|
|
16
|
+
export declare const encodeMidnightWithdrawCollateralBatch: (params: ParsedMidnightWithdrawCollateralBatch) => Readonly<Transaction<MidnightWithdrawCollateralBatchAction>>;
|
|
17
|
+
/** Encodes parsed supplyCollateral inputs without repeating static validation. @internal */
|
|
18
|
+
export declare const encodeMidnightSupplyCollateral: (params: ParsedMidnightSupplyCollateral) => Readonly<Transaction<MidnightSupplyCollateralAction>>;
|
|
19
|
+
/** Encodes parsed withdrawCollateral inputs without repeating static validation. @internal */
|
|
20
|
+
export declare const encodeMidnightWithdrawCollateral: (params: ParsedMidnightWithdrawCollateral) => Readonly<Transaction<MidnightWithdrawCollateralAction>>;
|
|
21
|
+
/** Encodes parsed redeem inputs without repeating static validation. @internal */
|
|
22
|
+
export declare const encodeMidnightRedeem: (params: ParsedMidnightRedeem) => Readonly<Transaction<MidnightRedeemAction>>;
|
|
23
|
+
/** Encodes parsed repayWithdrawCollateral inputs without repeating static validation. @internal */
|
|
24
|
+
export declare const encodeMidnightRepayWithdrawCollateral: (params: ParsedMidnightRepayWithdrawCollateral) => Readonly<Transaction<MidnightRepayWithdrawCollateralAction>>;
|
|
25
|
+
/** Encodes parsed TakeLend inputs and an owned feasibility-selected offer subset. @internal */
|
|
26
|
+
export declare const encodeMidnightTakeLend: (params: ParsedMidnightTakeLend, offerIndexes?: readonly number[]) => Readonly<Transaction<MidnightTakeLendAction>>;
|
|
27
|
+
/** Encodes parsed TakeBorrow inputs and an owned feasibility-selected offer subset. @internal */
|
|
28
|
+
export declare const encodeMidnightTakeBorrow: (params: ParsedMidnightTakeBorrow, offerIndexes?: readonly number[]) => Readonly<Transaction<MidnightTakeBorrowAction>>;
|
|
29
|
+
/** Encodes parsed TakeWithdraw inputs and an owned feasibility-selected offer subset. @internal */
|
|
30
|
+
export declare const encodeMidnightTakeWithdraw: (params: ParsedMidnightTakeWithdraw, offerIndexes?: readonly number[]) => Readonly<Transaction<MidnightTakeWithdrawAction>>;
|
|
31
|
+
/** Encodes parsed SupplyCollateralTakeBorrow inputs and an owned feasibility-selected offer subset. @internal */
|
|
32
|
+
export declare const encodeMidnightSupplyCollateralTakeBorrow: (params: ParsedMidnightSupplyCollateralTakeBorrow, offerIndexes?: readonly number[]) => Readonly<Transaction<MidnightSupplyCollateralTakeBorrowAction>>;
|
|
33
|
+
/** Encodes parsed TakeRepayWithdrawCollateral inputs and an owned feasibility-selected offer subset. @internal */
|
|
34
|
+
export declare const encodeMidnightTakeRepayWithdrawCollateral: (params: ParsedMidnightTakeRepayWithdrawCollateral, offerIndexes?: readonly number[]) => Readonly<Transaction<MidnightTakeRepayWithdrawCollateralAction>>;
|
|
35
|
+
/** Encodes parsed maker publications and cancellations without static revalidation. @internal */
|
|
36
|
+
export declare const encodeMidnightCancelAndMake: (params: ParsedMidnightCancelAndMake) => Readonly<Transaction<MidnightCancelAndMakeAction>>;
|