@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,248 @@
|
|
|
1
|
+
import { subaccountToHex } from '../utils/bytes32';
|
|
2
|
+
import { addDecimals, toIntegerString } from '../utils/math';
|
|
3
|
+
import {
|
|
4
|
+
EIP712BurnNlpValues,
|
|
5
|
+
EIP712LeaderboardAuthenticationValues,
|
|
6
|
+
EIP712LinkSignerValues,
|
|
7
|
+
EIP712LiquidateSubaccountValues,
|
|
8
|
+
EIP712ListTriggerOrdersValues,
|
|
9
|
+
EIP712MintNlpValues,
|
|
10
|
+
EIP712OrderCancellationValues,
|
|
11
|
+
EIP712OrderValues,
|
|
12
|
+
EIP712ProductOrdersCancellationValues,
|
|
13
|
+
EIP712TransferQuoteValues,
|
|
14
|
+
EIP712WithdrawCollateralValues,
|
|
15
|
+
SignableRequestTypeToEIP712Values,
|
|
16
|
+
} from './eip712ValueTypes';
|
|
17
|
+
import {
|
|
18
|
+
SignableRequestType,
|
|
19
|
+
SignableRequestTypeToParams,
|
|
20
|
+
} from './signableRequestType';
|
|
21
|
+
import {
|
|
22
|
+
EIP712BurnNlpParams,
|
|
23
|
+
EIP712CancelOrdersParams,
|
|
24
|
+
EIP712CancelProductOrdersParams,
|
|
25
|
+
EIP712LeaderboardAuthenticationParams,
|
|
26
|
+
EIP712LinkSignerParams,
|
|
27
|
+
EIP712LiquidateSubaccountParams,
|
|
28
|
+
EIP712ListTriggerOrdersParams,
|
|
29
|
+
EIP712MintNlpParams,
|
|
30
|
+
EIP712OrderParams,
|
|
31
|
+
EIP712TransferQuoteParams,
|
|
32
|
+
EIP712WithdrawCollateralParams,
|
|
33
|
+
} from './signatureParamTypes';
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Returns the EIP712 compatible values for signing.
|
|
37
|
+
*
|
|
38
|
+
* Note: We use the string representation of bigint to be compatible with JSON.stringify
|
|
39
|
+
*
|
|
40
|
+
* @param requestType
|
|
41
|
+
* @param params
|
|
42
|
+
*/
|
|
43
|
+
export function getNadoEIP712Values<TReqType extends SignableRequestType>(
|
|
44
|
+
requestType: TReqType,
|
|
45
|
+
params: SignableRequestTypeToParams[TReqType],
|
|
46
|
+
): SignableRequestTypeToEIP712Values[TReqType] {
|
|
47
|
+
// Typescript does not yet support type narrowing + generic lookup types, hence the hacks here
|
|
48
|
+
let values: SignableRequestTypeToEIP712Values[keyof SignableRequestTypeToEIP712Values];
|
|
49
|
+
switch (requestType) {
|
|
50
|
+
case 'withdraw_collateral':
|
|
51
|
+
values = getWithdrawCollateralValues(
|
|
52
|
+
params as EIP712WithdrawCollateralParams,
|
|
53
|
+
);
|
|
54
|
+
break;
|
|
55
|
+
case 'place_order':
|
|
56
|
+
values = getOrderValues(params as EIP712OrderParams);
|
|
57
|
+
break;
|
|
58
|
+
case 'list_trigger_orders':
|
|
59
|
+
values = getListTriggerOrdersValues(
|
|
60
|
+
params as EIP712ListTriggerOrdersParams,
|
|
61
|
+
);
|
|
62
|
+
break;
|
|
63
|
+
case 'cancel_orders':
|
|
64
|
+
values = getOrderCancellationValues(params as EIP712CancelOrdersParams);
|
|
65
|
+
break;
|
|
66
|
+
case 'cancel_product_orders':
|
|
67
|
+
values = getProductOrdersCancellationValues(
|
|
68
|
+
params as EIP712CancelProductOrdersParams,
|
|
69
|
+
);
|
|
70
|
+
break;
|
|
71
|
+
case 'liquidate_subaccount':
|
|
72
|
+
values = getLiquidateSubaccountValues(
|
|
73
|
+
params as EIP712LiquidateSubaccountParams,
|
|
74
|
+
);
|
|
75
|
+
break;
|
|
76
|
+
case 'link_signer':
|
|
77
|
+
values = getLinkSignerValues(params as EIP712LinkSignerParams);
|
|
78
|
+
break;
|
|
79
|
+
case 'transfer_quote':
|
|
80
|
+
values = getTransferQuoteValues(params as EIP712TransferQuoteParams);
|
|
81
|
+
break;
|
|
82
|
+
case 'leaderboard_authentication':
|
|
83
|
+
values = getLeaderboardAuthenticationValues(
|
|
84
|
+
params as EIP712LeaderboardAuthenticationParams,
|
|
85
|
+
);
|
|
86
|
+
break;
|
|
87
|
+
case 'mint_nlp':
|
|
88
|
+
values = getMintNlpValues(params as EIP712MintNlpParams);
|
|
89
|
+
break;
|
|
90
|
+
case 'burn_nlp':
|
|
91
|
+
values = getBurnNlpValues(params as EIP712BurnNlpParams);
|
|
92
|
+
break;
|
|
93
|
+
default:
|
|
94
|
+
throw new Error(`Unsupported request type: ${requestType}`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return values as SignableRequestTypeToEIP712Values[TReqType];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function getWithdrawCollateralValues(
|
|
101
|
+
params: EIP712WithdrawCollateralParams,
|
|
102
|
+
): EIP712WithdrawCollateralValues {
|
|
103
|
+
return {
|
|
104
|
+
sender: subaccountToHex({
|
|
105
|
+
subaccountOwner: params.subaccountOwner,
|
|
106
|
+
subaccountName: params.subaccountName,
|
|
107
|
+
}),
|
|
108
|
+
productId: params.productId,
|
|
109
|
+
amount: toIntegerString(params.amount),
|
|
110
|
+
nonce: params.nonce,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function getOrderValues(params: EIP712OrderParams): EIP712OrderValues {
|
|
115
|
+
return {
|
|
116
|
+
sender: subaccountToHex({
|
|
117
|
+
subaccountOwner: params.subaccountOwner,
|
|
118
|
+
subaccountName: params.subaccountName,
|
|
119
|
+
}),
|
|
120
|
+
priceX18: toIntegerString(addDecimals(params.price)),
|
|
121
|
+
amount: toIntegerString(params.amount),
|
|
122
|
+
expiration: toIntegerString(params.expiration),
|
|
123
|
+
nonce: params.nonce,
|
|
124
|
+
appendix: toIntegerString(params.appendix),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function getListTriggerOrdersValues(
|
|
129
|
+
params: EIP712ListTriggerOrdersParams,
|
|
130
|
+
): EIP712ListTriggerOrdersValues {
|
|
131
|
+
return {
|
|
132
|
+
recvTime: toIntegerString(params.recvTime),
|
|
133
|
+
sender: subaccountToHex({
|
|
134
|
+
subaccountOwner: params.subaccountOwner,
|
|
135
|
+
subaccountName: params.subaccountName,
|
|
136
|
+
}),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function getOrderCancellationValues(
|
|
141
|
+
params: EIP712CancelOrdersParams,
|
|
142
|
+
): EIP712OrderCancellationValues {
|
|
143
|
+
return {
|
|
144
|
+
sender: subaccountToHex({
|
|
145
|
+
subaccountOwner: params.subaccountOwner,
|
|
146
|
+
subaccountName: params.subaccountName,
|
|
147
|
+
}),
|
|
148
|
+
productIds: params.productIds,
|
|
149
|
+
digests: params.digests,
|
|
150
|
+
nonce: params.nonce,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function getProductOrdersCancellationValues(
|
|
155
|
+
params: EIP712CancelProductOrdersParams,
|
|
156
|
+
): EIP712ProductOrdersCancellationValues {
|
|
157
|
+
return {
|
|
158
|
+
sender: subaccountToHex({
|
|
159
|
+
subaccountOwner: params.subaccountOwner,
|
|
160
|
+
subaccountName: params.subaccountName,
|
|
161
|
+
}),
|
|
162
|
+
productIds: params.productIds,
|
|
163
|
+
nonce: params.nonce,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function getLiquidateSubaccountValues(
|
|
168
|
+
params: EIP712LiquidateSubaccountParams,
|
|
169
|
+
): EIP712LiquidateSubaccountValues {
|
|
170
|
+
return {
|
|
171
|
+
sender: subaccountToHex({
|
|
172
|
+
subaccountOwner: params.subaccountOwner,
|
|
173
|
+
subaccountName: params.subaccountName,
|
|
174
|
+
}),
|
|
175
|
+
liquidatee: subaccountToHex({
|
|
176
|
+
subaccountOwner: params.liquidateeOwner,
|
|
177
|
+
subaccountName: params.liquidateeName,
|
|
178
|
+
}),
|
|
179
|
+
mode: params.mode,
|
|
180
|
+
healthGroup: toIntegerString(params.healthGroup),
|
|
181
|
+
amount: toIntegerString(params.amount),
|
|
182
|
+
nonce: params.nonce,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function getLinkSignerValues(
|
|
187
|
+
params: EIP712LinkSignerParams,
|
|
188
|
+
): EIP712LinkSignerValues {
|
|
189
|
+
return {
|
|
190
|
+
sender: subaccountToHex({
|
|
191
|
+
subaccountOwner: params.subaccountOwner,
|
|
192
|
+
subaccountName: params.subaccountName,
|
|
193
|
+
}),
|
|
194
|
+
signer: params.signer,
|
|
195
|
+
nonce: params.nonce,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function getTransferQuoteValues(
|
|
200
|
+
params: EIP712TransferQuoteParams,
|
|
201
|
+
): EIP712TransferQuoteValues {
|
|
202
|
+
return {
|
|
203
|
+
sender: subaccountToHex({
|
|
204
|
+
subaccountOwner: params.subaccountOwner,
|
|
205
|
+
subaccountName: params.subaccountName,
|
|
206
|
+
}),
|
|
207
|
+
recipient: subaccountToHex({
|
|
208
|
+
subaccountOwner: params.subaccountOwner,
|
|
209
|
+
subaccountName: params.recipientSubaccountName,
|
|
210
|
+
}),
|
|
211
|
+
amount: toIntegerString(params.amount),
|
|
212
|
+
nonce: params.nonce,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function getLeaderboardAuthenticationValues(
|
|
217
|
+
params: EIP712LeaderboardAuthenticationParams,
|
|
218
|
+
): EIP712LeaderboardAuthenticationValues {
|
|
219
|
+
return {
|
|
220
|
+
sender: subaccountToHex({
|
|
221
|
+
subaccountOwner: params.subaccountOwner,
|
|
222
|
+
subaccountName: params.subaccountName,
|
|
223
|
+
}),
|
|
224
|
+
expiration: toIntegerString(params.expiration),
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function getMintNlpValues(params: EIP712MintNlpParams): EIP712MintNlpValues {
|
|
229
|
+
return {
|
|
230
|
+
sender: subaccountToHex({
|
|
231
|
+
subaccountOwner: params.subaccountOwner,
|
|
232
|
+
subaccountName: params.subaccountName,
|
|
233
|
+
}),
|
|
234
|
+
quoteAmount: toIntegerString(params.quoteAmount),
|
|
235
|
+
nonce: params.nonce,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function getBurnNlpValues(params: EIP712BurnNlpParams): EIP712BurnNlpValues {
|
|
240
|
+
return {
|
|
241
|
+
sender: subaccountToHex({
|
|
242
|
+
subaccountOwner: params.subaccountOwner,
|
|
243
|
+
subaccountName: params.subaccountName,
|
|
244
|
+
}),
|
|
245
|
+
nlpAmount: toIntegerString(params.nlpAmount),
|
|
246
|
+
nonce: params.nonce,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Address, toHex } from 'viem';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The EIP712 verifying address for an order is defined as `address(uint160(productId))`
|
|
5
|
+
* @param productId
|
|
6
|
+
*/
|
|
7
|
+
export function getOrderVerifyingAddress(productId: number): Address {
|
|
8
|
+
return toHex(productId, { size: 20 });
|
|
9
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { WalletClientWithAccount } from '../types/viemTypes';
|
|
2
|
+
import { getNadoEIP712Domain } from './getNadoEIP712Domain';
|
|
3
|
+
import { getNadoEIP712PrimaryType } from './getNadoEIP712PrimaryType';
|
|
4
|
+
import { getNadoEIP712Types } from './getNadoEIP712Types';
|
|
5
|
+
import { getNadoEIP712Values } from './getNadoEIP712Values';
|
|
6
|
+
import {
|
|
7
|
+
SignableRequestType,
|
|
8
|
+
SignableRequestTypeToParams,
|
|
9
|
+
} from './signableRequestType';
|
|
10
|
+
|
|
11
|
+
interface Params<TReqType extends SignableRequestType> {
|
|
12
|
+
requestType: TReqType;
|
|
13
|
+
requestParams: SignableRequestTypeToParams[TReqType];
|
|
14
|
+
// Allow explicit definition of `chainId` to enable signing for different chains
|
|
15
|
+
chainId: number;
|
|
16
|
+
// Orderbook for orders, Sequencer for other requests
|
|
17
|
+
verifyingContract: string;
|
|
18
|
+
walletClient: WalletClientWithAccount;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function getSignedTransactionRequest<
|
|
22
|
+
TReqType extends SignableRequestType,
|
|
23
|
+
>(params: Params<TReqType>) {
|
|
24
|
+
return params.walletClient.signTypedData({
|
|
25
|
+
domain: getNadoEIP712Domain(params.verifyingContract, params.chainId),
|
|
26
|
+
types: getNadoEIP712Types(params.requestType),
|
|
27
|
+
primaryType: getNadoEIP712PrimaryType(params.requestType),
|
|
28
|
+
message: getNadoEIP712Values(params.requestType, params.requestParams),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './getSignedTransactionRequest';
|
|
2
|
+
export * from './getNadoEIP712Values';
|
|
3
|
+
export * from './getNadoEIP712Types';
|
|
4
|
+
export * from './getNadoEIP712PrimaryType';
|
|
5
|
+
export * from './getNadoEIP712Domain';
|
|
6
|
+
export * from './orderDigest';
|
|
7
|
+
export * from './signableRequestType';
|
|
8
|
+
export * from './signatureParamTypes';
|
|
9
|
+
export * from './eip712ValueTypes';
|
|
10
|
+
export * from './getOrderVerifyingAddress';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { hashTypedData } from 'viem';
|
|
2
|
+
import { getNadoEIP712Domain } from './getNadoEIP712Domain';
|
|
3
|
+
import { getNadoEIP712PrimaryType } from './getNadoEIP712PrimaryType';
|
|
4
|
+
import { getNadoEIP712Types } from './getNadoEIP712Types';
|
|
5
|
+
import { getNadoEIP712Values } from './getNadoEIP712Values';
|
|
6
|
+
import { getOrderVerifyingAddress } from './getOrderVerifyingAddress';
|
|
7
|
+
import { EIP712OrderParams } from './signatureParamTypes';
|
|
8
|
+
|
|
9
|
+
interface OrderDigestParams {
|
|
10
|
+
order: EIP712OrderParams;
|
|
11
|
+
chainId: number;
|
|
12
|
+
productId: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Returns the EIP712 digest for an order
|
|
17
|
+
*
|
|
18
|
+
* @param params
|
|
19
|
+
*/
|
|
20
|
+
export function getOrderDigest(params: OrderDigestParams): string {
|
|
21
|
+
const { chainId, order, productId } = params;
|
|
22
|
+
return hashTypedData({
|
|
23
|
+
domain: getNadoEIP712Domain(getOrderVerifyingAddress(productId), chainId),
|
|
24
|
+
message: getNadoEIP712Values('place_order', order),
|
|
25
|
+
primaryType: getNadoEIP712PrimaryType('place_order'),
|
|
26
|
+
types: getNadoEIP712Types('place_order'),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EIP712BurnNlpParams,
|
|
3
|
+
EIP712CancelOrdersParams,
|
|
4
|
+
EIP712CancelProductOrdersParams,
|
|
5
|
+
EIP712LeaderboardAuthenticationParams,
|
|
6
|
+
EIP712LinkSignerParams,
|
|
7
|
+
EIP712LiquidateSubaccountParams,
|
|
8
|
+
EIP712ListTriggerOrdersParams,
|
|
9
|
+
EIP712MintNlpParams,
|
|
10
|
+
EIP712OrderParams,
|
|
11
|
+
EIP712TransferQuoteParams,
|
|
12
|
+
EIP712WithdrawCollateralParams,
|
|
13
|
+
} from './signatureParamTypes';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* All possible requests to be signed, to the expected params
|
|
17
|
+
*/
|
|
18
|
+
export interface SignableRequestTypeToParams {
|
|
19
|
+
burn_nlp: EIP712BurnNlpParams;
|
|
20
|
+
cancel_orders: EIP712CancelOrdersParams;
|
|
21
|
+
cancel_product_orders: EIP712CancelProductOrdersParams;
|
|
22
|
+
leaderboard_authentication: EIP712LeaderboardAuthenticationParams;
|
|
23
|
+
link_signer: EIP712LinkSignerParams;
|
|
24
|
+
liquidate_subaccount: EIP712LiquidateSubaccountParams;
|
|
25
|
+
list_trigger_orders: EIP712ListTriggerOrdersParams;
|
|
26
|
+
mint_nlp: EIP712MintNlpParams;
|
|
27
|
+
place_order: EIP712OrderParams;
|
|
28
|
+
transfer_quote: EIP712TransferQuoteParams;
|
|
29
|
+
withdraw_collateral: EIP712WithdrawCollateralParams;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type SignableRequestType = keyof SignableRequestTypeToParams;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Address } from 'viem';
|
|
2
|
+
import { Subaccount } from '../types/subaccountTypes';
|
|
3
|
+
import { BigDecimalish } from '../utils';
|
|
4
|
+
|
|
5
|
+
export interface SignedTx<TBaseTx> {
|
|
6
|
+
tx: TBaseTx;
|
|
7
|
+
signature: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface SignedEIP712OrderParams {
|
|
11
|
+
order: EIP712OrderParams;
|
|
12
|
+
signature: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface EIP712WithdrawCollateralParams extends Subaccount {
|
|
16
|
+
productId: number;
|
|
17
|
+
amount: BigDecimalish;
|
|
18
|
+
nonce: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface EIP712LiquidateSubaccountParams extends Subaccount {
|
|
22
|
+
// Subaccount being liquidated
|
|
23
|
+
liquidateeOwner: string;
|
|
24
|
+
liquidateeName: string;
|
|
25
|
+
// 0 = spread, 1 = long, 2 = short
|
|
26
|
+
mode: number;
|
|
27
|
+
// Spot & perp pair
|
|
28
|
+
healthGroup: BigDecimalish;
|
|
29
|
+
amount: BigDecimalish;
|
|
30
|
+
nonce: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface EIP712OrderParams extends Subaccount {
|
|
34
|
+
// Expiration time in seconds, with order type encoded if relevant
|
|
35
|
+
expiration: BigDecimalish;
|
|
36
|
+
// Limit price
|
|
37
|
+
price: BigDecimalish;
|
|
38
|
+
// Positive for buy, negative for sell
|
|
39
|
+
amount: BigDecimalish;
|
|
40
|
+
// A unique nonce to identify the order
|
|
41
|
+
nonce: string;
|
|
42
|
+
// Packed order appendix (uint128) to encode order details such as order execution behavior, isolated, etc.
|
|
43
|
+
appendix: BigDecimalish;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface EIP712ListTriggerOrdersParams extends Subaccount {
|
|
47
|
+
recvTime: BigDecimalish;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface EIP712CancelOrdersParams extends Subaccount {
|
|
51
|
+
productIds: number[];
|
|
52
|
+
digests: string[];
|
|
53
|
+
nonce: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface EIP712CancelProductOrdersParams extends Subaccount {
|
|
57
|
+
productIds: number[];
|
|
58
|
+
nonce: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface EIP712LinkSignerParams extends Subaccount {
|
|
62
|
+
signer: Address;
|
|
63
|
+
nonce: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface EIP712TransferQuoteParams extends Subaccount {
|
|
67
|
+
recipientSubaccountName: string;
|
|
68
|
+
amount: BigDecimalish;
|
|
69
|
+
nonce: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface EIP712LeaderboardAuthenticationParams extends Subaccount {
|
|
73
|
+
expiration: BigDecimalish;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface EIP712MintNlpParams extends Subaccount {
|
|
77
|
+
quoteAmount: BigDecimalish;
|
|
78
|
+
nonce: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface EIP712BurnNlpParams extends Subaccount {
|
|
82
|
+
nlpAmount: BigDecimalish;
|
|
83
|
+
nonce: string;
|
|
84
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { encodeAbiParameters, parseAbiParameters } from 'viem';
|
|
2
|
+
import {
|
|
3
|
+
EIP712WithdrawCollateralParams,
|
|
4
|
+
SignedEIP712OrderParams,
|
|
5
|
+
SignedTx,
|
|
6
|
+
} from '../eip712';
|
|
7
|
+
import { addDecimals, toBigInt } from '../utils';
|
|
8
|
+
|
|
9
|
+
export function encodeSignedWithdrawCollateralTx(
|
|
10
|
+
signed: SignedTx<EIP712WithdrawCollateralParams>,
|
|
11
|
+
) {
|
|
12
|
+
return encodeAbiParameters(
|
|
13
|
+
parseAbiParameters(
|
|
14
|
+
'(tuple(address sender, string subaccountName, uint32 productId, uint128 amount, uint64 nonce), bytes signature)',
|
|
15
|
+
),
|
|
16
|
+
[
|
|
17
|
+
[
|
|
18
|
+
[
|
|
19
|
+
signed.tx.subaccountOwner,
|
|
20
|
+
signed.tx.subaccountName,
|
|
21
|
+
signed.tx.productId,
|
|
22
|
+
signed.tx.amount,
|
|
23
|
+
signed.tx.nonce,
|
|
24
|
+
],
|
|
25
|
+
signed.signature,
|
|
26
|
+
],
|
|
27
|
+
],
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function encodeSignedOrder(signed: SignedEIP712OrderParams) {
|
|
32
|
+
return encodeAbiParameters(
|
|
33
|
+
parseAbiParameters(
|
|
34
|
+
'(tuple(tuple(address sender, string subaccountName, int128 priceX18, int128 amount, uint64 expiration, uint64 nonce), bytes signature))',
|
|
35
|
+
),
|
|
36
|
+
[
|
|
37
|
+
[
|
|
38
|
+
[
|
|
39
|
+
signed.order.subaccountOwner,
|
|
40
|
+
signed.order.subaccountName,
|
|
41
|
+
toBigInt(addDecimals(signed.order.price)),
|
|
42
|
+
signed.order.amount,
|
|
43
|
+
signed.order.expiration,
|
|
44
|
+
signed.order.nonce,
|
|
45
|
+
],
|
|
46
|
+
signed.signature,
|
|
47
|
+
],
|
|
48
|
+
],
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './encoding';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ERC20_ABI } from '../abis';
|
|
2
|
+
import { WithContract } from '../types/nadoContractTypes';
|
|
3
|
+
import { WriteableContractInstance } from '../types/viemTypes';
|
|
4
|
+
import { BigDecimalish, toBigInt } from '../utils';
|
|
5
|
+
|
|
6
|
+
export interface ApproveDepositAllowanceParams {
|
|
7
|
+
amount: BigDecimalish;
|
|
8
|
+
tokenContract: WriteableContractInstance<typeof ERC20_ABI>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Approves the endpoint contract to spend the amount of tokens specified
|
|
13
|
+
*/
|
|
14
|
+
export function approveDepositAllowance({
|
|
15
|
+
endpoint,
|
|
16
|
+
amount,
|
|
17
|
+
tokenContract,
|
|
18
|
+
}: WithContract<'endpoint', ApproveDepositAllowanceParams>) {
|
|
19
|
+
return tokenContract.write.approve([endpoint.address, toBigInt(amount)]);
|
|
20
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { toHex } from 'viem';
|
|
2
|
+
import { WithContract } from '../types/nadoContractTypes';
|
|
3
|
+
import { BigDecimalish, subaccountNameToBytes12, toBigInt } from '../utils';
|
|
4
|
+
|
|
5
|
+
export interface DepositCollateralParams {
|
|
6
|
+
subaccountName: string;
|
|
7
|
+
productId: number;
|
|
8
|
+
amount: BigDecimalish;
|
|
9
|
+
referralCode?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Deposits collateral through the Endpoint contract, which will be picked up automatically by the sequencer and
|
|
14
|
+
* submitted.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
export async function depositCollateral({
|
|
18
|
+
endpoint,
|
|
19
|
+
subaccountName,
|
|
20
|
+
productId,
|
|
21
|
+
amount,
|
|
22
|
+
referralCode,
|
|
23
|
+
}: WithContract<'endpoint', DepositCollateralParams>) {
|
|
24
|
+
const subaccountNameHex = toHex(subaccountNameToBytes12(subaccountName));
|
|
25
|
+
if (referralCode) {
|
|
26
|
+
return endpoint.write.depositCollateralWithReferral([
|
|
27
|
+
// bytes12
|
|
28
|
+
subaccountNameHex,
|
|
29
|
+
// uint32
|
|
30
|
+
productId,
|
|
31
|
+
// uint128
|
|
32
|
+
toBigInt(amount),
|
|
33
|
+
// string
|
|
34
|
+
referralCode,
|
|
35
|
+
]);
|
|
36
|
+
} else {
|
|
37
|
+
return endpoint.write.depositCollateral([
|
|
38
|
+
subaccountNameHex,
|
|
39
|
+
productId,
|
|
40
|
+
toBigInt(amount),
|
|
41
|
+
]);
|
|
42
|
+
}
|
|
43
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const LOCAL_CHAIN_ENVS = ['local'] as const satisfies string[];
|
|
2
|
+
|
|
3
|
+
export const TESTNET_CHAIN_ENVS = ['inkTestnet'] as const satisfies string[];
|
|
4
|
+
|
|
5
|
+
export const MAINNET_CHAIN_ENVS = ['arbitrum'] as const satisfies string[];
|
|
6
|
+
|
|
7
|
+
export const ALL_CHAIN_ENVS = [
|
|
8
|
+
...LOCAL_CHAIN_ENVS,
|
|
9
|
+
...TESTNET_CHAIN_ENVS,
|
|
10
|
+
...MAINNET_CHAIN_ENVS,
|
|
11
|
+
] as const satisfies string[];
|
|
12
|
+
|
|
13
|
+
export type ChainEnv = (typeof ALL_CHAIN_ENVS)[number];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution behavior of an order that can be sent to the engine:
|
|
3
|
+
* - `default`: Limit order
|
|
4
|
+
* - `ioc`: Immediate or Cancel order
|
|
5
|
+
* - `fok`: Fill or Kill order
|
|
6
|
+
* - `post_only`: Post Only order (will not match against existing orders)
|
|
7
|
+
*/
|
|
8
|
+
export type OrderExecutionType = 'default' | 'ioc' | 'fok' | 'post_only';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { BigDecimal } from '../utils/math';
|
|
2
|
+
import { HealthType } from './healthTypes';
|
|
3
|
+
import { PerpProduct, ProductEngineType, SpotProduct } from './productTypes';
|
|
4
|
+
|
|
5
|
+
export type BalanceSide = 'long' | 'short';
|
|
6
|
+
|
|
7
|
+
export type BalanceHealthContributions = Record<HealthType, BigDecimal>;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Shared properties of a product balance
|
|
11
|
+
*/
|
|
12
|
+
interface BaseBalance {
|
|
13
|
+
type: ProductEngineType;
|
|
14
|
+
productId: number;
|
|
15
|
+
// Amount for the balance
|
|
16
|
+
amount: BigDecimal;
|
|
17
|
+
// Contributions to subaccount health
|
|
18
|
+
healthContributions: BalanceHealthContributions;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Balance for a perp product
|
|
23
|
+
*/
|
|
24
|
+
export interface PerpBalance extends BaseBalance {
|
|
25
|
+
type: ProductEngineType.PERP;
|
|
26
|
+
/**
|
|
27
|
+
* As there is no "quote" product for the perp engine, this is a representation of the net quote balance
|
|
28
|
+
* associated with the position. The entry cost and funding is rolled into this.
|
|
29
|
+
*/
|
|
30
|
+
vQuoteBalance: BigDecimal;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type PerpBalanceWithProduct = PerpBalance & PerpProduct;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Balance for a spot product
|
|
37
|
+
*/
|
|
38
|
+
export interface SpotBalance extends BaseBalance {
|
|
39
|
+
type: ProductEngineType.SPOT;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type SpotBalanceWithProduct = SpotBalance & SpotProduct;
|
|
43
|
+
|
|
44
|
+
export type Balance = PerpBalance | SpotBalance;
|
|
45
|
+
export type BalanceWithProduct =
|
|
46
|
+
| SpotBalanceWithProduct
|
|
47
|
+
| PerpBalanceWithProduct;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Bytes = Uint8Array;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BigDecimal } from '../utils/math';
|
|
2
|
+
|
|
3
|
+
export type HealthType = 'maintenance' | 'initial' | 'unweighted';
|
|
4
|
+
|
|
5
|
+
export interface HealthStatus {
|
|
6
|
+
health: BigDecimal;
|
|
7
|
+
assets: BigDecimal;
|
|
8
|
+
liabilities: BigDecimal;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type HealthStatusByType = Record<HealthType, HealthStatus>;
|
|
12
|
+
|
|
13
|
+
// Represents a "linked" pair of spot & perp product IDs used for spread health calculations
|
|
14
|
+
export interface HealthGroup {
|
|
15
|
+
spotProductId: number;
|
|
16
|
+
perpProductId: number;
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './balanceTypes';
|
|
2
|
+
export * from './bytes';
|
|
3
|
+
export * from './ChainEnv';
|
|
4
|
+
export * from './healthTypes';
|
|
5
|
+
export * from './marketTypes';
|
|
6
|
+
export * from './productTypes';
|
|
7
|
+
export * from './subaccountTypes';
|
|
8
|
+
export * from './nadoContractTypes';
|
|
9
|
+
export * from './viemTypes';
|
|
10
|
+
export * from './OrderExecutionType';
|
|
11
|
+
export * from './orderAppendixTypes';
|