@nadohq/shared 0.1.0-alpha.4 → 0.1.0-alpha.40
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/dist/abis/index.cjs +12 -12
- package/dist/abis/index.cjs.map +1 -1
- package/dist/abis/index.d.cts +6 -6
- package/dist/abis/index.d.ts +6 -6
- package/dist/abis/index.js +6 -6
- package/dist/abis/index.js.map +1 -1
- package/dist/consts/chainEnvToChain.cjs +2 -2
- package/dist/consts/chainEnvToChain.cjs.map +1 -1
- package/dist/consts/chainEnvToChain.d.cts +308 -39
- package/dist/consts/chainEnvToChain.d.ts +308 -39
- package/dist/consts/chainEnvToChain.js +3 -3
- package/dist/consts/chainEnvToChain.js.map +1 -1
- package/dist/consts/productIds.cjs +1 -1
- package/dist/consts/productIds.cjs.map +1 -1
- package/dist/consts/productIds.d.cts +1 -1
- package/dist/consts/productIds.d.ts +1 -1
- package/dist/consts/productIds.js +1 -1
- package/dist/consts/productIds.js.map +1 -1
- package/dist/deployments/core/deployment.inkMainnet.json +13 -0
- package/dist/deployments/core/deployment.inkSepolia.json +13 -0
- package/dist/deployments/index.cjs +6 -6
- package/dist/deployments/index.cjs.map +1 -1
- package/dist/deployments/index.js +5 -5
- package/dist/deployments/index.js.map +1 -1
- package/dist/eip712/eip712ValueTypes.d.cts +1 -1
- package/dist/eip712/eip712ValueTypes.d.ts +1 -1
- package/dist/eip712/getNadoEIP712Domain.cjs.map +1 -1
- package/dist/eip712/getNadoEIP712Domain.js.map +1 -1
- package/dist/eip712/index.cjs +13 -13
- package/dist/eip712/index.cjs.map +1 -1
- package/dist/eip712/index.d.cts +9 -9
- package/dist/eip712/index.d.ts +9 -9
- package/dist/eip712/index.js +6 -6
- package/dist/eip712/index.js.map +1 -1
- package/dist/index.d.cts +33 -33
- package/dist/index.d.ts +33 -33
- package/dist/types/ChainEnv.cjs +1 -1
- package/dist/types/ChainEnv.cjs.map +1 -1
- package/dist/types/ChainEnv.d.cts +2 -2
- package/dist/types/ChainEnv.d.ts +2 -2
- package/dist/types/ChainEnv.js +1 -1
- package/dist/types/ChainEnv.js.map +1 -1
- package/dist/types/index.cjs +7 -7
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +4 -4
- package/dist/types/index.d.ts +4 -4
- package/dist/types/index.js +3 -3
- package/dist/types/index.js.map +1 -1
- package/dist/types/orderAppendixTypes.cjs.map +1 -1
- package/dist/types/orderAppendixTypes.d.cts +7 -3
- package/dist/types/orderAppendixTypes.d.ts +7 -3
- package/dist/utils/createDeterministicLinkedSignerPrivateKey.cjs.map +1 -1
- package/dist/utils/createDeterministicLinkedSignerPrivateKey.js.map +1 -1
- package/dist/utils/index.cjs +12 -12
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +21 -21
- package/dist/utils/index.d.ts +21 -21
- package/dist/utils/index.js +6 -6
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/math/index.cjs +8 -8
- package/dist/utils/math/index.cjs.map +1 -1
- package/dist/utils/math/index.d.cts +4 -4
- package/dist/utils/math/index.d.ts +4 -4
- package/dist/utils/math/index.js +4 -4
- package/dist/utils/math/index.js.map +1 -1
- package/dist/utils/orders/appendix/appendixIsolatedValue.cjs +50 -0
- package/dist/utils/orders/appendix/appendixIsolatedValue.cjs.map +1 -0
- package/dist/utils/orders/appendix/appendixIsolatedValue.d.cts +26 -0
- package/dist/utils/orders/appendix/appendixIsolatedValue.d.ts +26 -0
- package/dist/utils/orders/appendix/appendixIsolatedValue.js +31 -0
- package/dist/utils/orders/appendix/appendixIsolatedValue.js.map +1 -0
- package/dist/utils/orders/appendix/{appendixTWAPValue.cjs → appendixTwapValue.cjs} +14 -15
- package/dist/utils/orders/appendix/appendixTwapValue.cjs.map +1 -0
- package/dist/utils/orders/appendix/appendixTwapValue.d.cts +29 -0
- package/dist/utils/orders/appendix/appendixTwapValue.d.ts +29 -0
- package/dist/utils/orders/appendix/appendixTwapValue.js +25 -0
- package/dist/utils/orders/appendix/appendixTwapValue.js.map +1 -0
- package/dist/utils/orders/appendix/index.cjs +6 -6
- package/dist/utils/orders/appendix/index.cjs.map +1 -1
- package/dist/utils/orders/appendix/index.d.cts +3 -3
- package/dist/utils/orders/appendix/index.d.ts +3 -3
- package/dist/utils/orders/appendix/index.js +3 -3
- package/dist/utils/orders/appendix/index.js.map +1 -1
- package/dist/utils/orders/appendix/orderAppendix.test.cjs +11 -12
- package/dist/utils/orders/appendix/orderAppendix.test.cjs.map +1 -1
- package/dist/utils/orders/appendix/orderAppendix.test.js +11 -12
- package/dist/utils/orders/appendix/orderAppendix.test.js.map +1 -1
- package/dist/utils/orders/appendix/packOrderAppendix.cjs +7 -7
- package/dist/utils/orders/appendix/packOrderAppendix.cjs.map +1 -1
- package/dist/utils/orders/appendix/packOrderAppendix.js +7 -7
- package/dist/utils/orders/appendix/packOrderAppendix.js.map +1 -1
- package/dist/utils/orders/appendix/types.cjs.map +1 -1
- package/dist/utils/orders/appendix/types.d.cts +2 -2
- package/dist/utils/orders/appendix/types.d.ts +2 -2
- package/dist/utils/orders/appendix/unpackOrderAppendix.cjs +7 -6
- package/dist/utils/orders/appendix/unpackOrderAppendix.cjs.map +1 -1
- package/dist/utils/orders/appendix/unpackOrderAppendix.js +7 -6
- package/dist/utils/orders/appendix/unpackOrderAppendix.js.map +1 -1
- package/dist/utils/orders/index.cjs +3 -3
- package/dist/utils/orders/index.cjs.map +1 -1
- package/dist/utils/orders/index.d.cts +5 -5
- package/dist/utils/orders/index.d.ts +5 -5
- package/dist/utils/orders/index.js +1 -1
- package/dist/utils/orders/index.js.map +1 -1
- package/dist/utils/productTypeFilter.cjs.map +1 -1
- package/dist/utils/productTypeFilter.js.map +1 -1
- package/package.json +6 -2
- package/src/abis/index.ts +6 -6
- package/src/consts/chainEnvToChain.ts +2 -2
- package/src/consts/productIds.ts +1 -1
- package/src/deployments/core/deployment.inkMainnet.json +13 -0
- package/src/deployments/core/deployment.inkSepolia.json +13 -0
- package/src/deployments/index.ts +5 -5
- package/src/eip712/getNadoEIP712Domain.ts +1 -1
- package/src/eip712/index.ts +6 -6
- package/src/types/ChainEnv.ts +1 -1
- package/src/types/index.ts +3 -3
- package/src/types/orderAppendixTypes.ts +6 -2
- package/src/utils/createDeterministicLinkedSignerPrivateKey.ts +1 -1
- package/src/utils/index.ts +6 -6
- package/src/utils/math/index.ts +4 -4
- package/src/utils/orders/appendix/appendixIsolatedValue.ts +49 -0
- package/src/utils/orders/appendix/appendixTwapValue.ts +46 -0
- package/src/utils/orders/appendix/index.ts +3 -3
- package/src/utils/orders/appendix/orderAppendix.test.ts +10 -11
- package/src/utils/orders/appendix/packOrderAppendix.ts +8 -8
- package/src/utils/orders/appendix/types.ts +5 -5
- package/src/utils/orders/appendix/unpackOrderAppendix.ts +8 -7
- package/src/utils/orders/index.ts +1 -1
- package/src/utils/productTypeFilter.ts +2 -2
- package/dist/deployments/core/deployment.InkSepolia.json +0 -13
- package/dist/deployments/core/deployment.arbitrumOne.json +0 -18
- package/dist/utils/orders/appendix/appendixTWAPValue.cjs.map +0 -1
- package/dist/utils/orders/appendix/appendixTWAPValue.d.cts +0 -31
- package/dist/utils/orders/appendix/appendixTWAPValue.d.ts +0 -31
- package/dist/utils/orders/appendix/appendixTWAPValue.js +0 -26
- package/dist/utils/orders/appendix/appendixTWAPValue.js.map +0 -1
- package/src/deployments/core/deployment.InkSepolia.json +0 -13
- package/src/deployments/core/deployment.arbitrumOne.json +0 -18
- package/src/utils/orders/appendix/appendixTWAPValue.ts +0 -51
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export { packTWAPOrderAppendixValue, unpackTWAPOrderAppendixValue } from './appendix/appendixTWAPValue.cjs';
|
|
4
|
-
export { unpackOrderAppendix } from './appendix/unpackOrderAppendix.cjs';
|
|
1
|
+
export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './appendix/appendixTwapValue.cjs';
|
|
2
|
+
export { bitMaskValue } from './appendix/bitMaskValue.cjs';
|
|
5
3
|
export { packOrderAppendix } from './appendix/packOrderAppendix.cjs';
|
|
6
4
|
export { PackedOrderAppendixBits } from './appendix/types.cjs';
|
|
7
|
-
export {
|
|
5
|
+
export { unpackOrderAppendix } from './appendix/unpackOrderAppendix.cjs';
|
|
6
|
+
export { getOrderNonce, getRecvTimeFromOrderNonce } from './orderNonce.cjs';
|
|
7
|
+
export { getDefaultRecvTime } from './recvTime.cjs';
|
|
8
8
|
import '../../types/orderAppendixTypes.cjs';
|
|
9
9
|
import '../math/bigDecimal.cjs';
|
|
10
10
|
import 'bignumber.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export { packTWAPOrderAppendixValue, unpackTWAPOrderAppendixValue } from './appendix/appendixTWAPValue.js';
|
|
4
|
-
export { unpackOrderAppendix } from './appendix/unpackOrderAppendix.js';
|
|
1
|
+
export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './appendix/appendixTwapValue.js';
|
|
2
|
+
export { bitMaskValue } from './appendix/bitMaskValue.js';
|
|
5
3
|
export { packOrderAppendix } from './appendix/packOrderAppendix.js';
|
|
6
4
|
export { PackedOrderAppendixBits } from './appendix/types.js';
|
|
7
|
-
export {
|
|
5
|
+
export { unpackOrderAppendix } from './appendix/unpackOrderAppendix.js';
|
|
6
|
+
export { getOrderNonce, getRecvTimeFromOrderNonce } from './orderNonce.js';
|
|
7
|
+
export { getDefaultRecvTime } from './recvTime.js';
|
|
8
8
|
import '../../types/orderAppendixTypes.js';
|
|
9
9
|
import '../math/bigDecimal.js';
|
|
10
10
|
import 'bignumber.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/orders/index.ts"],"sourcesContent":["export * from './
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/orders/index.ts"],"sourcesContent":["export * from './appendix';\nexport * from './orderNonce';\nexport * from './recvTime';\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/productTypeFilter.ts"],"sourcesContent":["import { Balance, PerpBalance, SpotBalance } from '../types/balanceTypes';\nimport {\n
|
|
1
|
+
{"version":3,"sources":["../../src/utils/productTypeFilter.ts"],"sourcesContent":["import { Balance, PerpBalance, SpotBalance } from '../types/balanceTypes';\nimport {\n PerpProduct,\n Product,\n ProductEngineType,\n SpotProduct,\n} from '../types/productTypes';\n\nexport function isSpotProduct(product: Product): product is SpotProduct {\n return product.type === ProductEngineType.SPOT;\n}\n\nexport function isSpotBalance(balance: Balance): balance is SpotBalance {\n return balance.type === ProductEngineType.SPOT;\n}\n\nexport function isPerpProduct(product: Product): product is PerpProduct {\n return product.type === ProductEngineType.PERP;\n}\n\nexport function isPerpBalance(balance: Balance): balance is PerpBalance {\n return balance.type === ProductEngineType.PERP;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAKO;AAEA,SAAS,cAAc,SAA0C;AACtE,SAAO,QAAQ,SAAS,sCAAkB;AAC5C;AAEO,SAAS,cAAc,SAA0C;AACtE,SAAO,QAAQ,SAAS,sCAAkB;AAC5C;AAEO,SAAS,cAAc,SAA0C;AACtE,SAAO,QAAQ,SAAS,sCAAkB;AAC5C;AAEO,SAAS,cAAc,SAA0C;AACtE,SAAO,QAAQ,SAAS,sCAAkB;AAC5C;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/productTypeFilter.ts"],"sourcesContent":["import { Balance, PerpBalance, SpotBalance } from '../types/balanceTypes';\nimport {\n
|
|
1
|
+
{"version":3,"sources":["../../src/utils/productTypeFilter.ts"],"sourcesContent":["import { Balance, PerpBalance, SpotBalance } from '../types/balanceTypes';\nimport {\n PerpProduct,\n Product,\n ProductEngineType,\n SpotProduct,\n} from '../types/productTypes';\n\nexport function isSpotProduct(product: Product): product is SpotProduct {\n return product.type === ProductEngineType.SPOT;\n}\n\nexport function isSpotBalance(balance: Balance): balance is SpotBalance {\n return balance.type === ProductEngineType.SPOT;\n}\n\nexport function isPerpProduct(product: Product): product is PerpProduct {\n return product.type === ProductEngineType.PERP;\n}\n\nexport function isPerpBalance(balance: Balance): balance is PerpBalance {\n return balance.type === ProductEngineType.PERP;\n}\n"],"mappings":";;;AACA;AAAA,EAGE;AAAA,OAEK;AAEA,SAAS,cAAc,SAA0C;AACtE,SAAO,QAAQ,SAAS,kBAAkB;AAC5C;AAEO,SAAS,cAAc,SAA0C;AACtE,SAAO,QAAQ,SAAS,kBAAkB;AAC5C;AAEO,SAAS,cAAc,SAA0C;AACtE,SAAO,QAAQ,SAAS,kBAAkB;AAC5C;AAEO,SAAS,cAAc,SAA0C;AACtE,SAAO,QAAQ,SAAS,kBAAkB;AAC5C;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nadohq/shared",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.40",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Shared utilities, types, and contract helpers for Nado SDK",
|
|
@@ -36,6 +36,10 @@
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
|
+
"react-native": "./dist/index.js",
|
|
40
|
+
"main": "./dist/index.cjs",
|
|
41
|
+
"module": "./dist/index.js",
|
|
42
|
+
"types": "./dist/index.d.ts",
|
|
39
43
|
"peerDependencies": {
|
|
40
44
|
"bignumber.js": "^9.3.0",
|
|
41
45
|
"viem": "*"
|
|
@@ -45,5 +49,5 @@
|
|
|
45
49
|
"bignumber.js": "^9.3.0",
|
|
46
50
|
"viem": "*"
|
|
47
51
|
},
|
|
48
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "5dad68b2e53c49a0cfc95a1d8c6abfc1ee2a6f3b"
|
|
49
53
|
}
|
package/src/abis/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
export * from './Clearinghouse';
|
|
2
|
+
export * from './Endpoint';
|
|
1
3
|
export * from './ERC20';
|
|
2
4
|
export * from './MockERC20';
|
|
3
|
-
export * from './WithdrawPool';
|
|
4
|
-
export * from './SpotEngine';
|
|
5
|
-
export * from './Querier';
|
|
6
|
-
export * from './PerpEngine';
|
|
7
|
-
export * from './Endpoint';
|
|
8
|
-
export * from './Clearinghouse';
|
|
9
5
|
export * from './nadoAbis';
|
|
6
|
+
export * from './PerpEngine';
|
|
7
|
+
export * from './Querier';
|
|
8
|
+
export * from './SpotEngine';
|
|
9
|
+
export * from './WithdrawPool';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Chain } from 'viem';
|
|
2
|
-
import {
|
|
2
|
+
import { inkSepolia, ink, localhost } from 'viem/chains';
|
|
3
3
|
import { ChainEnv } from '../types';
|
|
4
4
|
|
|
5
5
|
export const CHAIN_ENV_TO_CHAIN = {
|
|
6
6
|
local: localhost,
|
|
7
|
-
arbitrum: arbitrum,
|
|
8
7
|
inkTestnet: inkSepolia,
|
|
8
|
+
inkMainnet: ink,
|
|
9
9
|
} as const satisfies Record<ChainEnv, Chain>;
|
|
10
10
|
|
|
11
11
|
export const CHAIN_ID_TO_CHAIN_ENV = Object.fromEntries(
|
package/src/consts/productIds.ts
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"nodeUrl": "https://ink.drpc.org",
|
|
3
|
+
"explorerUrl": "https://explorer.inkonchain.com",
|
|
4
|
+
"startBlock": 29851015,
|
|
5
|
+
"deployer": "0xC1cC56caB60e832665E6c3780BfEBe3C1C971603",
|
|
6
|
+
"quote": "0x0200C29006150606B650577BBE7B6248F58470c1",
|
|
7
|
+
"querier": "0x68798229F88251b31D534733D6C4098318c9dff8",
|
|
8
|
+
"clearinghouse": "0xD218103918C19D0A10cf35300E4CfAfbD444c5fE",
|
|
9
|
+
"endpoint": "0x05ec92D78ED421f3D3Ada77FFdE167106565974E",
|
|
10
|
+
"spotEngine": "0xFcD94770B95fd9Cc67143132BB172EB17A0907fE",
|
|
11
|
+
"perpEngine": "0xF8599D58d1137fC56EcDd9C16ee139C8BDf96da1",
|
|
12
|
+
"withdrawPool": "0x09fb495AA7859635f755E827d64c4C9A2e5b9651"
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"nodeUrl": "https://rpc-gel-sepolia.inkonchain.com",
|
|
3
|
+
"explorerUrl": "https://explorer-sepolia.inkonchain.com",
|
|
4
|
+
"startBlock": 33809962,
|
|
5
|
+
"deployer": "0x59841b3761Ed1D089a783E4d7CB49E4534CD4F85",
|
|
6
|
+
"quote": "0x60F50F902b2E91aef7D6c700Eb22599e297fa86F",
|
|
7
|
+
"querier": "0x8E693BEa316bcC0F4f8be403081b954a0E3743C8",
|
|
8
|
+
"clearinghouse": "0x23a283B359D55A941bBeEC58801B6b17D955CC73",
|
|
9
|
+
"endpoint": "0x698D87105274292B5673367DEC81874Ce3633Ac2",
|
|
10
|
+
"spotEngine": "0x3352b2fF0fAc4ce38A6eA1C188cF4F924df54E5D",
|
|
11
|
+
"perpEngine": "0x4E859C47fea3666B5053B16C81AF64e77567702e",
|
|
12
|
+
"withdrawPool": "0xBD672Fe513acbA5c1ceE7b02F998A1B542852b3b"
|
|
13
|
+
}
|
package/src/deployments/index.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { NadoContractName } from '../abis/nadoAbis';
|
|
|
3
3
|
|
|
4
4
|
import { ChainEnv } from '../types';
|
|
5
5
|
import { getValidatedAddress } from '../utils/getValidatedAddress';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import InkSepoliaCoreDeployment from './core/deployment.inkSepolia.json' with { type: 'json' };
|
|
7
|
+
import InkMainnetCoreDeployment from './core/deployment.inkMainnet.json' with { type: 'json' };
|
|
8
8
|
import LocalCoreDeployment from './core/deployment.localhost.json' with { type: 'json' };
|
|
9
9
|
|
|
10
10
|
export type NadoDeploymentAddresses = {
|
|
@@ -15,12 +15,12 @@ export type NadoDeploymentAddresses = {
|
|
|
15
15
|
* Known deployment addresses for the Nado contracts
|
|
16
16
|
*/
|
|
17
17
|
export const NADO_DEPLOYMENTS: Record<ChainEnv, NadoDeploymentAddresses> = {
|
|
18
|
-
arbitrum: validateDeployment({
|
|
19
|
-
...ArbitrumOneCoreDeployment,
|
|
20
|
-
}),
|
|
21
18
|
inkTestnet: validateDeployment({
|
|
22
19
|
...InkSepoliaCoreDeployment,
|
|
23
20
|
}),
|
|
21
|
+
inkMainnet: validateDeployment({
|
|
22
|
+
...InkMainnetCoreDeployment,
|
|
23
|
+
}),
|
|
24
24
|
local: validateDeployment({
|
|
25
25
|
...LocalCoreDeployment,
|
|
26
26
|
}),
|
package/src/eip712/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './getNadoEIP712Values';
|
|
3
|
-
export * from './getNadoEIP712Types';
|
|
4
|
-
export * from './getNadoEIP712PrimaryType';
|
|
1
|
+
export * from './eip712ValueTypes';
|
|
5
2
|
export * from './getNadoEIP712Domain';
|
|
3
|
+
export * from './getNadoEIP712PrimaryType';
|
|
4
|
+
export * from './getNadoEIP712Types';
|
|
5
|
+
export * from './getNadoEIP712Values';
|
|
6
|
+
export * from './getOrderVerifyingAddress';
|
|
7
|
+
export * from './getSignedTransactionRequest';
|
|
6
8
|
export * from './orderDigest';
|
|
7
9
|
export * from './signableRequestType';
|
|
8
10
|
export * from './signatureParamTypes';
|
|
9
|
-
export * from './eip712ValueTypes';
|
|
10
|
-
export * from './getOrderVerifyingAddress';
|
package/src/types/ChainEnv.ts
CHANGED
|
@@ -2,7 +2,7 @@ export const LOCAL_CHAIN_ENVS = ['local'] as const satisfies string[];
|
|
|
2
2
|
|
|
3
3
|
export const TESTNET_CHAIN_ENVS = ['inkTestnet'] as const satisfies string[];
|
|
4
4
|
|
|
5
|
-
export const MAINNET_CHAIN_ENVS = ['
|
|
5
|
+
export const MAINNET_CHAIN_ENVS = ['inkMainnet'] as const satisfies string[];
|
|
6
6
|
|
|
7
7
|
export const ALL_CHAIN_ENVS = [
|
|
8
8
|
...LOCAL_CHAIN_ENVS,
|
package/src/types/index.ts
CHANGED
|
@@ -3,9 +3,9 @@ export * from './bytes';
|
|
|
3
3
|
export * from './ChainEnv';
|
|
4
4
|
export * from './healthTypes';
|
|
5
5
|
export * from './marketTypes';
|
|
6
|
+
export * from './nadoContractTypes';
|
|
7
|
+
export * from './orderAppendixTypes';
|
|
8
|
+
export * from './OrderExecutionType';
|
|
6
9
|
export * from './productTypes';
|
|
7
10
|
export * from './subaccountTypes';
|
|
8
|
-
export * from './nadoContractTypes';
|
|
9
11
|
export * from './viemTypes';
|
|
10
|
-
export * from './OrderExecutionType';
|
|
11
|
-
export * from './orderAppendixTypes';
|
|
@@ -13,7 +13,7 @@ export type OrderAppendixTriggerType =
|
|
|
13
13
|
/**
|
|
14
14
|
* Fields associated with a TWAP trigger order.
|
|
15
15
|
*/
|
|
16
|
-
export interface
|
|
16
|
+
export interface OrderAppendixTwapFields {
|
|
17
17
|
/**
|
|
18
18
|
* Number of TWAP orders to be placed.
|
|
19
19
|
*/
|
|
@@ -31,6 +31,10 @@ export interface OrderAppendixTWAPFields {
|
|
|
31
31
|
export interface OrderAppendixIsolatedFields {
|
|
32
32
|
/**
|
|
33
33
|
* Amount of margin to transfer into the isolated position.
|
|
34
|
+
*
|
|
35
|
+
* Implementation Note:
|
|
36
|
+
* Packed appendix uses precision of 6 decimals on backend.
|
|
37
|
+
* SDK automatically converts to/from x18 during packing/unpacking.
|
|
34
38
|
*/
|
|
35
39
|
margin: BigDecimalish;
|
|
36
40
|
}
|
|
@@ -54,5 +58,5 @@ export interface OrderAppendix {
|
|
|
54
58
|
* Specify if the order is a TWAP order
|
|
55
59
|
* An order CANNOT be both a TWAP order and an isolated order.
|
|
56
60
|
*/
|
|
57
|
-
twap?:
|
|
61
|
+
twap?: OrderAppendixTwapFields;
|
|
58
62
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { keccak256 } from 'viem';
|
|
2
|
+
import { getNadoEIP712Domain } from '../eip712/getNadoEIP712Domain';
|
|
2
3
|
import { Subaccount } from '../types/subaccountTypes';
|
|
3
4
|
import { WalletClientWithAccount } from '../types/viemTypes';
|
|
4
|
-
import { getNadoEIP712Domain } from '../eip712/getNadoEIP712Domain';
|
|
5
5
|
import { subaccountToHex } from './bytes32';
|
|
6
6
|
|
|
7
7
|
interface Params extends Subaccount {
|
package/src/utils/index.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './interest';
|
|
3
|
-
export * from './productTypeFilter';
|
|
1
|
+
export * from './asyncResult';
|
|
4
2
|
export * from './balanceValue';
|
|
5
3
|
export * from './bytes32';
|
|
6
4
|
export * from './createDeterministicLinkedSignerPrivateKey';
|
|
7
|
-
export * from './isWriteableContract';
|
|
8
5
|
export * from './errors';
|
|
9
|
-
export * from './math';
|
|
10
|
-
export * from './asyncResult';
|
|
11
6
|
export * from './getValidatedAddress';
|
|
12
7
|
export * from './getValidatedHex';
|
|
8
|
+
export * from './interest';
|
|
9
|
+
export * from './isWriteableContract';
|
|
13
10
|
export * from './mapValues';
|
|
11
|
+
export * from './math';
|
|
12
|
+
export * from './orders';
|
|
13
|
+
export * from './productTypeFilter';
|
|
14
14
|
export * from './time';
|
|
15
15
|
export * from './toPrintableObject';
|
package/src/utils/math/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './bigDecimal';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './toBigInt';
|
|
2
|
+
export * from './BigDecimals';
|
|
4
3
|
export * from './clamp';
|
|
5
|
-
export * from './sumBigDecimalBy';
|
|
6
4
|
export * from './decimalAdjustment';
|
|
7
|
-
export * from './
|
|
5
|
+
export * from './sumBigDecimalBy';
|
|
6
|
+
export * from './toBigInt';
|
|
7
|
+
export * from './toIntegerString';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { OrderAppendixIsolatedFields } from '../../../types';
|
|
2
|
+
import {
|
|
3
|
+
addDecimals,
|
|
4
|
+
NADO_PRODUCT_DECIMALS,
|
|
5
|
+
removeDecimals,
|
|
6
|
+
toBigInt,
|
|
7
|
+
} from '../../math';
|
|
8
|
+
import { bitMaskValue } from './bitMaskValue';
|
|
9
|
+
|
|
10
|
+
const APPENDIX_V1_ISO_MARGIN_DECIMALS = 6;
|
|
11
|
+
|
|
12
|
+
/* Appendix v1 uses x6 precision, so we need to adjust precision to/from SDK's usual precision */
|
|
13
|
+
const MARGIN_DECIMAL_ADJUSTMENT =
|
|
14
|
+
NADO_PRODUCT_DECIMALS - APPENDIX_V1_ISO_MARGIN_DECIMALS;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Packs the provided margin into a single 64-bit bigint.
|
|
18
|
+
*
|
|
19
|
+
* Bit layout (MSB → LSB):
|
|
20
|
+
* | margin_x6 |
|
|
21
|
+
* |-----------|
|
|
22
|
+
* | 63..0 |
|
|
23
|
+
* | 64 bits |
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
export function packIsolatedOrderAppendixValue({
|
|
27
|
+
margin,
|
|
28
|
+
}: OrderAppendixIsolatedFields): bigint {
|
|
29
|
+
return bitMaskValue(
|
|
30
|
+
toBigInt(removeDecimals(margin, MARGIN_DECIMAL_ADJUSTMENT)),
|
|
31
|
+
64,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Unpacks a 64-bit bigint into its component fields for Isolated orders.
|
|
37
|
+
*
|
|
38
|
+
* @param value 64-bit bigint to unpack
|
|
39
|
+
* @returns Object with:
|
|
40
|
+
* - margin_x6: bigint, from bits 63..0
|
|
41
|
+
*/
|
|
42
|
+
export function unpackIsolatedOrderAppendixValue(
|
|
43
|
+
value: bigint,
|
|
44
|
+
): OrderAppendixIsolatedFields {
|
|
45
|
+
const margin = bitMaskValue(value, 64);
|
|
46
|
+
return {
|
|
47
|
+
margin: toBigInt(addDecimals(margin, MARGIN_DECIMAL_ADJUSTMENT)),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { OrderAppendixTwapFields } from '../../../types/orderAppendixTypes';
|
|
2
|
+
import { addDecimals, removeDecimals, toBigInt } from '../../math';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Packs the provided fields into a single 64-bit bigint.
|
|
6
|
+
*
|
|
7
|
+
* Bit layout (MSB → LSB):
|
|
8
|
+
* | times | slippage_x6 |
|
|
9
|
+
* |-----------|-------------|
|
|
10
|
+
* | 63..32 | 31..0 |
|
|
11
|
+
* | 32 bits | 32 bits |
|
|
12
|
+
*
|
|
13
|
+
* - `times` occupies bits 63..32 (most significant 32 bits)
|
|
14
|
+
* - `slippage_x6` occupies bits 31..0 (least significant 32 bits)
|
|
15
|
+
*/
|
|
16
|
+
export function packTwapOrderAppendixValue({
|
|
17
|
+
numOrders,
|
|
18
|
+
slippageFrac,
|
|
19
|
+
}: OrderAppendixTwapFields): bigint {
|
|
20
|
+
const numOrdersBigInt = toBigInt(numOrders);
|
|
21
|
+
const slippageX6BigInt = toBigInt(addDecimals(slippageFrac, 6));
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
((numOrdersBigInt & 0xffffffffn) << 32n) | (slippageX6BigInt & 0xffffffffn)
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Unpacks a 64-bit bigint into its component fields for TWAP orders.
|
|
30
|
+
*
|
|
31
|
+
* @param value 64-bit bigint to unpack
|
|
32
|
+
* @returns Object with:
|
|
33
|
+
* - times: number, from bits 63..32
|
|
34
|
+
* - slippage_x6: number, from bits 31..0
|
|
35
|
+
*/
|
|
36
|
+
export function unpackTwapOrderAppendixValue(
|
|
37
|
+
value: bigint,
|
|
38
|
+
): OrderAppendixTwapFields {
|
|
39
|
+
const numOrders = (value >> 32n) & 0xffffffffn;
|
|
40
|
+
const slippageX6 = value & 0xffffffffn;
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
numOrders: Number(numOrders),
|
|
44
|
+
slippageFrac: removeDecimals(slippageX6, 6).toNumber(),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
1
|
+
export * from './appendixTwapValue';
|
|
2
|
+
export * from './bitMaskValue';
|
|
3
3
|
export * from './packOrderAppendix';
|
|
4
4
|
export * from './types';
|
|
5
|
-
export * from './
|
|
5
|
+
export * from './unpackOrderAppendix';
|
|
@@ -11,7 +11,7 @@ describe('OrderAppendix packing/unpacking', () => {
|
|
|
11
11
|
};
|
|
12
12
|
const packed = packOrderAppendix(appendix);
|
|
13
13
|
const unpacked = unpackOrderAppendix(packed);
|
|
14
|
-
expect(packed).toBe(
|
|
14
|
+
expect(packed).toBe(4097n);
|
|
15
15
|
expect(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);
|
|
16
16
|
expect(unpacked.triggerType).toBe(appendix.triggerType);
|
|
17
17
|
expect(unpacked.reduceOnly).toBeFalsy();
|
|
@@ -25,7 +25,7 @@ describe('OrderAppendix packing/unpacking', () => {
|
|
|
25
25
|
};
|
|
26
26
|
const packed = packOrderAppendix(appendix);
|
|
27
27
|
const unpacked = unpackOrderAppendix(packed);
|
|
28
|
-
expect(packed).toBe(
|
|
28
|
+
expect(packed).toBe(6145n);
|
|
29
29
|
expect(unpacked.reduceOnly).toBe(true);
|
|
30
30
|
});
|
|
31
31
|
|
|
@@ -60,12 +60,12 @@ describe('OrderAppendix packing/unpacking', () => {
|
|
|
60
60
|
orderExecutionType: 'default',
|
|
61
61
|
triggerType: 'price',
|
|
62
62
|
|
|
63
|
-
isolated: { margin:
|
|
63
|
+
isolated: { margin: 12345678901000000000000n },
|
|
64
64
|
};
|
|
65
65
|
const packed = packOrderAppendix(appendix);
|
|
66
66
|
const unpacked = unpackOrderAppendix(packed);
|
|
67
|
-
expect(packed).toBe(
|
|
68
|
-
expect(unpacked.isolated?.margin).toBe(
|
|
67
|
+
expect(packed).toBe(227737579102942800187821658369n);
|
|
68
|
+
expect(unpacked.isolated?.margin).toBe(appendix.isolated?.margin);
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
it('should handle TWAP fields', () => {
|
|
@@ -77,7 +77,7 @@ describe('OrderAppendix packing/unpacking', () => {
|
|
|
77
77
|
};
|
|
78
78
|
const packed = packOrderAppendix(appendix);
|
|
79
79
|
const unpacked = unpackOrderAppendix(packed);
|
|
80
|
-
expect(packed).toBe(
|
|
80
|
+
expect(packed).toBe(792281717376363744483197591553n);
|
|
81
81
|
expect(unpacked.twap).toMatchObject({ numOrders: 10, slippageFrac: 0.005 });
|
|
82
82
|
});
|
|
83
83
|
|
|
@@ -86,16 +86,16 @@ describe('OrderAppendix packing/unpacking', () => {
|
|
|
86
86
|
orderExecutionType: 'post_only',
|
|
87
87
|
triggerType: undefined,
|
|
88
88
|
reduceOnly: true,
|
|
89
|
-
isolated: { margin:
|
|
89
|
+
isolated: { margin: 18446744073709551615n }, // 2^64-1
|
|
90
90
|
};
|
|
91
91
|
const packed = packOrderAppendix(appendix);
|
|
92
92
|
const unpacked = unpackOrderAppendix(packed);
|
|
93
93
|
expect(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);
|
|
94
94
|
expect(unpacked.triggerType).toBe(appendix.triggerType);
|
|
95
95
|
expect(unpacked.reduceOnly).toBe(appendix.reduceOnly);
|
|
96
|
-
expect(unpacked.isolated?.margin).toBe(
|
|
96
|
+
expect(unpacked.isolated?.margin).toBe(18446744000000000000n);
|
|
97
97
|
expect(unpacked.twap).toBe(undefined);
|
|
98
|
-
expect(packed).toBe(
|
|
98
|
+
expect(packed).toBe(340282365561237229015142145n);
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
it('should handle max values for all fields for TWAP orders', () => {
|
|
@@ -104,7 +104,6 @@ describe('OrderAppendix packing/unpacking', () => {
|
|
|
104
104
|
triggerType: 'twap_custom_amounts',
|
|
105
105
|
reduceOnly: true,
|
|
106
106
|
twap: {
|
|
107
|
-
// max 32-bit unsigned int
|
|
108
107
|
numOrders: 4294967295,
|
|
109
108
|
slippageFrac: 0.000001,
|
|
110
109
|
},
|
|
@@ -116,6 +115,6 @@ describe('OrderAppendix packing/unpacking', () => {
|
|
|
116
115
|
expect(unpacked.reduceOnly).toBe(appendix.reduceOnly);
|
|
117
116
|
expect(unpacked.twap?.slippageFrac).toBe(0.000001);
|
|
118
117
|
expect(unpacked.twap?.numOrders).toBe(4294967295);
|
|
119
|
-
expect(packed).toBe(
|
|
118
|
+
expect(packed).toBe(340282366841710300967557013911933828609n);
|
|
120
119
|
});
|
|
121
120
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OrderAppendix } from '../../../types/orderAppendixTypes';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { packIsolatedOrderAppendixValue } from './appendixIsolatedValue';
|
|
3
|
+
import { packTwapOrderAppendixValue } from './appendixTwapValue';
|
|
4
4
|
import { bitMaskValue } from './bitMaskValue';
|
|
5
5
|
import { PackedOrderAppendixBits } from './types';
|
|
6
6
|
|
|
@@ -9,10 +9,10 @@ function mapOrderAppendixToBitValues(
|
|
|
9
9
|
): PackedOrderAppendixBits {
|
|
10
10
|
const value = (() => {
|
|
11
11
|
if (appendix.twap) {
|
|
12
|
-
return
|
|
12
|
+
return packTwapOrderAppendixValue(appendix.twap);
|
|
13
13
|
}
|
|
14
14
|
if (appendix.isolated) {
|
|
15
|
-
return
|
|
15
|
+
return packIsolatedOrderAppendixValue(appendix.isolated);
|
|
16
16
|
}
|
|
17
17
|
return 0n;
|
|
18
18
|
})();
|
|
@@ -48,7 +48,7 @@ function mapOrderAppendixToBitValues(
|
|
|
48
48
|
reduceOnly: appendix.reduceOnly ? 1 : 0,
|
|
49
49
|
orderType,
|
|
50
50
|
isolated: appendix.isolated ? 1 : 0,
|
|
51
|
-
version:
|
|
51
|
+
version: 1,
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -59,9 +59,9 @@ function mapOrderAppendixToBitValues(
|
|
|
59
59
|
export function packOrderAppendix(appendix: OrderAppendix): bigint {
|
|
60
60
|
const bits = mapOrderAppendixToBitValues(appendix);
|
|
61
61
|
|
|
62
|
-
// Ensure value is within
|
|
63
|
-
let packed = bitMaskValue(bits.value,
|
|
64
|
-
packed = (packed <<
|
|
62
|
+
// Ensure value is within 64 bits
|
|
63
|
+
let packed = bitMaskValue(bits.value, 64);
|
|
64
|
+
packed = (packed << 50n) | bitMaskValue(bits.reserved, 50);
|
|
65
65
|
packed = (packed << 2n) | bitMaskValue(bits.trigger, 2);
|
|
66
66
|
packed = (packed << 1n) | bitMaskValue(bits.reduceOnly, 1);
|
|
67
67
|
packed = (packed << 2n) | bitMaskValue(bits.orderType, 2);
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
*
|
|
4
4
|
* | value | reserved | trigger | reduceOnly | orderType | isolated | version |
|
|
5
5
|
* |-----------|----------|---------|------------|-----------|----------|---------|
|
|
6
|
-
* | 127..
|
|
7
|
-
* |
|
|
6
|
+
* | 127..64 | 63..14 | 13..12 | 11 | 10..9 | 8 | 7..0 |
|
|
7
|
+
* | 64 bits | 50 bits | 2 bits | 1 bit | 2 bits | 1 bit | 8 bits |
|
|
8
8
|
*/
|
|
9
9
|
export interface PackedOrderAppendixBits {
|
|
10
|
-
value: bigint; //
|
|
11
|
-
reserved: number; //
|
|
10
|
+
value: bigint; // 64 bits
|
|
11
|
+
reserved: number; // 50 bits, set to 0
|
|
12
12
|
trigger: number; // 2 bits
|
|
13
13
|
reduceOnly: number; // 1 bit
|
|
14
14
|
orderType: number; // 2 bits
|
|
15
15
|
isolated: number; // 1 bit
|
|
16
|
-
version: number; // 8 bits, set to
|
|
16
|
+
version: number; // 8 bits, set to 1
|
|
17
17
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OrderAppendix } from '../../../types/orderAppendixTypes';
|
|
2
2
|
import { BigDecimalish, toBigInt } from '../../math';
|
|
3
|
-
import {
|
|
3
|
+
import { unpackIsolatedOrderAppendixValue } from './appendixIsolatedValue';
|
|
4
|
+
import { unpackTwapOrderAppendixValue } from './appendixTwapValue';
|
|
4
5
|
import { bitMaskValue } from './bitMaskValue';
|
|
5
6
|
import { PackedOrderAppendixBits } from './types';
|
|
6
7
|
|
|
@@ -35,13 +36,13 @@ function mapBitValuesToAppendix(bits: PackedOrderAppendixBits): OrderAppendix {
|
|
|
35
36
|
})();
|
|
36
37
|
const isolatedFields = (() => {
|
|
37
38
|
if (bits.isolated) {
|
|
38
|
-
return
|
|
39
|
+
return unpackIsolatedOrderAppendixValue(bits.value);
|
|
39
40
|
}
|
|
40
41
|
return undefined;
|
|
41
42
|
})();
|
|
42
43
|
const twapFields = (() => {
|
|
43
44
|
if (triggerType === 'twap' || triggerType === 'twap_custom_amounts') {
|
|
44
|
-
return
|
|
45
|
+
return unpackTwapOrderAppendixValue(bits.value);
|
|
45
46
|
}
|
|
46
47
|
})();
|
|
47
48
|
|
|
@@ -73,10 +74,10 @@ export function unpackOrderAppendix(packed: BigDecimalish): OrderAppendix {
|
|
|
73
74
|
temp >>= 1n;
|
|
74
75
|
const trigger = Number(bitMaskValue(temp, 2));
|
|
75
76
|
temp >>= 2n;
|
|
76
|
-
const reserved = Number(bitMaskValue(temp,
|
|
77
|
-
temp >>=
|
|
78
|
-
// The remaining bits are the value, which should be
|
|
79
|
-
const value = bitMaskValue(temp,
|
|
77
|
+
const reserved = Number(bitMaskValue(temp, 50));
|
|
78
|
+
temp >>= 50n;
|
|
79
|
+
// The remaining bits are the value, which should be 64 bits
|
|
80
|
+
const value = bitMaskValue(temp, 64);
|
|
80
81
|
|
|
81
82
|
return mapBitValuesToAppendix({
|
|
82
83
|
value,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Balance, PerpBalance, SpotBalance } from '../types/balanceTypes';
|
|
2
2
|
import {
|
|
3
|
-
ProductEngineType,
|
|
4
3
|
PerpProduct,
|
|
5
|
-
SpotProduct,
|
|
6
4
|
Product,
|
|
5
|
+
ProductEngineType,
|
|
6
|
+
SpotProduct,
|
|
7
7
|
} from '../types/productTypes';
|
|
8
8
|
|
|
9
9
|
export function isSpotProduct(product: Product): product is SpotProduct {
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"nodeUrl": "https://rpc-gel-sepolia.inkonchain.com",
|
|
3
|
-
"explorerUrl": "https://explorer-sepolia.inkonchain.com",
|
|
4
|
-
"startBlock": 27233833,
|
|
5
|
-
"deployer": "0x8177A1b5bFaAa10A4b1178c6D42aDaa4b75c8146",
|
|
6
|
-
"quote": "0x5F65358d61A9a281ea3BB930d05889ACa21E3f4f",
|
|
7
|
-
"querier": "0x5A62e748b2630560Ffe9E928780cF9Fe0e086A21",
|
|
8
|
-
"clearinghouse": "0x5E9b4336104069467E57E843033e62c79C667F8F",
|
|
9
|
-
"endpoint": "0xf8963f7860aF7DE9b94893EDb9A3b5c155e1Fc0c",
|
|
10
|
-
"spotEngine": "0x61AA7A636df5e72eBe34c70a340eB76ABB3A15bE",
|
|
11
|
-
"perpEngine": "0x3D6Ac7105cA399884739a8CC19cAdB4178844466",
|
|
12
|
-
"withdrawPool": "0xa59613a3e4ce46E20d83b0632E3D857e3f116F66"
|
|
13
|
-
}
|