viem 2.57.4 → 2.57.6
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/CHANGELOG.md +34 -0
- package/_cjs/actions/public/waitForTransactionReceipt.js +5 -2
- package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_cjs/actions/wallet/waitForCallsStatus.js +25 -2
- package/_cjs/actions/wallet/waitForCallsStatus.js.map +1 -1
- package/_cjs/chains/definitions/arcTestnet.js +11 -8
- package/_cjs/chains/definitions/arcTestnet.js.map +1 -1
- package/_cjs/chains/definitions/qmsTestnet.js +30 -0
- package/_cjs/chains/definitions/qmsTestnet.js.map +1 -0
- package/_cjs/chains/definitions/tempo.js +1 -1
- package/_cjs/chains/definitions/tempoModerato.js +2 -2
- package/_cjs/chains/index.js +7 -5
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/clients/transports/ipc.js +19 -10
- package/_cjs/clients/transports/ipc.js.map +1 -1
- package/_cjs/clients/transports/webSocket.js +19 -10
- package/_cjs/clients/transports/webSocket.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/tempo/Abis.js +297 -1
- package/_cjs/tempo/Abis.js.map +1 -1
- package/_cjs/tempo/Account.js +40 -40
- package/_cjs/tempo/Account.js.map +1 -1
- package/_cjs/tempo/Addresses.js +2 -1
- package/_cjs/tempo/Addresses.js.map +1 -1
- package/_cjs/tempo/Decorator.js +9 -8
- package/_cjs/tempo/Decorator.js.map +1 -1
- package/_cjs/tempo/ExecutionError.js +95 -4
- package/_cjs/tempo/ExecutionError.js.map +1 -1
- package/_cjs/tempo/Formatters.js +8 -7
- package/_cjs/tempo/Formatters.js.map +1 -1
- package/_cjs/tempo/KeyAuthorizationManager.js +25 -16
- package/_cjs/tempo/KeyAuthorizationManager.js.map +1 -1
- package/_cjs/tempo/Relay.js +9 -4
- package/_cjs/tempo/Relay.js.map +1 -1
- package/_cjs/tempo/Transaction.js +9 -9
- package/_cjs/tempo/Transaction.js.map +1 -1
- package/_cjs/tempo/Transport.js +21 -11
- package/_cjs/tempo/Transport.js.map +1 -1
- package/_cjs/tempo/{multisig → accounts}/Config.js +8 -8
- package/_cjs/tempo/{multisig → accounts}/Config.js.map +1 -1
- package/_cjs/tempo/{multisig → accounts}/Operation.js +10 -10
- package/_cjs/tempo/{multisig → accounts}/Operation.js.map +1 -1
- package/_cjs/tempo/{multisig → accounts}/Signature.js +2 -2
- package/_cjs/tempo/accounts/Signature.js.map +1 -0
- package/_cjs/tempo/actions/accessKey.js +442 -47
- package/_cjs/tempo/actions/accessKey.js.map +1 -1
- package/_cjs/tempo/actions/{multisig.js → accounts.js} +16 -20
- package/_cjs/tempo/actions/accounts.js.map +1 -0
- package/_cjs/tempo/actions/amm.js +90 -4
- package/_cjs/tempo/actions/amm.js.map +1 -1
- package/_cjs/tempo/actions/channel.js +183 -7
- package/_cjs/tempo/actions/channel.js.map +1 -1
- package/_cjs/tempo/actions/dex.js +507 -14
- package/_cjs/tempo/actions/dex.js.map +1 -1
- package/_cjs/tempo/actions/earn/deployment.js +4 -3
- package/_cjs/tempo/actions/earn/deployment.js.map +1 -1
- package/_cjs/tempo/actions/earn.js +22 -21
- package/_cjs/tempo/actions/earn.js.map +1 -1
- package/_cjs/tempo/actions/fee.js +85 -5
- package/_cjs/tempo/actions/fee.js.map +1 -1
- package/_cjs/tempo/actions/index.js +2 -2
- package/_cjs/tempo/actions/index.js.map +1 -1
- package/_cjs/tempo/actions/nonce.js +54 -1
- package/_cjs/tempo/actions/nonce.js.map +1 -1
- package/_cjs/tempo/actions/policy.js +35 -6
- package/_cjs/tempo/actions/policy.js.map +1 -1
- package/_cjs/tempo/actions/propAmm.js +18 -8
- package/_cjs/tempo/actions/propAmm.js.map +1 -1
- package/_cjs/tempo/actions/receivePolicy.js +7 -6
- package/_cjs/tempo/actions/receivePolicy.js.map +1 -1
- package/_cjs/tempo/actions/reward.js +7 -6
- package/_cjs/tempo/actions/reward.js.map +1 -1
- package/_cjs/tempo/actions/token.js +433 -22
- package/_cjs/tempo/actions/token.js.map +1 -1
- package/_cjs/tempo/actions/validator.js +12 -11
- package/_cjs/tempo/actions/validator.js.map +1 -1
- package/_cjs/tempo/actions/virtualAddress.js +3 -2
- package/_cjs/tempo/actions/virtualAddress.js.map +1 -1
- package/_cjs/tempo/actions/zone.js +12 -11
- package/_cjs/tempo/actions/zone.js.map +1 -1
- package/_cjs/tempo/chainConfig.js +37 -37
- package/_cjs/tempo/chainConfig.js.map +1 -1
- package/_cjs/tempo/errors.js +57 -1
- package/_cjs/tempo/errors.js.map +1 -1
- package/_cjs/tempo/index.js +3 -3
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/tempo/internal/errors.js +46 -0
- package/_cjs/tempo/internal/errors.js.map +1 -0
- package/_cjs/tempo/internal/relay/{multisig.js → accounts.js} +90 -93
- package/_cjs/tempo/internal/relay/accounts.js.map +1 -0
- package/_cjs/tempo/internal/relay/keyAuthorization.js +296 -0
- package/_cjs/tempo/internal/relay/keyAuthorization.js.map +1 -0
- package/_cjs/tempo/internal/relay/plugin.js +17 -7
- package/_cjs/tempo/internal/relay/plugin.js.map +1 -1
- package/_cjs/tempo/internal/resolveError.js +128 -0
- package/_cjs/tempo/internal/resolveError.js.map +1 -0
- package/_cjs/tempo/internal/utils.js +1 -0
- package/_cjs/tempo/internal/utils.js.map +1 -1
- package/_cjs/utils/hash/normalizeSignature.js +1 -1
- package/_cjs/utils/hash/normalizeSignature.js.map +1 -1
- package/_cjs/utils/rpc/http.js +66 -31
- package/_cjs/utils/rpc/http.js.map +1 -1
- package/_cjs/utils/rpc/socket.js +1 -1
- package/_cjs/utils/rpc/socket.js.map +1 -1
- package/_esm/actions/public/waitForTransactionReceipt.js +5 -2
- package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_esm/actions/wallet/waitForCallsStatus.js +39 -2
- package/_esm/actions/wallet/waitForCallsStatus.js.map +1 -1
- package/_esm/chains/definitions/arcTestnet.js +11 -8
- package/_esm/chains/definitions/arcTestnet.js.map +1 -1
- package/_esm/chains/definitions/qmsTestnet.js +27 -0
- package/_esm/chains/definitions/qmsTestnet.js.map +1 -0
- package/_esm/chains/definitions/tempo.js +1 -1
- package/_esm/chains/definitions/tempoModerato.js +2 -2
- package/_esm/chains/index.js +1 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/clients/transports/ipc.js +21 -10
- package/_esm/clients/transports/ipc.js.map +1 -1
- package/_esm/clients/transports/webSocket.js +21 -10
- package/_esm/clients/transports/webSocket.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/tempo/Abis.js +297 -0
- package/_esm/tempo/Abis.js.map +1 -1
- package/_esm/tempo/Account.js +42 -42
- package/_esm/tempo/Account.js.map +1 -1
- package/_esm/tempo/Addresses.js +1 -0
- package/_esm/tempo/Addresses.js.map +1 -1
- package/_esm/tempo/Client.js +3 -3
- package/_esm/tempo/Decorator.js +9 -8
- package/_esm/tempo/Decorator.js.map +1 -1
- package/_esm/tempo/ExecutionError.js +96 -3
- package/_esm/tempo/ExecutionError.js.map +1 -1
- package/_esm/tempo/Formatters.js +11 -10
- package/_esm/tempo/Formatters.js.map +1 -1
- package/_esm/tempo/KeyAuthorizationManager.js +58 -16
- package/_esm/tempo/KeyAuthorizationManager.js.map +1 -1
- package/_esm/tempo/Relay.js +49 -8
- package/_esm/tempo/Relay.js.map +1 -1
- package/_esm/tempo/Transaction.js +11 -11
- package/_esm/tempo/Transaction.js.map +1 -1
- package/_esm/tempo/Transport.js +22 -12
- package/_esm/tempo/Transport.js.map +1 -1
- package/_esm/tempo/{multisig → accounts}/Config.js +14 -14
- package/_esm/tempo/{multisig → accounts}/Config.js.map +1 -1
- package/_esm/tempo/{multisig → accounts}/Operation.js +17 -17
- package/_esm/tempo/{multisig → accounts}/Operation.js.map +1 -1
- package/_esm/tempo/accounts/Signature.js +9 -0
- package/_esm/tempo/accounts/Signature.js.map +1 -0
- package/_esm/tempo/actions/accessKey.js +499 -48
- package/_esm/tempo/actions/accessKey.js.map +1 -1
- package/_esm/tempo/actions/{multisig.js → accounts.js} +34 -38
- package/_esm/tempo/actions/accounts.js.map +1 -0
- package/_esm/tempo/actions/amm.js +95 -4
- package/_esm/tempo/actions/amm.js.map +1 -1
- package/_esm/tempo/actions/channel.js +191 -7
- package/_esm/tempo/actions/channel.js.map +1 -1
- package/_esm/tempo/actions/dex.js +537 -14
- package/_esm/tempo/actions/dex.js.map +1 -1
- package/_esm/tempo/actions/earn/deployment.js +4 -3
- package/_esm/tempo/actions/earn/deployment.js.map +1 -1
- package/_esm/tempo/actions/earn.js +22 -21
- package/_esm/tempo/actions/earn.js.map +1 -1
- package/_esm/tempo/actions/fee.js +90 -6
- package/_esm/tempo/actions/fee.js.map +1 -1
- package/_esm/tempo/actions/index.js +1 -1
- package/_esm/tempo/actions/index.js.map +1 -1
- package/_esm/tempo/actions/nonce.js +57 -1
- package/_esm/tempo/actions/nonce.js.map +1 -1
- package/_esm/tempo/actions/policy.js +36 -6
- package/_esm/tempo/actions/policy.js.map +1 -1
- package/_esm/tempo/actions/propAmm.js +18 -8
- package/_esm/tempo/actions/propAmm.js.map +1 -1
- package/_esm/tempo/actions/receivePolicy.js +7 -6
- package/_esm/tempo/actions/receivePolicy.js.map +1 -1
- package/_esm/tempo/actions/reward.js +7 -6
- package/_esm/tempo/actions/reward.js.map +1 -1
- package/_esm/tempo/actions/token.js +461 -22
- package/_esm/tempo/actions/token.js.map +1 -1
- package/_esm/tempo/actions/validator.js +12 -11
- package/_esm/tempo/actions/validator.js.map +1 -1
- package/_esm/tempo/actions/virtualAddress.js +3 -2
- package/_esm/tempo/actions/virtualAddress.js.map +1 -1
- package/_esm/tempo/actions/zone.js +12 -11
- package/_esm/tempo/actions/zone.js.map +1 -1
- package/_esm/tempo/chainConfig.js +38 -38
- package/_esm/tempo/chainConfig.js.map +1 -1
- package/_esm/tempo/errors.js +63 -0
- package/_esm/tempo/errors.js.map +1 -1
- package/_esm/tempo/index.js +2 -1
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/tempo/internal/errors.js +51 -0
- package/_esm/tempo/internal/errors.js.map +1 -0
- package/_esm/tempo/internal/relay/{multisig.js → accounts.js} +93 -98
- package/_esm/tempo/internal/relay/accounts.js.map +1 -0
- package/_esm/tempo/internal/relay/feePayer.js +1 -1
- package/_esm/tempo/internal/relay/feePayer.js.map +1 -1
- package/_esm/tempo/internal/relay/keyAuthorization.js +334 -0
- package/_esm/tempo/internal/relay/keyAuthorization.js.map +1 -0
- package/_esm/tempo/internal/relay/plugin.js +15 -6
- package/_esm/tempo/internal/relay/plugin.js.map +1 -1
- package/_esm/tempo/internal/resolveError.js +130 -0
- package/_esm/tempo/internal/resolveError.js.map +1 -0
- package/_esm/tempo/internal/utils.js +2 -0
- package/_esm/tempo/internal/utils.js.map +1 -1
- package/_esm/utils/hash/normalizeSignature.js +3 -2
- package/_esm/utils/hash/normalizeSignature.js.map +1 -1
- package/_esm/utils/rpc/http.js +74 -31
- package/_esm/utils/rpc/http.js.map +1 -1
- package/_esm/utils/rpc/socket.js +3 -1
- package/_esm/utils/rpc/socket.js.map +1 -1
- package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
- package/_types/actions/wallet/waitForCallsStatus.d.ts.map +1 -1
- package/_types/chains/definitions/arcTestnet.d.ts +5 -5
- package/_types/chains/definitions/arcTestnet.d.ts.map +1 -1
- package/_types/chains/definitions/qmsTestnet.d.ts +50 -0
- package/_types/chains/definitions/qmsTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/tempo.d.ts +2 -2
- package/_types/chains/definitions/tempoModerato.d.ts +4 -4
- package/_types/chains/index.d.ts +1 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/clients/transports/ipc.d.ts.map +1 -1
- package/_types/clients/transports/webSocket.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/tempo/Abis.d.ts +807 -0
- package/_types/tempo/Abis.d.ts.map +1 -1
- package/_types/tempo/Account.d.ts +28 -28
- package/_types/tempo/Account.d.ts.map +1 -1
- package/_types/tempo/Addresses.d.ts +1 -0
- package/_types/tempo/Addresses.d.ts.map +1 -1
- package/_types/tempo/Client.d.ts +3 -3
- package/_types/tempo/Decorator.d.ts +64 -38
- package/_types/tempo/Decorator.d.ts.map +1 -1
- package/_types/tempo/ExecutionError.d.ts +3 -1
- package/_types/tempo/ExecutionError.d.ts.map +1 -1
- package/_types/tempo/Formatters.d.ts.map +1 -1
- package/_types/tempo/KeyAuthorizationManager.d.ts +45 -2
- package/_types/tempo/KeyAuthorizationManager.d.ts.map +1 -1
- package/_types/tempo/Relay.d.ts +62 -12
- package/_types/tempo/Relay.d.ts.map +1 -1
- package/_types/tempo/Transaction.d.ts +14 -11
- package/_types/tempo/Transaction.d.ts.map +1 -1
- package/_types/tempo/Transport.d.ts +20 -7
- package/_types/tempo/Transport.d.ts.map +1 -1
- package/_types/tempo/{multisig → accounts}/Config.d.ts +7 -7
- package/_types/tempo/accounts/Config.d.ts.map +1 -0
- package/_types/tempo/{multisig → accounts}/Operation.d.ts +7 -7
- package/_types/tempo/accounts/Operation.d.ts.map +1 -0
- package/_types/tempo/{multisig → accounts}/Signature.d.ts +1 -1
- package/_types/tempo/accounts/Signature.d.ts.map +1 -0
- package/_types/tempo/actions/accessKey.d.ts +214 -25
- package/_types/tempo/actions/accessKey.d.ts.map +1 -1
- package/_types/tempo/actions/{multisig.d.ts → accounts.d.ts} +31 -29
- package/_types/tempo/actions/accounts.d.ts.map +1 -0
- package/_types/tempo/actions/amm.d.ts +39 -0
- package/_types/tempo/actions/amm.d.ts.map +1 -1
- package/_types/tempo/actions/channel.d.ts +77 -7
- package/_types/tempo/actions/channel.d.ts.map +1 -1
- package/_types/tempo/actions/dex.d.ts +222 -16
- package/_types/tempo/actions/dex.d.ts.map +1 -1
- package/_types/tempo/actions/earn/deployment.d.ts +7 -6
- package/_types/tempo/actions/earn/deployment.d.ts.map +1 -1
- package/_types/tempo/actions/earn.d.ts +15 -14
- package/_types/tempo/actions/earn.d.ts.map +1 -1
- package/_types/tempo/actions/fee.d.ts +32 -6
- package/_types/tempo/actions/fee.d.ts.map +1 -1
- package/_types/tempo/actions/index.d.ts +1 -1
- package/_types/tempo/actions/index.d.ts.map +1 -1
- package/_types/tempo/actions/nonce.d.ts +35 -0
- package/_types/tempo/actions/nonce.d.ts.map +1 -1
- package/_types/tempo/actions/policy.d.ts +29 -8
- package/_types/tempo/actions/policy.d.ts.map +1 -1
- package/_types/tempo/actions/propAmm.d.ts +9 -1
- package/_types/tempo/actions/propAmm.d.ts.map +1 -1
- package/_types/tempo/actions/receivePolicy.d.ts +10 -6
- package/_types/tempo/actions/receivePolicy.d.ts.map +1 -1
- package/_types/tempo/actions/reward.d.ts +7 -3
- package/_types/tempo/actions/reward.d.ts.map +1 -1
- package/_types/tempo/actions/token.d.ts +200 -32
- package/_types/tempo/actions/token.d.ts.map +1 -1
- package/_types/tempo/actions/validator.d.ts +17 -5
- package/_types/tempo/actions/validator.d.ts.map +1 -1
- package/_types/tempo/actions/virtualAddress.d.ts +4 -3
- package/_types/tempo/actions/virtualAddress.d.ts.map +1 -1
- package/_types/tempo/actions/zone.d.ts +10 -9
- package/_types/tempo/actions/zone.d.ts.map +1 -1
- package/_types/tempo/errors.d.ts +63 -1
- package/_types/tempo/errors.d.ts.map +1 -1
- package/_types/tempo/index.d.ts +3 -2
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/tempo/internal/errors.d.ts +59 -0
- package/_types/tempo/internal/errors.d.ts.map +1 -0
- package/_types/tempo/internal/relay/accounts.d.ts +15 -0
- package/_types/tempo/internal/relay/accounts.d.ts.map +1 -0
- package/_types/tempo/internal/relay/keyAuthorization.d.ts +25 -0
- package/_types/tempo/internal/relay/keyAuthorization.d.ts.map +1 -0
- package/_types/tempo/internal/relay/plugin.d.ts +6 -3
- package/_types/tempo/internal/relay/plugin.d.ts.map +1 -1
- package/_types/tempo/internal/resolveError.d.ts +8 -0
- package/_types/tempo/internal/resolveError.d.ts.map +1 -0
- package/_types/tempo/internal/utils.d.ts.map +1 -1
- package/_types/utils/hash/normalizeSignature.d.ts.map +1 -1
- package/_types/utils/rpc/http.d.ts.map +1 -1
- package/_types/utils/rpc/socket.d.ts.map +1 -1
- package/actions/public/waitForTransactionReceipt.ts +8 -2
- package/actions/wallet/waitForCallsStatus.ts +41 -2
- package/chains/definitions/arcTestnet.ts +11 -8
- package/chains/definitions/qmsTestnet.ts +27 -0
- package/chains/definitions/tempo.ts +1 -1
- package/chains/definitions/tempoModerato.ts +2 -2
- package/chains/index.ts +1 -0
- package/clients/transports/ipc.ts +38 -29
- package/clients/transports/webSocket.ts +42 -33
- package/errors/version.ts +1 -1
- package/package.json +2 -2
- package/tempo/Abis.ts +298 -0
- package/tempo/Account.ts +95 -84
- package/tempo/Addresses.ts +1 -0
- package/tempo/Client.ts +3 -3
- package/tempo/Decorator.ts +91 -60
- package/tempo/ExecutionError.ts +102 -4
- package/tempo/Formatters.ts +14 -13
- package/tempo/KeyAuthorizationManager.ts +71 -19
- package/tempo/Relay.ts +70 -14
- package/tempo/Transaction.ts +31 -23
- package/tempo/Transport.ts +49 -21
- package/tempo/{multisig → accounts}/Config.ts +21 -21
- package/tempo/{multisig → accounts}/Operation.ts +26 -26
- package/tempo/{multisig → accounts}/Signature.ts +5 -3
- package/tempo/actions/accessKey.ts +675 -104
- package/tempo/actions/{multisig.ts → accounts.ts} +54 -59
- package/tempo/actions/amm.ts +126 -4
- package/tempo/actions/channel.ts +248 -14
- package/tempo/actions/dex.ts +599 -33
- package/tempo/actions/earn/deployment.ts +11 -9
- package/tempo/actions/earn.ts +40 -35
- package/tempo/actions/fee.ts +111 -9
- package/tempo/actions/index.ts +1 -1
- package/tempo/actions/nonce.ts +86 -1
- package/tempo/actions/policy.ts +66 -14
- package/tempo/actions/propAmm.ts +36 -9
- package/tempo/actions/receivePolicy.ts +26 -15
- package/tempo/actions/reward.ts +17 -9
- package/tempo/actions/token.ts +519 -54
- package/tempo/actions/validator.ts +40 -16
- package/tempo/actions/virtualAddress.ts +7 -5
- package/tempo/actions/zone.ts +25 -20
- package/tempo/chainConfig.ts +52 -52
- package/tempo/errors.ts +114 -1
- package/tempo/index.ts +5 -4
- package/tempo/internal/errors.ts +110 -0
- package/tempo/internal/relay/{multisig.ts → accounts.ts} +118 -118
- package/tempo/internal/relay/feePayer.ts +1 -1
- package/tempo/internal/relay/keyAuthorization.ts +415 -0
- package/tempo/internal/relay/plugin.ts +20 -7
- package/tempo/internal/resolveError.ts +169 -0
- package/tempo/internal/utils.ts +2 -0
- package/utils/hash/normalizeSignature.ts +3 -2
- package/utils/rpc/http.ts +76 -30
- package/utils/rpc/socket.ts +3 -1
- package/_cjs/tempo/actions/multisig.js.map +0 -1
- package/_cjs/tempo/internal/relay/multisig.js.map +0 -1
- package/_cjs/tempo/multisig/Signature.js.map +0 -1
- package/_esm/tempo/actions/multisig.js.map +0 -1
- package/_esm/tempo/internal/relay/multisig.js.map +0 -1
- package/_esm/tempo/multisig/Signature.js +0 -9
- package/_esm/tempo/multisig/Signature.js.map +0 -1
- package/_types/tempo/actions/multisig.d.ts.map +0 -1
- package/_types/tempo/internal/relay/multisig.d.ts +0 -4
- package/_types/tempo/internal/relay/multisig.d.ts.map +0 -1
- package/_types/tempo/multisig/Config.d.ts.map +0 -1
- package/_types/tempo/multisig/Operation.d.ts.map +0 -1
- package/_types/tempo/multisig/Signature.d.ts.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.errorResolvers = exports.DexInsufficientBalanceError = exports.DexPairNotFoundError = exports.DexOrderNotStaleError = exports.DexOrderNotFoundError = exports.DexInvalidFlipTickError = exports.DexTickOutOfBoundsError = exports.DexBelowMinimumOrderSizeError = exports.DexInsufficientLiquidityError = exports.DexMaxInputExceededError = exports.DexInsufficientOutputError = void 0;
|
|
3
4
|
exports.buy = buy;
|
|
4
5
|
exports.buySync = buySync;
|
|
5
6
|
exports.cancel = cancel;
|
|
@@ -34,8 +35,11 @@ const watchContractEvent_js_1 = require("../../actions/public/watchContractEvent
|
|
|
34
35
|
const writeContract_js_1 = require("../../actions/wallet/writeContract.js");
|
|
35
36
|
const writeContractSync_js_1 = require("../../actions/wallet/writeContractSync.js");
|
|
36
37
|
const parseEventLogs_js_1 = require("../../utils/abi/parseEventLogs.js");
|
|
38
|
+
const isAddressEqual_js_1 = require("../../utils/address/isAddressEqual.js");
|
|
37
39
|
const Abis = require("../Abis.js");
|
|
38
40
|
const Addresses = require("../Addresses.js");
|
|
41
|
+
const errors_js_1 = require("../errors.js");
|
|
42
|
+
const errors_js_2 = require("../internal/errors.js");
|
|
39
43
|
const utils_js_1 = require("../internal/utils.js");
|
|
40
44
|
async function buy(client, parameters) {
|
|
41
45
|
return buy.inner(writeContract_js_1.writeContract, client, parameters);
|
|
@@ -44,7 +48,7 @@ async function buy(client, parameters) {
|
|
|
44
48
|
async function inner(action, client, parameters) {
|
|
45
49
|
const { tokenIn, tokenOut, amountOut, maxAmountIn, ...rest } = parameters;
|
|
46
50
|
const call = buy.call({ tokenIn, tokenOut, amountOut, maxAmountIn });
|
|
47
|
-
return (await action(client, {
|
|
51
|
+
return (await (0, errors_js_2.withExecutionError)(action)(client, {
|
|
48
52
|
...rest,
|
|
49
53
|
...call,
|
|
50
54
|
}));
|
|
@@ -76,7 +80,7 @@ async function cancel(client, parameters) {
|
|
|
76
80
|
async function inner(action, client, parameters) {
|
|
77
81
|
const { orderId, ...rest } = parameters;
|
|
78
82
|
const call = cancel.call({ orderId });
|
|
79
|
-
return (await action(client, {
|
|
83
|
+
return (await (0, errors_js_2.withExecutionError)(action)(client, {
|
|
80
84
|
...rest,
|
|
81
85
|
...call,
|
|
82
86
|
}));
|
|
@@ -126,7 +130,7 @@ async function cancelStale(client, parameters) {
|
|
|
126
130
|
async function inner(action, client, parameters) {
|
|
127
131
|
const { orderId, ...rest } = parameters;
|
|
128
132
|
const call = cancelStale.call({ orderId });
|
|
129
|
-
return (await action(client, {
|
|
133
|
+
return (await (0, errors_js_2.withExecutionError)(action)(client, {
|
|
130
134
|
...rest,
|
|
131
135
|
...call,
|
|
132
136
|
}));
|
|
@@ -176,7 +180,7 @@ async function createPair(client, parameters) {
|
|
|
176
180
|
async function inner(action, client, parameters) {
|
|
177
181
|
const { base, ...rest } = parameters;
|
|
178
182
|
const call = createPair.call({ base });
|
|
179
|
-
return (await action(client, {
|
|
183
|
+
return (await (0, errors_js_2.withExecutionError)(action)(client, {
|
|
180
184
|
...rest,
|
|
181
185
|
...call,
|
|
182
186
|
}));
|
|
@@ -224,7 +228,7 @@ async function getBalance(client, parameters) {
|
|
|
224
228
|
const address = acc ? (0, parseAccount_js_1.parseAccount)(acc).address : undefined;
|
|
225
229
|
if (!address)
|
|
226
230
|
throw new Error('account is required.');
|
|
227
|
-
return (0, readContract_js_1.readContract)(client, {
|
|
231
|
+
return (0, errors_js_2.withExecutionError)(readContract_js_1.readContract)(client, {
|
|
228
232
|
...rest,
|
|
229
233
|
...getBalance.call({ account: address, token }),
|
|
230
234
|
});
|
|
@@ -243,7 +247,7 @@ async function getBalance(client, parameters) {
|
|
|
243
247
|
})(getBalance || (exports.getBalance = getBalance = {}));
|
|
244
248
|
async function getBuyQuote(client, parameters) {
|
|
245
249
|
const { tokenIn, tokenOut, amountOut, ...rest } = parameters;
|
|
246
|
-
return (0, readContract_js_1.readContract)(client, {
|
|
250
|
+
return (0, errors_js_2.withExecutionError)(readContract_js_1.readContract)(client, {
|
|
247
251
|
...rest,
|
|
248
252
|
...getBuyQuote.call({ tokenIn, tokenOut, amountOut }),
|
|
249
253
|
});
|
|
@@ -262,7 +266,7 @@ async function getBuyQuote(client, parameters) {
|
|
|
262
266
|
})(getBuyQuote || (exports.getBuyQuote = getBuyQuote = {}));
|
|
263
267
|
async function getOrder(client, parameters) {
|
|
264
268
|
const { orderId, ...rest } = parameters;
|
|
265
|
-
return (0, readContract_js_1.readContract)(client, {
|
|
269
|
+
return (0, errors_js_2.withExecutionError)(readContract_js_1.readContract)(client, {
|
|
266
270
|
...rest,
|
|
267
271
|
...getOrder.call({ orderId }),
|
|
268
272
|
});
|
|
@@ -281,7 +285,7 @@ async function getOrder(client, parameters) {
|
|
|
281
285
|
})(getOrder || (exports.getOrder = getOrder = {}));
|
|
282
286
|
async function getOrderbook(client, parameters) {
|
|
283
287
|
const { base, quote, ...rest } = parameters;
|
|
284
|
-
return (0, readContract_js_1.readContract)(client, {
|
|
288
|
+
return (0, errors_js_2.withExecutionError)(readContract_js_1.readContract)(client, {
|
|
285
289
|
...rest,
|
|
286
290
|
...getOrderbook.call({ base, quote }),
|
|
287
291
|
});
|
|
@@ -301,7 +305,7 @@ async function getOrderbook(client, parameters) {
|
|
|
301
305
|
})(getOrderbook || (exports.getOrderbook = getOrderbook = {}));
|
|
302
306
|
async function getTickLevel(client, parameters) {
|
|
303
307
|
const { base, tick, isBid, ...rest } = parameters;
|
|
304
|
-
const [head, tail, totalLiquidity] = await (0, readContract_js_1.readContract)(client, {
|
|
308
|
+
const [head, tail, totalLiquidity] = await (0, errors_js_2.withExecutionError)(readContract_js_1.readContract)(client, {
|
|
305
309
|
...rest,
|
|
306
310
|
...getTickLevel.call({ base, tick, isBid }),
|
|
307
311
|
});
|
|
@@ -321,7 +325,7 @@ async function getTickLevel(client, parameters) {
|
|
|
321
325
|
})(getTickLevel || (exports.getTickLevel = getTickLevel = {}));
|
|
322
326
|
async function getSellQuote(client, parameters) {
|
|
323
327
|
const { tokenIn, tokenOut, amountIn, ...rest } = parameters;
|
|
324
|
-
return (0, readContract_js_1.readContract)(client, {
|
|
328
|
+
return (0, errors_js_2.withExecutionError)(readContract_js_1.readContract)(client, {
|
|
325
329
|
...rest,
|
|
326
330
|
...getSellQuote.call({ tokenIn, tokenOut, amountIn }),
|
|
327
331
|
});
|
|
@@ -345,7 +349,7 @@ async function place(client, parameters) {
|
|
|
345
349
|
async function inner(action, client, parameters) {
|
|
346
350
|
const { amount, token, type, tick, ...rest } = parameters;
|
|
347
351
|
const call = place.call({ amount, token, type, tick });
|
|
348
|
-
return (await action(client, {
|
|
352
|
+
return (await (0, errors_js_2.withExecutionError)(action)(client, {
|
|
349
353
|
...rest,
|
|
350
354
|
...call,
|
|
351
355
|
}));
|
|
@@ -382,7 +386,7 @@ async function placeFlip(client, parameters) {
|
|
|
382
386
|
async function inner(action, client, parameters) {
|
|
383
387
|
const { amount, flipTick, tick, token, type, ...rest } = parameters;
|
|
384
388
|
const call = placeFlip.call({ amount, flipTick, tick, token, type });
|
|
385
|
-
return (await action(client, {
|
|
389
|
+
return (await (0, errors_js_2.withExecutionError)(action)(client, {
|
|
386
390
|
...rest,
|
|
387
391
|
...call,
|
|
388
392
|
}));
|
|
@@ -448,7 +452,7 @@ async function sell(client, parameters) {
|
|
|
448
452
|
async function inner(action, client, parameters) {
|
|
449
453
|
const { tokenIn, tokenOut, amountIn, minAmountOut, ...rest } = parameters;
|
|
450
454
|
const call = sell.call({ tokenIn, tokenOut, amountIn, minAmountOut });
|
|
451
|
-
return (await action(client, {
|
|
455
|
+
return (await (0, errors_js_2.withExecutionError)(action)(client, {
|
|
452
456
|
...rest,
|
|
453
457
|
...call,
|
|
454
458
|
}));
|
|
@@ -552,7 +556,7 @@ async function withdraw(client, parameters) {
|
|
|
552
556
|
async function inner(action, client, parameters) {
|
|
553
557
|
const { token, amount, ...rest } = parameters;
|
|
554
558
|
const call = withdraw.call({ token, amount });
|
|
555
|
-
return (await action(client, {
|
|
559
|
+
return (await (0, errors_js_2.withExecutionError)(action)(client, {
|
|
556
560
|
...rest,
|
|
557
561
|
...call,
|
|
558
562
|
}));
|
|
@@ -580,4 +584,493 @@ async function withdrawSync(client, parameters) {
|
|
|
580
584
|
function getPairKey(base, quote) {
|
|
581
585
|
return Hash.keccak256(Hex.concat(base, quote));
|
|
582
586
|
}
|
|
587
|
+
class DexInsufficientOutputError extends errors_js_1.TempoExecutionError {
|
|
588
|
+
constructor(parameters) {
|
|
589
|
+
const { amountIn, minAmountOut, quote, tokenIn, tokenOut } = parameters;
|
|
590
|
+
super(parameters, {
|
|
591
|
+
details: {
|
|
592
|
+
'token in': tokenIn,
|
|
593
|
+
'token out': tokenOut,
|
|
594
|
+
'amount in': amountIn,
|
|
595
|
+
'min amount out': minAmountOut,
|
|
596
|
+
quote,
|
|
597
|
+
},
|
|
598
|
+
name: 'DexInsufficientOutputError',
|
|
599
|
+
});
|
|
600
|
+
Object.defineProperty(this, "amountIn", {
|
|
601
|
+
enumerable: true,
|
|
602
|
+
configurable: true,
|
|
603
|
+
writable: true,
|
|
604
|
+
value: void 0
|
|
605
|
+
});
|
|
606
|
+
Object.defineProperty(this, "minAmountOut", {
|
|
607
|
+
enumerable: true,
|
|
608
|
+
configurable: true,
|
|
609
|
+
writable: true,
|
|
610
|
+
value: void 0
|
|
611
|
+
});
|
|
612
|
+
Object.defineProperty(this, "quote", {
|
|
613
|
+
enumerable: true,
|
|
614
|
+
configurable: true,
|
|
615
|
+
writable: true,
|
|
616
|
+
value: void 0
|
|
617
|
+
});
|
|
618
|
+
Object.defineProperty(this, "tokenIn", {
|
|
619
|
+
enumerable: true,
|
|
620
|
+
configurable: true,
|
|
621
|
+
writable: true,
|
|
622
|
+
value: void 0
|
|
623
|
+
});
|
|
624
|
+
Object.defineProperty(this, "tokenOut", {
|
|
625
|
+
enumerable: true,
|
|
626
|
+
configurable: true,
|
|
627
|
+
writable: true,
|
|
628
|
+
value: void 0
|
|
629
|
+
});
|
|
630
|
+
this.amountIn = amountIn;
|
|
631
|
+
this.minAmountOut = minAmountOut;
|
|
632
|
+
this.quote = quote;
|
|
633
|
+
this.tokenIn = tokenIn;
|
|
634
|
+
this.tokenOut = tokenOut;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
exports.DexInsufficientOutputError = DexInsufficientOutputError;
|
|
638
|
+
class DexMaxInputExceededError extends errors_js_1.TempoExecutionError {
|
|
639
|
+
constructor(parameters) {
|
|
640
|
+
const { amountOut, maxAmountIn, quote, tokenIn, tokenOut } = parameters;
|
|
641
|
+
super(parameters, {
|
|
642
|
+
details: {
|
|
643
|
+
'token in': tokenIn,
|
|
644
|
+
'token out': tokenOut,
|
|
645
|
+
'amount out': amountOut,
|
|
646
|
+
'max amount in': maxAmountIn,
|
|
647
|
+
quote,
|
|
648
|
+
},
|
|
649
|
+
name: 'DexMaxInputExceededError',
|
|
650
|
+
});
|
|
651
|
+
Object.defineProperty(this, "amountOut", {
|
|
652
|
+
enumerable: true,
|
|
653
|
+
configurable: true,
|
|
654
|
+
writable: true,
|
|
655
|
+
value: void 0
|
|
656
|
+
});
|
|
657
|
+
Object.defineProperty(this, "maxAmountIn", {
|
|
658
|
+
enumerable: true,
|
|
659
|
+
configurable: true,
|
|
660
|
+
writable: true,
|
|
661
|
+
value: void 0
|
|
662
|
+
});
|
|
663
|
+
Object.defineProperty(this, "quote", {
|
|
664
|
+
enumerable: true,
|
|
665
|
+
configurable: true,
|
|
666
|
+
writable: true,
|
|
667
|
+
value: void 0
|
|
668
|
+
});
|
|
669
|
+
Object.defineProperty(this, "tokenIn", {
|
|
670
|
+
enumerable: true,
|
|
671
|
+
configurable: true,
|
|
672
|
+
writable: true,
|
|
673
|
+
value: void 0
|
|
674
|
+
});
|
|
675
|
+
Object.defineProperty(this, "tokenOut", {
|
|
676
|
+
enumerable: true,
|
|
677
|
+
configurable: true,
|
|
678
|
+
writable: true,
|
|
679
|
+
value: void 0
|
|
680
|
+
});
|
|
681
|
+
this.amountOut = amountOut;
|
|
682
|
+
this.maxAmountIn = maxAmountIn;
|
|
683
|
+
this.quote = quote;
|
|
684
|
+
this.tokenIn = tokenIn;
|
|
685
|
+
this.tokenOut = tokenOut;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
exports.DexMaxInputExceededError = DexMaxInputExceededError;
|
|
689
|
+
class DexInsufficientLiquidityError extends errors_js_1.TempoExecutionError {
|
|
690
|
+
constructor(parameters) {
|
|
691
|
+
const { amountIn, amountOut, tokenIn, tokenOut } = parameters;
|
|
692
|
+
super(parameters, {
|
|
693
|
+
details: {
|
|
694
|
+
'token in': tokenIn,
|
|
695
|
+
'token out': tokenOut,
|
|
696
|
+
'amount in': amountIn,
|
|
697
|
+
'amount out': amountOut,
|
|
698
|
+
},
|
|
699
|
+
name: 'DexInsufficientLiquidityError',
|
|
700
|
+
});
|
|
701
|
+
Object.defineProperty(this, "amountIn", {
|
|
702
|
+
enumerable: true,
|
|
703
|
+
configurable: true,
|
|
704
|
+
writable: true,
|
|
705
|
+
value: void 0
|
|
706
|
+
});
|
|
707
|
+
Object.defineProperty(this, "amountOut", {
|
|
708
|
+
enumerable: true,
|
|
709
|
+
configurable: true,
|
|
710
|
+
writable: true,
|
|
711
|
+
value: void 0
|
|
712
|
+
});
|
|
713
|
+
Object.defineProperty(this, "tokenIn", {
|
|
714
|
+
enumerable: true,
|
|
715
|
+
configurable: true,
|
|
716
|
+
writable: true,
|
|
717
|
+
value: void 0
|
|
718
|
+
});
|
|
719
|
+
Object.defineProperty(this, "tokenOut", {
|
|
720
|
+
enumerable: true,
|
|
721
|
+
configurable: true,
|
|
722
|
+
writable: true,
|
|
723
|
+
value: void 0
|
|
724
|
+
});
|
|
725
|
+
this.amountIn = amountIn;
|
|
726
|
+
this.amountOut = amountOut;
|
|
727
|
+
this.tokenIn = tokenIn;
|
|
728
|
+
this.tokenOut = tokenOut;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
exports.DexInsufficientLiquidityError = DexInsufficientLiquidityError;
|
|
732
|
+
class DexBelowMinimumOrderSizeError extends errors_js_1.TempoExecutionError {
|
|
733
|
+
constructor(parameters) {
|
|
734
|
+
const [amount] = parameters.error.args;
|
|
735
|
+
const { minimum } = parameters;
|
|
736
|
+
super(parameters, {
|
|
737
|
+
details: { amount, minimum },
|
|
738
|
+
name: 'DexBelowMinimumOrderSizeError',
|
|
739
|
+
shortMessage: `Order amount ${amount} is below the minimum${minimum === undefined ? '' : ` of ${minimum}`}.`,
|
|
740
|
+
});
|
|
741
|
+
Object.defineProperty(this, "amount", {
|
|
742
|
+
enumerable: true,
|
|
743
|
+
configurable: true,
|
|
744
|
+
writable: true,
|
|
745
|
+
value: void 0
|
|
746
|
+
});
|
|
747
|
+
Object.defineProperty(this, "minimum", {
|
|
748
|
+
enumerable: true,
|
|
749
|
+
configurable: true,
|
|
750
|
+
writable: true,
|
|
751
|
+
value: void 0
|
|
752
|
+
});
|
|
753
|
+
this.amount = amount;
|
|
754
|
+
this.minimum = minimum;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
exports.DexBelowMinimumOrderSizeError = DexBelowMinimumOrderSizeError;
|
|
758
|
+
class DexTickOutOfBoundsError extends errors_js_1.TempoExecutionError {
|
|
759
|
+
constructor(parameters) {
|
|
760
|
+
const [tick] = parameters.error.args;
|
|
761
|
+
const { maxTick, minTick } = parameters;
|
|
762
|
+
super(parameters, {
|
|
763
|
+
details: {
|
|
764
|
+
tick,
|
|
765
|
+
range: minTick === undefined || maxTick === undefined
|
|
766
|
+
? undefined
|
|
767
|
+
: `${minTick} to ${maxTick}`,
|
|
768
|
+
},
|
|
769
|
+
name: 'DexTickOutOfBoundsError',
|
|
770
|
+
});
|
|
771
|
+
Object.defineProperty(this, "maxTick", {
|
|
772
|
+
enumerable: true,
|
|
773
|
+
configurable: true,
|
|
774
|
+
writable: true,
|
|
775
|
+
value: void 0
|
|
776
|
+
});
|
|
777
|
+
Object.defineProperty(this, "minTick", {
|
|
778
|
+
enumerable: true,
|
|
779
|
+
configurable: true,
|
|
780
|
+
writable: true,
|
|
781
|
+
value: void 0
|
|
782
|
+
});
|
|
783
|
+
Object.defineProperty(this, "tick", {
|
|
784
|
+
enumerable: true,
|
|
785
|
+
configurable: true,
|
|
786
|
+
writable: true,
|
|
787
|
+
value: void 0
|
|
788
|
+
});
|
|
789
|
+
this.maxTick = maxTick;
|
|
790
|
+
this.minTick = minTick;
|
|
791
|
+
this.tick = tick;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
exports.DexTickOutOfBoundsError = DexTickOutOfBoundsError;
|
|
795
|
+
class DexInvalidFlipTickError extends errors_js_1.TempoExecutionError {
|
|
796
|
+
constructor(parameters) {
|
|
797
|
+
const { flipTick, side, tick, tickSpacing } = parameters;
|
|
798
|
+
super(parameters, {
|
|
799
|
+
details: {
|
|
800
|
+
side,
|
|
801
|
+
tick,
|
|
802
|
+
'flip tick': flipTick,
|
|
803
|
+
'tick spacing': tickSpacing,
|
|
804
|
+
},
|
|
805
|
+
name: 'DexInvalidFlipTickError',
|
|
806
|
+
shortMessage: side === 'buy'
|
|
807
|
+
? 'The flip tick of a buy order must be at or above its tick, and a multiple of the tick spacing.'
|
|
808
|
+
: side === 'sell'
|
|
809
|
+
? 'The flip tick of a sell order must be at or below its tick, and a multiple of the tick spacing.'
|
|
810
|
+
: undefined,
|
|
811
|
+
});
|
|
812
|
+
Object.defineProperty(this, "flipTick", {
|
|
813
|
+
enumerable: true,
|
|
814
|
+
configurable: true,
|
|
815
|
+
writable: true,
|
|
816
|
+
value: void 0
|
|
817
|
+
});
|
|
818
|
+
Object.defineProperty(this, "side", {
|
|
819
|
+
enumerable: true,
|
|
820
|
+
configurable: true,
|
|
821
|
+
writable: true,
|
|
822
|
+
value: void 0
|
|
823
|
+
});
|
|
824
|
+
Object.defineProperty(this, "tick", {
|
|
825
|
+
enumerable: true,
|
|
826
|
+
configurable: true,
|
|
827
|
+
writable: true,
|
|
828
|
+
value: void 0
|
|
829
|
+
});
|
|
830
|
+
Object.defineProperty(this, "tickSpacing", {
|
|
831
|
+
enumerable: true,
|
|
832
|
+
configurable: true,
|
|
833
|
+
writable: true,
|
|
834
|
+
value: void 0
|
|
835
|
+
});
|
|
836
|
+
this.flipTick = flipTick;
|
|
837
|
+
this.side = side;
|
|
838
|
+
this.tick = tick;
|
|
839
|
+
this.tickSpacing = tickSpacing;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
exports.DexInvalidFlipTickError = DexInvalidFlipTickError;
|
|
843
|
+
class DexOrderNotFoundError extends errors_js_1.TempoExecutionError {
|
|
844
|
+
constructor(parameters) {
|
|
845
|
+
super(parameters, {
|
|
846
|
+
details: { order: parameters.orderId },
|
|
847
|
+
name: 'DexOrderNotFoundError',
|
|
848
|
+
shortMessage: `Order ${parameters.orderId} does not exist or is already filled.`,
|
|
849
|
+
});
|
|
850
|
+
Object.defineProperty(this, "orderId", {
|
|
851
|
+
enumerable: true,
|
|
852
|
+
configurable: true,
|
|
853
|
+
writable: true,
|
|
854
|
+
value: void 0
|
|
855
|
+
});
|
|
856
|
+
this.orderId = parameters.orderId;
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
exports.DexOrderNotFoundError = DexOrderNotFoundError;
|
|
860
|
+
class DexOrderNotStaleError extends errors_js_1.TempoExecutionError {
|
|
861
|
+
constructor(parameters) {
|
|
862
|
+
super(parameters, {
|
|
863
|
+
details: { order: parameters.orderId },
|
|
864
|
+
name: 'DexOrderNotStaleError',
|
|
865
|
+
shortMessage: `Order ${parameters.orderId} is not stale: its maker is still authorized.`,
|
|
866
|
+
});
|
|
867
|
+
Object.defineProperty(this, "orderId", {
|
|
868
|
+
enumerable: true,
|
|
869
|
+
configurable: true,
|
|
870
|
+
writable: true,
|
|
871
|
+
value: void 0
|
|
872
|
+
});
|
|
873
|
+
this.orderId = parameters.orderId;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
exports.DexOrderNotStaleError = DexOrderNotStaleError;
|
|
877
|
+
class DexPairNotFoundError extends errors_js_1.TempoExecutionError {
|
|
878
|
+
constructor(parameters) {
|
|
879
|
+
super(parameters, {
|
|
880
|
+
details: { tokens: parameters.tokens.join(', ') || undefined },
|
|
881
|
+
name: 'DexPairNotFoundError',
|
|
882
|
+
});
|
|
883
|
+
Object.defineProperty(this, "tokens", {
|
|
884
|
+
enumerable: true,
|
|
885
|
+
configurable: true,
|
|
886
|
+
writable: true,
|
|
887
|
+
value: void 0
|
|
888
|
+
});
|
|
889
|
+
this.tokens = parameters.tokens;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
exports.DexPairNotFoundError = DexPairNotFoundError;
|
|
893
|
+
class DexInsufficientBalanceError extends errors_js_1.TempoExecutionError {
|
|
894
|
+
constructor(parameters) {
|
|
895
|
+
const { amount, balance, token } = parameters;
|
|
896
|
+
super(parameters, {
|
|
897
|
+
details: { token, amount, balance },
|
|
898
|
+
name: 'DexInsufficientBalanceError',
|
|
899
|
+
shortMessage: `Insufficient exchange balance of token "${token}".`,
|
|
900
|
+
});
|
|
901
|
+
Object.defineProperty(this, "amount", {
|
|
902
|
+
enumerable: true,
|
|
903
|
+
configurable: true,
|
|
904
|
+
writable: true,
|
|
905
|
+
value: void 0
|
|
906
|
+
});
|
|
907
|
+
Object.defineProperty(this, "balance", {
|
|
908
|
+
enumerable: true,
|
|
909
|
+
configurable: true,
|
|
910
|
+
writable: true,
|
|
911
|
+
value: void 0
|
|
912
|
+
});
|
|
913
|
+
Object.defineProperty(this, "token", {
|
|
914
|
+
enumerable: true,
|
|
915
|
+
configurable: true,
|
|
916
|
+
writable: true,
|
|
917
|
+
value: void 0
|
|
918
|
+
});
|
|
919
|
+
this.amount = amount;
|
|
920
|
+
this.balance = balance;
|
|
921
|
+
this.token = token;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
exports.DexInsufficientBalanceError = DexInsufficientBalanceError;
|
|
925
|
+
const exchange = {
|
|
926
|
+
address: Addresses.stablecoinDex,
|
|
927
|
+
abi: Abis.stablecoinDex,
|
|
928
|
+
};
|
|
929
|
+
function getExchangeCall(context) {
|
|
930
|
+
const { call } = context;
|
|
931
|
+
return call && (0, isAddressEqual_js_1.isAddressEqual)(call.address, Addresses.stablecoinDex)
|
|
932
|
+
? call
|
|
933
|
+
: undefined;
|
|
934
|
+
}
|
|
935
|
+
exports.errorResolvers = {
|
|
936
|
+
'BelowMinimumOrderSize(uint128)': async (context) => {
|
|
937
|
+
if (!getExchangeCall(context) || !context.base.error.args)
|
|
938
|
+
return undefined;
|
|
939
|
+
const [minimum] = await context.read([
|
|
940
|
+
{ ...exchange, functionName: 'MIN_ORDER_AMOUNT' },
|
|
941
|
+
]);
|
|
942
|
+
return new DexBelowMinimumOrderSizeError({
|
|
943
|
+
...context.base,
|
|
944
|
+
minimum: minimum?.result,
|
|
945
|
+
});
|
|
946
|
+
},
|
|
947
|
+
'InsufficientBalance()': async (context) => {
|
|
948
|
+
const call = getExchangeCall(context);
|
|
949
|
+
const token = call?.arg('token');
|
|
950
|
+
if (call?.functionName !== 'withdraw' || !token || !context.signer)
|
|
951
|
+
return undefined;
|
|
952
|
+
const [balance] = await context.read([
|
|
953
|
+
{
|
|
954
|
+
...exchange,
|
|
955
|
+
functionName: 'balanceOf',
|
|
956
|
+
args: [context.signer.address, token],
|
|
957
|
+
},
|
|
958
|
+
]);
|
|
959
|
+
return new DexInsufficientBalanceError({
|
|
960
|
+
...context.base,
|
|
961
|
+
amount: call.arg('amount'),
|
|
962
|
+
balance: balance?.result,
|
|
963
|
+
token,
|
|
964
|
+
});
|
|
965
|
+
},
|
|
966
|
+
'InsufficientLiquidity()': (context) => {
|
|
967
|
+
const call = getExchangeCall(context);
|
|
968
|
+
if (!call)
|
|
969
|
+
return undefined;
|
|
970
|
+
return new DexInsufficientLiquidityError({
|
|
971
|
+
...context.base,
|
|
972
|
+
amountIn: call.arg('amountIn'),
|
|
973
|
+
amountOut: call.arg('amountOut'),
|
|
974
|
+
tokenIn: call.arg('tokenIn'),
|
|
975
|
+
tokenOut: call.arg('tokenOut'),
|
|
976
|
+
});
|
|
977
|
+
},
|
|
978
|
+
'InsufficientOutput()': async (context) => {
|
|
979
|
+
const call = getExchangeCall(context);
|
|
980
|
+
if (!call)
|
|
981
|
+
return undefined;
|
|
982
|
+
const tokenIn = call.arg('tokenIn');
|
|
983
|
+
const tokenOut = call.arg('tokenOut');
|
|
984
|
+
const amountIn = call.arg('amountIn');
|
|
985
|
+
const [quote] = await context.read([
|
|
986
|
+
{
|
|
987
|
+
...exchange,
|
|
988
|
+
functionName: 'quoteSwapExactAmountIn',
|
|
989
|
+
args: [tokenIn, tokenOut, amountIn],
|
|
990
|
+
},
|
|
991
|
+
]);
|
|
992
|
+
return new DexInsufficientOutputError({
|
|
993
|
+
...context.base,
|
|
994
|
+
amountIn,
|
|
995
|
+
minAmountOut: call.arg('minAmountOut'),
|
|
996
|
+
quote: quote?.result,
|
|
997
|
+
tokenIn,
|
|
998
|
+
tokenOut,
|
|
999
|
+
});
|
|
1000
|
+
},
|
|
1001
|
+
'InvalidFlipTick()': async (context) => {
|
|
1002
|
+
const call = getExchangeCall(context);
|
|
1003
|
+
if (!call)
|
|
1004
|
+
return undefined;
|
|
1005
|
+
const [tickSpacing] = await context.read([
|
|
1006
|
+
{ ...exchange, functionName: 'TICK_SPACING' },
|
|
1007
|
+
]);
|
|
1008
|
+
const isBid = call.arg('isBid');
|
|
1009
|
+
return new DexInvalidFlipTickError({
|
|
1010
|
+
...context.base,
|
|
1011
|
+
flipTick: call.arg('flipTick'),
|
|
1012
|
+
side: isBid === undefined ? undefined : isBid ? 'buy' : 'sell',
|
|
1013
|
+
tick: call.arg('tick'),
|
|
1014
|
+
tickSpacing: tickSpacing?.result,
|
|
1015
|
+
});
|
|
1016
|
+
},
|
|
1017
|
+
'MaxInputExceeded()': async (context) => {
|
|
1018
|
+
const call = getExchangeCall(context);
|
|
1019
|
+
if (!call)
|
|
1020
|
+
return undefined;
|
|
1021
|
+
const tokenIn = call.arg('tokenIn');
|
|
1022
|
+
const tokenOut = call.arg('tokenOut');
|
|
1023
|
+
const amountOut = call.arg('amountOut');
|
|
1024
|
+
const [quote] = await context.read([
|
|
1025
|
+
{
|
|
1026
|
+
...exchange,
|
|
1027
|
+
functionName: 'quoteSwapExactAmountOut',
|
|
1028
|
+
args: [tokenIn, tokenOut, amountOut],
|
|
1029
|
+
},
|
|
1030
|
+
]);
|
|
1031
|
+
return new DexMaxInputExceededError({
|
|
1032
|
+
...context.base,
|
|
1033
|
+
amountOut,
|
|
1034
|
+
maxAmountIn: call.arg('maxAmountIn'),
|
|
1035
|
+
quote: quote?.result,
|
|
1036
|
+
tokenIn,
|
|
1037
|
+
tokenOut,
|
|
1038
|
+
});
|
|
1039
|
+
},
|
|
1040
|
+
'OrderDoesNotExist()': (context) => {
|
|
1041
|
+
const orderId = getExchangeCall(context)?.arg('orderId');
|
|
1042
|
+
if (orderId === undefined)
|
|
1043
|
+
return undefined;
|
|
1044
|
+
return new DexOrderNotFoundError({ ...context.base, orderId });
|
|
1045
|
+
},
|
|
1046
|
+
'OrderNotStale()': (context) => {
|
|
1047
|
+
const orderId = getExchangeCall(context)?.arg('orderId');
|
|
1048
|
+
if (orderId === undefined)
|
|
1049
|
+
return undefined;
|
|
1050
|
+
return new DexOrderNotStaleError({ ...context.base, orderId });
|
|
1051
|
+
},
|
|
1052
|
+
'PairDoesNotExist()': (context) => {
|
|
1053
|
+
const call = getExchangeCall(context);
|
|
1054
|
+
if (!call)
|
|
1055
|
+
return undefined;
|
|
1056
|
+
const tokens = ['token', 'tokenIn', 'tokenOut', 'base'].flatMap((name) => {
|
|
1057
|
+
const token = call.arg(name);
|
|
1058
|
+
return token ? [token] : [];
|
|
1059
|
+
});
|
|
1060
|
+
return new DexPairNotFoundError({ ...context.base, tokens });
|
|
1061
|
+
},
|
|
1062
|
+
'TickOutOfBounds(int16)': async (context) => {
|
|
1063
|
+
if (!getExchangeCall(context) || !context.base.error.args)
|
|
1064
|
+
return undefined;
|
|
1065
|
+
const [minTick, maxTick] = await context.read([
|
|
1066
|
+
{ ...exchange, functionName: 'MIN_TICK' },
|
|
1067
|
+
{ ...exchange, functionName: 'MAX_TICK' },
|
|
1068
|
+
]);
|
|
1069
|
+
return new DexTickOutOfBoundsError({
|
|
1070
|
+
...context.base,
|
|
1071
|
+
maxTick: maxTick?.result,
|
|
1072
|
+
minTick: minTick?.result,
|
|
1073
|
+
});
|
|
1074
|
+
},
|
|
1075
|
+
};
|
|
583
1076
|
//# sourceMappingURL=dex.js.map
|