@nadohq/shared 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -0
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -1,2 +1,74 @@
|
|
|
1
1
|
# `@nadohq/shared`
|
|
2
2
|
|
|
3
|
+
Shared utilities, types, and contract helpers for the Nado SDK. Provides ABIs, deployment addresses, EIP-712 signing logic, on-chain helpers, encoding utilities, and math/time functions used across all Nado packages.
|
|
4
|
+
|
|
5
|
+
[Full SDK Documentation](https://nadohq.github.io/nado-typescript-sdk/index.html)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @nadohq/shared viem bignumber.js
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Most apps should use `@nadohq/client` instead, which includes this package. Install `@nadohq/shared` directly when you need low-level access to contract ABIs, EIP-712 signing, or type definitions without pulling in the HTTP clients.
|
|
14
|
+
|
|
15
|
+
## Modules
|
|
16
|
+
|
|
17
|
+
### `abis`
|
|
18
|
+
|
|
19
|
+
Contract ABIs for all Nado contracts: `Clearinghouse`, `Endpoint`, `SpotEngine`, `PerpEngine`, `Querier`, `WithdrawPool`, `ERC20`. Aggregated via `NADO_ABIS`.
|
|
20
|
+
|
|
21
|
+
### `deployments`
|
|
22
|
+
|
|
23
|
+
On-chain contract addresses by environment via `NADO_DEPLOYMENTS`.
|
|
24
|
+
|
|
25
|
+
### `consts`
|
|
26
|
+
|
|
27
|
+
Chain environment mappings (`chainEnvToChain`), product ID constants, and chain configurations.
|
|
28
|
+
|
|
29
|
+
### `eip712`
|
|
30
|
+
|
|
31
|
+
EIP-712 typed signing for Nado transactions: `getSignedTransactionRequest`, `getNadoEIP712Values`, `getNadoEIP712Types`, `getNadoEIP712Domain`, `orderDigest`, and signable request type definitions.
|
|
32
|
+
|
|
33
|
+
### `execute`
|
|
34
|
+
|
|
35
|
+
On-chain transaction helpers: `depositCollateral`, `approveDepositAllowance`.
|
|
36
|
+
|
|
37
|
+
### `types`
|
|
38
|
+
|
|
39
|
+
Core type definitions: `ChainEnv`, market/subaccount/order/product types, `WalletClientWithAccount`, health types, and more.
|
|
40
|
+
|
|
41
|
+
### `utils`
|
|
42
|
+
|
|
43
|
+
- **Math**: `BigDecimal` helpers, `sumBigNumberBy`, `toBigInt`, `toIntegerString`, `clamp`, decimal adjustment
|
|
44
|
+
- **Orders**: nonce generation, appendix packing/unpacking, `recvTime`
|
|
45
|
+
- **Bytes**: `bytes32` encoding/decoding, hex validation, address validation
|
|
46
|
+
- **Errors**: `WalletNotProvidedError`
|
|
47
|
+
- **Other**: `createDeterministicLinkedSignerPrivateKey`, `asyncResult`, `toPrintableObject`, time utilities
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import {
|
|
53
|
+
NADO_DEPLOYMENTS,
|
|
54
|
+
NADO_ABIS,
|
|
55
|
+
getSignedTransactionRequest,
|
|
56
|
+
depositCollateral,
|
|
57
|
+
BigDecimal,
|
|
58
|
+
} from '@nadohq/shared';
|
|
59
|
+
|
|
60
|
+
// Get contract addresses for mainnet
|
|
61
|
+
const addresses = NADO_DEPLOYMENTS.inkMainnet;
|
|
62
|
+
|
|
63
|
+
// Sign an EIP-712 transaction
|
|
64
|
+
const signed = await getSignedTransactionRequest({
|
|
65
|
+
requestType: 'place_order',
|
|
66
|
+
params: { ... },
|
|
67
|
+
walletClient,
|
|
68
|
+
verifyingAddress: addresses.endpoint,
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
ISC
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nadohq/shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Shared utilities, types, and contract helpers for Nado SDK",
|
|
@@ -41,16 +41,16 @@
|
|
|
41
41
|
"module": "./dist/index.js",
|
|
42
42
|
"types": "./dist/index.d.ts",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"abitype": "
|
|
44
|
+
"abitype": "1.2.3"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"bignumber.js": "
|
|
48
|
-
"viem": "
|
|
47
|
+
"bignumber.js": "10.0.0",
|
|
48
|
+
"viem": "2.41.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@jest/globals": "
|
|
52
|
-
"bignumber.js": "
|
|
53
|
-
"viem": "
|
|
51
|
+
"@jest/globals": "30.2.0",
|
|
52
|
+
"bignumber.js": "10.0.2",
|
|
53
|
+
"viem": "2.41.2"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "e516a80d16ed2bc1ee29fa51d1ee23fd00006075"
|
|
56
56
|
}
|