@morpho-org/morpho-sdk 10.1.0-next.0 → 10.1.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 +2 -1
- package/lib/cjs/actions/blue/borrow.internal.d.ts +13 -0
- package/lib/cjs/actions/blue/borrow.internal.js +35 -0
- package/lib/cjs/actions/blue/borrow.js +4 -16
- package/lib/cjs/actions/blue/common.d.ts +50 -28
- package/lib/cjs/actions/blue/common.js +21 -34
- 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 +3 -2
- package/lib/cjs/actions/blue/refinance.internal.d.ts +42 -0
- package/lib/cjs/actions/blue/refinance.internal.js +62 -0
- package/lib/cjs/actions/blue/refinance.js +5 -63
- package/lib/cjs/actions/blue/refinanceValidation.d.ts +4 -5
- package/lib/cjs/actions/blue/refinanceValidation.js +1 -3
- package/lib/cjs/actions/blue/repay.d.ts +1 -1
- 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 +2 -17
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +2 -2
- 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 +3 -116
- 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 +1 -1
- 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 +2 -67
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +1 -1
- 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 +2 -17
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +4 -3
- package/lib/cjs/actions/blue/supplyCollateralBorrow.internal.d.ts +63 -0
- package/lib/cjs/actions/blue/supplyCollateralBorrow.internal.js +94 -0
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +5 -106
- package/lib/cjs/actions/blue/withdraw.d.ts +4 -3
- package/lib/cjs/actions/blue/withdraw.internal.d.ts +56 -0
- package/lib/cjs/actions/blue/withdraw.internal.js +84 -0
- package/lib/cjs/actions/blue/withdraw.js +5 -78
- 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.internal.d.ts +16 -0
- package/lib/cjs/actions/blue/withdrawCollateral.internal.js +39 -0
- package/lib/cjs/actions/blue/withdrawCollateral.js +2 -17
- 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 -66
- 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 -55
- package/lib/cjs/actions/midnight/takeLend.d.ts +21 -1
- package/lib/cjs/actions/midnight/takeLend.js +30 -57
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -2
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +34 -61
- package/lib/cjs/actions/midnight/takeWithdraw.d.ts +17 -2
- package/lib/cjs/actions/midnight/takeWithdraw.js +78 -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 +21 -0
- package/lib/cjs/actions/vaultV1/deposit.js +46 -10
- 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 +21 -0
- package/lib/cjs/actions/vaultV1/migrateToV2.js +49 -11
- package/lib/cjs/actions/vaultV1/redeem.d.ts +19 -0
- package/lib/cjs/actions/vaultV1/redeem.js +28 -7
- package/lib/cjs/actions/vaultV1/withdraw.d.ts +19 -0
- package/lib/cjs/actions/vaultV1/withdraw.js +28 -7
- package/lib/cjs/actions/vaultV2/deposit.d.ts +21 -0
- package/lib/cjs/actions/vaultV2/deposit.js +46 -10
- 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 +23 -1
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +36 -14
- 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 +19 -0
- package/lib/cjs/actions/vaultV2/redeem.js +28 -7
- package/lib/cjs/actions/vaultV2/withdraw.d.ts +19 -0
- package/lib/cjs/actions/vaultV2/withdraw.js +28 -7
- 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/entities/blue/blue.d.ts +35 -8
- package/lib/cjs/entities/blue/blue.js +467 -406
- 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/vaultV1.d.ts +17 -40
- package/lib/cjs/entities/vaultV1/vaultV1.js +228 -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 +29 -86
- package/lib/cjs/entities/vaultV2/vaultV2.js +226 -188
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +2 -3
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +2 -6
- 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/deadShares.js +0 -3
- 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/validate.d.ts +3 -2
- package/lib/cjs/helpers/validate.js +4 -0
- 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/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/refinance.js +17 -9
- package/lib/cjs/transactionPlan/blue/repay.js +2 -1
- package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.js +23 -4
- package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.js +2 -2
- package/lib/cjs/transactionPlan/blue/withdraw.d.ts +2 -2
- package/lib/cjs/transactionPlan/blue/withdraw.js +3 -3
- package/lib/cjs/transactionPlan/blue/withdrawCollateral.js +6 -2
- 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 +2 -2
- package/lib/cjs/transactionPlan/vaultv1/deposit.js +2 -2
- package/lib/cjs/types/action.d.ts +13 -2
- package/lib/cjs/types/error.d.ts +20 -2
- package/lib/cjs/types/error.js +32 -3
- 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 +2 -1
- package/lib/esm/actions/blue/borrow.internal.d.ts +13 -0
- package/lib/esm/actions/blue/borrow.internal.js +30 -0
- package/lib/esm/actions/blue/borrow.js +4 -16
- package/lib/esm/actions/blue/common.d.ts +50 -28
- package/lib/esm/actions/blue/common.js +21 -33
- 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 +3 -2
- package/lib/esm/actions/blue/refinance.internal.d.ts +42 -0
- package/lib/esm/actions/blue/refinance.internal.js +56 -0
- package/lib/esm/actions/blue/refinance.js +5 -63
- package/lib/esm/actions/blue/refinanceValidation.d.ts +4 -5
- package/lib/esm/actions/blue/refinanceValidation.js +2 -4
- package/lib/esm/actions/blue/repay.d.ts +1 -1
- 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 +2 -17
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +2 -2
- 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 +3 -116
- 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 +1 -1
- 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 +2 -67
- package/lib/esm/actions/blue/supplyCollateral.d.ts +1 -1
- 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 +2 -17
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +4 -3
- package/lib/esm/actions/blue/supplyCollateralBorrow.internal.d.ts +63 -0
- package/lib/esm/actions/blue/supplyCollateralBorrow.internal.js +87 -0
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +5 -106
- package/lib/esm/actions/blue/withdraw.d.ts +4 -3
- package/lib/esm/actions/blue/withdraw.internal.d.ts +56 -0
- package/lib/esm/actions/blue/withdraw.internal.js +77 -0
- package/lib/esm/actions/blue/withdraw.js +5 -78
- 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.internal.d.ts +16 -0
- package/lib/esm/actions/blue/withdrawCollateral.internal.js +34 -0
- package/lib/esm/actions/blue/withdrawCollateral.js +2 -17
- 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 +33 -61
- 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 +20 -51
- package/lib/esm/actions/midnight/takeLend.d.ts +21 -1
- package/lib/esm/actions/midnight/takeLend.js +26 -54
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -2
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +30 -58
- package/lib/esm/actions/midnight/takeWithdraw.d.ts +17 -2
- package/lib/esm/actions/midnight/takeWithdraw.js +76 -114
- 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 +21 -0
- package/lib/esm/actions/vaultV1/deposit.js +43 -9
- 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 +21 -0
- package/lib/esm/actions/vaultV1/migrateToV2.js +47 -11
- package/lib/esm/actions/vaultV1/redeem.d.ts +19 -0
- package/lib/esm/actions/vaultV1/redeem.js +26 -7
- package/lib/esm/actions/vaultV1/withdraw.d.ts +19 -0
- package/lib/esm/actions/vaultV1/withdraw.js +26 -7
- package/lib/esm/actions/vaultV2/deposit.d.ts +21 -0
- package/lib/esm/actions/vaultV2/deposit.js +43 -9
- 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 +23 -1
- package/lib/esm/actions/vaultV2/forceWithdraw.js +33 -13
- 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 +19 -0
- package/lib/esm/actions/vaultV2/redeem.js +26 -7
- package/lib/esm/actions/vaultV2/withdraw.d.ts +19 -0
- package/lib/esm/actions/vaultV2/withdraw.js +26 -7
- 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/entities/blue/blue.d.ts +35 -8
- package/lib/esm/entities/blue/blue.js +449 -388
- 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/vaultV1.d.ts +17 -40
- package/lib/esm/entities/vaultV1/vaultV1.js +208 -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 +29 -86
- package/lib/esm/entities/vaultV2/vaultV2.js +210 -172
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +2 -3
- package/lib/esm/entities/vaultV2BlueReallocationData.js +2 -6
- 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/deadShares.js +1 -4
- 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/validate.d.ts +3 -2
- package/lib/esm/helpers/validate.js +5 -1
- 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/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/refinance.js +18 -10
- package/lib/esm/transactionPlan/blue/repay.js +3 -2
- package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.js +24 -5
- package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.js +2 -2
- package/lib/esm/transactionPlan/blue/withdraw.d.ts +2 -2
- package/lib/esm/transactionPlan/blue/withdraw.js +3 -3
- package/lib/esm/transactionPlan/blue/withdrawCollateral.js +6 -2
- 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 +2 -2
- package/lib/esm/transactionPlan/vaultv1/deposit.js +2 -2
- package/lib/esm/types/action.d.ts +13 -2
- package/lib/esm/types/error.d.ts +20 -2
- package/lib/esm/types/error.js +27 -0
- 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,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.blueSupplyCollateralBorrow = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const validate_js_1 = require("../../helpers/validate.js");
|
|
7
|
-
const index_js_1 = require("../../types/index.js");
|
|
8
|
-
const common_js_1 = require("../bundles/common.js");
|
|
9
|
-
const common_js_2 = require("./common.js");
|
|
4
|
+
const encode_js_1 = require("./encode.js");
|
|
5
|
+
const supplyCollateralBorrow_internal_js_1 = require("./supplyCollateralBorrow.internal.js");
|
|
10
6
|
/**
|
|
11
7
|
* Encodes a direct BlueBundlesV1 collateral supply and/or borrow transaction.
|
|
12
8
|
*
|
|
@@ -30,7 +26,8 @@ const common_js_2 = require("./common.js");
|
|
|
30
26
|
* @param params.metadata - Optional transaction metadata.
|
|
31
27
|
* @returns A deep-frozen `Readonly<Transaction<BlueSupplyCollateralBorrowAction>>`
|
|
32
28
|
* whose `to` address is BlueBundlesV1 and whose `action` records the normalized inputs.
|
|
33
|
-
* @throws {MarketIdMismatchError} when
|
|
29
|
+
* @throws {MarketIdMismatchError} when the target market or a reallocation source market has an
|
|
30
|
+
* `id` that does not hash from its tuple fields.
|
|
34
31
|
* @throws {NegativeInputError} when an amount, `maxLtv`, native value, or fee is negative.
|
|
35
32
|
* @throws {NonPositiveInputError} when both operation legs are zero, the deadline is not positive,
|
|
36
33
|
* or a reallocation amount is not positive.
|
|
@@ -75,103 +72,5 @@ const common_js_2 = require("./common.js");
|
|
|
75
72
|
* // tx satisfies Readonly<Transaction<BlueSupplyCollateralBorrowAction>>
|
|
76
73
|
* ```
|
|
77
74
|
*/
|
|
78
|
-
const blueSupplyCollateralBorrow = (params) =>
|
|
79
|
-
const { chainId, marketParams } = params.market;
|
|
80
|
-
(0, validate_js_1.validateMarketParamsId)(marketParams);
|
|
81
|
-
const { userAddress, collateralAssets, borrowAssets, maxLtv, requirementSignature, authorizationSignature, } = params.args;
|
|
82
|
-
for (const [field, value] of [
|
|
83
|
-
["collateralAssets", collateralAssets],
|
|
84
|
-
["borrowAssets", borrowAssets],
|
|
85
|
-
["maxLtv", maxLtv],
|
|
86
|
-
]) {
|
|
87
|
-
(0, validate_js_1.validateUint256Field)(field, value);
|
|
88
|
-
}
|
|
89
|
-
if (collateralAssets === 0n && borrowAssets === 0n) {
|
|
90
|
-
throw new index_js_1.NonPositiveInputError("collateralAssets or borrowAssets", 0n);
|
|
91
|
-
}
|
|
92
|
-
const reallocations = [...(params.args.reallocations ?? [])];
|
|
93
|
-
if (borrowAssets === 0n && reallocations.length > 0) {
|
|
94
|
-
throw new index_js_1.ReallocationsRequireBorrowError();
|
|
95
|
-
}
|
|
96
|
-
if (collateralAssets === 0n && requirementSignature != null) {
|
|
97
|
-
throw new index_js_1.UnexpectedRequirementSignatureError(requirementSignature.action.type);
|
|
98
|
-
}
|
|
99
|
-
if (borrowAssets === 0n && authorizationSignature != null) {
|
|
100
|
-
throw new index_js_1.UnexpectedRequirementSignatureError("authorization");
|
|
101
|
-
}
|
|
102
|
-
const common = {
|
|
103
|
-
chainId,
|
|
104
|
-
userAddress,
|
|
105
|
-
deadline: params.args.deadline,
|
|
106
|
-
referralFeePct: params.args.referralFeePct,
|
|
107
|
-
referralFeeRecipient: params.args.referralFeeRecipient,
|
|
108
|
-
metadata: params.metadata,
|
|
109
|
-
};
|
|
110
|
-
const { referralFeePct, referralFeeRecipient } = (0, common_js_2.normalizeBlueBundlesV1CommonParams)(common);
|
|
111
|
-
const value = (0, common_js_2.validateBlueBundlesV1NativeFunding)({
|
|
112
|
-
chainId,
|
|
113
|
-
token: marketParams.collateralToken,
|
|
114
|
-
fundedAmount: collateralAssets,
|
|
115
|
-
nativeAmount: params.args.nativeAmount,
|
|
116
|
-
requirementSignature,
|
|
117
|
-
});
|
|
118
|
-
const collateralPermit = (0, common_js_2.getBlueBundlesV1TokenPermit)({
|
|
119
|
-
chainId,
|
|
120
|
-
userAddress,
|
|
121
|
-
token: marketParams.collateralToken,
|
|
122
|
-
amount: collateralAssets,
|
|
123
|
-
requirementSignature,
|
|
124
|
-
});
|
|
125
|
-
const signedAuthorization = (0, common_js_2.getBlueBundlesV1SignedAuthorization)({
|
|
126
|
-
chainId,
|
|
127
|
-
userAddress,
|
|
128
|
-
authorizationSignature,
|
|
129
|
-
});
|
|
130
|
-
const publicAllocations = (0, common_js_2.getBlueBundlesV1PublicAllocations)(reallocations, marketParams);
|
|
131
|
-
const reallocationPenaltyAssets = (0, common_js_2.getBlueBundlesV1PenaltyAssets)(publicAllocations);
|
|
132
|
-
if (reallocationPenaltyAssets > borrowAssets) {
|
|
133
|
-
throw new index_js_1.InputExceedsMaxError({
|
|
134
|
-
field: "reallocationPenaltyAssets",
|
|
135
|
-
value: reallocationPenaltyAssets,
|
|
136
|
-
max: borrowAssets,
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
return (0, common_js_2.finalizeBlueBundlesV1Transaction)({
|
|
140
|
-
common,
|
|
141
|
-
value,
|
|
142
|
-
data: (0, viem_1.encodeFunctionData)({
|
|
143
|
-
abi: abis_js_1.blueBundlesV1Abi,
|
|
144
|
-
functionName: "blueBundlesV1SupplyCollateralAndBorrow",
|
|
145
|
-
args: [
|
|
146
|
-
marketParams,
|
|
147
|
-
collateralAssets,
|
|
148
|
-
borrowAssets,
|
|
149
|
-
maxLtv,
|
|
150
|
-
collateralPermit,
|
|
151
|
-
signedAuthorization,
|
|
152
|
-
publicAllocations,
|
|
153
|
-
referralFeePct,
|
|
154
|
-
referralFeeRecipient,
|
|
155
|
-
params.args.deadline,
|
|
156
|
-
],
|
|
157
|
-
}),
|
|
158
|
-
action: {
|
|
159
|
-
type: "blueSupplyCollateralBorrow",
|
|
160
|
-
args: {
|
|
161
|
-
market: marketParams.id,
|
|
162
|
-
collateralAssets,
|
|
163
|
-
borrowAssets,
|
|
164
|
-
maxLtv,
|
|
165
|
-
onBehalf: userAddress,
|
|
166
|
-
nativeAmount: value > 0n ? value : undefined,
|
|
167
|
-
reallocations: publicAllocations.length,
|
|
168
|
-
reallocationPenaltyAssets,
|
|
169
|
-
referralFeePct,
|
|
170
|
-
referralFeeRecipient,
|
|
171
|
-
referralFeeAssets: (0, common_js_1.getBundlesReferralFeeAssets)(borrowAssets - reallocationPenaltyAssets, referralFeePct),
|
|
172
|
-
deadline: params.args.deadline,
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
});
|
|
176
|
-
};
|
|
75
|
+
const blueSupplyCollateralBorrow = (params) => (0, encode_js_1.encodeBlueSupplyCollateralBorrow)((0, supplyCollateralBorrow_internal_js_1.parseBlueSupplyCollateralBorrow)(params));
|
|
177
76
|
exports.blueSupplyCollateralBorrow = blueSupplyCollateralBorrow;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { Address } from "viem";
|
|
3
|
+
import type { AuthorizationRequirementSignature, BlueWithdrawAction, Metadata, Transaction, VaultV2BlueReallocation } from "../../types/index.js";
|
|
4
4
|
/** Parameters for {@link blueWithdraw}. */
|
|
5
5
|
export interface BlueWithdrawParams {
|
|
6
6
|
/** Chain and scoped Morpho Blue market. */
|
|
@@ -51,7 +51,8 @@ export interface BlueWithdrawParams {
|
|
|
51
51
|
* @param params.metadata - Optional transaction metadata.
|
|
52
52
|
* @returns A deep-frozen `Readonly<Transaction<BlueWithdrawAction>>` whose `to` address is
|
|
53
53
|
* BlueBundlesV1 and whose `action` records the normalized withdrawal inputs.
|
|
54
|
-
* @throws {MarketIdMismatchError} when
|
|
54
|
+
* @throws {MarketIdMismatchError} when the target market or a reallocation source market has an
|
|
55
|
+
* `id` that does not hash from its tuple fields.
|
|
55
56
|
* @throws {NegativeInputError} when an amount, fee, or reallocation penalty is negative.
|
|
56
57
|
* @throws {MutuallyExclusiveWithdrawAmountsError} when assets and shares are both nonzero.
|
|
57
58
|
* @throws {NonPositiveInputError} when neither mode, no valid deadline, or a non-positive
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { parseBlueMarket } from "../../helpers/parse.js";
|
|
2
|
+
import { type BlueWithdrawAction, type Transaction } from "../../types/index.js";
|
|
3
|
+
import type { BlueAllocations, BlueOperationInput } from "./common.js";
|
|
4
|
+
import { parseBlueAllocations } from "./common.js";
|
|
5
|
+
import type { BlueWithdrawParams } from "./withdraw.js";
|
|
6
|
+
declare const blueWithdrawBrand: unique symbol;
|
|
7
|
+
/** Validated withdrawal inputs. @internal */
|
|
8
|
+
export interface BlueWithdrawInput extends BlueOperationInput {
|
|
9
|
+
readonly withdrawAssets: bigint;
|
|
10
|
+
readonly withdrawShares: bigint;
|
|
11
|
+
readonly publicAllocations: BlueAllocations["publicAllocations"];
|
|
12
|
+
readonly reallocationPenaltyAssets: bigint;
|
|
13
|
+
readonly [blueWithdrawBrand]: true;
|
|
14
|
+
}
|
|
15
|
+
/** Parses withdrawal mode after the scalar amount stages. @internal */
|
|
16
|
+
export declare const parseBlueWithdrawMode: (marketParams: ReturnType<typeof parseBlueMarket>, params: {
|
|
17
|
+
readonly withdrawAssets: bigint;
|
|
18
|
+
readonly withdrawShares: bigint;
|
|
19
|
+
readonly field: string;
|
|
20
|
+
}) => {
|
|
21
|
+
withdrawAssets: bigint;
|
|
22
|
+
withdrawShares: bigint;
|
|
23
|
+
};
|
|
24
|
+
/** Parses the penalty bound for assets-mode withdrawals. @internal */
|
|
25
|
+
export declare const parseBlueWithdrawPenalty: (allocations: ReturnType<typeof parseBlueAllocations>, mode: ReturnType<typeof parseBlueWithdrawMode>) => {
|
|
26
|
+
readonly publicAllocations: readonly {
|
|
27
|
+
readonly vault: import("viem").Address;
|
|
28
|
+
readonly adapter: import("viem").Address;
|
|
29
|
+
readonly marketParams: import("../../helpers/parse.js").BlueMarket;
|
|
30
|
+
readonly fromIdle: boolean;
|
|
31
|
+
readonly sourceAdapter: import("viem").Address;
|
|
32
|
+
readonly sourceMarketParams: import("../../helpers/parse.js").BlueMarket;
|
|
33
|
+
readonly assets: bigint;
|
|
34
|
+
readonly penalty: bigint;
|
|
35
|
+
}[];
|
|
36
|
+
readonly penaltyAssets: bigint;
|
|
37
|
+
};
|
|
38
|
+
/** Constructs complete raw withdrawal params, including optional authorization. @internal */
|
|
39
|
+
export declare const parseBlueWithdraw: (params: BlueWithdrawParams) => {
|
|
40
|
+
deadline: bigint;
|
|
41
|
+
referralFeePct: bigint;
|
|
42
|
+
referralFeeRecipient: import("viem").Address;
|
|
43
|
+
chainId: number;
|
|
44
|
+
userAddress: import("viem").Address;
|
|
45
|
+
marketParams: import("../../helpers/parse.js").BlueMarket;
|
|
46
|
+
metadata?: import("../../index.js").Metadata;
|
|
47
|
+
withdrawAssets: bigint;
|
|
48
|
+
withdrawShares: bigint;
|
|
49
|
+
publicAllocations: BlueAllocations["publicAllocations"];
|
|
50
|
+
reallocationPenaltyAssets: bigint;
|
|
51
|
+
[blueWithdrawBrand]: true;
|
|
52
|
+
signedAuthorization: import("./common.js").BlueBundlesV1SignedAuthorization;
|
|
53
|
+
};
|
|
54
|
+
/** Encodes parsed inputs and independently validates supplied signatures. @internal */
|
|
55
|
+
export declare const buildBlueWithdraw: (parsed: BlueWithdrawInput, signatures?: Pick<BlueWithdrawParams["args"], "authorizationSignature">) => Readonly<Transaction<BlueWithdrawAction>>;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
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 ?? [])], marketParams), mode);
|
|
59
|
+
const fields = {
|
|
60
|
+
...normalized,
|
|
61
|
+
chainId: common.chainId,
|
|
62
|
+
userAddress: common.userAddress,
|
|
63
|
+
marketParams,
|
|
64
|
+
metadata: common.metadata,
|
|
65
|
+
...amounts,
|
|
66
|
+
publicAllocations: allocations.publicAllocations,
|
|
67
|
+
reallocationPenaltyAssets: allocations.penaltyAssets,
|
|
68
|
+
};
|
|
69
|
+
const input = fields;
|
|
70
|
+
return { ...input, signedAuthorization };
|
|
71
|
+
};
|
|
72
|
+
exports.parseBlueWithdraw = parseBlueWithdraw;
|
|
73
|
+
/** Encodes parsed inputs and independently validates supplied signatures. @internal */
|
|
74
|
+
const buildBlueWithdraw = (parsed, signatures = {}) => {
|
|
75
|
+
return (0, encode_js_1.encodeBlueWithdraw)({
|
|
76
|
+
...parsed,
|
|
77
|
+
signedAuthorization: (0, common_js_1.getBlueBundlesV1SignedAuthorization)({
|
|
78
|
+
chainId: parsed.chainId,
|
|
79
|
+
userAddress: parsed.userAddress,
|
|
80
|
+
authorizationSignature: signatures.authorizationSignature,
|
|
81
|
+
}),
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
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
|
*
|
|
@@ -28,7 +24,8 @@ const common_js_2 = require("./common.js");
|
|
|
28
24
|
* @param params.metadata - Optional transaction metadata.
|
|
29
25
|
* @returns A deep-frozen `Readonly<Transaction<BlueWithdrawAction>>` whose `to` address is
|
|
30
26
|
* BlueBundlesV1 and whose `action` records the normalized withdrawal inputs.
|
|
31
|
-
* @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.
|
|
32
29
|
* @throws {NegativeInputError} when an amount, fee, or reallocation penalty is negative.
|
|
33
30
|
* @throws {MutuallyExclusiveWithdrawAmountsError} when assets and shares are both nonzero.
|
|
34
31
|
* @throws {NonPositiveInputError} when neither mode, no valid deadline, or a non-positive
|
|
@@ -65,75 +62,5 @@ const common_js_2 = require("./common.js");
|
|
|
65
62
|
* // tx satisfies Readonly<Transaction<BlueWithdrawAction>>
|
|
66
63
|
* ```
|
|
67
64
|
*/
|
|
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
|
-
};
|
|
65
|
+
const blueWithdraw = (params) => (0, encode_js_1.encodeBlueWithdraw)((0, withdraw_internal_js_1.parseBlueWithdraw)(params));
|
|
139
66
|
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;
|
|
@@ -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
|
*
|
|
@@ -50,19 +49,5 @@ const repayWithdrawCollateral_js_1 = require("./repayWithdrawCollateral.js");
|
|
|
50
49
|
* // tx satisfies Readonly<Transaction<BlueWithdrawCollateralAction>>
|
|
51
50
|
* ```
|
|
52
51
|
*/
|
|
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
|
-
};
|
|
52
|
+
const blueWithdrawCollateral = (params) => (0, withdrawCollateral_internal_js_1.buildBlueWithdrawCollateral)((0, withdrawCollateral_internal_js_1.parseBlueWithdrawCollateral)(params));
|
|
68
53
|
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
|
*
|