@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,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildBlueRepayWithdrawCollateral = exports.parseBlueRepayCoverage = exports.parseBlueRepayCap = exports.parseBlueRepayMode = exports.parseBlueRepayWithdrawCollateral = void 0;
|
|
4
|
+
const parse_js_1 = require("../../helpers/parse.js");
|
|
5
|
+
const index_js_1 = require("../../types/index.js");
|
|
6
|
+
const common_js_1 = require("./common.js");
|
|
7
|
+
const encode_js_1 = require("./encode.js");
|
|
8
|
+
const signatures_js_1 = require("./signatures.js");
|
|
9
|
+
/** Constructs the complete raw repay operation, preserving signature and funding precedence. @internal */
|
|
10
|
+
const parseBlueRepayWithdrawCollateral = (params) => {
|
|
11
|
+
const marketParams = (0, parse_js_1.parseBlueMarket)(params.market.marketParams);
|
|
12
|
+
const amounts = {
|
|
13
|
+
repayAssets: (0, parse_js_1.parseUint256)("repayAssets", params.args.repayAssets),
|
|
14
|
+
repayShares: (0, parse_js_1.parseUint256)("repayShares", params.args.repayShares),
|
|
15
|
+
maxRepayAssets: (0, parse_js_1.parseUint256)("maxRepayAssets", params.args.maxRepayAssets),
|
|
16
|
+
collateralAssets: (0, parse_js_1.parseUint256)("collateralAssets", params.args.collateralAssets),
|
|
17
|
+
maxLtv: (0, parse_js_1.parseUint256)("maxLtv", params.args.maxLtv),
|
|
18
|
+
};
|
|
19
|
+
const mode = (0, exports.parseBlueRepayMode)(marketParams, amounts);
|
|
20
|
+
const cap = (0, exports.parseBlueRepayCap)(mode, amounts.maxRepayAssets);
|
|
21
|
+
// Reject signatures for inactive legs before continuing.
|
|
22
|
+
(0, signatures_js_1.validateBlueRepaySignatureLegs)(mode, params.args);
|
|
23
|
+
const common = {
|
|
24
|
+
chainId: params.market.chainId,
|
|
25
|
+
userAddress: params.args.userAddress,
|
|
26
|
+
deadline: params.args.deadline,
|
|
27
|
+
referralFeePct: params.args.referralFeePct,
|
|
28
|
+
referralFeeRecipient: params.args.referralFeeRecipient,
|
|
29
|
+
metadata: params.metadata,
|
|
30
|
+
};
|
|
31
|
+
const normalized = (0, common_js_1.parseBlueBundlesV1Common)(common);
|
|
32
|
+
const legs = {
|
|
33
|
+
...normalized,
|
|
34
|
+
chainId: common.chainId,
|
|
35
|
+
userAddress: common.userAddress,
|
|
36
|
+
marketParams,
|
|
37
|
+
metadata: common.metadata,
|
|
38
|
+
...amounts,
|
|
39
|
+
hasRepay: mode.hasRepay,
|
|
40
|
+
minimumRepayAssets: amounts.repayAssets +
|
|
41
|
+
(0, common_js_1.getBlueBundlesV1ReferralFeeAssets)(amounts.repayAssets, normalized.referralFeePct),
|
|
42
|
+
};
|
|
43
|
+
const maxRepayAssets = (0, exports.parseBlueRepayCoverage)(legs, cap);
|
|
44
|
+
const value = (0, parse_js_1.parseNativeFunding)({
|
|
45
|
+
chainId: common.chainId,
|
|
46
|
+
token: marketParams.loanToken,
|
|
47
|
+
fundedAmount: maxRepayAssets,
|
|
48
|
+
nativeAmount: params.args.nativeAmount,
|
|
49
|
+
});
|
|
50
|
+
const fields = {
|
|
51
|
+
...legs,
|
|
52
|
+
maxRepayAssets,
|
|
53
|
+
value,
|
|
54
|
+
};
|
|
55
|
+
const input = fields;
|
|
56
|
+
return {
|
|
57
|
+
...input,
|
|
58
|
+
bound: (0, signatures_js_1.bindBlueRepaySignatures)(input, {
|
|
59
|
+
maxRepayAssets,
|
|
60
|
+
signatures: params.args,
|
|
61
|
+
}),
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
exports.parseBlueRepayWithdrawCollateral = parseBlueRepayWithdrawCollateral;
|
|
65
|
+
/** Parses mutually exclusive repay modes and the nonempty leg rule. @internal */
|
|
66
|
+
const parseBlueRepayMode = (marketParams, amounts) => {
|
|
67
|
+
const { repayAssets, repayShares, collateralAssets } = amounts;
|
|
68
|
+
if (repayAssets > 0n && repayShares > 0n) {
|
|
69
|
+
throw new index_js_1.MutuallyExclusiveRepayAmountsError(marketParams.id);
|
|
70
|
+
}
|
|
71
|
+
const hasRepay = repayAssets > 0n || repayShares > 0n;
|
|
72
|
+
if (!hasRepay && collateralAssets === 0n) {
|
|
73
|
+
throw new index_js_1.NonPositiveInputError("repayAssets, repayShares, or collateralAssets", 0n);
|
|
74
|
+
}
|
|
75
|
+
const result = { hasRepay, collateralAssets };
|
|
76
|
+
return result;
|
|
77
|
+
};
|
|
78
|
+
exports.parseBlueRepayMode = parseBlueRepayMode;
|
|
79
|
+
/** Parses active/inactive funding-cap rules. @internal */
|
|
80
|
+
const parseBlueRepayCap = (mode, maxRepayAssets) => {
|
|
81
|
+
if (mode.hasRepay && maxRepayAssets === 0n) {
|
|
82
|
+
throw new index_js_1.NonPositiveInputError("maxRepayAssets", maxRepayAssets);
|
|
83
|
+
}
|
|
84
|
+
if (!mode.hasRepay && maxRepayAssets > 0n) {
|
|
85
|
+
throw new index_js_1.InputExceedsMaxError({
|
|
86
|
+
field: "maxRepayAssets",
|
|
87
|
+
value: maxRepayAssets,
|
|
88
|
+
max: 0n,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return maxRepayAssets;
|
|
92
|
+
};
|
|
93
|
+
exports.parseBlueRepayCap = parseBlueRepayCap;
|
|
94
|
+
/** Parses cap coverage, after common referral normalization. @internal */
|
|
95
|
+
const parseBlueRepayCoverage = (legs, maxRepayAssets) => {
|
|
96
|
+
if (legs.minimumRepayAssets > maxRepayAssets) {
|
|
97
|
+
throw new index_js_1.MaxRepayAssetsBelowRepayAssetsError(maxRepayAssets, legs.minimumRepayAssets);
|
|
98
|
+
}
|
|
99
|
+
return maxRepayAssets;
|
|
100
|
+
};
|
|
101
|
+
exports.parseBlueRepayCoverage = parseBlueRepayCoverage;
|
|
102
|
+
/** Independently validates fresh buildTx signatures before encoding. @internal */
|
|
103
|
+
const buildBlueRepayWithdrawCollateral = (parsed, signatures = {}) => {
|
|
104
|
+
const maxRepayAssets = (0, signatures_js_1.parseBlueRepaySignatureFunding)(parsed, signatures);
|
|
105
|
+
// Reject signatures for inactive legs before continuing.
|
|
106
|
+
(0, signatures_js_1.validateBlueRepaySignatureLegs)(parsed, signatures);
|
|
107
|
+
return (0, encode_js_1.encodeBlueRepayWithdrawCollateral)({
|
|
108
|
+
...parsed,
|
|
109
|
+
bound: (0, signatures_js_1.bindBlueRepaySignatures)(parsed, { maxRepayAssets, signatures }),
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
exports.buildBlueRepayWithdrawCollateral = buildBlueRepayWithdrawCollateral;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.blueRepayWithdrawCollateral = 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("./common.js");
|
|
4
|
+
const encode_js_1 = require("./encode.js");
|
|
5
|
+
const repayWithdrawCollateral_internal_js_1 = require("./repayWithdrawCollateral.internal.js");
|
|
9
6
|
/**
|
|
10
7
|
* Encodes a direct BlueBundlesV1 repay and/or collateral-withdrawal transaction.
|
|
11
8
|
*
|
|
@@ -24,7 +21,7 @@ const common_js_1 = require("./common.js");
|
|
|
24
21
|
* @param params.args.maxLtv - Maximum post-operation LTV.
|
|
25
22
|
* @param params.args.nativeAmount - Exclusive native repay funding.
|
|
26
23
|
* @param params.args.deadline - Final call deadline in Unix seconds.
|
|
27
|
-
* @param params.args.referralFeePct - Optional WAD-scaled fee
|
|
24
|
+
* @param params.args.referralFeePct - Optional WAD-scaled fee at most 10%.
|
|
28
25
|
* @param params.args.referralFeeRecipient - Recipient required for a positive fee.
|
|
29
26
|
* @param params.args.requirementSignature - Optional loan-token signature.
|
|
30
27
|
* @param params.args.authorizationSignature - Optional Blue authorization signature.
|
|
@@ -36,8 +33,9 @@ const common_js_1 = require("./common.js");
|
|
|
36
33
|
* @throws {MutuallyExclusiveRepayAmountsError} when assets and shares are both nonzero.
|
|
37
34
|
* @throws {NonPositiveInputError} when both operation legs are zero, repay funding is absent, or the deadline is invalid.
|
|
38
35
|
* @throws {MaxRepayAssetsBelowRepayAssetsError} when exact-asset funding cannot cover the repayment and referral fee.
|
|
39
|
-
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
40
36
|
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
37
|
+
* @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
|
|
38
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
41
39
|
* @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
|
|
42
40
|
* @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
|
|
43
41
|
* @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
|
|
@@ -72,115 +70,5 @@ const common_js_1 = require("./common.js");
|
|
|
72
70
|
* // tx satisfies Readonly<Transaction<BlueRepayWithdrawCollateralAction>>
|
|
73
71
|
* ```
|
|
74
72
|
*/
|
|
75
|
-
const blueRepayWithdrawCollateral = (params) =>
|
|
76
|
-
const { chainId, marketParams } = params.market;
|
|
77
|
-
(0, validate_js_1.validateMarketParamsId)(marketParams);
|
|
78
|
-
const { userAddress, repayAssets, repayShares, maxRepayAssets, collateralAssets, maxLtv, requirementSignature, authorizationSignature, } = params.args;
|
|
79
|
-
for (const [field, value] of [
|
|
80
|
-
["repayAssets", repayAssets],
|
|
81
|
-
["repayShares", repayShares],
|
|
82
|
-
["maxRepayAssets", maxRepayAssets],
|
|
83
|
-
["collateralAssets", collateralAssets],
|
|
84
|
-
["maxLtv", maxLtv],
|
|
85
|
-
]) {
|
|
86
|
-
(0, validate_js_1.validateUint256Field)(field, value);
|
|
87
|
-
}
|
|
88
|
-
if (repayAssets > 0n && repayShares > 0n) {
|
|
89
|
-
throw new index_js_1.MutuallyExclusiveRepayAmountsError(marketParams.id);
|
|
90
|
-
}
|
|
91
|
-
const hasRepay = repayAssets + repayShares > 0n;
|
|
92
|
-
if (repayAssets + repayShares + collateralAssets === 0n) {
|
|
93
|
-
throw new index_js_1.NonPositiveInputError("repayAssets, repayShares, or collateralAssets", 0n);
|
|
94
|
-
}
|
|
95
|
-
if (hasRepay && maxRepayAssets === 0n) {
|
|
96
|
-
throw new index_js_1.NonPositiveInputError("maxRepayAssets", maxRepayAssets);
|
|
97
|
-
}
|
|
98
|
-
if (!hasRepay && maxRepayAssets > 0n) {
|
|
99
|
-
// Withdrawal-only has no repay leg to fund: reject stray funding that would encode a phantom
|
|
100
|
-
// repay. Native funding is transitively rejected — `validateBlueBundlesV1NativeFunding`
|
|
101
|
-
// requires `nativeAmount === maxRepayAssets` (= 0).
|
|
102
|
-
throw new index_js_1.InputExceedsMaxError({
|
|
103
|
-
field: "maxRepayAssets",
|
|
104
|
-
value: maxRepayAssets,
|
|
105
|
-
max: 0n,
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
if (!hasRepay && requirementSignature != null) {
|
|
109
|
-
throw new index_js_1.UnexpectedRequirementSignatureError(requirementSignature.action.type);
|
|
110
|
-
}
|
|
111
|
-
if (collateralAssets === 0n && authorizationSignature != null) {
|
|
112
|
-
throw new index_js_1.UnexpectedRequirementSignatureError("authorization");
|
|
113
|
-
}
|
|
114
|
-
const common = {
|
|
115
|
-
chainId,
|
|
116
|
-
userAddress,
|
|
117
|
-
deadline: params.args.deadline,
|
|
118
|
-
referralFeePct: params.args.referralFeePct,
|
|
119
|
-
referralFeeRecipient: params.args.referralFeeRecipient,
|
|
120
|
-
metadata: params.metadata,
|
|
121
|
-
};
|
|
122
|
-
const { referralFeePct, referralFeeRecipient } = (0, common_js_1.normalizeBlueBundlesV1CommonParams)(common);
|
|
123
|
-
const minimumRepayAssets = repayAssets +
|
|
124
|
-
(0, common_js_1.getBlueBundlesV1ReferralFeeAssets)(repayAssets, referralFeePct);
|
|
125
|
-
if (minimumRepayAssets > maxRepayAssets) {
|
|
126
|
-
throw new index_js_1.MaxRepayAssetsBelowRepayAssetsError(maxRepayAssets, minimumRepayAssets);
|
|
127
|
-
}
|
|
128
|
-
const value = (0, common_js_1.validateBlueBundlesV1NativeFunding)({
|
|
129
|
-
chainId,
|
|
130
|
-
token: marketParams.loanToken,
|
|
131
|
-
fundedAmount: maxRepayAssets,
|
|
132
|
-
nativeAmount: params.args.nativeAmount,
|
|
133
|
-
requirementSignature,
|
|
134
|
-
});
|
|
135
|
-
const loanTokenPermit = (0, common_js_1.getBlueBundlesV1TokenPermit)({
|
|
136
|
-
chainId,
|
|
137
|
-
userAddress,
|
|
138
|
-
token: marketParams.loanToken,
|
|
139
|
-
amount: maxRepayAssets,
|
|
140
|
-
requirementSignature,
|
|
141
|
-
});
|
|
142
|
-
const signedAuthorization = (0, common_js_1.getBlueBundlesV1SignedAuthorization)({
|
|
143
|
-
chainId,
|
|
144
|
-
userAddress,
|
|
145
|
-
authorizationSignature,
|
|
146
|
-
});
|
|
147
|
-
return (0, common_js_1.finalizeBlueBundlesV1Transaction)({
|
|
148
|
-
common,
|
|
149
|
-
value,
|
|
150
|
-
data: (0, viem_1.encodeFunctionData)({
|
|
151
|
-
abi: abis_js_1.blueBundlesV1Abi,
|
|
152
|
-
functionName: "blueBundlesV1RepayAndWithdrawCollateral",
|
|
153
|
-
args: [
|
|
154
|
-
marketParams,
|
|
155
|
-
repayAssets,
|
|
156
|
-
repayShares,
|
|
157
|
-
maxRepayAssets,
|
|
158
|
-
collateralAssets,
|
|
159
|
-
maxLtv,
|
|
160
|
-
loanTokenPermit,
|
|
161
|
-
signedAuthorization,
|
|
162
|
-
referralFeePct,
|
|
163
|
-
referralFeeRecipient,
|
|
164
|
-
params.args.deadline,
|
|
165
|
-
],
|
|
166
|
-
}),
|
|
167
|
-
action: {
|
|
168
|
-
type: "blueRepayWithdrawCollateral",
|
|
169
|
-
args: {
|
|
170
|
-
market: marketParams.id,
|
|
171
|
-
repayAssets,
|
|
172
|
-
repayShares,
|
|
173
|
-
maxRepayAssets,
|
|
174
|
-
collateralAssets,
|
|
175
|
-
maxLtv,
|
|
176
|
-
onBehalf: userAddress,
|
|
177
|
-
nativeAmount: value > 0n ? value : undefined,
|
|
178
|
-
referralFeePct,
|
|
179
|
-
referralFeeRecipient,
|
|
180
|
-
referralFeeAssets: repayAssets > 0n ? minimumRepayAssets - repayAssets : undefined,
|
|
181
|
-
deadline: params.args.deadline,
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
});
|
|
185
|
-
};
|
|
73
|
+
const blueRepayWithdrawCollateral = (params) => (0, encode_js_1.encodeBlueRepayWithdrawCollateral)((0, repayWithdrawCollateral_internal_js_1.parseBlueRepayWithdrawCollateral)(params));
|
|
186
74
|
exports.blueRepayWithdrawCollateral = blueRepayWithdrawCollateral;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { getBlueBundlesV1SignedAuthorization, getBlueBundlesV1TokenPermit } from "./common.js";
|
|
2
|
+
import type { BlueRepayInput, parseBlueRepayMode } from "./repayWithdrawCollateral.internal.js";
|
|
3
|
+
import type { BlueRepayWithdrawCollateralParams } from "./repayWithdrawCollateral.js";
|
|
4
|
+
import type { BlueSupplyCollateralBorrowInput } from "./supplyCollateralBorrow.internal.js";
|
|
5
|
+
import type { BlueSupplyCollateralBorrowParams } from "./supplyCollateralBorrow.js";
|
|
6
|
+
/** Validates signature presence for inactive legs. @internal */
|
|
7
|
+
export declare const validateBlueSupplyCollateralBorrowSignatureLegs: (amounts: {
|
|
8
|
+
readonly collateralAssets: bigint;
|
|
9
|
+
readonly borrowAssets: bigint;
|
|
10
|
+
}, signatures: Pick<BlueSupplyCollateralBorrowParams["args"], "requirementSignature" | "authorizationSignature">) => void;
|
|
11
|
+
/** Independently binds signatures for active funding and borrow legs. @internal */
|
|
12
|
+
export declare const bindBlueSupplyCollateralBorrowSignatures: (parsed: Pick<BlueSupplyCollateralBorrowInput, "chainId" | "userAddress" | "marketParams" | "collateralAssets" | "value">, signatures: Pick<BlueSupplyCollateralBorrowParams["args"], "requirementSignature" | "authorizationSignature">) => {
|
|
13
|
+
readonly collateralPermit: ReturnType<typeof getBlueBundlesV1TokenPermit>;
|
|
14
|
+
readonly signedAuthorization: ReturnType<typeof getBlueBundlesV1SignedAuthorization>;
|
|
15
|
+
};
|
|
16
|
+
/** Validates signatures for inactive repay/withdraw legs. @internal */
|
|
17
|
+
export declare const validateBlueRepaySignatureLegs: (mode: Pick<ReturnType<typeof parseBlueRepayMode>, "hasRepay" | "collateralAssets">, signatures: Pick<BlueRepayWithdrawCollateralParams["args"], "requirementSignature" | "authorizationSignature">) => void;
|
|
18
|
+
/** Parses fresh signature-selected full-repay funding. @internal */
|
|
19
|
+
export declare const parseBlueRepaySignatureFunding: (parsed: BlueRepayInput, signatures: Pick<BlueRepayWithdrawCollateralParams["args"], "requirementSignature" | "authorizationSignature"> & {
|
|
20
|
+
readonly signatureFunding?: boolean;
|
|
21
|
+
}) => bigint;
|
|
22
|
+
/** Binds independently supplied token and authorization signatures. @internal */
|
|
23
|
+
export declare const bindBlueRepaySignatures: (parsed: BlueRepayInput, params: {
|
|
24
|
+
readonly maxRepayAssets: bigint;
|
|
25
|
+
readonly signatures: Pick<BlueRepayWithdrawCollateralParams["args"], "requirementSignature" | "authorizationSignature">;
|
|
26
|
+
}) => {
|
|
27
|
+
readonly maxRepayAssets: bigint;
|
|
28
|
+
readonly loanTokenPermit: ReturnType<typeof getBlueBundlesV1TokenPermit>;
|
|
29
|
+
readonly signedAuthorization: ReturnType<typeof getBlueBundlesV1SignedAuthorization>;
|
|
30
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bindBlueRepaySignatures = exports.parseBlueRepaySignatureFunding = exports.validateBlueRepaySignatureLegs = exports.bindBlueSupplyCollateralBorrowSignatures = exports.validateBlueSupplyCollateralBorrowSignatureLegs = 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
|
+
/** Validates signature presence for inactive legs. @internal */
|
|
8
|
+
const validateBlueSupplyCollateralBorrowSignatureLegs = (amounts, signatures) => {
|
|
9
|
+
const { collateralAssets, borrowAssets } = amounts;
|
|
10
|
+
const { requirementSignature, authorizationSignature } = signatures;
|
|
11
|
+
if (collateralAssets === 0n && requirementSignature != null) {
|
|
12
|
+
throw new index_js_1.UnexpectedRequirementSignatureError(requirementSignature.action.type);
|
|
13
|
+
}
|
|
14
|
+
if (borrowAssets === 0n && authorizationSignature != null) {
|
|
15
|
+
throw new index_js_1.UnexpectedRequirementSignatureError("authorization");
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
exports.validateBlueSupplyCollateralBorrowSignatureLegs = validateBlueSupplyCollateralBorrowSignatureLegs;
|
|
19
|
+
/** Independently binds signatures for active funding and borrow legs. @internal */
|
|
20
|
+
const bindBlueSupplyCollateralBorrowSignatures = (parsed, signatures) => {
|
|
21
|
+
const { chainId, userAddress, marketParams, collateralAssets, value } = parsed;
|
|
22
|
+
const { requirementSignature, authorizationSignature } = signatures;
|
|
23
|
+
if (value > 0n && requirementSignature != null) {
|
|
24
|
+
throw new index_js_1.UnexpectedRequirementSignatureError(requirementSignature.action.type);
|
|
25
|
+
}
|
|
26
|
+
const collateralPermit = (0, common_js_1.getBlueBundlesV1TokenPermit)({
|
|
27
|
+
chainId,
|
|
28
|
+
userAddress,
|
|
29
|
+
token: marketParams.collateralToken,
|
|
30
|
+
amount: collateralAssets,
|
|
31
|
+
requirementSignature,
|
|
32
|
+
});
|
|
33
|
+
const signedAuthorization = (0, common_js_1.getBlueBundlesV1SignedAuthorization)({
|
|
34
|
+
chainId,
|
|
35
|
+
userAddress,
|
|
36
|
+
authorizationSignature,
|
|
37
|
+
});
|
|
38
|
+
return { collateralPermit, signedAuthorization };
|
|
39
|
+
};
|
|
40
|
+
exports.bindBlueSupplyCollateralBorrowSignatures = bindBlueSupplyCollateralBorrowSignatures;
|
|
41
|
+
/** Validates signatures for inactive repay/withdraw legs. @internal */
|
|
42
|
+
const validateBlueRepaySignatureLegs = (mode, signatures) => {
|
|
43
|
+
const { hasRepay, collateralAssets } = mode;
|
|
44
|
+
const { requirementSignature, authorizationSignature } = signatures;
|
|
45
|
+
if (!hasRepay && requirementSignature != null) {
|
|
46
|
+
throw new index_js_1.UnexpectedRequirementSignatureError(requirementSignature.action.type);
|
|
47
|
+
}
|
|
48
|
+
if (collateralAssets === 0n && authorizationSignature != null) {
|
|
49
|
+
throw new index_js_1.UnexpectedRequirementSignatureError("authorization");
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
exports.validateBlueRepaySignatureLegs = validateBlueRepaySignatureLegs;
|
|
53
|
+
/** Parses fresh signature-selected full-repay funding. @internal */
|
|
54
|
+
const parseBlueRepaySignatureFunding = (parsed, signatures) => {
|
|
55
|
+
const { repayShares } = parsed;
|
|
56
|
+
const { requirementSignature, signatureFunding = false } = signatures;
|
|
57
|
+
const selectedMaxRepayAssets = signatureFunding && repayShares > 0n && requirementSignature != null
|
|
58
|
+
? requirementSignature.args.amount
|
|
59
|
+
: parsed.maxRepayAssets;
|
|
60
|
+
if (selectedMaxRepayAssets < parsed.maxRepayAssets) {
|
|
61
|
+
throw new index_js_1.MaxRepayAssetsBelowRepayAssetsError(selectedMaxRepayAssets, parsed.maxRepayAssets);
|
|
62
|
+
}
|
|
63
|
+
const maxRepayAssets = signatureFunding && repayShares > 0n && requirementSignature != null
|
|
64
|
+
? (0, parse_js_1.parseUint256)("maxRepayAssets", selectedMaxRepayAssets)
|
|
65
|
+
: selectedMaxRepayAssets;
|
|
66
|
+
return maxRepayAssets;
|
|
67
|
+
};
|
|
68
|
+
exports.parseBlueRepaySignatureFunding = parseBlueRepaySignatureFunding;
|
|
69
|
+
/** Binds independently supplied token and authorization signatures. @internal */
|
|
70
|
+
const bindBlueRepaySignatures = (parsed, params) => {
|
|
71
|
+
const { chainId, userAddress, marketParams, value } = parsed;
|
|
72
|
+
const { maxRepayAssets, signatures: { requirementSignature, authorizationSignature }, } = params;
|
|
73
|
+
if (value > 0n && requirementSignature != null) {
|
|
74
|
+
throw new index_js_1.UnexpectedRequirementSignatureError(requirementSignature.action.type);
|
|
75
|
+
}
|
|
76
|
+
const loanTokenPermit = (0, common_js_1.getBlueBundlesV1TokenPermit)({
|
|
77
|
+
chainId,
|
|
78
|
+
userAddress,
|
|
79
|
+
token: marketParams.loanToken,
|
|
80
|
+
amount: maxRepayAssets,
|
|
81
|
+
requirementSignature,
|
|
82
|
+
});
|
|
83
|
+
const signedAuthorization = (0, common_js_1.getBlueBundlesV1SignedAuthorization)({
|
|
84
|
+
chainId,
|
|
85
|
+
userAddress,
|
|
86
|
+
authorizationSignature,
|
|
87
|
+
});
|
|
88
|
+
return { maxRepayAssets, loanTokenPermit, signedAuthorization };
|
|
89
|
+
};
|
|
90
|
+
exports.bindBlueRepaySignatures = bindBlueRepaySignatures;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
-
import {
|
|
2
|
+
import type { Address } from "viem";
|
|
3
3
|
import type { BlueSupplyAction, BundlesTokenRequirementSignature, Metadata, Transaction } from "../../types/index.js";
|
|
4
4
|
/** Parameters for {@link blueSupply}. */
|
|
5
5
|
export interface BlueSupplyParams {
|
|
@@ -18,7 +18,7 @@ export interface BlueSupplyParams {
|
|
|
18
18
|
readonly nativeAmount?: bigint;
|
|
19
19
|
/** Final call deadline in Unix seconds. */
|
|
20
20
|
readonly deadline: bigint;
|
|
21
|
-
/** Optional WAD-scaled referral fee,
|
|
21
|
+
/** Optional WAD-scaled referral fee, at most 10%. */
|
|
22
22
|
readonly referralFeePct?: bigint;
|
|
23
23
|
/** Recipient required when `referralFeePct` is positive. */
|
|
24
24
|
readonly referralFeeRecipient?: Address;
|
|
@@ -41,7 +41,7 @@ export interface BlueSupplyParams {
|
|
|
41
41
|
* @param params.args.assets - Gross loan-token funding amount.
|
|
42
42
|
* @param params.args.nativeAmount - Exclusive native funding; must equal `assets`.
|
|
43
43
|
* @param params.args.deadline - Final call deadline in Unix seconds.
|
|
44
|
-
* @param params.args.referralFeePct - Optional WAD-scaled fee
|
|
44
|
+
* @param params.args.referralFeePct - Optional WAD-scaled fee at most 10%.
|
|
45
45
|
* @param params.args.referralFeeRecipient - Recipient required for a positive fee.
|
|
46
46
|
* @param params.args.requirementSignature - Optional ERC-2612 or Permit2 SignatureTransfer result.
|
|
47
47
|
* @param params.metadata - Optional transaction metadata.
|
|
@@ -50,8 +50,10 @@ export interface BlueSupplyParams {
|
|
|
50
50
|
* @throws {MarketIdMismatchError} when `marketParams.id` does not hash from its tuple fields.
|
|
51
51
|
* @throws {NonPositiveInputError} when `assets` or `deadline` is not positive.
|
|
52
52
|
* @throws {NegativeInputError} when `nativeAmount` or `referralFeePct` is negative.
|
|
53
|
-
* @throws {InputExceedsMaxError} when `assets` exceeds `uint256
|
|
53
|
+
* @throws {InputExceedsMaxError} when `assets` exceeds `uint256`.
|
|
54
54
|
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
55
|
+
* @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
|
|
56
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
55
57
|
* @throws {NativeFundingAmountMismatchError} when native funding does not equal `assets`.
|
|
56
58
|
* @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
|
|
57
59
|
* @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { BlueSupplyAction, Transaction } from "../../types/index.js";
|
|
2
|
+
import type { BlueOperationInput } from "./common.js";
|
|
3
|
+
import { getBlueBundlesV1TokenPermit } from "./common.js";
|
|
4
|
+
import type { BlueSupplyParams } from "./supply.js";
|
|
5
|
+
declare const blueSupplyBrand: unique symbol;
|
|
6
|
+
/** Validated supply inputs. @internal */
|
|
7
|
+
export interface BlueSupplyInput extends BlueOperationInput {
|
|
8
|
+
readonly assets: bigint;
|
|
9
|
+
readonly value: bigint;
|
|
10
|
+
readonly [blueSupplyBrand]: true;
|
|
11
|
+
}
|
|
12
|
+
/** Parses the complete raw supply, including its optional funding signature. @internal */
|
|
13
|
+
export declare const parseBlueSupply: (params: BlueSupplyParams) => {
|
|
14
|
+
deadline: bigint;
|
|
15
|
+
referralFeePct: bigint;
|
|
16
|
+
referralFeeRecipient: import("viem").Address;
|
|
17
|
+
chainId: number;
|
|
18
|
+
userAddress: import("viem").Address;
|
|
19
|
+
marketParams: import("../../helpers/parse.js").BlueMarket;
|
|
20
|
+
metadata?: import("../../index.js").Metadata;
|
|
21
|
+
assets: bigint;
|
|
22
|
+
value: bigint;
|
|
23
|
+
[blueSupplyBrand]: true;
|
|
24
|
+
tokenPermit: import("../index.js").BundlesTokenPermit;
|
|
25
|
+
};
|
|
26
|
+
/** Encodes parsed inputs and independently validates supplied signatures. @internal */
|
|
27
|
+
export declare const buildBlueSupply: (parsed: BlueSupplyInput, signatures?: Pick<BlueSupplyParams["args"], "requirementSignature">) => Readonly<Transaction<BlueSupplyAction>>;
|
|
28
|
+
/** Encodes a complete supply including its bound permit. @internal */
|
|
29
|
+
export declare const encodeBlueSupply: (parsed: BlueSupplyInput & {
|
|
30
|
+
readonly tokenPermit: ReturnType<typeof getBlueBundlesV1TokenPermit>;
|
|
31
|
+
}) => Readonly<Transaction<BlueSupplyAction>>;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeBlueSupply = exports.buildBlueSupply = exports.parseBlueSupply = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const abis_js_1 = require("../../abis.js");
|
|
6
|
+
const parse_js_1 = require("../../helpers/parse.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");
|
|
10
|
+
/** Parses the complete raw supply, including its optional funding signature. @internal */
|
|
11
|
+
const parseBlueSupply = (params) => {
|
|
12
|
+
const marketParams = (0, parse_js_1.parseBlueMarket)(params.market.marketParams);
|
|
13
|
+
const amount = params.args.assets;
|
|
14
|
+
if (amount <= 0n) {
|
|
15
|
+
throw new index_js_1.NonPositiveInputError("assets", amount);
|
|
16
|
+
}
|
|
17
|
+
const assets = (0, parse_js_1.parseUint256Max)("assets", amount);
|
|
18
|
+
const common = {
|
|
19
|
+
chainId: params.market.chainId,
|
|
20
|
+
userAddress: params.args.userAddress,
|
|
21
|
+
deadline: params.args.deadline,
|
|
22
|
+
referralFeePct: params.args.referralFeePct,
|
|
23
|
+
referralFeeRecipient: params.args.referralFeeRecipient,
|
|
24
|
+
metadata: params.metadata,
|
|
25
|
+
};
|
|
26
|
+
const normalized = (0, common_js_2.parseBlueBundlesV1Common)(common);
|
|
27
|
+
const value = (0, parse_js_1.parseNativeFunding)({
|
|
28
|
+
chainId: common.chainId,
|
|
29
|
+
token: marketParams.loanToken,
|
|
30
|
+
fundedAmount: assets,
|
|
31
|
+
nativeAmount: params.args.nativeAmount,
|
|
32
|
+
});
|
|
33
|
+
const parsed = {
|
|
34
|
+
...normalized,
|
|
35
|
+
chainId: common.chainId,
|
|
36
|
+
userAddress: common.userAddress,
|
|
37
|
+
marketParams,
|
|
38
|
+
metadata: common.metadata,
|
|
39
|
+
assets,
|
|
40
|
+
value,
|
|
41
|
+
};
|
|
42
|
+
const input = parsed;
|
|
43
|
+
return { ...input, tokenPermit: bindBlueSupplySignature(input, params.args) };
|
|
44
|
+
};
|
|
45
|
+
exports.parseBlueSupply = parseBlueSupply;
|
|
46
|
+
/** Encodes parsed inputs and independently validates supplied signatures. @internal */
|
|
47
|
+
const buildBlueSupply = (parsed, signatures = {}) => {
|
|
48
|
+
return (0, exports.encodeBlueSupply)({
|
|
49
|
+
...parsed,
|
|
50
|
+
tokenPermit: bindBlueSupplySignature(parsed, signatures),
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
exports.buildBlueSupply = buildBlueSupply;
|
|
54
|
+
const bindBlueSupplySignature = (parsed, signatures) => {
|
|
55
|
+
const { chainId, marketParams, assets, userAddress, value } = parsed;
|
|
56
|
+
const { requirementSignature } = signatures;
|
|
57
|
+
if (value > 0n && requirementSignature != null) {
|
|
58
|
+
throw new index_js_1.UnexpectedRequirementSignatureError(requirementSignature.action.type);
|
|
59
|
+
}
|
|
60
|
+
return (0, common_js_2.getBlueBundlesV1TokenPermit)({
|
|
61
|
+
chainId,
|
|
62
|
+
userAddress,
|
|
63
|
+
token: marketParams.loanToken,
|
|
64
|
+
amount: assets,
|
|
65
|
+
requirementSignature,
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
/** Encodes a complete supply including its bound permit. @internal */
|
|
69
|
+
const encodeBlueSupply = (parsed) => {
|
|
70
|
+
const { deadline, marketParams, assets, userAddress, referralFeePct, referralFeeRecipient, value, tokenPermit, } = parsed;
|
|
71
|
+
return (0, common_js_2.finalizeBlueBundlesV1Transaction)({
|
|
72
|
+
common: parsed,
|
|
73
|
+
value,
|
|
74
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
75
|
+
abi: abis_js_1.blueBundlesV1Abi,
|
|
76
|
+
functionName: "blueBundlesV1Supply",
|
|
77
|
+
args: [
|
|
78
|
+
marketParams,
|
|
79
|
+
assets,
|
|
80
|
+
tokenPermit,
|
|
81
|
+
referralFeePct,
|
|
82
|
+
referralFeeRecipient,
|
|
83
|
+
deadline,
|
|
84
|
+
],
|
|
85
|
+
}),
|
|
86
|
+
action: {
|
|
87
|
+
type: "blueSupply",
|
|
88
|
+
args: {
|
|
89
|
+
market: marketParams.id,
|
|
90
|
+
assets,
|
|
91
|
+
onBehalf: userAddress,
|
|
92
|
+
nativeAmount: value > 0n ? value : undefined,
|
|
93
|
+
referralFeePct,
|
|
94
|
+
referralFeeRecipient,
|
|
95
|
+
referralFeeAssets: (0, common_js_1.getBundlesReferralFeeAssets)(assets, referralFeePct),
|
|
96
|
+
deadline,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
exports.encodeBlueSupply = encodeBlueSupply;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.blueSupply = void 0;
|
|
4
|
-
const
|
|
5
|
-
const abis_js_1 = require("../../abis.js");
|
|
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 supply_internal_js_1 = require("./supply.internal.js");
|
|
10
5
|
/**
|
|
11
6
|
* Encodes a direct BlueBundlesV1 loan-asset supply transaction.
|
|
12
7
|
*
|
|
@@ -20,7 +15,7 @@ const common_js_2 = require("./common.js");
|
|
|
20
15
|
* @param params.args.assets - Gross loan-token funding amount.
|
|
21
16
|
* @param params.args.nativeAmount - Exclusive native funding; must equal `assets`.
|
|
22
17
|
* @param params.args.deadline - Final call deadline in Unix seconds.
|
|
23
|
-
* @param params.args.referralFeePct - Optional WAD-scaled fee
|
|
18
|
+
* @param params.args.referralFeePct - Optional WAD-scaled fee at most 10%.
|
|
24
19
|
* @param params.args.referralFeeRecipient - Recipient required for a positive fee.
|
|
25
20
|
* @param params.args.requirementSignature - Optional ERC-2612 or Permit2 SignatureTransfer result.
|
|
26
21
|
* @param params.metadata - Optional transaction metadata.
|
|
@@ -29,8 +24,10 @@ const common_js_2 = require("./common.js");
|
|
|
29
24
|
* @throws {MarketIdMismatchError} when `marketParams.id` does not hash from its tuple fields.
|
|
30
25
|
* @throws {NonPositiveInputError} when `assets` or `deadline` is not positive.
|
|
31
26
|
* @throws {NegativeInputError} when `nativeAmount` or `referralFeePct` is negative.
|
|
32
|
-
* @throws {InputExceedsMaxError} when `assets` exceeds `uint256
|
|
27
|
+
* @throws {InputExceedsMaxError} when `assets` exceeds `uint256`.
|
|
33
28
|
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
29
|
+
* @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
|
|
30
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
34
31
|
* @throws {NativeFundingAmountMismatchError} when native funding does not equal `assets`.
|
|
35
32
|
* @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
|
|
36
33
|
* @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
|
|
@@ -61,65 +58,5 @@ const common_js_2 = require("./common.js");
|
|
|
61
58
|
* // tx satisfies Readonly<Transaction<BlueSupplyAction>>
|
|
62
59
|
* ```
|
|
63
60
|
*/
|
|
64
|
-
const blueSupply = (params) =>
|
|
65
|
-
const { chainId, marketParams } = params.market;
|
|
66
|
-
(0, validate_js_1.validateMarketParamsId)(marketParams);
|
|
67
|
-
const { assets, userAddress, requirementSignature } = params.args;
|
|
68
|
-
if (assets <= 0n) {
|
|
69
|
-
throw new index_js_1.NonPositiveInputError("assets", assets);
|
|
70
|
-
}
|
|
71
|
-
(0, validate_js_1.validateUint256Field)("assets", assets);
|
|
72
|
-
const common = {
|
|
73
|
-
chainId,
|
|
74
|
-
userAddress,
|
|
75
|
-
deadline: params.args.deadline,
|
|
76
|
-
referralFeePct: params.args.referralFeePct,
|
|
77
|
-
referralFeeRecipient: params.args.referralFeeRecipient,
|
|
78
|
-
metadata: params.metadata,
|
|
79
|
-
};
|
|
80
|
-
const { referralFeePct, referralFeeRecipient } = (0, common_js_2.normalizeBlueBundlesV1CommonParams)(common);
|
|
81
|
-
const value = (0, common_js_2.validateBlueBundlesV1NativeFunding)({
|
|
82
|
-
chainId,
|
|
83
|
-
token: marketParams.loanToken,
|
|
84
|
-
fundedAmount: assets,
|
|
85
|
-
nativeAmount: params.args.nativeAmount,
|
|
86
|
-
requirementSignature,
|
|
87
|
-
});
|
|
88
|
-
const tokenPermit = (0, common_js_2.getBlueBundlesV1TokenPermit)({
|
|
89
|
-
chainId,
|
|
90
|
-
userAddress,
|
|
91
|
-
token: marketParams.loanToken,
|
|
92
|
-
amount: assets,
|
|
93
|
-
requirementSignature,
|
|
94
|
-
});
|
|
95
|
-
return (0, common_js_2.finalizeBlueBundlesV1Transaction)({
|
|
96
|
-
common,
|
|
97
|
-
value,
|
|
98
|
-
data: (0, viem_1.encodeFunctionData)({
|
|
99
|
-
abi: abis_js_1.blueBundlesV1Abi,
|
|
100
|
-
functionName: "blueBundlesV1Supply",
|
|
101
|
-
args: [
|
|
102
|
-
marketParams,
|
|
103
|
-
assets,
|
|
104
|
-
tokenPermit,
|
|
105
|
-
referralFeePct,
|
|
106
|
-
referralFeeRecipient,
|
|
107
|
-
params.args.deadline,
|
|
108
|
-
],
|
|
109
|
-
}),
|
|
110
|
-
action: {
|
|
111
|
-
type: "blueSupply",
|
|
112
|
-
args: {
|
|
113
|
-
market: marketParams.id,
|
|
114
|
-
assets,
|
|
115
|
-
onBehalf: userAddress,
|
|
116
|
-
nativeAmount: value > 0n ? value : undefined,
|
|
117
|
-
referralFeePct,
|
|
118
|
-
referralFeeRecipient,
|
|
119
|
-
referralFeeAssets: (0, common_js_1.getBundlesReferralFeeAssets)(assets, referralFeePct),
|
|
120
|
-
deadline: params.args.deadline,
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
});
|
|
124
|
-
};
|
|
61
|
+
const blueSupply = (params) => (0, supply_internal_js_1.encodeBlueSupply)((0, supply_internal_js_1.parseBlueSupply)(params));
|
|
125
62
|
exports.blueSupply = blueSupply;
|