@nadohq/shared 0.1.0-alpha.4
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 +2 -0
- package/dist/abis/Clearinghouse.cjs +891 -0
- package/dist/abis/Clearinghouse.cjs.map +1 -0
- package/dist/abis/Clearinghouse.d.cts +669 -0
- package/dist/abis/Clearinghouse.d.ts +669 -0
- package/dist/abis/Clearinghouse.js +868 -0
- package/dist/abis/Clearinghouse.js.map +1 -0
- package/dist/abis/ERC20.cjs +215 -0
- package/dist/abis/ERC20.cjs.map +1 -0
- package/dist/abis/ERC20.d.cts +143 -0
- package/dist/abis/ERC20.d.ts +143 -0
- package/dist/abis/ERC20.js +192 -0
- package/dist/abis/ERC20.js.map +1 -0
- package/dist/abis/Endpoint.cjs +589 -0
- package/dist/abis/Endpoint.cjs.map +1 -0
- package/dist/abis/Endpoint.d.cts +433 -0
- package/dist/abis/Endpoint.d.ts +433 -0
- package/dist/abis/Endpoint.js +566 -0
- package/dist/abis/Endpoint.js.map +1 -0
- package/dist/abis/MockERC20.cjs +341 -0
- package/dist/abis/MockERC20.cjs.map +1 -0
- package/dist/abis/MockERC20.d.cts +239 -0
- package/dist/abis/MockERC20.d.ts +239 -0
- package/dist/abis/MockERC20.js +318 -0
- package/dist/abis/MockERC20.js.map +1 -0
- package/dist/abis/PerpEngine.cjs +886 -0
- package/dist/abis/PerpEngine.cjs.map +1 -0
- package/dist/abis/PerpEngine.d.cts +661 -0
- package/dist/abis/PerpEngine.d.ts +661 -0
- package/dist/abis/PerpEngine.js +863 -0
- package/dist/abis/PerpEngine.js.map +1 -0
- package/dist/abis/Querier.cjs +1522 -0
- package/dist/abis/Querier.cjs.map +1 -0
- package/dist/abis/Querier.d.cts +1149 -0
- package/dist/abis/Querier.d.ts +1149 -0
- package/dist/abis/Querier.js +1499 -0
- package/dist/abis/Querier.js.map +1 -0
- package/dist/abis/SpotEngine.cjs +937 -0
- package/dist/abis/SpotEngine.cjs.map +1 -0
- package/dist/abis/SpotEngine.d.cts +701 -0
- package/dist/abis/SpotEngine.d.ts +701 -0
- package/dist/abis/SpotEngine.js +914 -0
- package/dist/abis/SpotEngine.js.map +1 -0
- package/dist/abis/WithdrawPool.cjs +307 -0
- package/dist/abis/WithdrawPool.cjs.map +1 -0
- package/dist/abis/WithdrawPool.d.cts +214 -0
- package/dist/abis/WithdrawPool.d.ts +214 -0
- package/dist/abis/WithdrawPool.js +284 -0
- package/dist/abis/WithdrawPool.js.map +1 -0
- package/dist/abis/index.cjs +41 -0
- package/dist/abis/index.cjs.map +1 -0
- package/dist/abis/index.d.cts +9 -0
- package/dist/abis/index.d.ts +9 -0
- package/dist/abis/index.js +11 -0
- package/dist/abis/index.js.map +1 -0
- package/dist/abis/nadoAbis.cjs +44 -0
- package/dist/abis/nadoAbis.cjs.map +1 -0
- package/dist/abis/nadoAbis.d.cts +3821 -0
- package/dist/abis/nadoAbis.d.ts +3821 -0
- package/dist/abis/nadoAbis.js +21 -0
- package/dist/abis/nadoAbis.js.map +1 -0
- package/dist/chunk-5WRI5ZAA.js +31 -0
- package/dist/chunk-5WRI5ZAA.js.map +1 -0
- package/dist/chunk-TUJ4HQKF.js +33 -0
- package/dist/chunk-TUJ4HQKF.js.map +1 -0
- package/dist/consts/chainEnvToChain.cjs +44 -0
- package/dist/consts/chainEnvToChain.cjs.map +1 -0
- package/dist/consts/chainEnvToChain.d.cts +388 -0
- package/dist/consts/chainEnvToChain.d.ts +388 -0
- package/dist/consts/chainEnvToChain.js +20 -0
- package/dist/consts/chainEnvToChain.js.map +1 -0
- package/dist/consts/index.cjs +27 -0
- package/dist/consts/index.cjs.map +1 -0
- package/dist/consts/index.d.cts +6 -0
- package/dist/consts/index.d.ts +6 -0
- package/dist/consts/index.js +4 -0
- package/dist/consts/index.js.map +1 -0
- package/dist/consts/productIds.cjs +34 -0
- package/dist/consts/productIds.cjs.map +1 -0
- package/dist/consts/productIds.d.cts +4 -0
- package/dist/consts/productIds.d.ts +4 -0
- package/dist/consts/productIds.js +10 -0
- package/dist/consts/productIds.js.map +1 -0
- package/dist/deployments/core/deployment.InkSepolia.json +13 -0
- package/dist/deployments/core/deployment.arbitrumOne.json +18 -0
- package/dist/deployments/core/deployment.localhost.json +18 -0
- package/dist/deployments/index.cjs +65 -0
- package/dist/deployments/index.cjs.map +1 -0
- package/dist/deployments/index.d.cts +13 -0
- package/dist/deployments/index.d.ts +13 -0
- package/dist/deployments/index.js +32 -0
- package/dist/deployments/index.js.map +1 -0
- package/dist/eip712/eip712ValueTypes.cjs +19 -0
- package/dist/eip712/eip712ValueTypes.cjs.map +1 -0
- package/dist/eip712/eip712ValueTypes.d.cts +48 -0
- package/dist/eip712/eip712ValueTypes.d.ts +48 -0
- package/dist/eip712/eip712ValueTypes.js +1 -0
- package/dist/eip712/eip712ValueTypes.js.map +1 -0
- package/dist/eip712/getNadoEIP712Domain.cjs +39 -0
- package/dist/eip712/getNadoEIP712Domain.cjs.map +1 -0
- package/dist/eip712/getNadoEIP712Domain.d.cts +11 -0
- package/dist/eip712/getNadoEIP712Domain.d.ts +11 -0
- package/dist/eip712/getNadoEIP712Domain.js +16 -0
- package/dist/eip712/getNadoEIP712Domain.js.map +1 -0
- package/dist/eip712/getNadoEIP712PrimaryType.cjs +35 -0
- package/dist/eip712/getNadoEIP712PrimaryType.cjs.map +1 -0
- package/dist/eip712/getNadoEIP712PrimaryType.d.cts +16 -0
- package/dist/eip712/getNadoEIP712PrimaryType.d.ts +16 -0
- package/dist/eip712/getNadoEIP712PrimaryType.js +12 -0
- package/dist/eip712/getNadoEIP712PrimaryType.js.map +1 -0
- package/dist/eip712/getNadoEIP712Types.cjs +129 -0
- package/dist/eip712/getNadoEIP712Types.cjs.map +1 -0
- package/dist/eip712/getNadoEIP712Types.d.cts +20 -0
- package/dist/eip712/getNadoEIP712Types.d.ts +20 -0
- package/dist/eip712/getNadoEIP712Types.js +106 -0
- package/dist/eip712/getNadoEIP712Types.js.map +1 -0
- package/dist/eip712/getNadoEIP712Values.cjs +206 -0
- package/dist/eip712/getNadoEIP712Values.cjs.map +1 -0
- package/dist/eip712/getNadoEIP712Values.d.cts +20 -0
- package/dist/eip712/getNadoEIP712Values.d.ts +20 -0
- package/dist/eip712/getNadoEIP712Values.js +183 -0
- package/dist/eip712/getNadoEIP712Values.js.map +1 -0
- package/dist/eip712/getOrderVerifyingAddress.cjs +34 -0
- package/dist/eip712/getOrderVerifyingAddress.cjs.map +1 -0
- package/dist/eip712/getOrderVerifyingAddress.d.cts +9 -0
- package/dist/eip712/getOrderVerifyingAddress.d.ts +9 -0
- package/dist/eip712/getOrderVerifyingAddress.js +11 -0
- package/dist/eip712/getOrderVerifyingAddress.js.map +1 -0
- package/dist/eip712/getSignedTransactionRequest.cjs +42 -0
- package/dist/eip712/getSignedTransactionRequest.cjs.map +1 -0
- package/dist/eip712/getSignedTransactionRequest.d.cts +19 -0
- package/dist/eip712/getSignedTransactionRequest.d.ts +19 -0
- package/dist/eip712/getSignedTransactionRequest.js +19 -0
- package/dist/eip712/getSignedTransactionRequest.js.map +1 -0
- package/dist/eip712/index.cjs +43 -0
- package/dist/eip712/index.cjs.map +1 -0
- package/dist/eip712/index.d.cts +17 -0
- package/dist/eip712/index.d.ts +17 -0
- package/dist/eip712/index.js +12 -0
- package/dist/eip712/index.js.map +1 -0
- package/dist/eip712/orderDigest.cjs +45 -0
- package/dist/eip712/orderDigest.cjs.map +1 -0
- package/dist/eip712/orderDigest.d.cts +20 -0
- package/dist/eip712/orderDigest.d.ts +20 -0
- package/dist/eip712/orderDigest.js +22 -0
- package/dist/eip712/orderDigest.js.map +1 -0
- package/dist/eip712/signableRequestType.cjs +19 -0
- package/dist/eip712/signableRequestType.cjs.map +1 -0
- package/dist/eip712/signableRequestType.d.cts +26 -0
- package/dist/eip712/signableRequestType.d.ts +26 -0
- package/dist/eip712/signableRequestType.js +1 -0
- package/dist/eip712/signableRequestType.js.map +1 -0
- package/dist/eip712/signatureParamTypes.cjs +19 -0
- package/dist/eip712/signatureParamTypes.cjs.map +1 -0
- package/dist/eip712/signatureParamTypes.d.cts +68 -0
- package/dist/eip712/signatureParamTypes.d.ts +68 -0
- package/dist/eip712/signatureParamTypes.js +1 -0
- package/dist/eip712/signatureParamTypes.js.map +1 -0
- package/dist/encoding/encoding.cjs +73 -0
- package/dist/encoding/encoding.cjs.map +1 -0
- package/dist/encoding/encoding.d.cts +11 -0
- package/dist/encoding/encoding.d.ts +11 -0
- package/dist/encoding/encoding.js +49 -0
- package/dist/encoding/encoding.js.map +1 -0
- package/dist/encoding/index.cjs +25 -0
- package/dist/encoding/index.cjs.map +1 -0
- package/dist/encoding/index.d.cts +7 -0
- package/dist/encoding/index.d.ts +7 -0
- package/dist/encoding/index.js +3 -0
- package/dist/encoding/index.js.map +1 -0
- package/dist/execute/approveDepositAllowance.cjs +38 -0
- package/dist/execute/approveDepositAllowance.cjs.map +1 -0
- package/dist/execute/approveDepositAllowance.d.cts +18 -0
- package/dist/execute/approveDepositAllowance.d.ts +18 -0
- package/dist/execute/approveDepositAllowance.js +15 -0
- package/dist/execute/approveDepositAllowance.js.map +1 -0
- package/dist/execute/depositCollateral.cjs +59 -0
- package/dist/execute/depositCollateral.cjs.map +1 -0
- package/dist/execute/depositCollateral.d.cts +21 -0
- package/dist/execute/depositCollateral.d.ts +21 -0
- package/dist/execute/depositCollateral.js +36 -0
- package/dist/execute/depositCollateral.js.map +1 -0
- package/dist/execute/index.cjs +27 -0
- package/dist/execute/index.cjs.map +1 -0
- package/dist/execute/index.d.cts +9 -0
- package/dist/execute/index.d.ts +9 -0
- package/dist/execute/index.js +4 -0
- package/dist/execute/index.js.map +1 -0
- package/dist/index.cjs +39 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +67 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/types/ChainEnv.cjs +44 -0
- package/dist/types/ChainEnv.cjs.map +1 -0
- package/dist/types/ChainEnv.d.cts +7 -0
- package/dist/types/ChainEnv.d.ts +7 -0
- package/dist/types/ChainEnv.js +18 -0
- package/dist/types/ChainEnv.js.map +1 -0
- package/dist/types/OrderExecutionType.cjs +19 -0
- package/dist/types/OrderExecutionType.cjs.map +1 -0
- package/dist/types/OrderExecutionType.d.cts +10 -0
- package/dist/types/OrderExecutionType.d.ts +10 -0
- package/dist/types/OrderExecutionType.js +1 -0
- package/dist/types/OrderExecutionType.js.map +1 -0
- package/dist/types/balanceTypes.cjs +19 -0
- package/dist/types/balanceTypes.cjs.map +1 -0
- package/dist/types/balanceTypes.d.cts +38 -0
- package/dist/types/balanceTypes.d.ts +38 -0
- package/dist/types/balanceTypes.js +1 -0
- package/dist/types/balanceTypes.js.map +1 -0
- package/dist/types/bytes.cjs +19 -0
- package/dist/types/bytes.cjs.map +1 -0
- package/dist/types/bytes.d.cts +3 -0
- package/dist/types/bytes.d.ts +3 -0
- package/dist/types/bytes.js +1 -0
- package/dist/types/bytes.js.map +1 -0
- package/dist/types/healthTypes.cjs +19 -0
- package/dist/types/healthTypes.cjs.map +1 -0
- package/dist/types/healthTypes.d.cts +15 -0
- package/dist/types/healthTypes.d.ts +15 -0
- package/dist/types/healthTypes.js +1 -0
- package/dist/types/healthTypes.js.map +1 -0
- package/dist/types/index.cjs +45 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +15 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.js +13 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/marketTypes.cjs +19 -0
- package/dist/types/marketTypes.cjs.map +1 -0
- package/dist/types/marketTypes.d.cts +31 -0
- package/dist/types/marketTypes.d.ts +31 -0
- package/dist/types/marketTypes.js +1 -0
- package/dist/types/marketTypes.js.map +1 -0
- package/dist/types/nadoContractTypes.cjs +19 -0
- package/dist/types/nadoContractTypes.cjs.map +1 -0
- package/dist/types/nadoContractTypes.d.cts +14 -0
- package/dist/types/nadoContractTypes.d.ts +14 -0
- package/dist/types/nadoContractTypes.js +1 -0
- package/dist/types/nadoContractTypes.js.map +1 -0
- package/dist/types/orderAppendixTypes.cjs +19 -0
- package/dist/types/orderAppendixTypes.cjs.map +1 -0
- package/dist/types/orderAppendixTypes.d.cts +54 -0
- package/dist/types/orderAppendixTypes.d.ts +54 -0
- package/dist/types/orderAppendixTypes.js +1 -0
- package/dist/types/orderAppendixTypes.js.map +1 -0
- package/dist/types/productTypes.cjs +47 -0
- package/dist/types/productTypes.cjs.map +1 -0
- package/dist/types/productTypes.d.cts +55 -0
- package/dist/types/productTypes.d.ts +55 -0
- package/dist/types/productTypes.js +23 -0
- package/dist/types/productTypes.js.map +1 -0
- package/dist/types/subaccountTypes.cjs +19 -0
- package/dist/types/subaccountTypes.cjs.map +1 -0
- package/dist/types/subaccountTypes.d.cts +13 -0
- package/dist/types/subaccountTypes.d.ts +13 -0
- package/dist/types/subaccountTypes.js +1 -0
- package/dist/types/subaccountTypes.js.map +1 -0
- package/dist/types/viemTypes.cjs +19 -0
- package/dist/types/viemTypes.cjs.map +1 -0
- package/dist/types/viemTypes.d.cts +23 -0
- package/dist/types/viemTypes.d.ts +23 -0
- package/dist/types/viemTypes.js +1 -0
- package/dist/types/viemTypes.js.map +1 -0
- package/dist/utils/asyncResult.cjs +36 -0
- package/dist/utils/asyncResult.cjs.map +1 -0
- package/dist/utils/asyncResult.d.cts +4 -0
- package/dist/utils/asyncResult.d.ts +4 -0
- package/dist/utils/asyncResult.js +13 -0
- package/dist/utils/asyncResult.js.map +1 -0
- package/dist/utils/balanceValue.cjs +43 -0
- package/dist/utils/balanceValue.cjs.map +1 -0
- package/dist/utils/balanceValue.d.cts +25 -0
- package/dist/utils/balanceValue.d.ts +25 -0
- package/dist/utils/balanceValue.js +18 -0
- package/dist/utils/balanceValue.js.map +1 -0
- package/dist/utils/bytes32.cjs +92 -0
- package/dist/utils/bytes32.cjs.map +1 -0
- package/dist/utils/bytes32.d.cts +47 -0
- package/dist/utils/bytes32.d.ts +47 -0
- package/dist/utils/bytes32.js +64 -0
- package/dist/utils/bytes32.js.map +1 -0
- package/dist/utils/bytes32.test.cjs +203 -0
- package/dist/utils/bytes32.test.cjs.map +1 -0
- package/dist/utils/bytes32.test.d.cts +2 -0
- package/dist/utils/bytes32.test.d.ts +2 -0
- package/dist/utils/bytes32.test.js +165 -0
- package/dist/utils/bytes32.test.js.map +1 -0
- package/dist/utils/createDeterministicLinkedSignerPrivateKey.cjs +56 -0
- package/dist/utils/createDeterministicLinkedSignerPrivateKey.cjs.map +1 -0
- package/dist/utils/createDeterministicLinkedSignerPrivateKey.d.cts +20 -0
- package/dist/utils/createDeterministicLinkedSignerPrivateKey.d.ts +20 -0
- package/dist/utils/createDeterministicLinkedSignerPrivateKey.js +33 -0
- package/dist/utils/createDeterministicLinkedSignerPrivateKey.js.map +1 -0
- package/dist/utils/errors/WalletNotProvidedError.cjs +36 -0
- package/dist/utils/errors/WalletNotProvidedError.cjs.map +1 -0
- package/dist/utils/errors/WalletNotProvidedError.d.cts +5 -0
- package/dist/utils/errors/WalletNotProvidedError.d.ts +5 -0
- package/dist/utils/errors/WalletNotProvidedError.js +13 -0
- package/dist/utils/errors/WalletNotProvidedError.js.map +1 -0
- package/dist/utils/errors/index.cjs +25 -0
- package/dist/utils/errors/index.cjs.map +1 -0
- package/dist/utils/errors/index.d.cts +1 -0
- package/dist/utils/errors/index.d.ts +1 -0
- package/dist/utils/errors/index.js +3 -0
- package/dist/utils/errors/index.js.map +1 -0
- package/dist/utils/getValidatedAddress.cjs +37 -0
- package/dist/utils/getValidatedAddress.cjs.map +1 -0
- package/dist/utils/getValidatedAddress.d.cts +9 -0
- package/dist/utils/getValidatedAddress.d.ts +9 -0
- package/dist/utils/getValidatedAddress.js +14 -0
- package/dist/utils/getValidatedAddress.js.map +1 -0
- package/dist/utils/getValidatedHex.cjs +37 -0
- package/dist/utils/getValidatedHex.cjs.map +1 -0
- package/dist/utils/getValidatedHex.d.cts +9 -0
- package/dist/utils/getValidatedHex.d.ts +9 -0
- package/dist/utils/getValidatedHex.js +14 -0
- package/dist/utils/getValidatedHex.js.map +1 -0
- package/dist/utils/index.cjs +53 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +37 -0
- package/dist/utils/index.d.ts +37 -0
- package/dist/utils/index.js +17 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/interest.cjs +94 -0
- package/dist/utils/interest.cjs.map +1 -0
- package/dist/utils/interest.d.cts +50 -0
- package/dist/utils/interest.d.ts +50 -0
- package/dist/utils/interest.js +70 -0
- package/dist/utils/interest.js.map +1 -0
- package/dist/utils/isWriteableContract.cjs +33 -0
- package/dist/utils/isWriteableContract.cjs.map +1 -0
- package/dist/utils/isWriteableContract.d.cts +6 -0
- package/dist/utils/isWriteableContract.d.ts +6 -0
- package/dist/utils/isWriteableContract.js +10 -0
- package/dist/utils/isWriteableContract.js.map +1 -0
- package/dist/utils/mapValues.cjs +38 -0
- package/dist/utils/mapValues.cjs.map +1 -0
- package/dist/utils/mapValues.d.cts +6 -0
- package/dist/utils/mapValues.d.ts +6 -0
- package/dist/utils/mapValues.js +15 -0
- package/dist/utils/mapValues.js.map +1 -0
- package/dist/utils/math/BigDecimals.cjs +37 -0
- package/dist/utils/math/BigDecimals.cjs.map +1 -0
- package/dist/utils/math/BigDecimals.d.cts +8 -0
- package/dist/utils/math/BigDecimals.d.ts +8 -0
- package/dist/utils/math/BigDecimals.js +14 -0
- package/dist/utils/math/BigDecimals.js.map +1 -0
- package/dist/utils/math/bigDecimal.cjs +57 -0
- package/dist/utils/math/bigDecimal.cjs.map +1 -0
- package/dist/utils/math/bigDecimal.d.cts +18 -0
- package/dist/utils/math/bigDecimal.d.ts +18 -0
- package/dist/utils/math/bigDecimal.js +23 -0
- package/dist/utils/math/bigDecimal.js.map +1 -0
- package/dist/utils/math/clamp.cjs +38 -0
- package/dist/utils/math/clamp.cjs.map +1 -0
- package/dist/utils/math/clamp.d.cts +15 -0
- package/dist/utils/math/clamp.d.ts +15 -0
- package/dist/utils/math/clamp.js +15 -0
- package/dist/utils/math/clamp.js.map +1 -0
- package/dist/utils/math/decimalAdjustment.cjs +60 -0
- package/dist/utils/math/decimalAdjustment.cjs.map +1 -0
- package/dist/utils/math/decimalAdjustment.d.cts +31 -0
- package/dist/utils/math/decimalAdjustment.d.ts +31 -0
- package/dist/utils/math/decimalAdjustment.js +35 -0
- package/dist/utils/math/decimalAdjustment.js.map +1 -0
- package/dist/utils/math/index.cjs +37 -0
- package/dist/utils/math/index.cjs.map +1 -0
- package/dist/utils/math/index.d.cts +8 -0
- package/dist/utils/math/index.d.ts +8 -0
- package/dist/utils/math/index.js +9 -0
- package/dist/utils/math/index.js.map +1 -0
- package/dist/utils/math/sumBigDecimalBy.cjs +36 -0
- package/dist/utils/math/sumBigDecimalBy.cjs.map +1 -0
- package/dist/utils/math/sumBigDecimalBy.d.cts +10 -0
- package/dist/utils/math/sumBigDecimalBy.d.ts +10 -0
- package/dist/utils/math/sumBigDecimalBy.js +13 -0
- package/dist/utils/math/sumBigDecimalBy.js.map +1 -0
- package/dist/utils/math/toBigInt.cjs +34 -0
- package/dist/utils/math/toBigInt.cjs.map +1 -0
- package/dist/utils/math/toBigInt.d.cts +11 -0
- package/dist/utils/math/toBigInt.d.ts +11 -0
- package/dist/utils/math/toBigInt.js +11 -0
- package/dist/utils/math/toBigInt.js.map +1 -0
- package/dist/utils/math/toIntegerString.cjs +34 -0
- package/dist/utils/math/toIntegerString.cjs.map +1 -0
- package/dist/utils/math/toIntegerString.d.cts +11 -0
- package/dist/utils/math/toIntegerString.d.ts +11 -0
- package/dist/utils/math/toIntegerString.js +11 -0
- package/dist/utils/math/toIntegerString.js.map +1 -0
- package/dist/utils/orders/appendix/appendixTWAPValue.cjs +50 -0
- package/dist/utils/orders/appendix/appendixTWAPValue.cjs.map +1 -0
- package/dist/utils/orders/appendix/appendixTWAPValue.d.cts +31 -0
- package/dist/utils/orders/appendix/appendixTWAPValue.d.ts +31 -0
- package/dist/utils/orders/appendix/appendixTWAPValue.js +26 -0
- package/dist/utils/orders/appendix/appendixTWAPValue.js.map +1 -0
- package/dist/utils/orders/appendix/bitMaskValue.cjs +34 -0
- package/dist/utils/orders/appendix/bitMaskValue.cjs.map +1 -0
- package/dist/utils/orders/appendix/bitMaskValue.d.cts +10 -0
- package/dist/utils/orders/appendix/bitMaskValue.d.ts +10 -0
- package/dist/utils/orders/appendix/bitMaskValue.js +11 -0
- package/dist/utils/orders/appendix/bitMaskValue.js.map +1 -0
- package/dist/utils/orders/appendix/index.cjs +33 -0
- package/dist/utils/orders/appendix/index.cjs.map +1 -0
- package/dist/utils/orders/appendix/index.d.cts +9 -0
- package/dist/utils/orders/appendix/index.d.ts +9 -0
- package/dist/utils/orders/appendix/index.js +7 -0
- package/dist/utils/orders/appendix/index.js.map +1 -0
- package/dist/utils/orders/appendix/orderAppendix.test.cjs +165 -0
- package/dist/utils/orders/appendix/orderAppendix.test.cjs.map +1 -0
- package/dist/utils/orders/appendix/orderAppendix.test.d.cts +2 -0
- package/dist/utils/orders/appendix/orderAppendix.test.d.ts +2 -0
- package/dist/utils/orders/appendix/orderAppendix.test.js +120 -0
- package/dist/utils/orders/appendix/orderAppendix.test.js.map +1 -0
- package/dist/utils/orders/appendix/packOrderAppendix.cjs +88 -0
- package/dist/utils/orders/appendix/packOrderAppendix.cjs.map +1 -0
- package/dist/utils/orders/appendix/packOrderAppendix.d.cts +12 -0
- package/dist/utils/orders/appendix/packOrderAppendix.d.ts +12 -0
- package/dist/utils/orders/appendix/packOrderAppendix.js +65 -0
- package/dist/utils/orders/appendix/packOrderAppendix.js.map +1 -0
- package/dist/utils/orders/appendix/types.cjs +19 -0
- package/dist/utils/orders/appendix/types.cjs.map +1 -0
- package/dist/utils/orders/appendix/types.d.cts +19 -0
- package/dist/utils/orders/appendix/types.d.ts +19 -0
- package/dist/utils/orders/appendix/types.js +1 -0
- package/dist/utils/orders/appendix/types.js.map +1 -0
- package/dist/utils/orders/appendix/unpackOrderAppendix.cjs +106 -0
- package/dist/utils/orders/appendix/unpackOrderAppendix.cjs.map +1 -0
- package/dist/utils/orders/appendix/unpackOrderAppendix.d.cts +12 -0
- package/dist/utils/orders/appendix/unpackOrderAppendix.d.ts +12 -0
- package/dist/utils/orders/appendix/unpackOrderAppendix.js +83 -0
- package/dist/utils/orders/appendix/unpackOrderAppendix.js.map +1 -0
- package/dist/utils/orders/index.cjs +29 -0
- package/dist/utils/orders/index.cjs.map +1 -0
- package/dist/utils/orders/index.d.cts +11 -0
- package/dist/utils/orders/index.d.ts +11 -0
- package/dist/utils/orders/index.js +5 -0
- package/dist/utils/orders/index.js.map +1 -0
- package/dist/utils/orders/orderNonce.cjs +44 -0
- package/dist/utils/orders/orderNonce.cjs.map +1 -0
- package/dist/utils/orders/orderNonce.d.cts +14 -0
- package/dist/utils/orders/orderNonce.d.ts +14 -0
- package/dist/utils/orders/orderNonce.js +20 -0
- package/dist/utils/orders/orderNonce.js.map +1 -0
- package/dist/utils/orders/recvTime.cjs +33 -0
- package/dist/utils/orders/recvTime.cjs.map +1 -0
- package/dist/utils/orders/recvTime.d.cts +9 -0
- package/dist/utils/orders/recvTime.d.ts +9 -0
- package/dist/utils/orders/recvTime.js +10 -0
- package/dist/utils/orders/recvTime.js.map +1 -0
- package/dist/utils/productTypeFilter.cjs +49 -0
- package/dist/utils/productTypeFilter.cjs.map +1 -0
- package/dist/utils/productTypeFilter.d.cts +11 -0
- package/dist/utils/productTypeFilter.d.ts +11 -0
- package/dist/utils/productTypeFilter.js +25 -0
- package/dist/utils/productTypeFilter.js.map +1 -0
- package/dist/utils/time.cjs +47 -0
- package/dist/utils/time.cjs.map +1 -0
- package/dist/utils/time.d.cts +17 -0
- package/dist/utils/time.d.ts +17 -0
- package/dist/utils/time.js +22 -0
- package/dist/utils/time.js.map +1 -0
- package/dist/utils/toPrintableObject.cjs +51 -0
- package/dist/utils/toPrintableObject.cjs.map +1 -0
- package/dist/utils/toPrintableObject.d.cts +6 -0
- package/dist/utils/toPrintableObject.d.ts +6 -0
- package/dist/utils/toPrintableObject.js +28 -0
- package/dist/utils/toPrintableObject.js.map +1 -0
- package/package.json +49 -0
- package/src/abis/Clearinghouse.ts +861 -0
- package/src/abis/ERC20.ts +185 -0
- package/src/abis/Endpoint.ts +559 -0
- package/src/abis/MockERC20.ts +311 -0
- package/src/abis/PerpEngine.ts +856 -0
- package/src/abis/Querier.ts +1492 -0
- package/src/abis/SpotEngine.ts +907 -0
- package/src/abis/WithdrawPool.ts +277 -0
- package/src/abis/index.ts +9 -0
- package/src/abis/nadoAbis.ts +19 -0
- package/src/consts/chainEnvToChain.ts +16 -0
- package/src/consts/index.ts +2 -0
- package/src/consts/productIds.ts +3 -0
- package/src/deployments/core/deployment.InkSepolia.json +13 -0
- package/src/deployments/core/deployment.arbitrumOne.json +18 -0
- package/src/deployments/core/deployment.localhost.json +18 -0
- package/src/deployments/index.ts +40 -0
- package/src/eip712/eip712ValueTypes.ts +83 -0
- package/src/eip712/getNadoEIP712Domain.ts +20 -0
- package/src/eip712/getNadoEIP712PrimaryType.ts +13 -0
- package/src/eip712/getNadoEIP712Types.ts +113 -0
- package/src/eip712/getNadoEIP712Values.ts +248 -0
- package/src/eip712/getOrderVerifyingAddress.ts +9 -0
- package/src/eip712/getSignedTransactionRequest.ts +30 -0
- package/src/eip712/index.ts +10 -0
- package/src/eip712/orderDigest.ts +28 -0
- package/src/eip712/signableRequestType.ts +32 -0
- package/src/eip712/signatureParamTypes.ts +84 -0
- package/src/encoding/encoding.ts +50 -0
- package/src/encoding/index.ts +1 -0
- package/src/execute/approveDepositAllowance.ts +20 -0
- package/src/execute/depositCollateral.ts +43 -0
- package/src/execute/index.ts +2 -0
- package/src/index.ts +8 -0
- package/src/types/ChainEnv.ts +13 -0
- package/src/types/OrderExecutionType.ts +8 -0
- package/src/types/balanceTypes.ts +47 -0
- package/src/types/bytes.ts +1 -0
- package/src/types/healthTypes.ts +17 -0
- package/src/types/index.ts +11 -0
- package/src/types/marketTypes.ts +40 -0
- package/src/types/nadoContractTypes.ts +14 -0
- package/src/types/orderAppendixTypes.ts +58 -0
- package/src/types/productTypes.ts +76 -0
- package/src/types/subaccountTypes.ts +13 -0
- package/src/types/viemTypes.ts +42 -0
- package/src/utils/asyncResult.ts +12 -0
- package/src/utils/balanceValue.ts +42 -0
- package/src/utils/bytes32.test.ts +117 -0
- package/src/utils/bytes32.ts +110 -0
- package/src/utils/createDeterministicLinkedSignerPrivateKey.ts +46 -0
- package/src/utils/errors/WalletNotProvidedError.ts +6 -0
- package/src/utils/errors/index.ts +1 -0
- package/src/utils/getValidatedAddress.ts +13 -0
- package/src/utils/getValidatedHex.ts +13 -0
- package/src/utils/index.ts +15 -0
- package/src/utils/interest.ts +133 -0
- package/src/utils/isWriteableContract.ts +11 -0
- package/src/utils/mapValues.ts +18 -0
- package/src/utils/math/BigDecimals.ts +8 -0
- package/src/utils/math/bigDecimal.ts +32 -0
- package/src/utils/math/clamp.ts +26 -0
- package/src/utils/math/decimalAdjustment.ts +65 -0
- package/src/utils/math/index.ts +7 -0
- package/src/utils/math/sumBigDecimalBy.ts +18 -0
- package/src/utils/math/toBigInt.ts +11 -0
- package/src/utils/math/toIntegerString.ts +11 -0
- package/src/utils/orders/appendix/appendixTWAPValue.ts +51 -0
- package/src/utils/orders/appendix/bitMaskValue.ts +11 -0
- package/src/utils/orders/appendix/index.ts +5 -0
- package/src/utils/orders/appendix/orderAppendix.test.ts +121 -0
- package/src/utils/orders/appendix/packOrderAppendix.ts +71 -0
- package/src/utils/orders/appendix/types.ts +17 -0
- package/src/utils/orders/appendix/unpackOrderAppendix.ts +90 -0
- package/src/utils/orders/index.ts +3 -0
- package/src/utils/orders/orderNonce.ts +32 -0
- package/src/utils/orders/recvTime.ts +9 -0
- package/src/utils/productTypeFilter.ts +23 -0
- package/src/utils/time.ts +21 -0
- package/src/utils/toPrintableObject.ts +25 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/isWriteableContract.ts
|
|
21
|
+
var isWriteableContract_exports = {};
|
|
22
|
+
__export(isWriteableContract_exports, {
|
|
23
|
+
isWriteableContract: () => isWriteableContract
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(isWriteableContract_exports);
|
|
26
|
+
function isWriteableContract(contract) {
|
|
27
|
+
return "write" in contract;
|
|
28
|
+
}
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
isWriteableContract
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=isWriteableContract.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/isWriteableContract.ts"],"sourcesContent":["import { Abi } from 'viem';\nimport {\n ContractInstance,\n WriteableContractInstance,\n} from '../types/viemTypes';\n\nexport function isWriteableContract<TAbi extends Abi>(\n contract: ContractInstance<TAbi>,\n): contract is WriteableContractInstance<TAbi> {\n return 'write' in contract;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,SAAS,oBACd,UAC6C;AAC7C,SAAO,WAAW;AACpB;","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Abi } from 'viem';
|
|
2
|
+
import { ContractInstance, WriteableContractInstance } from '../types/viemTypes.cjs';
|
|
3
|
+
|
|
4
|
+
declare function isWriteableContract<TAbi extends Abi>(contract: ContractInstance<TAbi>): contract is WriteableContractInstance<TAbi>;
|
|
5
|
+
|
|
6
|
+
export { isWriteableContract };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Abi } from 'viem';
|
|
2
|
+
import { ContractInstance, WriteableContractInstance } from '../types/viemTypes.js';
|
|
3
|
+
|
|
4
|
+
declare function isWriteableContract<TAbi extends Abi>(contract: ContractInstance<TAbi>): contract is WriteableContractInstance<TAbi>;
|
|
5
|
+
|
|
6
|
+
export { isWriteableContract };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/isWriteableContract.ts"],"sourcesContent":["import { Abi } from 'viem';\nimport {\n ContractInstance,\n WriteableContractInstance,\n} from '../types/viemTypes';\n\nexport function isWriteableContract<TAbi extends Abi>(\n contract: ContractInstance<TAbi>,\n): contract is WriteableContractInstance<TAbi> {\n return 'write' in contract;\n}\n"],"mappings":";;;AAMO,SAAS,oBACd,UAC6C;AAC7C,SAAO,WAAW;AACpB;","names":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/mapValues.ts
|
|
21
|
+
var mapValues_exports = {};
|
|
22
|
+
__export(mapValues_exports, {
|
|
23
|
+
mapValues: () => mapValues
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(mapValues_exports);
|
|
26
|
+
function mapValues(obj, mapFn) {
|
|
27
|
+
return Object.fromEntries(
|
|
28
|
+
Object.entries(obj).map(([key, value], index) => [
|
|
29
|
+
key,
|
|
30
|
+
mapFn(value, key, index)
|
|
31
|
+
])
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
mapValues
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=mapValues.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/mapValues.ts"],"sourcesContent":["/**\n * Map values of an object given mapFn. Avoids needing to pull in lodash\n */\nexport function mapValues<\n TKey extends string | number | symbol,\n TValue,\n TNewValue,\n>(\n obj: Record<TKey, TValue>,\n mapFn: (value: TValue, key: TKey, index: number) => TNewValue,\n): Record<TKey, TNewValue> {\n return Object.fromEntries(\n Object.entries(obj).map(([key, value], index) => [\n key,\n mapFn(value as TValue, key as TKey, index),\n ]),\n ) as Record<TKey, TNewValue>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,SAAS,UAKd,KACA,OACyB;AACzB,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,GAAG,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,GAAG,UAAU;AAAA,MAC/C;AAAA,MACA,MAAM,OAAiB,KAAa,KAAK;AAAA,IAC3C,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map values of an object given mapFn. Avoids needing to pull in lodash
|
|
3
|
+
*/
|
|
4
|
+
declare function mapValues<TKey extends string | number | symbol, TValue, TNewValue>(obj: Record<TKey, TValue>, mapFn: (value: TValue, key: TKey, index: number) => TNewValue): Record<TKey, TNewValue>;
|
|
5
|
+
|
|
6
|
+
export { mapValues };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map values of an object given mapFn. Avoids needing to pull in lodash
|
|
3
|
+
*/
|
|
4
|
+
declare function mapValues<TKey extends string | number | symbol, TValue, TNewValue>(obj: Record<TKey, TValue>, mapFn: (value: TValue, key: TKey, index: number) => TNewValue): Record<TKey, TNewValue>;
|
|
5
|
+
|
|
6
|
+
export { mapValues };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "../chunk-5WRI5ZAA.js";
|
|
2
|
+
|
|
3
|
+
// src/utils/mapValues.ts
|
|
4
|
+
function mapValues(obj, mapFn) {
|
|
5
|
+
return Object.fromEntries(
|
|
6
|
+
Object.entries(obj).map(([key, value], index) => [
|
|
7
|
+
key,
|
|
8
|
+
mapFn(value, key, index)
|
|
9
|
+
])
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
mapValues
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=mapValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/mapValues.ts"],"sourcesContent":["/**\n * Map values of an object given mapFn. Avoids needing to pull in lodash\n */\nexport function mapValues<\n TKey extends string | number | symbol,\n TValue,\n TNewValue,\n>(\n obj: Record<TKey, TValue>,\n mapFn: (value: TValue, key: TKey, index: number) => TNewValue,\n): Record<TKey, TNewValue> {\n return Object.fromEntries(\n Object.entries(obj).map(([key, value], index) => [\n key,\n mapFn(value as TValue, key as TKey, index),\n ]),\n ) as Record<TKey, TNewValue>;\n}\n"],"mappings":";;;AAGO,SAAS,UAKd,KACA,OACyB;AACzB,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,GAAG,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,GAAG,UAAU;AAAA,MAC/C;AAAA,MACA,MAAM,OAAiB,KAAa,KAAK;AAAA,IAC3C,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/math/BigDecimals.ts
|
|
21
|
+
var BigDecimals_exports = {};
|
|
22
|
+
__export(BigDecimals_exports, {
|
|
23
|
+
BigDecimals: () => BigDecimals
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(BigDecimals_exports);
|
|
26
|
+
var import_bigDecimal = require("./bigDecimal.cjs");
|
|
27
|
+
var BigDecimals = Object.freeze({
|
|
28
|
+
ZERO: (0, import_bigDecimal.toBigDecimal)(0),
|
|
29
|
+
ONE: (0, import_bigDecimal.toBigDecimal)(1),
|
|
30
|
+
INF: (0, import_bigDecimal.toBigDecimal)(Infinity),
|
|
31
|
+
MAX_I128: (0, import_bigDecimal.toBigDecimal)("170141183460469231731687303715884105727")
|
|
32
|
+
});
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
BigDecimals
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=BigDecimals.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/math/BigDecimals.ts"],"sourcesContent":["import { toBigDecimal } from './bigDecimal';\n\nexport const BigDecimals = Object.freeze({\n ZERO: toBigDecimal(0),\n ONE: toBigDecimal(1),\n INF: toBigDecimal(Infinity),\n MAX_I128: toBigDecimal('170141183460469231731687303715884105727'),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAA6B;AAEtB,IAAM,cAAc,OAAO,OAAO;AAAA,EACvC,UAAM,gCAAa,CAAC;AAAA,EACpB,SAAK,gCAAa,CAAC;AAAA,EACnB,SAAK,gCAAa,QAAQ;AAAA,EAC1B,cAAU,gCAAa,yCAAyC;AAClE,CAAC;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "../../chunk-5WRI5ZAA.js";
|
|
2
|
+
|
|
3
|
+
// src/utils/math/BigDecimals.ts
|
|
4
|
+
import { toBigDecimal } from "./bigDecimal.js";
|
|
5
|
+
var BigDecimals = Object.freeze({
|
|
6
|
+
ZERO: toBigDecimal(0),
|
|
7
|
+
ONE: toBigDecimal(1),
|
|
8
|
+
INF: toBigDecimal(Infinity),
|
|
9
|
+
MAX_I128: toBigDecimal("170141183460469231731687303715884105727")
|
|
10
|
+
});
|
|
11
|
+
export {
|
|
12
|
+
BigDecimals
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=BigDecimals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/math/BigDecimals.ts"],"sourcesContent":["import { toBigDecimal } from './bigDecimal';\n\nexport const BigDecimals = Object.freeze({\n ZERO: toBigDecimal(0),\n ONE: toBigDecimal(1),\n INF: toBigDecimal(Infinity),\n MAX_I128: toBigDecimal('170141183460469231731687303715884105727'),\n});\n"],"mappings":";;;AAAA,SAAS,oBAAoB;AAEtB,IAAM,cAAc,OAAO,OAAO;AAAA,EACvC,MAAM,aAAa,CAAC;AAAA,EACpB,KAAK,aAAa,CAAC;AAAA,EACnB,KAAK,aAAa,QAAQ;AAAA,EAC1B,UAAU,aAAa,yCAAyC;AAClE,CAAC;","names":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/utils/math/bigDecimal.ts
|
|
31
|
+
var bigDecimal_exports = {};
|
|
32
|
+
__export(bigDecimal_exports, {
|
|
33
|
+
BigDecimal: () => import_bignumber2.default,
|
|
34
|
+
toBigDecimal: () => toBigDecimal
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(bigDecimal_exports);
|
|
37
|
+
var import_bignumber = __toESM(require("bignumber.js"), 1);
|
|
38
|
+
var import_bignumber2 = __toESM(require("bignumber.js"), 1);
|
|
39
|
+
function toBigDecimal(val) {
|
|
40
|
+
const bnConstructorVal = (() => {
|
|
41
|
+
if (val instanceof import_bignumber.default) {
|
|
42
|
+
return val;
|
|
43
|
+
} else if (typeof val === "string" || typeof val === "number") {
|
|
44
|
+
return val;
|
|
45
|
+
} else if (typeof val === "bigint") {
|
|
46
|
+
return val.toString();
|
|
47
|
+
}
|
|
48
|
+
return JSON.stringify(val);
|
|
49
|
+
})();
|
|
50
|
+
return new import_bignumber.default(bnConstructorVal);
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
BigDecimal,
|
|
55
|
+
toBigDecimal
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=bigDecimal.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/math/bigDecimal.ts"],"sourcesContent":["import { default as BigDecimal } from 'bignumber.js';\n\n// Renames `BigNumber` type from `bignumber.js`.\nexport { default as BigDecimal } from 'bignumber.js';\n\n/**\n * BigDecimal is a renamed `BigNumber` type from `bignumber.js`.\n * Includes valid values & instances for BigDecimal.\n *\n * @see https://mikemcl.github.io/bignumber.js/\n */\nexport type BigDecimalish = BigDecimal | BigDecimal.Value | bigint;\n\n/**\n * Converts a value to an instance of BigDecimal\n *\n * @param val\n */\nexport function toBigDecimal(val: BigDecimalish): BigDecimal {\n const bnConstructorVal = (() => {\n if (val instanceof BigDecimal) {\n return val;\n } else if (typeof val === 'string' || typeof val === 'number') {\n return val;\n } else if (typeof val === 'bigint') {\n return val.toString();\n }\n // This is unlikely to occur, but it's here for completeness. Uses the suggestion here: https://typescript-eslint.io/rules/no-base-to-string/#alternatives\n return JSON.stringify(val);\n })();\n return new BigDecimal(bnConstructorVal);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsC;AAGtC,IAAAA,oBAAsC;AAe/B,SAAS,aAAa,KAAgC;AAC3D,QAAM,oBAAoB,MAAM;AAC9B,QAAI,eAAe,iBAAAC,SAAY;AAC7B,aAAO;AAAA,IACT,WAAW,OAAO,QAAQ,YAAY,OAAO,QAAQ,UAAU;AAC7D,aAAO;AAAA,IACT,WAAW,OAAO,QAAQ,UAAU;AAClC,aAAO,IAAI,SAAS;AAAA,IACtB;AAEA,WAAO,KAAK,UAAU,GAAG;AAAA,EAC3B,GAAG;AACH,SAAO,IAAI,iBAAAA,QAAW,gBAAgB;AACxC;","names":["import_bignumber","BigDecimal"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import BigDecimal from 'bignumber.js';
|
|
2
|
+
export { default as BigDecimal } from 'bignumber.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* BigDecimal is a renamed `BigNumber` type from `bignumber.js`.
|
|
6
|
+
* Includes valid values & instances for BigDecimal.
|
|
7
|
+
*
|
|
8
|
+
* @see https://mikemcl.github.io/bignumber.js/
|
|
9
|
+
*/
|
|
10
|
+
type BigDecimalish = BigDecimal | BigDecimal.Value | bigint;
|
|
11
|
+
/**
|
|
12
|
+
* Converts a value to an instance of BigDecimal
|
|
13
|
+
*
|
|
14
|
+
* @param val
|
|
15
|
+
*/
|
|
16
|
+
declare function toBigDecimal(val: BigDecimalish): BigDecimal;
|
|
17
|
+
|
|
18
|
+
export { type BigDecimalish, toBigDecimal };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import BigDecimal from 'bignumber.js';
|
|
2
|
+
export { default as BigDecimal } from 'bignumber.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* BigDecimal is a renamed `BigNumber` type from `bignumber.js`.
|
|
6
|
+
* Includes valid values & instances for BigDecimal.
|
|
7
|
+
*
|
|
8
|
+
* @see https://mikemcl.github.io/bignumber.js/
|
|
9
|
+
*/
|
|
10
|
+
type BigDecimalish = BigDecimal | BigDecimal.Value | bigint;
|
|
11
|
+
/**
|
|
12
|
+
* Converts a value to an instance of BigDecimal
|
|
13
|
+
*
|
|
14
|
+
* @param val
|
|
15
|
+
*/
|
|
16
|
+
declare function toBigDecimal(val: BigDecimalish): BigDecimal;
|
|
17
|
+
|
|
18
|
+
export { type BigDecimalish, toBigDecimal };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "../../chunk-5WRI5ZAA.js";
|
|
2
|
+
|
|
3
|
+
// src/utils/math/bigDecimal.ts
|
|
4
|
+
import { default as BigDecimal } from "bignumber.js";
|
|
5
|
+
import { default as default2 } from "bignumber.js";
|
|
6
|
+
function toBigDecimal(val) {
|
|
7
|
+
const bnConstructorVal = (() => {
|
|
8
|
+
if (val instanceof BigDecimal) {
|
|
9
|
+
return val;
|
|
10
|
+
} else if (typeof val === "string" || typeof val === "number") {
|
|
11
|
+
return val;
|
|
12
|
+
} else if (typeof val === "bigint") {
|
|
13
|
+
return val.toString();
|
|
14
|
+
}
|
|
15
|
+
return JSON.stringify(val);
|
|
16
|
+
})();
|
|
17
|
+
return new BigDecimal(bnConstructorVal);
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
default2 as BigDecimal,
|
|
21
|
+
toBigDecimal
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=bigDecimal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/math/bigDecimal.ts"],"sourcesContent":["import { default as BigDecimal } from 'bignumber.js';\n\n// Renames `BigNumber` type from `bignumber.js`.\nexport { default as BigDecimal } from 'bignumber.js';\n\n/**\n * BigDecimal is a renamed `BigNumber` type from `bignumber.js`.\n * Includes valid values & instances for BigDecimal.\n *\n * @see https://mikemcl.github.io/bignumber.js/\n */\nexport type BigDecimalish = BigDecimal | BigDecimal.Value | bigint;\n\n/**\n * Converts a value to an instance of BigDecimal\n *\n * @param val\n */\nexport function toBigDecimal(val: BigDecimalish): BigDecimal {\n const bnConstructorVal = (() => {\n if (val instanceof BigDecimal) {\n return val;\n } else if (typeof val === 'string' || typeof val === 'number') {\n return val;\n } else if (typeof val === 'bigint') {\n return val.toString();\n }\n // This is unlikely to occur, but it's here for completeness. Uses the suggestion here: https://typescript-eslint.io/rules/no-base-to-string/#alternatives\n return JSON.stringify(val);\n })();\n return new BigDecimal(bnConstructorVal);\n}\n"],"mappings":";;;AAAA,SAAS,WAAW,kBAAkB;AAGtC,SAAoB,WAAXA,gBAA6B;AAe/B,SAAS,aAAa,KAAgC;AAC3D,QAAM,oBAAoB,MAAM;AAC9B,QAAI,eAAe,YAAY;AAC7B,aAAO;AAAA,IACT,WAAW,OAAO,QAAQ,YAAY,OAAO,QAAQ,UAAU;AAC7D,aAAO;AAAA,IACT,WAAW,OAAO,QAAQ,UAAU;AAClC,aAAO,IAAI,SAAS;AAAA,IACtB;AAEA,WAAO,KAAK,UAAU,GAAG;AAAA,EAC3B,GAAG;AACH,SAAO,IAAI,WAAW,gBAAgB;AACxC;","names":["default"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/math/clamp.ts
|
|
21
|
+
var clamp_exports = {};
|
|
22
|
+
__export(clamp_exports, {
|
|
23
|
+
clampBigDecimal: () => clampBigDecimal
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(clamp_exports);
|
|
26
|
+
function clampBigDecimal(val, opts) {
|
|
27
|
+
if (opts.min != null && val.lt(opts.min)) {
|
|
28
|
+
return opts.min;
|
|
29
|
+
} else if (opts.max != null && val.gt(opts.max)) {
|
|
30
|
+
return opts.max;
|
|
31
|
+
}
|
|
32
|
+
return val;
|
|
33
|
+
}
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
clampBigDecimal
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=clamp.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/math/clamp.ts"],"sourcesContent":["import { BigDecimal } from './bigDecimal';\n\ninterface ClampOptions {\n // Inclusive minimum value\n min?: BigDecimal;\n // Inclusive maximum value\n max?: BigDecimal;\n}\n\n/**\n * Clamps a value between optional minimum and maximum values.\n *\n * @param val\n * @param opts Clamp options\n */\nexport function clampBigDecimal(\n val: BigDecimal,\n opts: ClampOptions,\n): BigDecimal {\n if (opts.min != null && val.lt(opts.min)) {\n return opts.min;\n } else if (opts.max != null && val.gt(opts.max)) {\n return opts.max;\n }\n return val;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAeO,SAAS,gBACd,KACA,MACY;AACZ,MAAI,KAAK,OAAO,QAAQ,IAAI,GAAG,KAAK,GAAG,GAAG;AACxC,WAAO,KAAK;AAAA,EACd,WAAW,KAAK,OAAO,QAAQ,IAAI,GAAG,KAAK,GAAG,GAAG;AAC/C,WAAO,KAAK;AAAA,EACd;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import BigDecimal from 'bignumber.js';
|
|
2
|
+
|
|
3
|
+
interface ClampOptions {
|
|
4
|
+
min?: BigDecimal;
|
|
5
|
+
max?: BigDecimal;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Clamps a value between optional minimum and maximum values.
|
|
9
|
+
*
|
|
10
|
+
* @param val
|
|
11
|
+
* @param opts Clamp options
|
|
12
|
+
*/
|
|
13
|
+
declare function clampBigDecimal(val: BigDecimal, opts: ClampOptions): BigDecimal;
|
|
14
|
+
|
|
15
|
+
export { clampBigDecimal };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import BigDecimal from 'bignumber.js';
|
|
2
|
+
|
|
3
|
+
interface ClampOptions {
|
|
4
|
+
min?: BigDecimal;
|
|
5
|
+
max?: BigDecimal;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Clamps a value between optional minimum and maximum values.
|
|
9
|
+
*
|
|
10
|
+
* @param val
|
|
11
|
+
* @param opts Clamp options
|
|
12
|
+
*/
|
|
13
|
+
declare function clampBigDecimal(val: BigDecimal, opts: ClampOptions): BigDecimal;
|
|
14
|
+
|
|
15
|
+
export { clampBigDecimal };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "../../chunk-5WRI5ZAA.js";
|
|
2
|
+
|
|
3
|
+
// src/utils/math/clamp.ts
|
|
4
|
+
function clampBigDecimal(val, opts) {
|
|
5
|
+
if (opts.min != null && val.lt(opts.min)) {
|
|
6
|
+
return opts.min;
|
|
7
|
+
} else if (opts.max != null && val.gt(opts.max)) {
|
|
8
|
+
return opts.max;
|
|
9
|
+
}
|
|
10
|
+
return val;
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
clampBigDecimal
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=clamp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/math/clamp.ts"],"sourcesContent":["import { BigDecimal } from './bigDecimal';\n\ninterface ClampOptions {\n // Inclusive minimum value\n min?: BigDecimal;\n // Inclusive maximum value\n max?: BigDecimal;\n}\n\n/**\n * Clamps a value between optional minimum and maximum values.\n *\n * @param val\n * @param opts Clamp options\n */\nexport function clampBigDecimal(\n val: BigDecimal,\n opts: ClampOptions,\n): BigDecimal {\n if (opts.min != null && val.lt(opts.min)) {\n return opts.min;\n } else if (opts.max != null && val.gt(opts.max)) {\n return opts.max;\n }\n return val;\n}\n"],"mappings":";;;AAeO,SAAS,gBACd,KACA,MACY;AACZ,MAAI,KAAK,OAAO,QAAQ,IAAI,GAAG,KAAK,GAAG,GAAG;AACxC,WAAO,KAAK;AAAA,EACd,WAAW,KAAK,OAAO,QAAQ,IAAI,GAAG,KAAK,GAAG,GAAG;AAC/C,WAAO,KAAK;AAAA,EACd;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/math/decimalAdjustment.ts
|
|
21
|
+
var decimalAdjustment_exports = {};
|
|
22
|
+
__export(decimalAdjustment_exports, {
|
|
23
|
+
NADO_PRODUCT_DECIMALS: () => NADO_PRODUCT_DECIMALS,
|
|
24
|
+
addDecimals: () => addDecimals,
|
|
25
|
+
removeDecimals: () => removeDecimals
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(decimalAdjustment_exports);
|
|
28
|
+
var import_bigDecimal = require("./bigDecimal.cjs");
|
|
29
|
+
var NADO_PRODUCT_DECIMALS = 18;
|
|
30
|
+
function addDecimals(value, decimals = NADO_PRODUCT_DECIMALS) {
|
|
31
|
+
const getResult = () => {
|
|
32
|
+
if (value == null) {
|
|
33
|
+
return void 0;
|
|
34
|
+
}
|
|
35
|
+
const adjustedValue = (0, import_bigDecimal.toBigDecimal)(value).multipliedBy(
|
|
36
|
+
(0, import_bigDecimal.toBigDecimal)(10).pow(decimals)
|
|
37
|
+
);
|
|
38
|
+
return typeof value === "number" ? adjustedValue.toNumber() : adjustedValue;
|
|
39
|
+
};
|
|
40
|
+
return getResult();
|
|
41
|
+
}
|
|
42
|
+
function removeDecimals(value, decimals = NADO_PRODUCT_DECIMALS) {
|
|
43
|
+
const getResult = () => {
|
|
44
|
+
if (value == null) {
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
|
47
|
+
const adjustedValue = (0, import_bigDecimal.toBigDecimal)(value).dividedBy(
|
|
48
|
+
(0, import_bigDecimal.toBigDecimal)(10).pow(decimals)
|
|
49
|
+
);
|
|
50
|
+
return typeof value === "number" ? adjustedValue.toNumber() : adjustedValue;
|
|
51
|
+
};
|
|
52
|
+
return getResult();
|
|
53
|
+
}
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
NADO_PRODUCT_DECIMALS,
|
|
57
|
+
addDecimals,
|
|
58
|
+
removeDecimals
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=decimalAdjustment.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/math/decimalAdjustment.ts"],"sourcesContent":["import { BigDecimal, BigDecimalish, toBigDecimal } from './bigDecimal';\n\n/**\n * All Nado balances have 18 decimals. Ex. 1e18 = 1.0\n */\nexport const NADO_PRODUCT_DECIMALS = 18;\n\n/**\n * Determines the result type after adjusting decimals based on the input type `T`.\n *\n * - If `T` is `undefined`, the result is `undefined`.\n * - If `T` is a `number`, the result is a `number`.\n * - Otherwise, the result is a `BigDecimal`.\n */\ntype AdjustDecimalsResult<T extends BigDecimalish | undefined> =\n T extends undefined ? undefined : T extends number ? number : BigDecimal;\n\n/**\n * Adds the specified # of decimals to the number. For example, value = 1, decimals = 2, returns 100.\n *\n * @param value can be undefined for better developer experience. If undefined, returns undefined.\n * @param decimals number of decimal places to add, defaults to 18, which is the standard within Nado\n */\n\nexport function addDecimals<T extends BigDecimalish | undefined>(\n value: T,\n decimals: number = NADO_PRODUCT_DECIMALS,\n): AdjustDecimalsResult<T> {\n const getResult = () => {\n if (value == null) {\n return undefined;\n }\n\n const adjustedValue = toBigDecimal(value).multipliedBy(\n toBigDecimal(10).pow(decimals),\n );\n return typeof value === 'number' ? adjustedValue.toNumber() : adjustedValue;\n };\n\n return getResult() as AdjustDecimalsResult<T>;\n}\n\n/**\n * Removes the specified # of decimals from the number. For example, value = 100, decimals = 2, returns 1.\n *\n * @param value can be undefined for better developer experience. If undefined, returns undefined.\n * @param decimals number of decimal places to remove, defaults to 18, which is the standard within Nado\n */\nexport function removeDecimals<T extends BigDecimalish | undefined>(\n value: T,\n decimals: number = NADO_PRODUCT_DECIMALS,\n): AdjustDecimalsResult<T> {\n const getResult = () => {\n if (value == null) {\n return undefined;\n }\n\n const adjustedValue = toBigDecimal(value).dividedBy(\n toBigDecimal(10).pow(decimals),\n );\n return typeof value === 'number' ? adjustedValue.toNumber() : adjustedValue;\n };\n\n return getResult() as AdjustDecimalsResult<T>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAwD;AAKjD,IAAM,wBAAwB;AAmB9B,SAAS,YACd,OACA,WAAmB,uBACM;AACzB,QAAM,YAAY,MAAM;AACtB,QAAI,SAAS,MAAM;AACjB,aAAO;AAAA,IACT;AAEA,UAAM,oBAAgB,gCAAa,KAAK,EAAE;AAAA,UACxC,gCAAa,EAAE,EAAE,IAAI,QAAQ;AAAA,IAC/B;AACA,WAAO,OAAO,UAAU,WAAW,cAAc,SAAS,IAAI;AAAA,EAChE;AAEA,SAAO,UAAU;AACnB;AAQO,SAAS,eACd,OACA,WAAmB,uBACM;AACzB,QAAM,YAAY,MAAM;AACtB,QAAI,SAAS,MAAM;AACjB,aAAO;AAAA,IACT;AAEA,UAAM,oBAAgB,gCAAa,KAAK,EAAE;AAAA,UACxC,gCAAa,EAAE,EAAE,IAAI,QAAQ;AAAA,IAC/B;AACA,WAAO,OAAO,UAAU,WAAW,cAAc,SAAS,IAAI;AAAA,EAChE;AAEA,SAAO,UAAU;AACnB;","names":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BigDecimalish } from './bigDecimal.cjs';
|
|
2
|
+
import BigDecimal from 'bignumber.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* All Nado balances have 18 decimals. Ex. 1e18 = 1.0
|
|
6
|
+
*/
|
|
7
|
+
declare const NADO_PRODUCT_DECIMALS = 18;
|
|
8
|
+
/**
|
|
9
|
+
* Determines the result type after adjusting decimals based on the input type `T`.
|
|
10
|
+
*
|
|
11
|
+
* - If `T` is `undefined`, the result is `undefined`.
|
|
12
|
+
* - If `T` is a `number`, the result is a `number`.
|
|
13
|
+
* - Otherwise, the result is a `BigDecimal`.
|
|
14
|
+
*/
|
|
15
|
+
type AdjustDecimalsResult<T extends BigDecimalish | undefined> = T extends undefined ? undefined : T extends number ? number : BigDecimal;
|
|
16
|
+
/**
|
|
17
|
+
* Adds the specified # of decimals to the number. For example, value = 1, decimals = 2, returns 100.
|
|
18
|
+
*
|
|
19
|
+
* @param value can be undefined for better developer experience. If undefined, returns undefined.
|
|
20
|
+
* @param decimals number of decimal places to add, defaults to 18, which is the standard within Nado
|
|
21
|
+
*/
|
|
22
|
+
declare function addDecimals<T extends BigDecimalish | undefined>(value: T, decimals?: number): AdjustDecimalsResult<T>;
|
|
23
|
+
/**
|
|
24
|
+
* Removes the specified # of decimals from the number. For example, value = 100, decimals = 2, returns 1.
|
|
25
|
+
*
|
|
26
|
+
* @param value can be undefined for better developer experience. If undefined, returns undefined.
|
|
27
|
+
* @param decimals number of decimal places to remove, defaults to 18, which is the standard within Nado
|
|
28
|
+
*/
|
|
29
|
+
declare function removeDecimals<T extends BigDecimalish | undefined>(value: T, decimals?: number): AdjustDecimalsResult<T>;
|
|
30
|
+
|
|
31
|
+
export { NADO_PRODUCT_DECIMALS, addDecimals, removeDecimals };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BigDecimalish } from './bigDecimal.js';
|
|
2
|
+
import BigDecimal from 'bignumber.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* All Nado balances have 18 decimals. Ex. 1e18 = 1.0
|
|
6
|
+
*/
|
|
7
|
+
declare const NADO_PRODUCT_DECIMALS = 18;
|
|
8
|
+
/**
|
|
9
|
+
* Determines the result type after adjusting decimals based on the input type `T`.
|
|
10
|
+
*
|
|
11
|
+
* - If `T` is `undefined`, the result is `undefined`.
|
|
12
|
+
* - If `T` is a `number`, the result is a `number`.
|
|
13
|
+
* - Otherwise, the result is a `BigDecimal`.
|
|
14
|
+
*/
|
|
15
|
+
type AdjustDecimalsResult<T extends BigDecimalish | undefined> = T extends undefined ? undefined : T extends number ? number : BigDecimal;
|
|
16
|
+
/**
|
|
17
|
+
* Adds the specified # of decimals to the number. For example, value = 1, decimals = 2, returns 100.
|
|
18
|
+
*
|
|
19
|
+
* @param value can be undefined for better developer experience. If undefined, returns undefined.
|
|
20
|
+
* @param decimals number of decimal places to add, defaults to 18, which is the standard within Nado
|
|
21
|
+
*/
|
|
22
|
+
declare function addDecimals<T extends BigDecimalish | undefined>(value: T, decimals?: number): AdjustDecimalsResult<T>;
|
|
23
|
+
/**
|
|
24
|
+
* Removes the specified # of decimals from the number. For example, value = 100, decimals = 2, returns 1.
|
|
25
|
+
*
|
|
26
|
+
* @param value can be undefined for better developer experience. If undefined, returns undefined.
|
|
27
|
+
* @param decimals number of decimal places to remove, defaults to 18, which is the standard within Nado
|
|
28
|
+
*/
|
|
29
|
+
declare function removeDecimals<T extends BigDecimalish | undefined>(value: T, decimals?: number): AdjustDecimalsResult<T>;
|
|
30
|
+
|
|
31
|
+
export { NADO_PRODUCT_DECIMALS, addDecimals, removeDecimals };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import "../../chunk-5WRI5ZAA.js";
|
|
2
|
+
|
|
3
|
+
// src/utils/math/decimalAdjustment.ts
|
|
4
|
+
import { toBigDecimal } from "./bigDecimal.js";
|
|
5
|
+
var NADO_PRODUCT_DECIMALS = 18;
|
|
6
|
+
function addDecimals(value, decimals = NADO_PRODUCT_DECIMALS) {
|
|
7
|
+
const getResult = () => {
|
|
8
|
+
if (value == null) {
|
|
9
|
+
return void 0;
|
|
10
|
+
}
|
|
11
|
+
const adjustedValue = toBigDecimal(value).multipliedBy(
|
|
12
|
+
toBigDecimal(10).pow(decimals)
|
|
13
|
+
);
|
|
14
|
+
return typeof value === "number" ? adjustedValue.toNumber() : adjustedValue;
|
|
15
|
+
};
|
|
16
|
+
return getResult();
|
|
17
|
+
}
|
|
18
|
+
function removeDecimals(value, decimals = NADO_PRODUCT_DECIMALS) {
|
|
19
|
+
const getResult = () => {
|
|
20
|
+
if (value == null) {
|
|
21
|
+
return void 0;
|
|
22
|
+
}
|
|
23
|
+
const adjustedValue = toBigDecimal(value).dividedBy(
|
|
24
|
+
toBigDecimal(10).pow(decimals)
|
|
25
|
+
);
|
|
26
|
+
return typeof value === "number" ? adjustedValue.toNumber() : adjustedValue;
|
|
27
|
+
};
|
|
28
|
+
return getResult();
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
NADO_PRODUCT_DECIMALS,
|
|
32
|
+
addDecimals,
|
|
33
|
+
removeDecimals
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=decimalAdjustment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/math/decimalAdjustment.ts"],"sourcesContent":["import { BigDecimal, BigDecimalish, toBigDecimal } from './bigDecimal';\n\n/**\n * All Nado balances have 18 decimals. Ex. 1e18 = 1.0\n */\nexport const NADO_PRODUCT_DECIMALS = 18;\n\n/**\n * Determines the result type after adjusting decimals based on the input type `T`.\n *\n * - If `T` is `undefined`, the result is `undefined`.\n * - If `T` is a `number`, the result is a `number`.\n * - Otherwise, the result is a `BigDecimal`.\n */\ntype AdjustDecimalsResult<T extends BigDecimalish | undefined> =\n T extends undefined ? undefined : T extends number ? number : BigDecimal;\n\n/**\n * Adds the specified # of decimals to the number. For example, value = 1, decimals = 2, returns 100.\n *\n * @param value can be undefined for better developer experience. If undefined, returns undefined.\n * @param decimals number of decimal places to add, defaults to 18, which is the standard within Nado\n */\n\nexport function addDecimals<T extends BigDecimalish | undefined>(\n value: T,\n decimals: number = NADO_PRODUCT_DECIMALS,\n): AdjustDecimalsResult<T> {\n const getResult = () => {\n if (value == null) {\n return undefined;\n }\n\n const adjustedValue = toBigDecimal(value).multipliedBy(\n toBigDecimal(10).pow(decimals),\n );\n return typeof value === 'number' ? adjustedValue.toNumber() : adjustedValue;\n };\n\n return getResult() as AdjustDecimalsResult<T>;\n}\n\n/**\n * Removes the specified # of decimals from the number. For example, value = 100, decimals = 2, returns 1.\n *\n * @param value can be undefined for better developer experience. If undefined, returns undefined.\n * @param decimals number of decimal places to remove, defaults to 18, which is the standard within Nado\n */\nexport function removeDecimals<T extends BigDecimalish | undefined>(\n value: T,\n decimals: number = NADO_PRODUCT_DECIMALS,\n): AdjustDecimalsResult<T> {\n const getResult = () => {\n if (value == null) {\n return undefined;\n }\n\n const adjustedValue = toBigDecimal(value).dividedBy(\n toBigDecimal(10).pow(decimals),\n );\n return typeof value === 'number' ? adjustedValue.toNumber() : adjustedValue;\n };\n\n return getResult() as AdjustDecimalsResult<T>;\n}\n"],"mappings":";;;AAAA,SAAoC,oBAAoB;AAKjD,IAAM,wBAAwB;AAmB9B,SAAS,YACd,OACA,WAAmB,uBACM;AACzB,QAAM,YAAY,MAAM;AACtB,QAAI,SAAS,MAAM;AACjB,aAAO;AAAA,IACT;AAEA,UAAM,gBAAgB,aAAa,KAAK,EAAE;AAAA,MACxC,aAAa,EAAE,EAAE,IAAI,QAAQ;AAAA,IAC/B;AACA,WAAO,OAAO,UAAU,WAAW,cAAc,SAAS,IAAI;AAAA,EAChE;AAEA,SAAO,UAAU;AACnB;AAQO,SAAS,eACd,OACA,WAAmB,uBACM;AACzB,QAAM,YAAY,MAAM;AACtB,QAAI,SAAS,MAAM;AACjB,aAAO;AAAA,IACT;AAEA,UAAM,gBAAgB,aAAa,KAAK,EAAE;AAAA,MACxC,aAAa,EAAE,EAAE,IAAI,QAAQ;AAAA,IAC/B;AACA,WAAO,OAAO,UAAU,WAAW,cAAc,SAAS,IAAI;AAAA,EAChE;AAEA,SAAO,UAAU;AACnB;","names":[]}
|