@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,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("../../types/metadata.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,91 @@
|
|
|
1
|
+
import { parseBlueMarket, parseNativeFunding, parseUint256, } from "../../helpers/parse.js";
|
|
2
|
+
import { InputExceedsMaxError, NonPositiveInputError, ReallocationsRequireBorrowError, } from "../../types/index.js";
|
|
3
|
+
import { parseBlueAllocations, parseBlueBundlesV1Common } from "./common.js";
|
|
4
|
+
import { encodeBlueSupplyCollateralBorrow } from "./encode.js";
|
|
5
|
+
import { bindBlueSupplyCollateralBorrowSignatures, validateBlueSupplyCollateralBorrowSignatureLegs, } from "./signatures.js";
|
|
6
|
+
/** Constructs the complete standalone operation from raw params in established error order. @internal */
|
|
7
|
+
export const parseBlueSupplyCollateralBorrow = (params) => {
|
|
8
|
+
const marketParams = parseBlueMarket(params.market.marketParams);
|
|
9
|
+
const amounts = {
|
|
10
|
+
collateralAssets: parseUint256("collateralAssets", params.args.collateralAssets),
|
|
11
|
+
borrowAssets: parseUint256("borrowAssets", params.args.borrowAssets),
|
|
12
|
+
maxLtv: parseUint256("maxLtv", params.args.maxLtv),
|
|
13
|
+
};
|
|
14
|
+
if (amounts.collateralAssets === 0n && amounts.borrowAssets === 0n) {
|
|
15
|
+
throw new NonPositiveInputError("collateralAssets or borrowAssets", 0n);
|
|
16
|
+
}
|
|
17
|
+
const mode = parseBlueSupplyCollateralBorrowMode({
|
|
18
|
+
...amounts,
|
|
19
|
+
reallocations: [...(params.args.reallocations ?? [])],
|
|
20
|
+
maxPenalty: params.args.maxPenalty,
|
|
21
|
+
});
|
|
22
|
+
// Reject signatures for inactive legs before continuing.
|
|
23
|
+
validateBlueSupplyCollateralBorrowSignatureLegs(amounts, params.args);
|
|
24
|
+
const common = {
|
|
25
|
+
chainId: params.market.chainId,
|
|
26
|
+
userAddress: params.args.userAddress,
|
|
27
|
+
deadline: params.args.deadline,
|
|
28
|
+
referralFeePct: params.args.referralFeePct,
|
|
29
|
+
referralFeeRecipient: params.args.referralFeeRecipient,
|
|
30
|
+
metadata: params.metadata,
|
|
31
|
+
};
|
|
32
|
+
const normalized = parseBlueBundlesV1Common(common);
|
|
33
|
+
const value = parseNativeFunding({
|
|
34
|
+
chainId: common.chainId,
|
|
35
|
+
token: marketParams.collateralToken,
|
|
36
|
+
fundedAmount: amounts.collateralAssets,
|
|
37
|
+
nativeAmount: params.args.nativeAmount,
|
|
38
|
+
});
|
|
39
|
+
const bound = bindBlueSupplyCollateralBorrowSignatures({
|
|
40
|
+
...common,
|
|
41
|
+
marketParams,
|
|
42
|
+
collateralAssets: amounts.collateralAssets,
|
|
43
|
+
value,
|
|
44
|
+
}, params.args);
|
|
45
|
+
const allocations = parseBlueSupplyCollateralBorrowAllocations(marketParams, mode);
|
|
46
|
+
const fields = {
|
|
47
|
+
...normalized,
|
|
48
|
+
chainId: common.chainId,
|
|
49
|
+
userAddress: common.userAddress,
|
|
50
|
+
marketParams,
|
|
51
|
+
metadata: common.metadata,
|
|
52
|
+
...amounts,
|
|
53
|
+
value,
|
|
54
|
+
publicAllocations: allocations.publicAllocations,
|
|
55
|
+
reallocationPenaltyAssets: allocations.penaltyAssets,
|
|
56
|
+
};
|
|
57
|
+
const input = fields;
|
|
58
|
+
return { ...input, bound };
|
|
59
|
+
};
|
|
60
|
+
/** Checks reallocation compatibility after the constructor's nonzero-leg guard. @internal */
|
|
61
|
+
export const parseBlueSupplyCollateralBorrowMode = (params) => {
|
|
62
|
+
const { borrowAssets, reallocations } = params;
|
|
63
|
+
if (borrowAssets === 0n && reallocations.length > 0) {
|
|
64
|
+
throw new ReallocationsRequireBorrowError();
|
|
65
|
+
}
|
|
66
|
+
return params;
|
|
67
|
+
};
|
|
68
|
+
/** Parses allocations and their input-only borrow penalty bound. @internal */
|
|
69
|
+
export const parseBlueSupplyCollateralBorrowAllocations = (marketParams, mode) => {
|
|
70
|
+
const allocations = parseBlueAllocations([...mode.reallocations], {
|
|
71
|
+
marketParams,
|
|
72
|
+
maxPenalty: mode.maxPenalty,
|
|
73
|
+
});
|
|
74
|
+
if (allocations.penaltyAssets > mode.borrowAssets) {
|
|
75
|
+
throw new InputExceedsMaxError({
|
|
76
|
+
field: "reallocationPenaltyAssets",
|
|
77
|
+
value: allocations.penaltyAssets,
|
|
78
|
+
max: mode.borrowAssets,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return allocations;
|
|
82
|
+
};
|
|
83
|
+
/** Independently validates fresh buildTx signatures before encoding. @internal */
|
|
84
|
+
export const buildBlueSupplyCollateralBorrow = (parsed, signatures = {}) => {
|
|
85
|
+
// Reject signatures for inactive legs before continuing.
|
|
86
|
+
validateBlueSupplyCollateralBorrowSignatureLegs(parsed, signatures);
|
|
87
|
+
return encodeBlueSupplyCollateralBorrow({
|
|
88
|
+
...parsed,
|
|
89
|
+
bound: bindBlueSupplyCollateralBorrowSignatures(parsed, signatures),
|
|
90
|
+
});
|
|
91
|
+
};
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { validateMarketParamsId, validateUint256Field, } from "../../helpers/validate.js";
|
|
4
|
-
import { InputExceedsMaxError, NonPositiveInputError, ReallocationsRequireBorrowError, UnexpectedRequirementSignatureError, } from "../../types/index.js";
|
|
5
|
-
import { getBundlesReferralFeeAssets } from "../bundles/common.js";
|
|
6
|
-
import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1PenaltyAssets, getBlueBundlesV1PublicAllocations, getBlueBundlesV1SignedAuthorization, getBlueBundlesV1TokenPermit, normalizeBlueBundlesV1CommonParams, validateBlueBundlesV1NativeFunding, } from "./common.js";
|
|
1
|
+
import { encodeBlueSupplyCollateralBorrow } from "./encode.js";
|
|
2
|
+
import { parseBlueSupplyCollateralBorrow } from "./supplyCollateralBorrow.internal.js";
|
|
7
3
|
/**
|
|
8
4
|
* Encodes a direct BlueBundlesV1 collateral supply and/or borrow transaction.
|
|
9
5
|
*
|
|
@@ -19,21 +15,28 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1PenaltyAssets, getBlu
|
|
|
19
15
|
* @param params.args.maxLtv - Maximum post-operation LTV.
|
|
20
16
|
* @param params.args.nativeAmount - Exclusive native collateral funding.
|
|
21
17
|
* @param params.args.reallocations - Vault V2 reallocations executed before borrowing.
|
|
18
|
+
* @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.
|
|
22
19
|
* @param params.args.deadline - Final call deadline in Unix seconds.
|
|
23
|
-
* @param params.args.referralFeePct - Optional WAD-scaled fee
|
|
20
|
+
* @param params.args.referralFeePct - Optional WAD-scaled fee at most 10%.
|
|
24
21
|
* @param params.args.referralFeeRecipient - Recipient required for a positive fee.
|
|
25
22
|
* @param params.args.requirementSignature - Optional collateral token signature.
|
|
26
23
|
* @param params.args.authorizationSignature - Optional Blue authorization signature.
|
|
27
24
|
* @param params.metadata - Optional transaction metadata.
|
|
28
25
|
* @returns A deep-frozen `Readonly<Transaction<BlueSupplyCollateralBorrowAction>>`
|
|
29
26
|
* whose `to` address is BlueBundlesV1 and whose `action` records the normalized inputs.
|
|
30
|
-
* @throws {MarketIdMismatchError} when
|
|
27
|
+
* @throws {MarketIdMismatchError} when the target market or a reallocation source market has an
|
|
28
|
+
* `id` that does not hash from its tuple fields.
|
|
29
|
+
* @throws {InvalidBigIntInputError} when a supplied maxPenalty is not a bigint.
|
|
31
30
|
* @throws {NegativeInputError} when an amount, `maxLtv`, native value, or fee is negative.
|
|
31
|
+
* Also thrown when maxPenalty is negative.
|
|
32
32
|
* @throws {NonPositiveInputError} when both operation legs are zero, the deadline is not positive,
|
|
33
33
|
* or a reallocation amount is not positive.
|
|
34
34
|
* @throws {ReallocationsRequireBorrowError} when reallocations accompany no borrow.
|
|
35
|
-
* @throws {InputExceedsMaxError} when a
|
|
35
|
+
* @throws {InputExceedsMaxError} when a reallocation amount or penalty exceeds its ABI bound.
|
|
36
|
+
* Also thrown when maxPenalty exceeds WAD or a penalty exceeds maxPenalty (zero by default).
|
|
36
37
|
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
38
|
+
* @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
|
|
39
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
37
40
|
* @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
|
|
38
41
|
* @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
|
|
39
42
|
* @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
|
|
@@ -72,102 +75,4 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1PenaltyAssets, getBlu
|
|
|
72
75
|
* // tx satisfies Readonly<Transaction<BlueSupplyCollateralBorrowAction>>
|
|
73
76
|
* ```
|
|
74
77
|
*/
|
|
75
|
-
export const blueSupplyCollateralBorrow = (params) =>
|
|
76
|
-
const { chainId, marketParams } = params.market;
|
|
77
|
-
validateMarketParamsId(marketParams);
|
|
78
|
-
const { userAddress, collateralAssets, borrowAssets, maxLtv, requirementSignature, authorizationSignature, } = params.args;
|
|
79
|
-
for (const [field, value] of [
|
|
80
|
-
["collateralAssets", collateralAssets],
|
|
81
|
-
["borrowAssets", borrowAssets],
|
|
82
|
-
["maxLtv", maxLtv],
|
|
83
|
-
]) {
|
|
84
|
-
validateUint256Field(field, value);
|
|
85
|
-
}
|
|
86
|
-
if (collateralAssets === 0n && borrowAssets === 0n) {
|
|
87
|
-
throw new NonPositiveInputError("collateralAssets or borrowAssets", 0n);
|
|
88
|
-
}
|
|
89
|
-
const reallocations = [...(params.args.reallocations ?? [])];
|
|
90
|
-
if (borrowAssets === 0n && reallocations.length > 0) {
|
|
91
|
-
throw new ReallocationsRequireBorrowError();
|
|
92
|
-
}
|
|
93
|
-
if (collateralAssets === 0n && requirementSignature != null) {
|
|
94
|
-
throw new UnexpectedRequirementSignatureError(requirementSignature.action.type);
|
|
95
|
-
}
|
|
96
|
-
if (borrowAssets === 0n && authorizationSignature != null) {
|
|
97
|
-
throw new UnexpectedRequirementSignatureError("authorization");
|
|
98
|
-
}
|
|
99
|
-
const common = {
|
|
100
|
-
chainId,
|
|
101
|
-
userAddress,
|
|
102
|
-
deadline: params.args.deadline,
|
|
103
|
-
referralFeePct: params.args.referralFeePct,
|
|
104
|
-
referralFeeRecipient: params.args.referralFeeRecipient,
|
|
105
|
-
metadata: params.metadata,
|
|
106
|
-
};
|
|
107
|
-
const { referralFeePct, referralFeeRecipient } = normalizeBlueBundlesV1CommonParams(common);
|
|
108
|
-
const value = validateBlueBundlesV1NativeFunding({
|
|
109
|
-
chainId,
|
|
110
|
-
token: marketParams.collateralToken,
|
|
111
|
-
fundedAmount: collateralAssets,
|
|
112
|
-
nativeAmount: params.args.nativeAmount,
|
|
113
|
-
requirementSignature,
|
|
114
|
-
});
|
|
115
|
-
const collateralPermit = getBlueBundlesV1TokenPermit({
|
|
116
|
-
chainId,
|
|
117
|
-
userAddress,
|
|
118
|
-
token: marketParams.collateralToken,
|
|
119
|
-
amount: collateralAssets,
|
|
120
|
-
requirementSignature,
|
|
121
|
-
});
|
|
122
|
-
const signedAuthorization = getBlueBundlesV1SignedAuthorization({
|
|
123
|
-
chainId,
|
|
124
|
-
userAddress,
|
|
125
|
-
authorizationSignature,
|
|
126
|
-
});
|
|
127
|
-
const publicAllocations = getBlueBundlesV1PublicAllocations(reallocations, marketParams);
|
|
128
|
-
const reallocationPenaltyAssets = getBlueBundlesV1PenaltyAssets(publicAllocations);
|
|
129
|
-
if (reallocationPenaltyAssets > borrowAssets) {
|
|
130
|
-
throw new InputExceedsMaxError({
|
|
131
|
-
field: "reallocationPenaltyAssets",
|
|
132
|
-
value: reallocationPenaltyAssets,
|
|
133
|
-
max: borrowAssets,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
return finalizeBlueBundlesV1Transaction({
|
|
137
|
-
common,
|
|
138
|
-
value,
|
|
139
|
-
data: encodeFunctionData({
|
|
140
|
-
abi: blueBundlesV1Abi,
|
|
141
|
-
functionName: "blueBundlesV1SupplyCollateralAndBorrow",
|
|
142
|
-
args: [
|
|
143
|
-
marketParams,
|
|
144
|
-
collateralAssets,
|
|
145
|
-
borrowAssets,
|
|
146
|
-
maxLtv,
|
|
147
|
-
collateralPermit,
|
|
148
|
-
signedAuthorization,
|
|
149
|
-
publicAllocations,
|
|
150
|
-
referralFeePct,
|
|
151
|
-
referralFeeRecipient,
|
|
152
|
-
params.args.deadline,
|
|
153
|
-
],
|
|
154
|
-
}),
|
|
155
|
-
action: {
|
|
156
|
-
type: "blueSupplyCollateralBorrow",
|
|
157
|
-
args: {
|
|
158
|
-
market: marketParams.id,
|
|
159
|
-
collateralAssets,
|
|
160
|
-
borrowAssets,
|
|
161
|
-
maxLtv,
|
|
162
|
-
onBehalf: userAddress,
|
|
163
|
-
nativeAmount: value > 0n ? value : undefined,
|
|
164
|
-
reallocations: publicAllocations.length,
|
|
165
|
-
reallocationPenaltyAssets,
|
|
166
|
-
referralFeePct,
|
|
167
|
-
referralFeeRecipient,
|
|
168
|
-
referralFeeAssets: getBundlesReferralFeeAssets(borrowAssets - reallocationPenaltyAssets, referralFeePct),
|
|
169
|
-
deadline: params.args.deadline,
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
});
|
|
173
|
-
};
|
|
78
|
+
export const blueSupplyCollateralBorrow = (params) => encodeBlueSupplyCollateralBorrow(parseBlueSupplyCollateralBorrow(params));
|
|
@@ -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("../../types/metadata.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 {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { parseBlueMarket, parseUint256 } from "../../helpers/parse.js";
|
|
2
|
+
import { InputExceedsMaxError, MutuallyExclusiveWithdrawAmountsError, NonPositiveInputError, } from "../../types/index.js";
|
|
3
|
+
import { getBlueBundlesV1SignedAuthorization, parseBlueAllocations, parseBlueBundlesV1Common, } from "./common.js";
|
|
4
|
+
import { encodeBlueWithdraw } from "./encode.js";
|
|
5
|
+
/** Parses withdrawal mode after the scalar amount stages. @internal */
|
|
6
|
+
export const parseBlueWithdrawMode = (marketParams, params) => {
|
|
7
|
+
const { withdrawAssets, withdrawShares, field } = params;
|
|
8
|
+
if (withdrawAssets > 0n && withdrawShares > 0n) {
|
|
9
|
+
throw new MutuallyExclusiveWithdrawAmountsError(marketParams.id);
|
|
10
|
+
}
|
|
11
|
+
if (withdrawAssets === 0n && withdrawShares === 0n) {
|
|
12
|
+
throw new NonPositiveInputError(field, 0n);
|
|
13
|
+
}
|
|
14
|
+
const result = { withdrawAssets, withdrawShares };
|
|
15
|
+
return result;
|
|
16
|
+
};
|
|
17
|
+
/** Parses the penalty bound for assets-mode withdrawals. @internal */
|
|
18
|
+
export const parseBlueWithdrawPenalty = (allocations, mode) => {
|
|
19
|
+
if (mode.withdrawAssets > 0n &&
|
|
20
|
+
allocations.penaltyAssets > mode.withdrawAssets) {
|
|
21
|
+
throw new InputExceedsMaxError({
|
|
22
|
+
field: "reallocationPenaltyAssets",
|
|
23
|
+
value: allocations.penaltyAssets,
|
|
24
|
+
max: mode.withdrawAssets,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return allocations;
|
|
28
|
+
};
|
|
29
|
+
/** Constructs complete raw withdrawal params, including optional authorization. @internal */
|
|
30
|
+
export const parseBlueWithdraw = (params) => {
|
|
31
|
+
const marketParams = parseBlueMarket(params.market.marketParams);
|
|
32
|
+
const amounts = {
|
|
33
|
+
withdrawAssets: parseUint256("withdrawAssets", params.args.withdrawAssets),
|
|
34
|
+
withdrawShares: parseUint256("withdrawShares", params.args.withdrawShares),
|
|
35
|
+
};
|
|
36
|
+
const mode = parseBlueWithdrawMode(marketParams, {
|
|
37
|
+
...amounts,
|
|
38
|
+
field: "withdrawAssets or withdrawShares",
|
|
39
|
+
});
|
|
40
|
+
const common = {
|
|
41
|
+
chainId: params.market.chainId,
|
|
42
|
+
userAddress: params.args.userAddress,
|
|
43
|
+
deadline: params.args.deadline,
|
|
44
|
+
referralFeePct: params.args.referralFeePct,
|
|
45
|
+
referralFeeRecipient: params.args.referralFeeRecipient,
|
|
46
|
+
metadata: params.metadata,
|
|
47
|
+
};
|
|
48
|
+
const normalized = parseBlueBundlesV1Common(common);
|
|
49
|
+
const signedAuthorization = getBlueBundlesV1SignedAuthorization({
|
|
50
|
+
...common,
|
|
51
|
+
authorizationSignature: params.args.authorizationSignature,
|
|
52
|
+
});
|
|
53
|
+
const allocations = parseBlueWithdrawPenalty(parseBlueAllocations([...(params.args.reallocations ?? [])], {
|
|
54
|
+
marketParams,
|
|
55
|
+
maxPenalty: params.args.maxPenalty,
|
|
56
|
+
}), mode);
|
|
57
|
+
const fields = {
|
|
58
|
+
...normalized,
|
|
59
|
+
chainId: common.chainId,
|
|
60
|
+
userAddress: common.userAddress,
|
|
61
|
+
marketParams,
|
|
62
|
+
metadata: common.metadata,
|
|
63
|
+
...amounts,
|
|
64
|
+
publicAllocations: allocations.publicAllocations,
|
|
65
|
+
reallocationPenaltyAssets: allocations.penaltyAssets,
|
|
66
|
+
};
|
|
67
|
+
const input = fields;
|
|
68
|
+
return { ...input, signedAuthorization };
|
|
69
|
+
};
|
|
70
|
+
/** Encodes parsed inputs and independently validates supplied signatures. @internal */
|
|
71
|
+
export const buildBlueWithdraw = (parsed, signatures = {}) => {
|
|
72
|
+
return encodeBlueWithdraw({
|
|
73
|
+
...parsed,
|
|
74
|
+
signedAuthorization: getBlueBundlesV1SignedAuthorization({
|
|
75
|
+
chainId: parsed.chainId,
|
|
76
|
+
userAddress: parsed.userAddress,
|
|
77
|
+
authorizationSignature: signatures.authorizationSignature,
|
|
78
|
+
}),
|
|
79
|
+
});
|
|
80
|
+
};
|