@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
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildBlueWithdraw = exports.parseBlueWithdraw = exports.parseBlueWithdrawPenalty = exports.parseBlueWithdrawMode = 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
|
+
/** Parses withdrawal mode after the scalar amount stages. @internal */
|
|
9
|
+
const parseBlueWithdrawMode = (marketParams, params) => {
|
|
10
|
+
const { withdrawAssets, withdrawShares, field } = params;
|
|
11
|
+
if (withdrawAssets > 0n && withdrawShares > 0n) {
|
|
12
|
+
throw new index_js_1.MutuallyExclusiveWithdrawAmountsError(marketParams.id);
|
|
13
|
+
}
|
|
14
|
+
if (withdrawAssets === 0n && withdrawShares === 0n) {
|
|
15
|
+
throw new index_js_1.NonPositiveInputError(field, 0n);
|
|
16
|
+
}
|
|
17
|
+
const result = { withdrawAssets, withdrawShares };
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
20
|
+
exports.parseBlueWithdrawMode = parseBlueWithdrawMode;
|
|
21
|
+
/** Parses the penalty bound for assets-mode withdrawals. @internal */
|
|
22
|
+
const parseBlueWithdrawPenalty = (allocations, mode) => {
|
|
23
|
+
if (mode.withdrawAssets > 0n &&
|
|
24
|
+
allocations.penaltyAssets > mode.withdrawAssets) {
|
|
25
|
+
throw new index_js_1.InputExceedsMaxError({
|
|
26
|
+
field: "reallocationPenaltyAssets",
|
|
27
|
+
value: allocations.penaltyAssets,
|
|
28
|
+
max: mode.withdrawAssets,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return allocations;
|
|
32
|
+
};
|
|
33
|
+
exports.parseBlueWithdrawPenalty = parseBlueWithdrawPenalty;
|
|
34
|
+
/** Constructs complete raw withdrawal params, including optional authorization. @internal */
|
|
35
|
+
const parseBlueWithdraw = (params) => {
|
|
36
|
+
const marketParams = (0, parse_js_1.parseBlueMarket)(params.market.marketParams);
|
|
37
|
+
const amounts = {
|
|
38
|
+
withdrawAssets: (0, parse_js_1.parseUint256)("withdrawAssets", params.args.withdrawAssets),
|
|
39
|
+
withdrawShares: (0, parse_js_1.parseUint256)("withdrawShares", params.args.withdrawShares),
|
|
40
|
+
};
|
|
41
|
+
const mode = (0, exports.parseBlueWithdrawMode)(marketParams, {
|
|
42
|
+
...amounts,
|
|
43
|
+
field: "withdrawAssets or withdrawShares",
|
|
44
|
+
});
|
|
45
|
+
const common = {
|
|
46
|
+
chainId: params.market.chainId,
|
|
47
|
+
userAddress: params.args.userAddress,
|
|
48
|
+
deadline: params.args.deadline,
|
|
49
|
+
referralFeePct: params.args.referralFeePct,
|
|
50
|
+
referralFeeRecipient: params.args.referralFeeRecipient,
|
|
51
|
+
metadata: params.metadata,
|
|
52
|
+
};
|
|
53
|
+
const normalized = (0, common_js_1.parseBlueBundlesV1Common)(common);
|
|
54
|
+
const signedAuthorization = (0, common_js_1.getBlueBundlesV1SignedAuthorization)({
|
|
55
|
+
...common,
|
|
56
|
+
authorizationSignature: params.args.authorizationSignature,
|
|
57
|
+
});
|
|
58
|
+
const allocations = (0, exports.parseBlueWithdrawPenalty)((0, common_js_1.parseBlueAllocations)([...(params.args.reallocations ?? [])], {
|
|
59
|
+
marketParams,
|
|
60
|
+
maxPenalty: params.args.maxPenalty,
|
|
61
|
+
}), mode);
|
|
62
|
+
const fields = {
|
|
63
|
+
...normalized,
|
|
64
|
+
chainId: common.chainId,
|
|
65
|
+
userAddress: common.userAddress,
|
|
66
|
+
marketParams,
|
|
67
|
+
metadata: common.metadata,
|
|
68
|
+
...amounts,
|
|
69
|
+
publicAllocations: allocations.publicAllocations,
|
|
70
|
+
reallocationPenaltyAssets: allocations.penaltyAssets,
|
|
71
|
+
};
|
|
72
|
+
const input = fields;
|
|
73
|
+
return { ...input, signedAuthorization };
|
|
74
|
+
};
|
|
75
|
+
exports.parseBlueWithdraw = parseBlueWithdraw;
|
|
76
|
+
/** Encodes parsed inputs and independently validates supplied signatures. @internal */
|
|
77
|
+
const buildBlueWithdraw = (parsed, signatures = {}) => {
|
|
78
|
+
return (0, encode_js_1.encodeBlueWithdraw)({
|
|
79
|
+
...parsed,
|
|
80
|
+
signedAuthorization: (0, common_js_1.getBlueBundlesV1SignedAuthorization)({
|
|
81
|
+
chainId: parsed.chainId,
|
|
82
|
+
userAddress: parsed.userAddress,
|
|
83
|
+
authorizationSignature: signatures.authorizationSignature,
|
|
84
|
+
}),
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
exports.buildBlueWithdraw = buildBlueWithdraw;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.blueWithdraw = 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 withdraw_internal_js_1 = require("./withdraw.internal.js");
|
|
10
6
|
/**
|
|
11
7
|
* Encodes a direct BlueBundlesV1 loan-asset withdrawal transaction.
|
|
12
8
|
*
|
|
@@ -21,20 +17,27 @@ const common_js_2 = require("./common.js");
|
|
|
21
17
|
* @param params.args.withdrawAssets - Exact assets withdrawn, exclusive with shares.
|
|
22
18
|
* @param params.args.withdrawShares - Exact shares burned, exclusive with assets.
|
|
23
19
|
* @param params.args.reallocations - Vault V2 reallocations executed before withdrawal.
|
|
20
|
+
* @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.
|
|
24
21
|
* @param params.args.deadline - Final call deadline in Unix seconds.
|
|
25
|
-
* @param params.args.referralFeePct - Optional WAD-scaled fee
|
|
22
|
+
* @param params.args.referralFeePct - Optional WAD-scaled fee at most 10%.
|
|
26
23
|
* @param params.args.referralFeeRecipient - Recipient required for a positive fee.
|
|
27
24
|
* @param params.args.authorizationSignature - Optional Blue authorization signature.
|
|
28
25
|
* @param params.metadata - Optional transaction metadata.
|
|
29
26
|
* @returns A deep-frozen `Readonly<Transaction<BlueWithdrawAction>>` whose `to` address is
|
|
30
27
|
* BlueBundlesV1 and whose `action` records the normalized withdrawal inputs.
|
|
31
|
-
* @throws {MarketIdMismatchError} when
|
|
28
|
+
* @throws {MarketIdMismatchError} when the target market or a reallocation source market has an
|
|
29
|
+
* `id` that does not hash from its tuple fields.
|
|
30
|
+
* @throws {InvalidBigIntInputError} when a supplied maxPenalty is not a bigint.
|
|
32
31
|
* @throws {NegativeInputError} when an amount, fee, or reallocation penalty is negative.
|
|
32
|
+
* Also thrown when maxPenalty is negative.
|
|
33
33
|
* @throws {MutuallyExclusiveWithdrawAmountsError} when assets and shares are both nonzero.
|
|
34
34
|
* @throws {NonPositiveInputError} when neither mode, no valid deadline, or a non-positive
|
|
35
35
|
* reallocation amount is provided.
|
|
36
|
-
* @throws {InputExceedsMaxError} when a withdraw amount,
|
|
36
|
+
* @throws {InputExceedsMaxError} when a withdraw amount, reallocation amount, or penalty exceeds its ABI bound.
|
|
37
|
+
* Also thrown when maxPenalty exceeds WAD or a penalty exceeds maxPenalty (zero by default).
|
|
37
38
|
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
39
|
+
* @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
|
|
40
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
38
41
|
* @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
|
|
39
42
|
* @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
|
|
40
43
|
* @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
|
|
@@ -65,75 +68,5 @@ const common_js_2 = require("./common.js");
|
|
|
65
68
|
* // tx satisfies Readonly<Transaction<BlueWithdrawAction>>
|
|
66
69
|
* ```
|
|
67
70
|
*/
|
|
68
|
-
const blueWithdraw = (params) =>
|
|
69
|
-
const { chainId, marketParams } = params.market;
|
|
70
|
-
(0, validate_js_1.validateMarketParamsId)(marketParams);
|
|
71
|
-
const { userAddress, withdrawAssets, withdrawShares, authorizationSignature, } = params.args;
|
|
72
|
-
(0, validate_js_1.validateUint256Field)("withdrawAssets", withdrawAssets);
|
|
73
|
-
(0, validate_js_1.validateUint256Field)("withdrawShares", withdrawShares);
|
|
74
|
-
if (withdrawAssets > 0n && withdrawShares > 0n) {
|
|
75
|
-
throw new index_js_1.MutuallyExclusiveWithdrawAmountsError(marketParams.id);
|
|
76
|
-
}
|
|
77
|
-
if (withdrawAssets === 0n && withdrawShares === 0n) {
|
|
78
|
-
throw new index_js_1.NonPositiveInputError("withdrawAssets or withdrawShares", 0n);
|
|
79
|
-
}
|
|
80
|
-
const common = {
|
|
81
|
-
chainId,
|
|
82
|
-
userAddress,
|
|
83
|
-
deadline: params.args.deadline,
|
|
84
|
-
referralFeePct: params.args.referralFeePct,
|
|
85
|
-
referralFeeRecipient: params.args.referralFeeRecipient,
|
|
86
|
-
metadata: params.metadata,
|
|
87
|
-
};
|
|
88
|
-
const { referralFeePct, referralFeeRecipient } = (0, common_js_2.normalizeBlueBundlesV1CommonParams)(common);
|
|
89
|
-
const signedAuthorization = (0, common_js_2.getBlueBundlesV1SignedAuthorization)({
|
|
90
|
-
chainId,
|
|
91
|
-
userAddress,
|
|
92
|
-
authorizationSignature,
|
|
93
|
-
});
|
|
94
|
-
const publicAllocations = (0, common_js_2.getBlueBundlesV1PublicAllocations)([...(params.args.reallocations ?? [])], marketParams);
|
|
95
|
-
const reallocationPenaltyAssets = (0, common_js_2.getBlueBundlesV1PenaltyAssets)(publicAllocations);
|
|
96
|
-
if (withdrawAssets > 0n && reallocationPenaltyAssets > withdrawAssets) {
|
|
97
|
-
throw new index_js_1.InputExceedsMaxError({
|
|
98
|
-
field: "reallocationPenaltyAssets",
|
|
99
|
-
value: reallocationPenaltyAssets,
|
|
100
|
-
max: withdrawAssets,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
return (0, common_js_2.finalizeBlueBundlesV1Transaction)({
|
|
104
|
-
common,
|
|
105
|
-
value: 0n,
|
|
106
|
-
data: (0, viem_1.encodeFunctionData)({
|
|
107
|
-
abi: abis_js_1.blueBundlesV1Abi,
|
|
108
|
-
functionName: "blueBundlesV1Withdraw",
|
|
109
|
-
args: [
|
|
110
|
-
marketParams,
|
|
111
|
-
withdrawAssets,
|
|
112
|
-
withdrawShares,
|
|
113
|
-
signedAuthorization,
|
|
114
|
-
publicAllocations,
|
|
115
|
-
referralFeePct,
|
|
116
|
-
referralFeeRecipient,
|
|
117
|
-
params.args.deadline,
|
|
118
|
-
],
|
|
119
|
-
}),
|
|
120
|
-
action: {
|
|
121
|
-
type: "blueWithdraw",
|
|
122
|
-
args: {
|
|
123
|
-
market: marketParams.id,
|
|
124
|
-
withdrawAssets,
|
|
125
|
-
withdrawShares,
|
|
126
|
-
onBehalf: userAddress,
|
|
127
|
-
reallocations: publicAllocations.length,
|
|
128
|
-
reallocationPenaltyAssets,
|
|
129
|
-
referralFeePct,
|
|
130
|
-
referralFeeRecipient,
|
|
131
|
-
referralFeeAssets: withdrawAssets > 0n
|
|
132
|
-
? (0, common_js_1.getBundlesReferralFeeAssets)(withdrawAssets - reallocationPenaltyAssets, referralFeePct)
|
|
133
|
-
: undefined,
|
|
134
|
-
deadline: params.args.deadline,
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
};
|
|
71
|
+
const blueWithdraw = (params) => (0, encode_js_1.encodeBlueWithdraw)((0, withdraw_internal_js_1.parseBlueWithdraw)(params));
|
|
139
72
|
exports.blueWithdraw = blueWithdraw;
|
|
@@ -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 { BlueWithdrawBuyCallbackAction, Metadata, Transaction } from "../../types/index.js";
|
|
4
4
|
/** Parameters for {@link blueWithdrawBuyCallback}. */
|
|
5
5
|
export interface BlueWithdrawBuyCallbackParams {
|
|
6
6
|
/** Chain and scoped Morpho Blue market. */
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Address } from "viem";
|
|
2
|
+
import type { BlueMarket } from "../../helpers/parse.js";
|
|
3
|
+
import { type BlueWithdrawBuyCallbackAction, type Metadata, type Transaction } from "../../types/index.js";
|
|
4
|
+
import type { BlueWithdrawBuyCallbackParams } from "./withdrawBuyCallback.js";
|
|
5
|
+
declare const blueWithdrawBuyCallbackBrand: unique symbol;
|
|
6
|
+
/** Validated direct callback withdrawal inputs. @internal */
|
|
7
|
+
export interface BlueWithdrawBuyCallbackInput {
|
|
8
|
+
readonly metadata?: Metadata;
|
|
9
|
+
readonly marketParams: BlueMarket;
|
|
10
|
+
readonly callbackAddress: Address;
|
|
11
|
+
readonly userAddress: Address;
|
|
12
|
+
readonly shares: bigint;
|
|
13
|
+
readonly to: Address;
|
|
14
|
+
readonly [blueWithdrawBuyCallbackBrand]: true;
|
|
15
|
+
}
|
|
16
|
+
/** Parses the direct callback withdrawal without reading chain state. @internal */
|
|
17
|
+
export declare const parseBlueWithdrawBuyCallback: (params: BlueWithdrawBuyCallbackParams) => BlueWithdrawBuyCallbackInput;
|
|
18
|
+
/** Encodes an already parsed direct callback withdrawal. @internal */
|
|
19
|
+
export declare const buildBlueWithdrawBuyCallback: (parsed: ReturnType<typeof parseBlueWithdrawBuyCallback>) => Readonly<Transaction<BlueWithdrawBuyCallbackAction>>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildBlueWithdrawBuyCallback = exports.parseBlueWithdrawBuyCallback = void 0;
|
|
4
|
+
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
5
|
+
const viem_1 = require("viem");
|
|
6
|
+
const abis_js_1 = require("../../abis.js");
|
|
7
|
+
const index_js_1 = require("../../helpers/index.js");
|
|
8
|
+
const parse_js_1 = require("../../helpers/parse.js");
|
|
9
|
+
const index_js_2 = require("../../types/index.js");
|
|
10
|
+
/** Parses the direct callback withdrawal without reading chain state. @internal */
|
|
11
|
+
const parseBlueWithdrawBuyCallback = (params) => {
|
|
12
|
+
const marketParams = (0, parse_js_1.parseBlueMarket)(params.market.marketParams);
|
|
13
|
+
const { chainId } = params.market;
|
|
14
|
+
const { callbackAddress, userAddress } = params.args;
|
|
15
|
+
const shares = (0, parse_js_1.parseUint256)("shares", params.args.shares);
|
|
16
|
+
if (shares === 0n) {
|
|
17
|
+
throw new index_js_2.NonPositiveInputError("shares", shares);
|
|
18
|
+
}
|
|
19
|
+
const result = {
|
|
20
|
+
metadata: params.metadata,
|
|
21
|
+
marketParams,
|
|
22
|
+
callbackAddress,
|
|
23
|
+
userAddress,
|
|
24
|
+
shares,
|
|
25
|
+
to: (0, morpho_ts_1.getChainAddress)(chainId, "blue"),
|
|
26
|
+
};
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
exports.parseBlueWithdrawBuyCallback = parseBlueWithdrawBuyCallback;
|
|
30
|
+
/** Encodes an already parsed direct callback withdrawal. @internal */
|
|
31
|
+
const buildBlueWithdrawBuyCallback = (parsed) => {
|
|
32
|
+
const { metadata, marketParams, callbackAddress, userAddress, shares, to } = parsed;
|
|
33
|
+
let tx = {
|
|
34
|
+
to,
|
|
35
|
+
value: 0n,
|
|
36
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
37
|
+
abi: abis_js_1.blueAbi,
|
|
38
|
+
functionName: "withdraw",
|
|
39
|
+
args: [marketParams, 0n, shares, callbackAddress, userAddress],
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
if (metadata) {
|
|
43
|
+
tx = (0, index_js_1.addTransactionMetadata)(tx, metadata);
|
|
44
|
+
}
|
|
45
|
+
return (0, morpho_ts_1.deepFreeze)({
|
|
46
|
+
...tx,
|
|
47
|
+
action: {
|
|
48
|
+
type: "blueWithdrawBuyCallback",
|
|
49
|
+
args: {
|
|
50
|
+
market: marketParams.id,
|
|
51
|
+
shares,
|
|
52
|
+
onBehalf: callbackAddress,
|
|
53
|
+
receiver: userAddress,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
exports.buildBlueWithdrawBuyCallback = buildBlueWithdrawBuyCallback;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.blueWithdrawBuyCallback = void 0;
|
|
4
|
-
const
|
|
5
|
-
const viem_1 = require("viem");
|
|
6
|
-
const abis_js_1 = require("../../abis.js");
|
|
7
|
-
const index_js_1 = require("../../helpers/index.js");
|
|
8
|
-
const validate_js_1 = require("../../helpers/validate.js");
|
|
9
|
-
const index_js_2 = require("../../types/index.js");
|
|
4
|
+
const withdrawBuyCallback_internal_js_1 = require("./withdrawBuyCallback.internal.js");
|
|
10
5
|
/**
|
|
11
6
|
* Encodes a direct Morpho Blue `withdraw` of a BlueBuyCallback's supply shares to its owner.
|
|
12
7
|
*
|
|
@@ -44,37 +39,5 @@ const index_js_2 = require("../../types/index.js");
|
|
|
44
39
|
* // tx satisfies Readonly<Transaction<BlueWithdrawBuyCallbackAction>>
|
|
45
40
|
* ```
|
|
46
41
|
*/
|
|
47
|
-
const blueWithdrawBuyCallback = (params) =>
|
|
48
|
-
const { chainId, marketParams } = params.market;
|
|
49
|
-
const { callbackAddress, userAddress, shares } = params.args;
|
|
50
|
-
(0, validate_js_1.validateMarketParamsId)(marketParams);
|
|
51
|
-
(0, validate_js_1.validateUint256Field)("shares", shares);
|
|
52
|
-
if (shares === 0n) {
|
|
53
|
-
throw new index_js_2.NonPositiveInputError("shares", shares);
|
|
54
|
-
}
|
|
55
|
-
let tx = {
|
|
56
|
-
to: (0, morpho_ts_1.getChainAddress)(chainId, "blue"),
|
|
57
|
-
value: 0n,
|
|
58
|
-
data: (0, viem_1.encodeFunctionData)({
|
|
59
|
-
abi: abis_js_1.blueAbi,
|
|
60
|
-
functionName: "withdraw",
|
|
61
|
-
args: [marketParams, 0n, shares, callbackAddress, userAddress],
|
|
62
|
-
}),
|
|
63
|
-
};
|
|
64
|
-
if (params.metadata) {
|
|
65
|
-
tx = (0, index_js_1.addTransactionMetadata)(tx, params.metadata);
|
|
66
|
-
}
|
|
67
|
-
return (0, morpho_ts_1.deepFreeze)({
|
|
68
|
-
...tx,
|
|
69
|
-
action: {
|
|
70
|
-
type: "blueWithdrawBuyCallback",
|
|
71
|
-
args: {
|
|
72
|
-
market: marketParams.id,
|
|
73
|
-
shares,
|
|
74
|
-
onBehalf: callbackAddress,
|
|
75
|
-
receiver: userAddress,
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
};
|
|
42
|
+
const blueWithdrawBuyCallback = (params) => (0, withdrawBuyCallback_internal_js_1.buildBlueWithdrawBuyCallback)((0, withdrawBuyCallback_internal_js_1.parseBlueWithdrawBuyCallback)(params));
|
|
80
43
|
exports.blueWithdrawBuyCallback = blueWithdrawBuyCallback;
|
|
@@ -18,7 +18,7 @@ export interface BlueWithdrawCollateralParams {
|
|
|
18
18
|
readonly maxLtv: 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 BlueWithdrawCollateralParams {
|
|
|
41
41
|
* @param params.args.collateralAssets - Collateral assets withdrawn.
|
|
42
42
|
* @param params.args.maxLtv - Maximum post-operation LTV.
|
|
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.authorizationSignature - Optional Blue authorization signature.
|
|
47
47
|
* @param params.metadata - Optional transaction metadata.
|
|
@@ -50,8 +50,9 @@ export interface BlueWithdrawCollateralParams {
|
|
|
50
50
|
* @throws {MarketIdMismatchError} when `marketParams.id` does not hash from its tuple fields.
|
|
51
51
|
* @throws {NegativeInputError} when collateral, LTV, or fee is negative.
|
|
52
52
|
* @throws {NonPositiveInputError} when collateral or deadline is not positive.
|
|
53
|
-
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
54
53
|
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
54
|
+
* @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
|
|
55
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
55
56
|
* @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
|
|
56
57
|
* @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
|
|
57
58
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BlueWithdrawCollateralAction, Transaction } from "../../types/index.js";
|
|
2
|
+
import { type BlueRepayInput, parseBlueRepayWithdrawCollateral } from "./repayWithdrawCollateral.internal.js";
|
|
3
|
+
import type { BlueWithdrawCollateralParams } from "./withdrawCollateral.js";
|
|
4
|
+
/** Complete collateral-withdrawal input with repayment disabled. @internal */
|
|
5
|
+
export interface BlueWithdrawCollateralInput extends BlueRepayInput {
|
|
6
|
+
readonly repayAssets: 0n;
|
|
7
|
+
readonly repayShares: 0n;
|
|
8
|
+
readonly maxRepayAssets: 0n;
|
|
9
|
+
readonly hasRepay: false;
|
|
10
|
+
}
|
|
11
|
+
/** Constructs the complete raw collateral withdrawal with repayment disabled. @internal */
|
|
12
|
+
export declare const parseBlueWithdrawCollateral: (params: BlueWithdrawCollateralParams & {
|
|
13
|
+
readonly args: Pick<Parameters<typeof parseBlueRepayWithdrawCollateral>[0]["args"], "requirementSignature">;
|
|
14
|
+
}) => BlueWithdrawCollateralInput & Pick<ReturnType<typeof parseBlueRepayWithdrawCollateral>, "bound">;
|
|
15
|
+
/** Encodes only a completed pure collateral-withdrawal operation. @internal */
|
|
16
|
+
export declare const buildBlueWithdrawCollateral: (parsed: ReturnType<typeof parseBlueWithdrawCollateral>) => Readonly<Transaction<BlueWithdrawCollateralAction>>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildBlueWithdrawCollateral = exports.parseBlueWithdrawCollateral = void 0;
|
|
4
|
+
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
5
|
+
const encode_js_1 = require("./encode.js");
|
|
6
|
+
const repayWithdrawCollateral_internal_js_1 = require("./repayWithdrawCollateral.internal.js");
|
|
7
|
+
/** Constructs the complete raw collateral withdrawal with repayment disabled. @internal */
|
|
8
|
+
const parseBlueWithdrawCollateral = (params) => ({
|
|
9
|
+
...(0, repayWithdrawCollateral_internal_js_1.parseBlueRepayWithdrawCollateral)({
|
|
10
|
+
...params,
|
|
11
|
+
args: {
|
|
12
|
+
requirementSignature: params.args.requirementSignature,
|
|
13
|
+
userAddress: params.args.userAddress,
|
|
14
|
+
collateralAssets: params.args.collateralAssets,
|
|
15
|
+
maxLtv: params.args.maxLtv,
|
|
16
|
+
deadline: params.args.deadline,
|
|
17
|
+
referralFeePct: params.args.referralFeePct,
|
|
18
|
+
referralFeeRecipient: params.args.referralFeeRecipient,
|
|
19
|
+
authorizationSignature: params.args.authorizationSignature,
|
|
20
|
+
repayAssets: 0n,
|
|
21
|
+
repayShares: 0n,
|
|
22
|
+
maxRepayAssets: 0n,
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
repayAssets: 0n,
|
|
26
|
+
repayShares: 0n,
|
|
27
|
+
maxRepayAssets: 0n,
|
|
28
|
+
hasRepay: false,
|
|
29
|
+
});
|
|
30
|
+
exports.parseBlueWithdrawCollateral = parseBlueWithdrawCollateral;
|
|
31
|
+
/** Encodes only a completed pure collateral-withdrawal operation. @internal */
|
|
32
|
+
const buildBlueWithdrawCollateral = (parsed) => {
|
|
33
|
+
const transaction = (0, encode_js_1.encodeBlueRepayWithdrawCollateral)(parsed);
|
|
34
|
+
return (0, morpho_ts_1.deepFreeze)({
|
|
35
|
+
...transaction,
|
|
36
|
+
action: { ...transaction.action, type: "blueWithdrawCollateral" },
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
exports.buildBlueWithdrawCollateral = buildBlueWithdrawCollateral;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.blueWithdrawCollateral = void 0;
|
|
4
|
-
const
|
|
5
|
-
const repayWithdrawCollateral_js_1 = require("./repayWithdrawCollateral.js");
|
|
4
|
+
const withdrawCollateral_internal_js_1 = require("./withdrawCollateral.internal.js");
|
|
6
5
|
/**
|
|
7
6
|
* Encodes a pure collateral withdrawal through BlueBundlesV1.
|
|
8
7
|
*
|
|
@@ -16,7 +15,7 @@ const repayWithdrawCollateral_js_1 = require("./repayWithdrawCollateral.js");
|
|
|
16
15
|
* @param params.args.collateralAssets - Collateral assets withdrawn.
|
|
17
16
|
* @param params.args.maxLtv - Maximum post-operation LTV.
|
|
18
17
|
* @param params.args.deadline - Final call deadline in Unix seconds.
|
|
19
|
-
* @param params.args.referralFeePct - Optional WAD-scaled referral fee
|
|
18
|
+
* @param params.args.referralFeePct - Optional WAD-scaled referral fee, at most 10%.
|
|
20
19
|
* @param params.args.referralFeeRecipient - Recipient required for a positive fee.
|
|
21
20
|
* @param params.args.authorizationSignature - Optional Blue authorization signature.
|
|
22
21
|
* @param params.metadata - Optional transaction metadata.
|
|
@@ -25,8 +24,9 @@ const repayWithdrawCollateral_js_1 = require("./repayWithdrawCollateral.js");
|
|
|
25
24
|
* @throws {MarketIdMismatchError} when `marketParams.id` does not hash from its tuple fields.
|
|
26
25
|
* @throws {NegativeInputError} when collateral, LTV, or fee is negative.
|
|
27
26
|
* @throws {NonPositiveInputError} when collateral or deadline is not positive.
|
|
28
|
-
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
29
27
|
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
28
|
+
* @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
|
|
29
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
30
30
|
* @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
|
|
31
31
|
* @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
|
|
32
32
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
@@ -50,19 +50,5 @@ const repayWithdrawCollateral_js_1 = require("./repayWithdrawCollateral.js");
|
|
|
50
50
|
* // tx satisfies Readonly<Transaction<BlueWithdrawCollateralAction>>
|
|
51
51
|
* ```
|
|
52
52
|
*/
|
|
53
|
-
const blueWithdrawCollateral = (params) =>
|
|
54
|
-
const transaction = (0, repayWithdrawCollateral_js_1.blueRepayWithdrawCollateral)({
|
|
55
|
-
...params,
|
|
56
|
-
args: {
|
|
57
|
-
...params.args,
|
|
58
|
-
repayAssets: 0n,
|
|
59
|
-
repayShares: 0n,
|
|
60
|
-
maxRepayAssets: 0n,
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
return (0, morpho_ts_1.deepFreeze)({
|
|
64
|
-
...transaction,
|
|
65
|
-
action: { ...transaction.action, type: "blueWithdrawCollateral" },
|
|
66
|
-
});
|
|
67
|
-
};
|
|
53
|
+
const blueWithdrawCollateral = (params) => (0, withdrawCollateral_internal_js_1.buildBlueWithdrawCollateral)((0, withdrawCollateral_internal_js_1.parseBlueWithdrawCollateral)(params));
|
|
68
54
|
exports.blueWithdrawCollateral = blueWithdrawCollateral;
|
|
@@ -176,6 +176,15 @@ export declare const getBundlesSharesPermit: (params: {
|
|
|
176
176
|
readonly amount?: bigint;
|
|
177
177
|
readonly requirementSignature?: PermitRequirementSignature;
|
|
178
178
|
}) => BundleSharesPermit;
|
|
179
|
+
/** Binds a fresh share signature to a complete operation's checked fallback deadline. @internal */
|
|
180
|
+
export declare const getParsedBundlesSharesPermit: (params: {
|
|
181
|
+
readonly vault: Address;
|
|
182
|
+
readonly deadline: bigint;
|
|
183
|
+
readonly owner?: Address;
|
|
184
|
+
readonly spender?: Address;
|
|
185
|
+
readonly amount?: bigint;
|
|
186
|
+
readonly requirementSignature?: PermitRequirementSignature;
|
|
187
|
+
}) => BundleSharesPermit;
|
|
179
188
|
/**
|
|
180
189
|
* Selects the one token signature accepted by a bundles-funded call.
|
|
181
190
|
*
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.finalizeVaultBundlesV1Transaction = exports.getBundlesReferralFeeAssets = exports.selectBundlesSharesPermitSignature = exports.selectBundlesTokenRequirementSignature = exports.getBundlesSharesPermit = exports.normalizeBundlesSignature = exports.getBundlesTokenPermit = exports.resolveBundlesFunding = exports.normalizeBundlesCommonParams = exports.BundlesPermitKind = void 0;
|
|
3
|
+
exports.finalizeVaultBundlesV1Transaction = exports.getBundlesReferralFeeAssets = exports.selectBundlesSharesPermitSignature = exports.selectBundlesTokenRequirementSignature = exports.getParsedBundlesSharesPermit = exports.getBundlesSharesPermit = exports.normalizeBundlesSignature = exports.getBundlesTokenPermit = exports.resolveBundlesFunding = exports.normalizeBundlesCommonParams = exports.BundlesPermitKind = void 0;
|
|
4
4
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
6
|
const viem_1 = require("viem");
|
|
7
7
|
const index_js_1 = require("../../helpers/index.js");
|
|
8
|
+
const parse_js_1 = require("../../helpers/parse.js");
|
|
8
9
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
9
10
|
const index_js_2 = require("../../types/index.js");
|
|
10
11
|
/** Numeric permit kinds consumed by `TokenLib.pullToken`. */
|
|
@@ -31,10 +32,11 @@ const EMPTY_TOKEN_PERMIT = {
|
|
|
31
32
|
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
32
33
|
*/
|
|
33
34
|
const normalizeBundlesCommonParams = (params) => {
|
|
34
|
-
|
|
35
|
+
const { deadline } = params;
|
|
36
|
+
(0, validate_js_1.validateDeadline)(deadline);
|
|
35
37
|
const { referralFeePct, referralFeeRecipient } = (0, validate_js_1.validateReferralFee)(params);
|
|
36
38
|
return {
|
|
37
|
-
deadline
|
|
39
|
+
deadline,
|
|
38
40
|
referralFeePct,
|
|
39
41
|
referralFeeRecipient,
|
|
40
42
|
};
|
|
@@ -261,9 +263,19 @@ const validateBundlesPermitValue = (params) => {
|
|
|
261
263
|
* ```
|
|
262
264
|
*/
|
|
263
265
|
const getBundlesSharesPermit = (params) => {
|
|
266
|
+
return (0, exports.getParsedBundlesSharesPermit)({
|
|
267
|
+
deadline: (0, parse_js_1.parseDeadline)(params.deadline),
|
|
268
|
+
vault: params.vault,
|
|
269
|
+
owner: params.owner,
|
|
270
|
+
spender: params.spender,
|
|
271
|
+
amount: params.amount,
|
|
272
|
+
requirementSignature: params.requirementSignature,
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
exports.getBundlesSharesPermit = getBundlesSharesPermit;
|
|
276
|
+
/** Binds a fresh share signature to a complete operation's checked fallback deadline. @internal */
|
|
277
|
+
const getParsedBundlesSharesPermit = (params) => {
|
|
264
278
|
const { requirementSignature } = params;
|
|
265
|
-
// Require a positive uint256 for the fallback permit deadline.
|
|
266
|
-
(0, validate_js_1.validateDeadline)(params.deadline);
|
|
267
279
|
if (requirementSignature == null) {
|
|
268
280
|
return {
|
|
269
281
|
value: 0n,
|
|
@@ -346,7 +358,7 @@ const getBundlesSharesPermit = (params) => {
|
|
|
346
358
|
...signature,
|
|
347
359
|
};
|
|
348
360
|
};
|
|
349
|
-
exports.
|
|
361
|
+
exports.getParsedBundlesSharesPermit = getParsedBundlesSharesPermit;
|
|
350
362
|
/**
|
|
351
363
|
* Selects the one token signature accepted by a bundles-funded call.
|
|
352
364
|
*
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export type { BundleSharesPermit, BundlesCommonParams, BundlesTokenPermit, NormalizedBundlesCommonParams, } from "./common.js";
|
|
2
2
|
export { BundlesPermitKind, getBundlesSharesPermit, getBundlesTokenPermit, resolveBundlesFunding, } from "./common.js";
|
|
3
|
-
export
|
|
3
|
+
export { type BundlesTokenRequirementsState, resolveBundlesTokenRequirements, } from "./resolveBundlesTokenRequirements.js";
|
|
@@ -1,23 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.resolveBundlesFunding = exports.getBundlesTokenPermit = exports.getBundlesSharesPermit = exports.BundlesPermitKind = void 0;
|
|
3
|
+
exports.resolveBundlesTokenRequirements = exports.resolveBundlesFunding = exports.getBundlesTokenPermit = exports.getBundlesSharesPermit = exports.BundlesPermitKind = void 0;
|
|
18
4
|
var common_js_1 = require("./common.js");
|
|
19
5
|
Object.defineProperty(exports, "BundlesPermitKind", { enumerable: true, get: function () { return common_js_1.BundlesPermitKind; } });
|
|
20
6
|
Object.defineProperty(exports, "getBundlesSharesPermit", { enumerable: true, get: function () { return common_js_1.getBundlesSharesPermit; } });
|
|
21
7
|
Object.defineProperty(exports, "getBundlesTokenPermit", { enumerable: true, get: function () { return common_js_1.getBundlesTokenPermit; } });
|
|
22
8
|
Object.defineProperty(exports, "resolveBundlesFunding", { enumerable: true, get: function () { return common_js_1.resolveBundlesFunding; } });
|
|
23
|
-
|
|
9
|
+
var resolveBundlesTokenRequirements_js_1 = require("./resolveBundlesTokenRequirements.js");
|
|
10
|
+
Object.defineProperty(exports, "resolveBundlesTokenRequirements", { enumerable: true, get: function () { return resolveBundlesTokenRequirements_js_1.resolveBundlesTokenRequirements; } });
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
import { type BundlesTokenSignatureRequirement, type ERC20ApprovalAction, type ReferenceTimestampParams, type Transaction } from "../../types/index.js";
|
|
3
|
+
import { type Erc20Permit2SignatureTransferInput } from "../requirements/encode/encodeErc20Permit2SignatureTransfer.js";
|
|
4
|
+
import { type RequirementsApprovalInput } from "../requirements/getRequirementsApproval.js";
|
|
5
|
+
declare const bundlesTokenRequirementsInput: unique symbol;
|
|
6
|
+
/** Complete checked state-resolution invocation, with ordered child operations. @internal */
|
|
7
|
+
export interface BundlesTokenRequirementsInput {
|
|
8
|
+
readonly approval?: RequirementsApprovalInput;
|
|
9
|
+
readonly permit?: Erc20Permit2SignatureTransferInput;
|
|
10
|
+
readonly [bundlesTokenRequirementsInput]: true;
|
|
11
|
+
}
|
|
12
|
+
/** Owns the complete state-dependent static contract and legacy error precedence. @internal */
|
|
13
|
+
export declare const parseBundlesTokenRequirements: (params: Parameters<typeof resolveBundlesTokenRequirements>[0]) => BundlesTokenRequirementsInput;
|
|
3
14
|
/** Plain onchain state used by {@link resolveBundlesTokenRequirements}. */
|
|
4
15
|
export type BundlesTokenRequirementsState = {
|
|
5
16
|
readonly type: "approval";
|
|
@@ -76,3 +87,6 @@ export declare const resolveBundlesTokenRequirements: (params: {
|
|
|
76
87
|
readonly deadline: bigint;
|
|
77
88
|
readonly state: BundlesTokenRequirementsState;
|
|
78
89
|
} & ReferenceTimestampParams) => readonly (Readonly<Transaction<ERC20ApprovalAction>> | BundlesTokenSignatureRequirement)[];
|
|
90
|
+
/** Resolves the complete checked operation without repeating its static guards. @internal */
|
|
91
|
+
export declare const resolveParsedBundlesTokenRequirements: (params: BundlesTokenRequirementsInput) => readonly (Readonly<Transaction<ERC20ApprovalAction>> | BundlesTokenSignatureRequirement)[];
|
|
92
|
+
export {};
|