@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,5 +1,5 @@
|
|
|
1
1
|
import type { MarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
-
import {
|
|
2
|
+
import type { Address } from "viem";
|
|
3
3
|
import type { BlueSupplyCollateralAction, BundlesTokenRequirementSignature, Metadata, Transaction } from "../../types/index.js";
|
|
4
4
|
/** Parameters for {@link blueSupplyCollateral}. */
|
|
5
5
|
export interface BlueSupplyCollateralParams {
|
|
@@ -18,7 +18,7 @@ export interface BlueSupplyCollateralParams {
|
|
|
18
18
|
readonly nativeAmount?: bigint;
|
|
19
19
|
/** Final call deadline in Unix seconds. */
|
|
20
20
|
readonly deadline: bigint;
|
|
21
|
-
/** Optional WAD-scaled referral fee,
|
|
21
|
+
/** Optional WAD-scaled referral fee, at most 10%. */
|
|
22
22
|
readonly referralFeePct?: bigint;
|
|
23
23
|
/** Recipient required when `referralFeePct` is positive. */
|
|
24
24
|
readonly referralFeeRecipient?: Address;
|
|
@@ -41,7 +41,7 @@ export interface BlueSupplyCollateralParams {
|
|
|
41
41
|
* @param params.args.collateralAssets - Gross collateral assets supplied.
|
|
42
42
|
* @param params.args.nativeAmount - Exclusive native collateral funding.
|
|
43
43
|
* @param params.args.deadline - Final call deadline in Unix seconds.
|
|
44
|
-
* @param params.args.referralFeePct - Optional WAD-scaled referral fee
|
|
44
|
+
* @param params.args.referralFeePct - Optional WAD-scaled referral fee, at most 10%.
|
|
45
45
|
* @param params.args.referralFeeRecipient - Recipient required for a positive fee.
|
|
46
46
|
* @param params.args.requirementSignature - Optional collateral-token signature.
|
|
47
47
|
* @param params.metadata - Optional transaction metadata.
|
|
@@ -59,8 +59,9 @@ export interface BlueSupplyCollateralParams {
|
|
|
59
59
|
* @throws {DepositAmountMismatchError} when the signed amount differs from `collateralAssets`.
|
|
60
60
|
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
61
61
|
* @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be encoded safely.
|
|
62
|
-
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
63
62
|
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
63
|
+
* @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
|
|
64
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
64
65
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
65
66
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
66
67
|
* @example
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BlueSupplyCollateralAction, Transaction } from "../../types/index.js";
|
|
2
|
+
import type { BlueSupplyCollateralParams } from "./supplyCollateral.js";
|
|
3
|
+
import { type BlueSupplyCollateralBorrowInput, parseBlueSupplyCollateralBorrow } from "./supplyCollateralBorrow.internal.js";
|
|
4
|
+
/** Complete collateral-supply input with borrowing disabled. @internal */
|
|
5
|
+
export interface BlueSupplyCollateralInput extends BlueSupplyCollateralBorrowInput {
|
|
6
|
+
readonly borrowAssets: 0n;
|
|
7
|
+
}
|
|
8
|
+
/** Constructs the complete raw collateral supply with a fixed inactive borrow leg. @internal */
|
|
9
|
+
export declare const parseBlueSupplyCollateral: (params: BlueSupplyCollateralParams & {
|
|
10
|
+
readonly args: Pick<Parameters<typeof parseBlueSupplyCollateralBorrow>[0]["args"], "authorizationSignature" | "reallocations">;
|
|
11
|
+
}) => BlueSupplyCollateralInput & Pick<ReturnType<typeof parseBlueSupplyCollateralBorrow>, "bound">;
|
|
12
|
+
/** Encodes only a completed pure collateral-supply operation. @internal */
|
|
13
|
+
export declare const buildBlueSupplyCollateral: (parsed: ReturnType<typeof parseBlueSupplyCollateral>) => Readonly<Transaction<BlueSupplyCollateralAction>>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildBlueSupplyCollateral = exports.parseBlueSupplyCollateral = void 0;
|
|
4
|
+
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
5
|
+
const viem_1 = require("viem");
|
|
6
|
+
const encode_js_1 = require("./encode.js");
|
|
7
|
+
const supplyCollateralBorrow_internal_js_1 = require("./supplyCollateralBorrow.internal.js");
|
|
8
|
+
/** Constructs the complete raw collateral supply with a fixed inactive borrow leg. @internal */
|
|
9
|
+
const parseBlueSupplyCollateral = (params) => ({
|
|
10
|
+
...(0, supplyCollateralBorrow_internal_js_1.parseBlueSupplyCollateralBorrow)({
|
|
11
|
+
...params,
|
|
12
|
+
args: {
|
|
13
|
+
authorizationSignature: params.args.authorizationSignature,
|
|
14
|
+
reallocations: params.args.reallocations,
|
|
15
|
+
userAddress: params.args.userAddress,
|
|
16
|
+
collateralAssets: params.args.collateralAssets,
|
|
17
|
+
nativeAmount: params.args.nativeAmount,
|
|
18
|
+
deadline: params.args.deadline,
|
|
19
|
+
referralFeePct: params.args.referralFeePct,
|
|
20
|
+
referralFeeRecipient: params.args.referralFeeRecipient,
|
|
21
|
+
requirementSignature: params.args.requirementSignature,
|
|
22
|
+
borrowAssets: 0n,
|
|
23
|
+
maxLtv: viem_1.maxUint256,
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
26
|
+
borrowAssets: 0n,
|
|
27
|
+
});
|
|
28
|
+
exports.parseBlueSupplyCollateral = parseBlueSupplyCollateral;
|
|
29
|
+
/** Encodes only a completed pure collateral-supply operation. @internal */
|
|
30
|
+
const buildBlueSupplyCollateral = (parsed) => {
|
|
31
|
+
const transaction = (0, encode_js_1.encodeBlueSupplyCollateralBorrow)(parsed);
|
|
32
|
+
return (0, morpho_ts_1.deepFreeze)({
|
|
33
|
+
...transaction,
|
|
34
|
+
action: { ...transaction.action, type: "blueSupplyCollateral" },
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
exports.buildBlueSupplyCollateral = buildBlueSupplyCollateral;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.blueSupplyCollateral = void 0;
|
|
4
|
-
const
|
|
5
|
-
const viem_1 = require("viem");
|
|
6
|
-
const supplyCollateralBorrow_js_1 = require("./supplyCollateralBorrow.js");
|
|
4
|
+
const supplyCollateral_internal_js_1 = require("./supplyCollateral.internal.js");
|
|
7
5
|
/**
|
|
8
6
|
* Encodes a pure collateral supply through BlueBundlesV1.
|
|
9
7
|
*
|
|
@@ -17,7 +15,7 @@ const supplyCollateralBorrow_js_1 = require("./supplyCollateralBorrow.js");
|
|
|
17
15
|
* @param params.args.collateralAssets - Gross collateral assets supplied.
|
|
18
16
|
* @param params.args.nativeAmount - Exclusive native collateral funding.
|
|
19
17
|
* @param params.args.deadline - Final call deadline in Unix seconds.
|
|
20
|
-
* @param params.args.referralFeePct - Optional WAD-scaled referral fee
|
|
18
|
+
* @param params.args.referralFeePct - Optional WAD-scaled referral fee, at most 10%.
|
|
21
19
|
* @param params.args.referralFeeRecipient - Recipient required for a positive fee.
|
|
22
20
|
* @param params.args.requirementSignature - Optional collateral-token signature.
|
|
23
21
|
* @param params.metadata - Optional transaction metadata.
|
|
@@ -35,8 +33,9 @@ const supplyCollateralBorrow_js_1 = require("./supplyCollateralBorrow.js");
|
|
|
35
33
|
* @throws {DepositAmountMismatchError} when the signed amount differs from `collateralAssets`.
|
|
36
34
|
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
37
35
|
* @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be encoded safely.
|
|
38
|
-
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
39
36
|
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
37
|
+
* @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
|
|
38
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
40
39
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
41
40
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
42
41
|
* @example
|
|
@@ -57,18 +56,5 @@ const supplyCollateralBorrow_js_1 = require("./supplyCollateralBorrow.js");
|
|
|
57
56
|
* // tx satisfies Readonly<Transaction<BlueSupplyCollateralAction>>
|
|
58
57
|
* ```
|
|
59
58
|
*/
|
|
60
|
-
const blueSupplyCollateral = (params) =>
|
|
61
|
-
const transaction = (0, supplyCollateralBorrow_js_1.blueSupplyCollateralBorrow)({
|
|
62
|
-
...params,
|
|
63
|
-
args: {
|
|
64
|
-
...params.args,
|
|
65
|
-
borrowAssets: 0n,
|
|
66
|
-
maxLtv: viem_1.maxUint256,
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
return (0, morpho_ts_1.deepFreeze)({
|
|
70
|
-
...transaction,
|
|
71
|
-
action: { ...transaction.action, type: "blueSupplyCollateral" },
|
|
72
|
-
});
|
|
73
|
-
};
|
|
59
|
+
const blueSupplyCollateral = (params) => (0, supplyCollateral_internal_js_1.buildBlueSupplyCollateral)((0, supplyCollateral_internal_js_1.parseBlueSupplyCollateral)(params));
|
|
74
60
|
exports.blueSupplyCollateral = blueSupplyCollateral;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { Address } from "viem";
|
|
3
|
+
import type { AuthorizationRequirementSignature, BlueSupplyCollateralBorrowAction, BundlesTokenRequirementSignature, Metadata, Transaction, VaultV2BlueReallocation } from "../../types/index.js";
|
|
4
4
|
/** Parameters for {@link blueSupplyCollateralBorrow}. */
|
|
5
5
|
export interface BlueSupplyCollateralBorrowParams {
|
|
6
6
|
/** Chain and scoped Morpho Blue market. */
|
|
@@ -22,9 +22,11 @@ export interface BlueSupplyCollateralBorrowParams {
|
|
|
22
22
|
readonly nativeAmount?: bigint;
|
|
23
23
|
/** Optional validated Vault V2 BluePublicAllocator reallocations. */
|
|
24
24
|
readonly reallocations?: Iterable<VaultV2BlueReallocation>;
|
|
25
|
+
/** Maximum WAD-scaled penalty rate per reallocation, defaulting to zero; it does not bound total proceeds lost. */
|
|
26
|
+
readonly maxPenalty?: bigint;
|
|
25
27
|
/** Final call deadline in Unix seconds. */
|
|
26
28
|
readonly deadline: bigint;
|
|
27
|
-
/** Optional WAD-scaled referral fee,
|
|
29
|
+
/** Optional WAD-scaled referral fee, at most 10%. */
|
|
28
30
|
readonly referralFeePct?: bigint;
|
|
29
31
|
/** Recipient required when `referralFeePct` is positive. */
|
|
30
32
|
readonly referralFeeRecipient?: Address;
|
|
@@ -51,21 +53,28 @@ export interface BlueSupplyCollateralBorrowParams {
|
|
|
51
53
|
* @param params.args.maxLtv - Maximum post-operation LTV.
|
|
52
54
|
* @param params.args.nativeAmount - Exclusive native collateral funding.
|
|
53
55
|
* @param params.args.reallocations - Vault V2 reallocations executed before borrowing.
|
|
56
|
+
* @param params.args.maxPenalty - Maximum WAD-scaled penalty rate per reallocation in [0, WAD], defaulting to zero. Each rate applies to that reallocation's assets, so it does not bound total proceeds lost.
|
|
54
57
|
* @param params.args.deadline - Final call deadline in Unix seconds.
|
|
55
|
-
* @param params.args.referralFeePct - Optional WAD-scaled fee
|
|
58
|
+
* @param params.args.referralFeePct - Optional WAD-scaled fee at most 10%.
|
|
56
59
|
* @param params.args.referralFeeRecipient - Recipient required for a positive fee.
|
|
57
60
|
* @param params.args.requirementSignature - Optional collateral token signature.
|
|
58
61
|
* @param params.args.authorizationSignature - Optional Blue authorization signature.
|
|
59
62
|
* @param params.metadata - Optional transaction metadata.
|
|
60
63
|
* @returns A deep-frozen `Readonly<Transaction<BlueSupplyCollateralBorrowAction>>`
|
|
61
64
|
* whose `to` address is BlueBundlesV1 and whose `action` records the normalized inputs.
|
|
62
|
-
* @throws {MarketIdMismatchError} when
|
|
65
|
+
* @throws {MarketIdMismatchError} when the target market or a reallocation source market has an
|
|
66
|
+
* `id` that does not hash from its tuple fields.
|
|
67
|
+
* @throws {InvalidBigIntInputError} when a supplied maxPenalty is not a bigint.
|
|
63
68
|
* @throws {NegativeInputError} when an amount, `maxLtv`, native value, or fee is negative.
|
|
69
|
+
* Also thrown when maxPenalty is negative.
|
|
64
70
|
* @throws {NonPositiveInputError} when both operation legs are zero, the deadline is not positive,
|
|
65
71
|
* or a reallocation amount is not positive.
|
|
66
72
|
* @throws {ReallocationsRequireBorrowError} when reallocations accompany no borrow.
|
|
67
|
-
* @throws {InputExceedsMaxError} when a
|
|
73
|
+
* @throws {InputExceedsMaxError} when a reallocation amount or penalty exceeds its ABI bound.
|
|
74
|
+
* Also thrown when maxPenalty exceeds WAD or a penalty exceeds maxPenalty (zero by default).
|
|
68
75
|
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
76
|
+
* @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
|
|
77
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
69
78
|
* @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
|
|
70
79
|
* @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
|
|
71
80
|
* @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { parseBlueMarket } from "../../helpers/parse.js";
|
|
2
|
+
import { type BlueSupplyCollateralBorrowAction, type Transaction, type VaultV2BlueReallocation } from "../../types/index.js";
|
|
3
|
+
import type { BlueAllocations, BlueOperationInput } from "./common.js";
|
|
4
|
+
import type { BlueSupplyCollateralBorrowParams } from "./supplyCollateralBorrow.js";
|
|
5
|
+
declare const blueSupplyCollateralBorrowBrand: unique symbol;
|
|
6
|
+
/** Validated collateral supply and borrow inputs. @internal */
|
|
7
|
+
export interface BlueSupplyCollateralBorrowInput extends BlueOperationInput {
|
|
8
|
+
readonly collateralAssets: bigint;
|
|
9
|
+
readonly borrowAssets: bigint;
|
|
10
|
+
readonly maxLtv: bigint;
|
|
11
|
+
readonly value: bigint;
|
|
12
|
+
readonly publicAllocations: BlueAllocations["publicAllocations"];
|
|
13
|
+
readonly reallocationPenaltyAssets: bigint;
|
|
14
|
+
readonly [blueSupplyCollateralBorrowBrand]: true;
|
|
15
|
+
}
|
|
16
|
+
/** Constructs the complete standalone operation from raw params in established error order. @internal */
|
|
17
|
+
export declare const parseBlueSupplyCollateralBorrow: (params: BlueSupplyCollateralBorrowParams) => {
|
|
18
|
+
deadline: bigint;
|
|
19
|
+
referralFeePct: bigint;
|
|
20
|
+
referralFeeRecipient: import("viem").Address;
|
|
21
|
+
chainId: number;
|
|
22
|
+
userAddress: import("viem").Address;
|
|
23
|
+
marketParams: import("../../helpers/parse.js").BlueMarket;
|
|
24
|
+
metadata?: import("../../index.js").Metadata;
|
|
25
|
+
collateralAssets: bigint;
|
|
26
|
+
borrowAssets: bigint;
|
|
27
|
+
maxLtv: bigint;
|
|
28
|
+
value: bigint;
|
|
29
|
+
publicAllocations: BlueAllocations["publicAllocations"];
|
|
30
|
+
reallocationPenaltyAssets: bigint;
|
|
31
|
+
[blueSupplyCollateralBorrowBrand]: true;
|
|
32
|
+
bound: {
|
|
33
|
+
readonly collateralPermit: ReturnType<typeof import("./common.js").getBlueBundlesV1TokenPermit>;
|
|
34
|
+
readonly signedAuthorization: ReturnType<typeof import("./common.js").getBlueBundlesV1SignedAuthorization>;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
/** Checks reallocation compatibility after the constructor's nonzero-leg guard. @internal */
|
|
38
|
+
export declare const parseBlueSupplyCollateralBorrowMode: (params: {
|
|
39
|
+
readonly collateralAssets: bigint;
|
|
40
|
+
readonly borrowAssets: bigint;
|
|
41
|
+
readonly reallocations: readonly VaultV2BlueReallocation[];
|
|
42
|
+
readonly maxPenalty?: bigint;
|
|
43
|
+
}) => {
|
|
44
|
+
readonly collateralAssets: bigint;
|
|
45
|
+
readonly borrowAssets: bigint;
|
|
46
|
+
readonly reallocations: readonly VaultV2BlueReallocation[];
|
|
47
|
+
readonly maxPenalty?: bigint;
|
|
48
|
+
};
|
|
49
|
+
/** Parses allocations and their input-only borrow penalty bound. @internal */
|
|
50
|
+
export declare const parseBlueSupplyCollateralBorrowAllocations: (marketParams: ReturnType<typeof parseBlueMarket>, mode: ReturnType<typeof parseBlueSupplyCollateralBorrowMode>) => {
|
|
51
|
+
readonly publicAllocations: readonly {
|
|
52
|
+
readonly vault: import("viem").Address;
|
|
53
|
+
readonly adapter: import("viem").Address;
|
|
54
|
+
readonly marketParams: import("../../helpers/parse.js").BlueMarket;
|
|
55
|
+
readonly fromIdle: boolean;
|
|
56
|
+
readonly sourceAdapter: import("viem").Address;
|
|
57
|
+
readonly sourceMarketParams: import("../../helpers/parse.js").BlueMarket;
|
|
58
|
+
readonly assets: bigint;
|
|
59
|
+
readonly penalty: bigint;
|
|
60
|
+
}[];
|
|
61
|
+
readonly penaltyAssets: bigint;
|
|
62
|
+
};
|
|
63
|
+
/** Independently validates fresh buildTx signatures before encoding. @internal */
|
|
64
|
+
export declare const buildBlueSupplyCollateralBorrow: (parsed: BlueSupplyCollateralBorrowInput, signatures?: Pick<BlueSupplyCollateralBorrowParams["args"], "requirementSignature" | "authorizationSignature">) => Readonly<Transaction<BlueSupplyCollateralBorrowAction>>;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildBlueSupplyCollateralBorrow = exports.parseBlueSupplyCollateralBorrowAllocations = exports.parseBlueSupplyCollateralBorrowMode = exports.parseBlueSupplyCollateralBorrow = void 0;
|
|
4
|
+
const parse_js_1 = require("../../helpers/parse.js");
|
|
5
|
+
const index_js_1 = require("../../types/index.js");
|
|
6
|
+
const common_js_1 = require("./common.js");
|
|
7
|
+
const encode_js_1 = require("./encode.js");
|
|
8
|
+
const signatures_js_1 = require("./signatures.js");
|
|
9
|
+
/** Constructs the complete standalone operation from raw params in established error order. @internal */
|
|
10
|
+
const parseBlueSupplyCollateralBorrow = (params) => {
|
|
11
|
+
const marketParams = (0, parse_js_1.parseBlueMarket)(params.market.marketParams);
|
|
12
|
+
const amounts = {
|
|
13
|
+
collateralAssets: (0, parse_js_1.parseUint256)("collateralAssets", params.args.collateralAssets),
|
|
14
|
+
borrowAssets: (0, parse_js_1.parseUint256)("borrowAssets", params.args.borrowAssets),
|
|
15
|
+
maxLtv: (0, parse_js_1.parseUint256)("maxLtv", params.args.maxLtv),
|
|
16
|
+
};
|
|
17
|
+
if (amounts.collateralAssets === 0n && amounts.borrowAssets === 0n) {
|
|
18
|
+
throw new index_js_1.NonPositiveInputError("collateralAssets or borrowAssets", 0n);
|
|
19
|
+
}
|
|
20
|
+
const mode = (0, exports.parseBlueSupplyCollateralBorrowMode)({
|
|
21
|
+
...amounts,
|
|
22
|
+
reallocations: [...(params.args.reallocations ?? [])],
|
|
23
|
+
maxPenalty: params.args.maxPenalty,
|
|
24
|
+
});
|
|
25
|
+
// Reject signatures for inactive legs before continuing.
|
|
26
|
+
(0, signatures_js_1.validateBlueSupplyCollateralBorrowSignatureLegs)(amounts, params.args);
|
|
27
|
+
const common = {
|
|
28
|
+
chainId: params.market.chainId,
|
|
29
|
+
userAddress: params.args.userAddress,
|
|
30
|
+
deadline: params.args.deadline,
|
|
31
|
+
referralFeePct: params.args.referralFeePct,
|
|
32
|
+
referralFeeRecipient: params.args.referralFeeRecipient,
|
|
33
|
+
metadata: params.metadata,
|
|
34
|
+
};
|
|
35
|
+
const normalized = (0, common_js_1.parseBlueBundlesV1Common)(common);
|
|
36
|
+
const value = (0, parse_js_1.parseNativeFunding)({
|
|
37
|
+
chainId: common.chainId,
|
|
38
|
+
token: marketParams.collateralToken,
|
|
39
|
+
fundedAmount: amounts.collateralAssets,
|
|
40
|
+
nativeAmount: params.args.nativeAmount,
|
|
41
|
+
});
|
|
42
|
+
const bound = (0, signatures_js_1.bindBlueSupplyCollateralBorrowSignatures)({
|
|
43
|
+
...common,
|
|
44
|
+
marketParams,
|
|
45
|
+
collateralAssets: amounts.collateralAssets,
|
|
46
|
+
value,
|
|
47
|
+
}, params.args);
|
|
48
|
+
const allocations = (0, exports.parseBlueSupplyCollateralBorrowAllocations)(marketParams, mode);
|
|
49
|
+
const fields = {
|
|
50
|
+
...normalized,
|
|
51
|
+
chainId: common.chainId,
|
|
52
|
+
userAddress: common.userAddress,
|
|
53
|
+
marketParams,
|
|
54
|
+
metadata: common.metadata,
|
|
55
|
+
...amounts,
|
|
56
|
+
value,
|
|
57
|
+
publicAllocations: allocations.publicAllocations,
|
|
58
|
+
reallocationPenaltyAssets: allocations.penaltyAssets,
|
|
59
|
+
};
|
|
60
|
+
const input = fields;
|
|
61
|
+
return { ...input, bound };
|
|
62
|
+
};
|
|
63
|
+
exports.parseBlueSupplyCollateralBorrow = parseBlueSupplyCollateralBorrow;
|
|
64
|
+
/** Checks reallocation compatibility after the constructor's nonzero-leg guard. @internal */
|
|
65
|
+
const parseBlueSupplyCollateralBorrowMode = (params) => {
|
|
66
|
+
const { borrowAssets, reallocations } = params;
|
|
67
|
+
if (borrowAssets === 0n && reallocations.length > 0) {
|
|
68
|
+
throw new index_js_1.ReallocationsRequireBorrowError();
|
|
69
|
+
}
|
|
70
|
+
return params;
|
|
71
|
+
};
|
|
72
|
+
exports.parseBlueSupplyCollateralBorrowMode = parseBlueSupplyCollateralBorrowMode;
|
|
73
|
+
/** Parses allocations and their input-only borrow penalty bound. @internal */
|
|
74
|
+
const parseBlueSupplyCollateralBorrowAllocations = (marketParams, mode) => {
|
|
75
|
+
const allocations = (0, common_js_1.parseBlueAllocations)([...mode.reallocations], {
|
|
76
|
+
marketParams,
|
|
77
|
+
maxPenalty: mode.maxPenalty,
|
|
78
|
+
});
|
|
79
|
+
if (allocations.penaltyAssets > mode.borrowAssets) {
|
|
80
|
+
throw new index_js_1.InputExceedsMaxError({
|
|
81
|
+
field: "reallocationPenaltyAssets",
|
|
82
|
+
value: allocations.penaltyAssets,
|
|
83
|
+
max: mode.borrowAssets,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return allocations;
|
|
87
|
+
};
|
|
88
|
+
exports.parseBlueSupplyCollateralBorrowAllocations = parseBlueSupplyCollateralBorrowAllocations;
|
|
89
|
+
/** Independently validates fresh buildTx signatures before encoding. @internal */
|
|
90
|
+
const buildBlueSupplyCollateralBorrow = (parsed, signatures = {}) => {
|
|
91
|
+
// Reject signatures for inactive legs before continuing.
|
|
92
|
+
(0, signatures_js_1.validateBlueSupplyCollateralBorrowSignatureLegs)(parsed, signatures);
|
|
93
|
+
return (0, encode_js_1.encodeBlueSupplyCollateralBorrow)({
|
|
94
|
+
...parsed,
|
|
95
|
+
bound: (0, signatures_js_1.bindBlueSupplyCollateralBorrowSignatures)(parsed, signatures),
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
exports.buildBlueSupplyCollateralBorrow = buildBlueSupplyCollateralBorrow;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.blueSupplyCollateralBorrow = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const validate_js_1 = require("../../helpers/validate.js");
|
|
7
|
-
const index_js_1 = require("../../types/index.js");
|
|
8
|
-
const common_js_1 = require("../bundles/common.js");
|
|
9
|
-
const common_js_2 = require("./common.js");
|
|
4
|
+
const encode_js_1 = require("./encode.js");
|
|
5
|
+
const supplyCollateralBorrow_internal_js_1 = require("./supplyCollateralBorrow.internal.js");
|
|
10
6
|
/**
|
|
11
7
|
* Encodes a direct BlueBundlesV1 collateral supply and/or borrow transaction.
|
|
12
8
|
*
|
|
@@ -22,21 +18,28 @@ const common_js_2 = require("./common.js");
|
|
|
22
18
|
* @param params.args.maxLtv - Maximum post-operation LTV.
|
|
23
19
|
* @param params.args.nativeAmount - Exclusive native collateral funding.
|
|
24
20
|
* @param params.args.reallocations - Vault V2 reallocations executed before borrowing.
|
|
21
|
+
* @param params.args.maxPenalty - Maximum WAD-scaled penalty rate per reallocation in [0, WAD], defaulting to zero. Each rate applies to that reallocation's assets, so it does not bound total proceeds lost.
|
|
25
22
|
* @param params.args.deadline - Final call deadline in Unix seconds.
|
|
26
|
-
* @param params.args.referralFeePct - Optional WAD-scaled fee
|
|
23
|
+
* @param params.args.referralFeePct - Optional WAD-scaled fee at most 10%.
|
|
27
24
|
* @param params.args.referralFeeRecipient - Recipient required for a positive fee.
|
|
28
25
|
* @param params.args.requirementSignature - Optional collateral token signature.
|
|
29
26
|
* @param params.args.authorizationSignature - Optional Blue authorization signature.
|
|
30
27
|
* @param params.metadata - Optional transaction metadata.
|
|
31
28
|
* @returns A deep-frozen `Readonly<Transaction<BlueSupplyCollateralBorrowAction>>`
|
|
32
29
|
* whose `to` address is BlueBundlesV1 and whose `action` records the normalized inputs.
|
|
33
|
-
* @throws {MarketIdMismatchError} when
|
|
30
|
+
* @throws {MarketIdMismatchError} when the target market or a reallocation source market has an
|
|
31
|
+
* `id` that does not hash from its tuple fields.
|
|
32
|
+
* @throws {InvalidBigIntInputError} when a supplied maxPenalty is not a bigint.
|
|
34
33
|
* @throws {NegativeInputError} when an amount, `maxLtv`, native value, or fee is negative.
|
|
34
|
+
* Also thrown when maxPenalty is negative.
|
|
35
35
|
* @throws {NonPositiveInputError} when both operation legs are zero, the deadline is not positive,
|
|
36
36
|
* or a reallocation amount is not positive.
|
|
37
37
|
* @throws {ReallocationsRequireBorrowError} when reallocations accompany no borrow.
|
|
38
|
-
* @throws {InputExceedsMaxError} when a
|
|
38
|
+
* @throws {InputExceedsMaxError} when a reallocation amount or penalty exceeds its ABI bound.
|
|
39
|
+
* Also thrown when maxPenalty exceeds WAD or a penalty exceeds maxPenalty (zero by default).
|
|
39
40
|
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
41
|
+
* @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
|
|
42
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
40
43
|
* @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
|
|
41
44
|
* @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
|
|
42
45
|
* @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
|
|
@@ -75,103 +78,5 @@ const common_js_2 = require("./common.js");
|
|
|
75
78
|
* // tx satisfies Readonly<Transaction<BlueSupplyCollateralBorrowAction>>
|
|
76
79
|
* ```
|
|
77
80
|
*/
|
|
78
|
-
const blueSupplyCollateralBorrow = (params) =>
|
|
79
|
-
const { chainId, marketParams } = params.market;
|
|
80
|
-
(0, validate_js_1.validateMarketParamsId)(marketParams);
|
|
81
|
-
const { userAddress, collateralAssets, borrowAssets, maxLtv, requirementSignature, authorizationSignature, } = params.args;
|
|
82
|
-
for (const [field, value] of [
|
|
83
|
-
["collateralAssets", collateralAssets],
|
|
84
|
-
["borrowAssets", borrowAssets],
|
|
85
|
-
["maxLtv", maxLtv],
|
|
86
|
-
]) {
|
|
87
|
-
(0, validate_js_1.validateUint256Field)(field, value);
|
|
88
|
-
}
|
|
89
|
-
if (collateralAssets === 0n && borrowAssets === 0n) {
|
|
90
|
-
throw new index_js_1.NonPositiveInputError("collateralAssets or borrowAssets", 0n);
|
|
91
|
-
}
|
|
92
|
-
const reallocations = [...(params.args.reallocations ?? [])];
|
|
93
|
-
if (borrowAssets === 0n && reallocations.length > 0) {
|
|
94
|
-
throw new index_js_1.ReallocationsRequireBorrowError();
|
|
95
|
-
}
|
|
96
|
-
if (collateralAssets === 0n && requirementSignature != null) {
|
|
97
|
-
throw new index_js_1.UnexpectedRequirementSignatureError(requirementSignature.action.type);
|
|
98
|
-
}
|
|
99
|
-
if (borrowAssets === 0n && authorizationSignature != null) {
|
|
100
|
-
throw new index_js_1.UnexpectedRequirementSignatureError("authorization");
|
|
101
|
-
}
|
|
102
|
-
const common = {
|
|
103
|
-
chainId,
|
|
104
|
-
userAddress,
|
|
105
|
-
deadline: params.args.deadline,
|
|
106
|
-
referralFeePct: params.args.referralFeePct,
|
|
107
|
-
referralFeeRecipient: params.args.referralFeeRecipient,
|
|
108
|
-
metadata: params.metadata,
|
|
109
|
-
};
|
|
110
|
-
const { referralFeePct, referralFeeRecipient } = (0, common_js_2.normalizeBlueBundlesV1CommonParams)(common);
|
|
111
|
-
const value = (0, common_js_2.validateBlueBundlesV1NativeFunding)({
|
|
112
|
-
chainId,
|
|
113
|
-
token: marketParams.collateralToken,
|
|
114
|
-
fundedAmount: collateralAssets,
|
|
115
|
-
nativeAmount: params.args.nativeAmount,
|
|
116
|
-
requirementSignature,
|
|
117
|
-
});
|
|
118
|
-
const collateralPermit = (0, common_js_2.getBlueBundlesV1TokenPermit)({
|
|
119
|
-
chainId,
|
|
120
|
-
userAddress,
|
|
121
|
-
token: marketParams.collateralToken,
|
|
122
|
-
amount: collateralAssets,
|
|
123
|
-
requirementSignature,
|
|
124
|
-
});
|
|
125
|
-
const signedAuthorization = (0, common_js_2.getBlueBundlesV1SignedAuthorization)({
|
|
126
|
-
chainId,
|
|
127
|
-
userAddress,
|
|
128
|
-
authorizationSignature,
|
|
129
|
-
});
|
|
130
|
-
const publicAllocations = (0, common_js_2.getBlueBundlesV1PublicAllocations)(reallocations, marketParams);
|
|
131
|
-
const reallocationPenaltyAssets = (0, common_js_2.getBlueBundlesV1PenaltyAssets)(publicAllocations);
|
|
132
|
-
if (reallocationPenaltyAssets > borrowAssets) {
|
|
133
|
-
throw new index_js_1.InputExceedsMaxError({
|
|
134
|
-
field: "reallocationPenaltyAssets",
|
|
135
|
-
value: reallocationPenaltyAssets,
|
|
136
|
-
max: borrowAssets,
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
return (0, common_js_2.finalizeBlueBundlesV1Transaction)({
|
|
140
|
-
common,
|
|
141
|
-
value,
|
|
142
|
-
data: (0, viem_1.encodeFunctionData)({
|
|
143
|
-
abi: abis_js_1.blueBundlesV1Abi,
|
|
144
|
-
functionName: "blueBundlesV1SupplyCollateralAndBorrow",
|
|
145
|
-
args: [
|
|
146
|
-
marketParams,
|
|
147
|
-
collateralAssets,
|
|
148
|
-
borrowAssets,
|
|
149
|
-
maxLtv,
|
|
150
|
-
collateralPermit,
|
|
151
|
-
signedAuthorization,
|
|
152
|
-
publicAllocations,
|
|
153
|
-
referralFeePct,
|
|
154
|
-
referralFeeRecipient,
|
|
155
|
-
params.args.deadline,
|
|
156
|
-
],
|
|
157
|
-
}),
|
|
158
|
-
action: {
|
|
159
|
-
type: "blueSupplyCollateralBorrow",
|
|
160
|
-
args: {
|
|
161
|
-
market: marketParams.id,
|
|
162
|
-
collateralAssets,
|
|
163
|
-
borrowAssets,
|
|
164
|
-
maxLtv,
|
|
165
|
-
onBehalf: userAddress,
|
|
166
|
-
nativeAmount: value > 0n ? value : undefined,
|
|
167
|
-
reallocations: publicAllocations.length,
|
|
168
|
-
reallocationPenaltyAssets,
|
|
169
|
-
referralFeePct,
|
|
170
|
-
referralFeeRecipient,
|
|
171
|
-
referralFeeAssets: (0, common_js_1.getBundlesReferralFeeAssets)(borrowAssets - reallocationPenaltyAssets, referralFeePct),
|
|
172
|
-
deadline: params.args.deadline,
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
});
|
|
176
|
-
};
|
|
81
|
+
const blueSupplyCollateralBorrow = (params) => (0, encode_js_1.encodeBlueSupplyCollateralBorrow)((0, supplyCollateralBorrow_internal_js_1.parseBlueSupplyCollateralBorrow)(params));
|
|
177
82
|
exports.blueSupplyCollateralBorrow = blueSupplyCollateralBorrow;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { Address } from "viem";
|
|
3
|
+
import type { AuthorizationRequirementSignature, BlueWithdrawAction, Metadata, Transaction, VaultV2BlueReallocation } from "../../types/index.js";
|
|
4
4
|
/** Parameters for {@link blueWithdraw}. */
|
|
5
5
|
export interface BlueWithdrawParams {
|
|
6
6
|
/** Chain and scoped Morpho Blue market. */
|
|
@@ -18,9 +18,11 @@ export interface BlueWithdrawParams {
|
|
|
18
18
|
readonly withdrawShares: bigint;
|
|
19
19
|
/** Optional validated Vault V2 BluePublicAllocator reallocations. */
|
|
20
20
|
readonly reallocations?: Iterable<VaultV2BlueReallocation>;
|
|
21
|
+
/** Maximum WAD-scaled penalty rate per reallocation, defaulting to zero; it does not bound total proceeds lost. */
|
|
22
|
+
readonly maxPenalty?: bigint;
|
|
21
23
|
/** Final call deadline in Unix seconds. */
|
|
22
24
|
readonly deadline: bigint;
|
|
23
|
-
/** Optional WAD-scaled referral fee,
|
|
25
|
+
/** Optional WAD-scaled referral fee, at most 10%. */
|
|
24
26
|
readonly referralFeePct?: bigint;
|
|
25
27
|
/** Recipient required when `referralFeePct` is positive. */
|
|
26
28
|
readonly referralFeeRecipient?: Address;
|
|
@@ -44,20 +46,27 @@ export interface BlueWithdrawParams {
|
|
|
44
46
|
* @param params.args.withdrawAssets - Exact assets withdrawn, exclusive with shares.
|
|
45
47
|
* @param params.args.withdrawShares - Exact shares burned, exclusive with assets.
|
|
46
48
|
* @param params.args.reallocations - Vault V2 reallocations executed before withdrawal.
|
|
49
|
+
* @param params.args.maxPenalty - Maximum WAD-scaled penalty rate per reallocation in [0, WAD], defaulting to zero. Each rate applies to that reallocation's assets, so it does not bound total proceeds lost.
|
|
47
50
|
* @param params.args.deadline - Final call deadline in Unix seconds.
|
|
48
|
-
* @param params.args.referralFeePct - Optional WAD-scaled fee
|
|
51
|
+
* @param params.args.referralFeePct - Optional WAD-scaled fee at most 10%.
|
|
49
52
|
* @param params.args.referralFeeRecipient - Recipient required for a positive fee.
|
|
50
53
|
* @param params.args.authorizationSignature - Optional Blue authorization signature.
|
|
51
54
|
* @param params.metadata - Optional transaction metadata.
|
|
52
55
|
* @returns A deep-frozen `Readonly<Transaction<BlueWithdrawAction>>` whose `to` address is
|
|
53
56
|
* BlueBundlesV1 and whose `action` records the normalized withdrawal inputs.
|
|
54
|
-
* @throws {MarketIdMismatchError} when
|
|
57
|
+
* @throws {MarketIdMismatchError} when the target market or a reallocation source market has an
|
|
58
|
+
* `id` that does not hash from its tuple fields.
|
|
59
|
+
* @throws {InvalidBigIntInputError} when a supplied maxPenalty is not a bigint.
|
|
55
60
|
* @throws {NegativeInputError} when an amount, fee, or reallocation penalty is negative.
|
|
61
|
+
* Also thrown when maxPenalty is negative.
|
|
56
62
|
* @throws {MutuallyExclusiveWithdrawAmountsError} when assets and shares are both nonzero.
|
|
57
63
|
* @throws {NonPositiveInputError} when neither mode, no valid deadline, or a non-positive
|
|
58
64
|
* reallocation amount is provided.
|
|
59
|
-
* @throws {InputExceedsMaxError} when a withdraw amount,
|
|
65
|
+
* @throws {InputExceedsMaxError} when a withdraw amount, reallocation amount, or penalty exceeds its ABI bound.
|
|
66
|
+
* Also thrown when maxPenalty exceeds WAD or a penalty exceeds maxPenalty (zero by default).
|
|
60
67
|
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
68
|
+
* @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
|
|
69
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
61
70
|
* @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
|
|
62
71
|
* @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
|
|
63
72
|
* @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { parseBlueMarket } from "../../helpers/parse.js";
|
|
2
|
+
import { type BlueWithdrawAction, type Transaction } from "../../types/index.js";
|
|
3
|
+
import type { BlueAllocations, BlueOperationInput } from "./common.js";
|
|
4
|
+
import { parseBlueAllocations } from "./common.js";
|
|
5
|
+
import type { BlueWithdrawParams } from "./withdraw.js";
|
|
6
|
+
declare const blueWithdrawBrand: unique symbol;
|
|
7
|
+
/** Validated withdrawal inputs. @internal */
|
|
8
|
+
export interface BlueWithdrawInput extends BlueOperationInput {
|
|
9
|
+
readonly withdrawAssets: bigint;
|
|
10
|
+
readonly withdrawShares: bigint;
|
|
11
|
+
readonly publicAllocations: BlueAllocations["publicAllocations"];
|
|
12
|
+
readonly reallocationPenaltyAssets: bigint;
|
|
13
|
+
readonly [blueWithdrawBrand]: true;
|
|
14
|
+
}
|
|
15
|
+
/** Parses withdrawal mode after the scalar amount stages. @internal */
|
|
16
|
+
export declare const parseBlueWithdrawMode: (marketParams: ReturnType<typeof parseBlueMarket>, params: {
|
|
17
|
+
readonly withdrawAssets: bigint;
|
|
18
|
+
readonly withdrawShares: bigint;
|
|
19
|
+
readonly field: string;
|
|
20
|
+
}) => {
|
|
21
|
+
withdrawAssets: bigint;
|
|
22
|
+
withdrawShares: bigint;
|
|
23
|
+
};
|
|
24
|
+
/** Parses the penalty bound for assets-mode withdrawals. @internal */
|
|
25
|
+
export declare const parseBlueWithdrawPenalty: (allocations: ReturnType<typeof parseBlueAllocations>, mode: ReturnType<typeof parseBlueWithdrawMode>) => {
|
|
26
|
+
readonly publicAllocations: readonly {
|
|
27
|
+
readonly vault: import("viem").Address;
|
|
28
|
+
readonly adapter: import("viem").Address;
|
|
29
|
+
readonly marketParams: import("../../helpers/parse.js").BlueMarket;
|
|
30
|
+
readonly fromIdle: boolean;
|
|
31
|
+
readonly sourceAdapter: import("viem").Address;
|
|
32
|
+
readonly sourceMarketParams: import("../../helpers/parse.js").BlueMarket;
|
|
33
|
+
readonly assets: bigint;
|
|
34
|
+
readonly penalty: bigint;
|
|
35
|
+
}[];
|
|
36
|
+
readonly penaltyAssets: bigint;
|
|
37
|
+
};
|
|
38
|
+
/** Constructs complete raw withdrawal params, including optional authorization. @internal */
|
|
39
|
+
export declare const parseBlueWithdraw: (params: BlueWithdrawParams) => {
|
|
40
|
+
deadline: bigint;
|
|
41
|
+
referralFeePct: bigint;
|
|
42
|
+
referralFeeRecipient: import("viem").Address;
|
|
43
|
+
chainId: number;
|
|
44
|
+
userAddress: import("viem").Address;
|
|
45
|
+
marketParams: import("../../helpers/parse.js").BlueMarket;
|
|
46
|
+
metadata?: import("../../index.js").Metadata;
|
|
47
|
+
withdrawAssets: bigint;
|
|
48
|
+
withdrawShares: bigint;
|
|
49
|
+
publicAllocations: BlueAllocations["publicAllocations"];
|
|
50
|
+
reallocationPenaltyAssets: bigint;
|
|
51
|
+
[blueWithdrawBrand]: true;
|
|
52
|
+
signedAuthorization: import("./common.js").BlueBundlesV1SignedAuthorization;
|
|
53
|
+
};
|
|
54
|
+
/** Encodes parsed inputs and independently validates supplied signatures. @internal */
|
|
55
|
+
export declare const buildBlueWithdraw: (parsed: BlueWithdrawInput, signatures?: Pick<BlueWithdrawParams["args"], "authorizationSignature">) => Readonly<Transaction<BlueWithdrawAction>>;
|
|
56
|
+
export {};
|