@nadohq/client 0.36.0 → 0.38.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpotExecuteAPI.cjs","names":["BaseSpotAPI","WalletNotProvidedError","MOCK_ERC20_ABI"],"sources":["../../../src/apis/spot/SpotExecuteAPI.ts"],"sourcesContent":["import {\n approveDepositAllowance,\n depositCollateral,\n DepositCollateralParams,\n isWriteableContract,\n MOCK_ERC20_ABI,\n toBigInt,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport { BaseSpotAPI } from './BaseSpotAPI';\nimport {\n ApproveAllowanceParams,\n BurnNlpParams,\n MintMockERC20Params,\n MintNlpParams,\n TransferQuoteParams,\n WithdrawCollateralParams,\n WithdrawCollateralV2Params,\n} from './types';\n\nexport class SpotExecuteAPI extends BaseSpotAPI {\n async deposit(params: DepositCollateralParams) {\n if (!isWriteableContract(this.context.contracts.endpoint)) {\n throw new WalletNotProvidedError();\n }\n
|
|
1
|
+
{"version":3,"file":"SpotExecuteAPI.cjs","names":["BaseSpotAPI","WalletNotProvidedError","MOCK_ERC20_ABI"],"sources":["../../../src/apis/spot/SpotExecuteAPI.ts"],"sourcesContent":["import {\n approveDepositAllowance,\n depositCollateral,\n DepositCollateralParams,\n isWriteableContract,\n MOCK_ERC20_ABI,\n toBigInt,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport { BaseSpotAPI } from './BaseSpotAPI';\nimport {\n ApproveAllowanceParams,\n BurnNlpParams,\n MintMockERC20Params,\n MintNlpParams,\n TransferQuoteParams,\n WithdrawCollateralParams,\n WithdrawCollateralV2Params,\n} from './types';\n\nexport class SpotExecuteAPI extends BaseSpotAPI {\n async deposit(params: DepositCollateralParams) {\n if (!isWriteableContract(this.context.contracts.endpoint)) {\n throw new WalletNotProvidedError();\n }\n\n return depositCollateral({\n endpoint: this.context.contracts.endpoint,\n subaccountName: params.subaccountName,\n productId: params.productId,\n amount: params.amount,\n referralCode: params.referralCode,\n });\n }\n\n async withdraw(params: WithdrawCollateralParams) {\n return this.context.engineClient.withdrawCollateral({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n });\n }\n\n /**\n * Withdraws collateral to a custom recipient address via the `withdraw_collateral_v2` execute.\n *\n * When `sendTo` is the zero address, funds are sent to the subaccount owner. When `sendTo` is a\n * non-zero address, the transaction must be signed by the subaccount owner (linked signers are\n * not permitted).\n *\n * @param params\n */\n async withdrawV2(params: WithdrawCollateralV2Params) {\n return this.context.engineClient.withdrawCollateralV2({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n });\n }\n\n async approveAllowance(params: ApproveAllowanceParams) {\n const tokenContract = await this.getTokenContractForProduct(params);\n if (!isWriteableContract(tokenContract)) {\n throw new Error(\n 'Token contract does not permit writes. Is a wallet client provided?',\n );\n }\n\n return approveDepositAllowance({\n amount: params.amount,\n endpoint: this.context.contracts.endpoint,\n tokenContract,\n });\n }\n\n /**\n * Transfers quote between subaccounts under the same wallet.\n *\n * @param params\n */\n async transferQuote(params: TransferQuoteParams) {\n return this.context.engineClient.transferQuote({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n });\n }\n\n async mintNlp(params: MintNlpParams) {\n return this.context.engineClient.mintNlp({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n });\n }\n\n async burnNlp(params: BurnNlpParams) {\n return this.context.engineClient.burnNlp({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n });\n }\n\n async _mintMockERC20(params: MintMockERC20Params) {\n if (!this.context.walletClient) {\n throw new WalletNotProvidedError();\n }\n\n const config = await this.context.contracts.spotEngine.read.getConfig([\n params.productId,\n ]);\n\n return this.context.walletClient.writeContract({\n abi: MOCK_ERC20_ABI,\n address: config.token,\n functionName: 'mint',\n args: [this.getWalletClientAddress(), toBigInt(params.amount)],\n });\n }\n}\n"],"mappings":";;;;AAoBA,IAAa,iBAAb,cAAoCA,8BAAAA,YAAY;CAC9C,MAAM,QAAQ,QAAiC;EAC7C,IAAI,EAAA,GAAA,eAAA,qBAAqB,KAAK,QAAQ,UAAU,QAAQ,GACtD,MAAM,IAAIC,eAAAA,uBAAuB;EAGnC,QAAA,GAAA,eAAA,mBAAyB;GACvB,UAAU,KAAK,QAAQ,UAAU;GACjC,gBAAgB,OAAO;GACvB,WAAW,OAAO;GAClB,QAAQ,OAAO;GACf,cAAc,OAAO;EACvB,CAAC;CACH;CAEA,MAAM,SAAS,QAAkC;EAC/C,OAAO,KAAK,QAAQ,aAAa,mBAAmB;GAClD,GAAG;GACH,iBAAiB,KAAK,2BAA2B,MAAM;GACvD,SAAS,KAAK,+BAA+B,MAAM;GACnD,eAAe,OAAO,iBAAiB,KAAK,mBAAmB;EACjE,CAAC;CACH;;;;;;;;;;CAWA,MAAM,WAAW,QAAoC;EACnD,OAAO,KAAK,QAAQ,aAAa,qBAAqB;GACpD,GAAG;GACH,iBAAiB,KAAK,2BAA2B,MAAM;GACvD,SAAS,KAAK,+BAA+B,MAAM;GACnD,eAAe,OAAO,iBAAiB,KAAK,mBAAmB;EACjE,CAAC;CACH;CAEA,MAAM,iBAAiB,QAAgC;EACrD,MAAM,gBAAgB,MAAM,KAAK,2BAA2B,MAAM;EAClE,IAAI,EAAA,GAAA,eAAA,qBAAqB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approveDepositAllowance,\n depositCollateral,\n DepositCollateralParams,\n isWriteableContract,\n MOCK_ERC20_ABI,\n toBigInt,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport { BaseSpotAPI } from './BaseSpotAPI';\nimport {\n ApproveAllowanceParams,\n BurnNlpParams,\n MintMockERC20Params,\n MintNlpParams,\n TransferQuoteParams,\n WithdrawCollateralParams,\n WithdrawCollateralV2Params,\n} from './types';\n\nexport class SpotExecuteAPI extends BaseSpotAPI {\n async deposit(params: DepositCollateralParams) {\n if (!isWriteableContract(this.context.contracts.endpoint)) {\n throw new WalletNotProvidedError();\n }\n
|
|
1
|
+
{"version":3,"file":"SpotExecuteAPI.js","names":[],"sources":["../../../src/apis/spot/SpotExecuteAPI.ts"],"sourcesContent":["import {\n approveDepositAllowance,\n depositCollateral,\n DepositCollateralParams,\n isWriteableContract,\n MOCK_ERC20_ABI,\n toBigInt,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport { BaseSpotAPI } from './BaseSpotAPI';\nimport {\n ApproveAllowanceParams,\n BurnNlpParams,\n MintMockERC20Params,\n MintNlpParams,\n TransferQuoteParams,\n WithdrawCollateralParams,\n WithdrawCollateralV2Params,\n} from './types';\n\nexport class SpotExecuteAPI extends BaseSpotAPI {\n async deposit(params: DepositCollateralParams) {\n if (!isWriteableContract(this.context.contracts.endpoint)) {\n throw new WalletNotProvidedError();\n }\n\n return depositCollateral({\n endpoint: this.context.contracts.endpoint,\n subaccountName: params.subaccountName,\n productId: params.productId,\n amount: params.amount,\n referralCode: params.referralCode,\n });\n }\n\n async withdraw(params: WithdrawCollateralParams) {\n return this.context.engineClient.withdrawCollateral({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n });\n }\n\n /**\n * Withdraws collateral to a custom recipient address via the `withdraw_collateral_v2` execute.\n *\n * When `sendTo` is the zero address, funds are sent to the subaccount owner. When `sendTo` is a\n * non-zero address, the transaction must be signed by the subaccount owner (linked signers are\n * not permitted).\n *\n * @param params\n */\n async withdrawV2(params: WithdrawCollateralV2Params) {\n return this.context.engineClient.withdrawCollateralV2({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n });\n }\n\n async approveAllowance(params: ApproveAllowanceParams) {\n const tokenContract = await this.getTokenContractForProduct(params);\n if (!isWriteableContract(tokenContract)) {\n throw new Error(\n 'Token contract does not permit writes. Is a wallet client provided?',\n );\n }\n\n return approveDepositAllowance({\n amount: params.amount,\n endpoint: this.context.contracts.endpoint,\n tokenContract,\n });\n }\n\n /**\n * Transfers quote between subaccounts under the same wallet.\n *\n * @param params\n */\n async transferQuote(params: TransferQuoteParams) {\n return this.context.engineClient.transferQuote({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n });\n }\n\n async mintNlp(params: MintNlpParams) {\n return this.context.engineClient.mintNlp({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n });\n }\n\n async burnNlp(params: BurnNlpParams) {\n return this.context.engineClient.burnNlp({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n });\n }\n\n async _mintMockERC20(params: MintMockERC20Params) {\n if (!this.context.walletClient) {\n throw new WalletNotProvidedError();\n }\n\n const config = await this.context.contracts.spotEngine.read.getConfig([\n params.productId,\n ]);\n\n return this.context.walletClient.writeContract({\n abi: MOCK_ERC20_ABI,\n address: config.token,\n functionName: 'mint',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AAO,KAAK,QAAQ,aAAa,QAAQ;GACvC,GAAG;GACH,iBAAiB,KAAK,2BAA2B,MAAM;GACvD,SAAS,KAAK,+BAA+B,MAAM;GACnD,eAAe,OAAO,iBAAiB,KAAK,mBAAmB;EACjE,CAAC;CACH;CAEA,MAAM,QAAQ,QAAuB;EACnC,OAAO,KAAK,QAAQ,aAAa,QAAQ;GACvC,GAAG;GACH,iBAAiB,KAAK,2BAA2B,MAAM;GACvD,SAAS,KAAK,+BAA+B,MAAM;GACnD,eAAe,OAAO,iBAAiB,KAAK,mBAAmB;EACjE,CAAC;CACH;CAEA,MAAM,eAAe,QAA6B;EAChD,IAAI,CAAC,KAAK,QAAQ,cAChB,MAAM,IAAI,uBAAuB;EAGnC,MAAM,SAAS,MAAM,KAAK,QAAQ,UAAU,WAAW,KAAK,UAAU,CACpE,OAAO,SACT,CAAC;EAED,OAAO,KAAK,QAAQ,aAAa,cAAc;GAC7C,KAAK;GACL,SAAS,OAAO;GAChB,cAAc;GACd,MAAM,CAAC,KAAK,uBAAuB,GAAG,SAAS,OAAO,MAAM,CAAC;EAC/D,CAAC;CACH;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nadohq/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Nado SDK client — unified API for trading, market data, and collateral management on Nado",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"module": "./dist/index.js",
|
|
42
42
|
"types": "./dist/index.d.ts",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@nadohq/engine-client": "^0.
|
|
45
|
-
"@nadohq/indexer-client": "^0.
|
|
46
|
-
"@nadohq/mobile-client": "^0.
|
|
47
|
-
"@nadohq/shared": "^0.
|
|
48
|
-
"@nadohq/trigger-client": "^0.
|
|
44
|
+
"@nadohq/engine-client": "^0.38.0",
|
|
45
|
+
"@nadohq/indexer-client": "^0.38.0",
|
|
46
|
+
"@nadohq/mobile-client": "^0.38.0",
|
|
47
|
+
"@nadohq/shared": "^0.38.0",
|
|
48
|
+
"@nadohq/trigger-client": "^0.38.0",
|
|
49
49
|
"ts-mixer": "6.0.4"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"bignumber.js": "11.1.1",
|
|
57
57
|
"viem": "2.52.0"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "1a536b7f05b1b042ef257b290cdb8c83f48f4dd0"
|
|
60
60
|
}
|
|
@@ -23,7 +23,7 @@ export class SpotExecuteAPI extends BaseSpotAPI {
|
|
|
23
23
|
if (!isWriteableContract(this.context.contracts.endpoint)) {
|
|
24
24
|
throw new WalletNotProvidedError();
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
return depositCollateral({
|
|
28
28
|
endpoint: this.context.contracts.endpoint,
|
|
29
29
|
subaccountName: params.subaccountName,
|