xrpl 2.10.0 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/xrpl-latest-min.js +1 -1
- package/build/xrpl-latest-min.js.map +1 -1
- package/build/xrpl-latest.js +728 -28
- package/build/xrpl-latest.js.map +1 -1
- package/dist/npm/Wallet/walletFromSecretNumbers.d.ts +7 -0
- package/dist/npm/Wallet/walletFromSecretNumbers.d.ts.map +1 -0
- package/dist/npm/Wallet/walletFromSecretNumbers.js +27 -0
- package/dist/npm/Wallet/walletFromSecretNumbers.js.map +1 -0
- package/dist/npm/client/index.d.ts +2 -1
- package/dist/npm/client/index.d.ts.map +1 -1
- package/dist/npm/client/index.js.map +1 -1
- package/dist/npm/index.d.ts +1 -0
- package/dist/npm/index.d.ts.map +1 -1
- package/dist/npm/index.js +3 -1
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/models/common/index.d.ts +5 -0
- package/dist/npm/models/common/index.d.ts.map +1 -1
- package/dist/npm/models/ledger/AMM.d.ts +27 -0
- package/dist/npm/models/ledger/AMM.d.ts.map +1 -0
- package/dist/npm/models/ledger/AMM.js +3 -0
- package/dist/npm/models/ledger/AMM.js.map +1 -0
- package/dist/npm/models/ledger/AccountRoot.d.ts +2 -0
- package/dist/npm/models/ledger/AccountRoot.d.ts.map +1 -1
- package/dist/npm/models/ledger/AccountRoot.js +1 -0
- package/dist/npm/models/ledger/AccountRoot.js.map +1 -1
- package/dist/npm/models/ledger/LedgerEntry.d.ts +2 -1
- package/dist/npm/models/ledger/LedgerEntry.d.ts.map +1 -1
- package/dist/npm/models/methods/ammInfo.d.ts +39 -0
- package/dist/npm/models/methods/ammInfo.d.ts.map +1 -0
- package/dist/npm/models/methods/ammInfo.js +3 -0
- package/dist/npm/models/methods/ammInfo.js.map +1 -0
- package/dist/npm/models/methods/index.d.ts +4 -3
- package/dist/npm/models/methods/index.d.ts.map +1 -1
- package/dist/npm/models/methods/ledgerEntry.d.ts +10 -0
- package/dist/npm/models/methods/ledgerEntry.d.ts.map +1 -1
- package/dist/npm/models/transactions/AMMBid.d.ts +12 -0
- package/dist/npm/models/transactions/AMMBid.d.ts.map +1 -0
- package/dist/npm/models/transactions/AMMBid.js +56 -0
- package/dist/npm/models/transactions/AMMBid.js.map +1 -0
- package/dist/npm/models/transactions/AMMCreate.d.ts +11 -0
- package/dist/npm/models/transactions/AMMCreate.d.ts.map +1 -0
- package/dist/npm/models/transactions/AMMCreate.js +32 -0
- package/dist/npm/models/transactions/AMMCreate.js.map +1 -0
- package/dist/npm/models/transactions/AMMDelete.d.ts +9 -0
- package/dist/npm/models/transactions/AMMDelete.d.ts.map +1 -0
- package/dist/npm/models/transactions/AMMDelete.js +22 -0
- package/dist/npm/models/transactions/AMMDelete.js.map +1 -0
- package/dist/npm/models/transactions/AMMDeposit.d.ts +27 -0
- package/dist/npm/models/transactions/AMMDeposit.d.ts.map +1 -0
- package/dist/npm/models/transactions/AMMDeposit.js +51 -0
- package/dist/npm/models/transactions/AMMDeposit.js.map +1 -0
- package/dist/npm/models/transactions/AMMVote.d.ts +10 -0
- package/dist/npm/models/transactions/AMMVote.d.ts.map +1 -0
- package/dist/npm/models/transactions/AMMVote.js +32 -0
- package/dist/npm/models/transactions/AMMVote.js.map +1 -0
- package/dist/npm/models/transactions/AMMWithdraw.d.ts +31 -0
- package/dist/npm/models/transactions/AMMWithdraw.d.ts.map +1 -0
- package/dist/npm/models/transactions/AMMWithdraw.js +50 -0
- package/dist/npm/models/transactions/AMMWithdraw.js.map +1 -0
- package/dist/npm/models/transactions/common.d.ts +2 -1
- package/dist/npm/models/transactions/common.d.ts.map +1 -1
- package/dist/npm/models/transactions/common.js +12 -1
- package/dist/npm/models/transactions/common.js.map +1 -1
- package/dist/npm/models/transactions/index.d.ts +6 -0
- package/dist/npm/models/transactions/index.d.ts.map +1 -1
- package/dist/npm/models/transactions/index.js +5 -1
- package/dist/npm/models/transactions/index.js.map +1 -1
- package/dist/npm/models/transactions/transaction.d.ts +7 -1
- package/dist/npm/models/transactions/transaction.d.ts.map +1 -1
- package/dist/npm/models/transactions/transaction.js +24 -0
- package/dist/npm/models/transactions/transaction.js.map +1 -1
- package/dist/npm/models/utils/flags.d.ts.map +1 -1
- package/dist/npm/models/utils/flags.js +14 -21
- package/dist/npm/models/utils/flags.js.map +1 -1
- package/dist/npm/snippets/tsconfig.tsbuildinfo +1 -1
- package/dist/npm/src/Wallet/walletFromSecretNumbers.d.ts +7 -0
- package/dist/npm/src/Wallet/walletFromSecretNumbers.d.ts.map +1 -0
- package/dist/npm/src/Wallet/walletFromSecretNumbers.js +27 -0
- package/dist/npm/src/Wallet/walletFromSecretNumbers.js.map +1 -0
- package/dist/npm/src/client/index.d.ts +2 -1
- package/dist/npm/src/client/index.d.ts.map +1 -1
- package/dist/npm/src/client/index.js.map +1 -1
- package/dist/npm/src/index.d.ts +1 -0
- package/dist/npm/src/index.d.ts.map +1 -1
- package/dist/npm/src/index.js +3 -1
- package/dist/npm/src/index.js.map +1 -1
- package/dist/npm/src/models/common/index.d.ts +5 -0
- package/dist/npm/src/models/common/index.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/AMM.d.ts +27 -0
- package/dist/npm/src/models/ledger/AMM.d.ts.map +1 -0
- package/dist/npm/src/models/ledger/AMM.js +3 -0
- package/dist/npm/src/models/ledger/AMM.js.map +1 -0
- package/dist/npm/src/models/ledger/AccountRoot.d.ts +2 -0
- package/dist/npm/src/models/ledger/AccountRoot.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/AccountRoot.js +1 -0
- package/dist/npm/src/models/ledger/AccountRoot.js.map +1 -1
- package/dist/npm/src/models/ledger/LedgerEntry.d.ts +2 -1
- package/dist/npm/src/models/ledger/LedgerEntry.d.ts.map +1 -1
- package/dist/npm/src/models/methods/ammInfo.d.ts +39 -0
- package/dist/npm/src/models/methods/ammInfo.d.ts.map +1 -0
- package/dist/npm/src/models/methods/ammInfo.js +3 -0
- package/dist/npm/src/models/methods/ammInfo.js.map +1 -0
- package/dist/npm/src/models/methods/index.d.ts +4 -3
- package/dist/npm/src/models/methods/index.d.ts.map +1 -1
- package/dist/npm/src/models/methods/ledgerEntry.d.ts +10 -0
- package/dist/npm/src/models/methods/ledgerEntry.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/AMMBid.d.ts +12 -0
- package/dist/npm/src/models/transactions/AMMBid.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/AMMBid.js +56 -0
- package/dist/npm/src/models/transactions/AMMBid.js.map +1 -0
- package/dist/npm/src/models/transactions/AMMCreate.d.ts +11 -0
- package/dist/npm/src/models/transactions/AMMCreate.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/AMMCreate.js +32 -0
- package/dist/npm/src/models/transactions/AMMCreate.js.map +1 -0
- package/dist/npm/src/models/transactions/AMMDelete.d.ts +9 -0
- package/dist/npm/src/models/transactions/AMMDelete.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/AMMDelete.js +22 -0
- package/dist/npm/src/models/transactions/AMMDelete.js.map +1 -0
- package/dist/npm/src/models/transactions/AMMDeposit.d.ts +27 -0
- package/dist/npm/src/models/transactions/AMMDeposit.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/AMMDeposit.js +51 -0
- package/dist/npm/src/models/transactions/AMMDeposit.js.map +1 -0
- package/dist/npm/src/models/transactions/AMMVote.d.ts +10 -0
- package/dist/npm/src/models/transactions/AMMVote.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/AMMVote.js +32 -0
- package/dist/npm/src/models/transactions/AMMVote.js.map +1 -0
- package/dist/npm/src/models/transactions/AMMWithdraw.d.ts +31 -0
- package/dist/npm/src/models/transactions/AMMWithdraw.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/AMMWithdraw.js +50 -0
- package/dist/npm/src/models/transactions/AMMWithdraw.js.map +1 -0
- package/dist/npm/src/models/transactions/common.d.ts +2 -1
- package/dist/npm/src/models/transactions/common.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/common.js +12 -1
- package/dist/npm/src/models/transactions/common.js.map +1 -1
- package/dist/npm/src/models/transactions/index.d.ts +6 -0
- package/dist/npm/src/models/transactions/index.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/index.js +5 -1
- package/dist/npm/src/models/transactions/index.js.map +1 -1
- package/dist/npm/src/models/transactions/transaction.d.ts +7 -1
- package/dist/npm/src/models/transactions/transaction.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/transaction.js +24 -0
- package/dist/npm/src/models/transactions/transaction.js.map +1 -1
- package/dist/npm/src/models/utils/flags.d.ts.map +1 -1
- package/dist/npm/src/models/utils/flags.js +14 -21
- package/dist/npm/src/models/utils/flags.js.map +1 -1
- package/dist/npm/src/sugar/autofill.d.ts.map +1 -1
- package/dist/npm/src/sugar/autofill.js +4 -3
- package/dist/npm/src/sugar/autofill.js.map +1 -1
- package/dist/npm/sugar/autofill.d.ts.map +1 -1
- package/dist/npm/sugar/autofill.js +4 -3
- package/dist/npm/sugar/autofill.js.map +1 -1
- package/package.json +8 -6
- package/src/ECDSA.ts +6 -0
- package/src/Wallet/defaultFaucets.ts +82 -0
- package/src/Wallet/fundWallet.ts +344 -0
- package/src/Wallet/index.ts +504 -0
- package/src/Wallet/rfc1751.ts +190 -0
- package/src/Wallet/rfc1751Words.json +243 -0
- package/src/Wallet/signer.ts +173 -0
- package/src/Wallet/walletFromSecretNumbers.ts +37 -0
- package/src/client/BroadcastClient.ts +84 -0
- package/src/client/ConnectionManager.ts +40 -0
- package/src/client/ExponentialBackoff.ts +71 -0
- package/src/client/RequestManager.ts +194 -0
- package/src/client/WSWrapper.ts +106 -0
- package/src/client/connection.ts +593 -0
- package/src/client/index.ts +712 -0
- package/src/client/partialPayment.ts +153 -0
- package/src/errors.ts +161 -0
- package/src/index.ts +20 -0
- package/src/models/common/index.ts +149 -0
- package/src/models/index.ts +16 -0
- package/src/models/ledger/AMM.ts +78 -0
- package/src/models/ledger/AccountRoot.ts +217 -0
- package/src/models/ledger/Amendments.ts +45 -0
- package/src/models/ledger/BaseLedgerEntry.ts +3 -0
- package/src/models/ledger/Check.ts +70 -0
- package/src/models/ledger/DepositPreauth.ts +35 -0
- package/src/models/ledger/DirectoryNode.ts +46 -0
- package/src/models/ledger/Escrow.ts +74 -0
- package/src/models/ledger/FeeSettings.ts +52 -0
- package/src/models/ledger/Ledger.ts +65 -0
- package/src/models/ledger/LedgerEntry.ts +34 -0
- package/src/models/ledger/LedgerHashes.ts +24 -0
- package/src/models/ledger/NFTokenOffer.ts +16 -0
- package/src/models/ledger/NFTokenPage.ts +20 -0
- package/src/models/ledger/NegativeUNL.ts +34 -0
- package/src/models/ledger/Offer.ts +52 -0
- package/src/models/ledger/PayChannel.ts +107 -0
- package/src/models/ledger/RippleState.ts +88 -0
- package/src/models/ledger/SignerList.ts +56 -0
- package/src/models/ledger/Ticket.ts +36 -0
- package/src/models/ledger/index.ts +58 -0
- package/src/models/methods/accountChannels.ts +93 -0
- package/src/models/methods/accountCurrencies.ts +45 -0
- package/src/models/methods/accountInfo.ts +182 -0
- package/src/models/methods/accountLines.ts +137 -0
- package/src/models/methods/accountNFTs.ts +72 -0
- package/src/models/methods/accountObjects.ts +120 -0
- package/src/models/methods/accountOffers.ts +100 -0
- package/src/models/methods/accountTx.ts +109 -0
- package/src/models/methods/ammInfo.ts +145 -0
- package/src/models/methods/baseMethod.ts +58 -0
- package/src/models/methods/bookOffers.ts +96 -0
- package/src/models/methods/channelVerify.ts +41 -0
- package/src/models/methods/depositAuthorized.ts +56 -0
- package/src/models/methods/fee.ts +91 -0
- package/src/models/methods/gatewayBalances.ts +85 -0
- package/src/models/methods/index.ts +391 -0
- package/src/models/methods/ledger.ts +125 -0
- package/src/models/methods/ledgerClosed.ts +32 -0
- package/src/models/methods/ledgerCurrent.ts +31 -0
- package/src/models/methods/ledgerData.ts +78 -0
- package/src/models/methods/ledgerEntry.ts +177 -0
- package/src/models/methods/manifest.ts +54 -0
- package/src/models/methods/nftBuyOffers.ts +37 -0
- package/src/models/methods/nftHistory.ts +113 -0
- package/src/models/methods/nftInfo.ts +25 -0
- package/src/models/methods/nftSellOffers.ts +37 -0
- package/src/models/methods/norippleCheck.ts +82 -0
- package/src/models/methods/pathFind.ts +116 -0
- package/src/models/methods/ping.ts +21 -0
- package/src/models/methods/random.ts +23 -0
- package/src/models/methods/ripplePathFind.ts +81 -0
- package/src/models/methods/serverInfo.ts +257 -0
- package/src/models/methods/serverState.ts +77 -0
- package/src/models/methods/submit.ts +94 -0
- package/src/models/methods/submitMultisigned.ts +51 -0
- package/src/models/methods/subscribe.ts +435 -0
- package/src/models/methods/transactionEntry.ts +47 -0
- package/src/models/methods/tx.ts +69 -0
- package/src/models/methods/unsubscribe.ts +49 -0
- package/src/models/transactions/AMMBid.ts +140 -0
- package/src/models/transactions/AMMCreate.ts +80 -0
- package/src/models/transactions/AMMDelete.ts +55 -0
- package/src/models/transactions/AMMDeposit.ts +130 -0
- package/src/models/transactions/AMMVote.ts +71 -0
- package/src/models/transactions/AMMWithdraw.ts +126 -0
- package/src/models/transactions/NFTokenAcceptOffer.ts +104 -0
- package/src/models/transactions/NFTokenBurn.ts +48 -0
- package/src/models/transactions/NFTokenCancelOffer.ts +45 -0
- package/src/models/transactions/NFTokenCreateOffer.ts +145 -0
- package/src/models/transactions/NFTokenMint.ts +123 -0
- package/src/models/transactions/UNLModify.ts +20 -0
- package/src/models/transactions/accountDelete.ts +50 -0
- package/src/models/transactions/accountSet.ts +228 -0
- package/src/models/transactions/checkCancel.ts +34 -0
- package/src/models/transactions/checkCash.ts +73 -0
- package/src/models/transactions/checkCreate.ts +90 -0
- package/src/models/transactions/clawback.ts +49 -0
- package/src/models/transactions/common.ts +295 -0
- package/src/models/transactions/depositPreauth.ts +68 -0
- package/src/models/transactions/enableAmendment.ts +26 -0
- package/src/models/transactions/escrowCancel.ts +45 -0
- package/src/models/transactions/escrowCreate.ts +100 -0
- package/src/models/transactions/escrowFinish.ts +63 -0
- package/src/models/transactions/index.ts +66 -0
- package/src/models/transactions/metadata.ts +69 -0
- package/src/models/transactions/offerCancel.ts +37 -0
- package/src/models/transactions/offerCreate.ts +144 -0
- package/src/models/transactions/payment.ts +278 -0
- package/src/models/transactions/paymentChannelClaim.ts +165 -0
- package/src/models/transactions/paymentChannelCreate.ts +116 -0
- package/src/models/transactions/paymentChannelFund.ts +65 -0
- package/src/models/transactions/setFee.ts +48 -0
- package/src/models/transactions/setRegularKey.ts +33 -0
- package/src/models/transactions/signerListSet.ts +89 -0
- package/src/models/transactions/ticketCreate.ts +50 -0
- package/src/models/transactions/transaction.ts +303 -0
- package/src/models/transactions/trustSet.ts +146 -0
- package/src/models/utils/flags.ts +98 -0
- package/src/models/utils/index.ts +37 -0
- package/src/sugar/autofill.ts +373 -0
- package/src/sugar/balances.ts +123 -0
- package/src/sugar/getFeeXrp.ts +45 -0
- package/src/sugar/getLedgerIndex.ts +15 -0
- package/src/sugar/getOrderbook.ts +152 -0
- package/src/sugar/index.ts +11 -0
- package/src/sugar/submit.ts +305 -0
- package/src/sugar/utils.ts +29 -0
- package/src/utils/derive.ts +23 -0
- package/src/utils/getBalanceChanges.ts +186 -0
- package/src/utils/getNFTokenID.ts +97 -0
- package/src/utils/hashes/HashPrefix.ts +40 -0
- package/src/utils/hashes/README.md +65 -0
- package/src/utils/hashes/SHAMap/InnerNode.ts +124 -0
- package/src/utils/hashes/SHAMap/LeafNode.ts +69 -0
- package/src/utils/hashes/SHAMap/index.ts +41 -0
- package/src/utils/hashes/SHAMap/node.ts +14 -0
- package/src/utils/hashes/hashLedger.ts +236 -0
- package/src/utils/hashes/index.ts +187 -0
- package/src/utils/hashes/ledgerSpaces.ts +34 -0
- package/src/utils/hashes/sha512Half.ts +19 -0
- package/src/utils/index.ts +223 -0
- package/src/utils/parseNFTokenID.ts +84 -0
- package/src/utils/quality.ts +169 -0
- package/src/utils/signPaymentChannelClaim.ts +27 -0
- package/src/utils/stringConversion.ts +27 -0
- package/src/utils/timeConversion.ts +53 -0
- package/src/utils/verifyPaymentChannelClaim.ts +30 -0
- package/src/utils/xrpConversion.ts +104 -0
@@ -0,0 +1,140 @@
|
|
1
|
+
/* eslint-disable complexity -- required for validateAMMBid */
|
2
|
+
import { ValidationError } from '../../errors'
|
3
|
+
import { Amount, AuthAccount, Currency } from '../common'
|
4
|
+
|
5
|
+
import {
|
6
|
+
BaseTransaction,
|
7
|
+
isAmount,
|
8
|
+
isCurrency,
|
9
|
+
validateBaseTransaction,
|
10
|
+
} from './common'
|
11
|
+
|
12
|
+
const MAX_AUTH_ACCOUNTS = 4
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Bid on an Automated Market Maker's (AMM's) auction slot.
|
16
|
+
*
|
17
|
+
* If you win, you can trade against the AMM at a discounted fee until you are outbid or 24 hours have passed.
|
18
|
+
* If you are outbid before 24 hours have passed, you are refunded part of the cost of your bid based on how much time remains.
|
19
|
+
* You bid using the AMM's LP Tokens; the amount of a winning bid is returned to the AMM,
|
20
|
+
* decreasing the outstanding balance of LP Tokens.
|
21
|
+
*/
|
22
|
+
export interface AMMBid extends BaseTransaction {
|
23
|
+
TransactionType: 'AMMBid'
|
24
|
+
|
25
|
+
/**
|
26
|
+
* The definition for one of the assets in the AMM's pool.
|
27
|
+
*/
|
28
|
+
Asset: Currency
|
29
|
+
|
30
|
+
/**
|
31
|
+
* The definition for the other asset in the AMM's pool.
|
32
|
+
*/
|
33
|
+
Asset2: Currency
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Pay at least this amount for the slot.
|
37
|
+
* Setting this value higher makes it harder for others to outbid you.
|
38
|
+
* If omitted, pay the minimum necessary to win the bid.
|
39
|
+
*/
|
40
|
+
BidMin?: Amount
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Pay at most this amount for the slot.
|
44
|
+
* If the cost to win the bid is higher than this amount, the transaction fails.
|
45
|
+
* If omitted, pay as much as necessary to win the bid.
|
46
|
+
*/
|
47
|
+
BidMax?: Amount
|
48
|
+
|
49
|
+
/**
|
50
|
+
* A list of up to 4 additional accounts that you allow to trade at the discounted fee.
|
51
|
+
* This cannot include the address of the transaction sender.
|
52
|
+
*/
|
53
|
+
AuthAccounts?: AuthAccount[]
|
54
|
+
}
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Verify the form and type of an AMMBid at runtime.
|
58
|
+
*
|
59
|
+
* @param tx - An AMMBid Transaction.
|
60
|
+
* @throws When the AMMBid is Malformed.
|
61
|
+
*/
|
62
|
+
export function validateAMMBid(tx: Record<string, unknown>): void {
|
63
|
+
validateBaseTransaction(tx)
|
64
|
+
|
65
|
+
if (tx.Asset == null) {
|
66
|
+
throw new ValidationError('AMMBid: missing field Asset')
|
67
|
+
}
|
68
|
+
|
69
|
+
if (!isCurrency(tx.Asset)) {
|
70
|
+
throw new ValidationError('AMMBid: Asset must be a Currency')
|
71
|
+
}
|
72
|
+
|
73
|
+
if (tx.Asset2 == null) {
|
74
|
+
throw new ValidationError('AMMBid: missing field Asset2')
|
75
|
+
}
|
76
|
+
|
77
|
+
if (!isCurrency(tx.Asset2)) {
|
78
|
+
throw new ValidationError('AMMBid: Asset2 must be a Currency')
|
79
|
+
}
|
80
|
+
|
81
|
+
if (tx.BidMin != null && !isAmount(tx.BidMin)) {
|
82
|
+
throw new ValidationError('AMMBid: BidMin must be an Amount')
|
83
|
+
}
|
84
|
+
|
85
|
+
if (tx.BidMax != null && !isAmount(tx.BidMax)) {
|
86
|
+
throw new ValidationError('AMMBid: BidMax must be an Amount')
|
87
|
+
}
|
88
|
+
|
89
|
+
if (tx.AuthAccounts != null) {
|
90
|
+
if (!Array.isArray(tx.AuthAccounts)) {
|
91
|
+
throw new ValidationError(
|
92
|
+
`AMMBid: AuthAccounts must be an AuthAccount array`,
|
93
|
+
)
|
94
|
+
}
|
95
|
+
if (tx.AuthAccounts.length > MAX_AUTH_ACCOUNTS) {
|
96
|
+
throw new ValidationError(
|
97
|
+
`AMMBid: AuthAccounts length must not be greater than ${MAX_AUTH_ACCOUNTS}`,
|
98
|
+
)
|
99
|
+
}
|
100
|
+
validateAuthAccounts(
|
101
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Only used by JS
|
102
|
+
tx.Account as string,
|
103
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Only used by JS
|
104
|
+
tx.AuthAccounts as Array<Record<string, unknown>>,
|
105
|
+
)
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
function validateAuthAccounts(
|
110
|
+
senderAddress: string,
|
111
|
+
authAccounts: Array<Record<string, unknown>>,
|
112
|
+
): boolean {
|
113
|
+
for (const authAccount of authAccounts) {
|
114
|
+
if (
|
115
|
+
authAccount.AuthAccount == null ||
|
116
|
+
typeof authAccount.AuthAccount !== 'object'
|
117
|
+
) {
|
118
|
+
throw new ValidationError(`AMMBid: invalid AuthAccounts`)
|
119
|
+
}
|
120
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- used for null check
|
121
|
+
// @ts-expect-error -- used for null check
|
122
|
+
if (authAccount.AuthAccount.Account == null) {
|
123
|
+
throw new ValidationError(`AMMBid: invalid AuthAccounts`)
|
124
|
+
}
|
125
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- used for null check
|
126
|
+
// @ts-expect-error -- used for null check
|
127
|
+
if (typeof authAccount.AuthAccount.Account !== 'string') {
|
128
|
+
throw new ValidationError(`AMMBid: invalid AuthAccounts`)
|
129
|
+
}
|
130
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- used for null check
|
131
|
+
// @ts-expect-error -- used for null check
|
132
|
+
if (authAccount.AuthAccount.Account === senderAddress) {
|
133
|
+
throw new ValidationError(
|
134
|
+
`AMMBid: AuthAccounts must not include sender's address`,
|
135
|
+
)
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
return true
|
140
|
+
}
|
@@ -0,0 +1,80 @@
|
|
1
|
+
import { ValidationError } from '../../errors'
|
2
|
+
import { Amount } from '../common'
|
3
|
+
|
4
|
+
import { BaseTransaction, isAmount, validateBaseTransaction } from './common'
|
5
|
+
|
6
|
+
export const AMM_MAX_TRADING_FEE = 1000
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Create a new Automated Market Maker (AMM) instance for trading a pair of assets (fungible tokens or XRP).
|
10
|
+
*
|
11
|
+
* Creates both an AMM object and a special AccountRoot object to represent the AMM.
|
12
|
+
* Also transfers ownership of the starting balance of both assets from the sender to the created AccountRoot
|
13
|
+
* and issues an initial balance of liquidity provider tokens (LP Tokens) from the AMM account to the sender.
|
14
|
+
*
|
15
|
+
* CAUTION: When you create the AMM, you should fund it with (approximately) equal-value amounts of each asset.
|
16
|
+
* Otherwise, other users can profit at your expense by trading with this AMM (performing arbitrage).
|
17
|
+
* The currency risk that liquidity providers take on increases with the volatility (potential for imbalance) of the asset pair.
|
18
|
+
* The higher the trading fee, the more it offsets this risk,
|
19
|
+
* so it's best to set the trading fee based on the volatility of the asset pair.
|
20
|
+
*/
|
21
|
+
export interface AMMCreate extends BaseTransaction {
|
22
|
+
TransactionType: 'AMMCreate'
|
23
|
+
|
24
|
+
/**
|
25
|
+
* The first of the two assets to fund this AMM with. This must be a positive amount.
|
26
|
+
*/
|
27
|
+
Amount: Amount
|
28
|
+
|
29
|
+
/**
|
30
|
+
* The second of the two assets to fund this AMM with. This must be a positive amount.
|
31
|
+
*/
|
32
|
+
Amount2: Amount
|
33
|
+
|
34
|
+
/**
|
35
|
+
* The fee to charge for trades against this AMM instance, in units of 1/100,000; a value of 1 is equivalent to 0.001%.
|
36
|
+
* The maximum value is 1000, indicating a 1% fee.
|
37
|
+
* The minimum value is 0.
|
38
|
+
*/
|
39
|
+
TradingFee: number
|
40
|
+
}
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Verify the form and type of an AMMCreate at runtime.
|
44
|
+
*
|
45
|
+
* @param tx - An AMMCreate Transaction.
|
46
|
+
* @throws When the AMMCreate is Malformed.
|
47
|
+
*/
|
48
|
+
export function validateAMMCreate(tx: Record<string, unknown>): void {
|
49
|
+
validateBaseTransaction(tx)
|
50
|
+
|
51
|
+
if (tx.Amount == null) {
|
52
|
+
throw new ValidationError('AMMCreate: missing field Amount')
|
53
|
+
}
|
54
|
+
|
55
|
+
if (!isAmount(tx.Amount)) {
|
56
|
+
throw new ValidationError('AMMCreate: Amount must be an Amount')
|
57
|
+
}
|
58
|
+
|
59
|
+
if (tx.Amount2 == null) {
|
60
|
+
throw new ValidationError('AMMCreate: missing field Amount2')
|
61
|
+
}
|
62
|
+
|
63
|
+
if (!isAmount(tx.Amount2)) {
|
64
|
+
throw new ValidationError('AMMCreate: Amount2 must be an Amount')
|
65
|
+
}
|
66
|
+
|
67
|
+
if (tx.TradingFee == null) {
|
68
|
+
throw new ValidationError('AMMCreate: missing field TradingFee')
|
69
|
+
}
|
70
|
+
|
71
|
+
if (typeof tx.TradingFee !== 'number') {
|
72
|
+
throw new ValidationError('AMMCreate: TradingFee must be a number')
|
73
|
+
}
|
74
|
+
|
75
|
+
if (tx.TradingFee < 0 || tx.TradingFee > AMM_MAX_TRADING_FEE) {
|
76
|
+
throw new ValidationError(
|
77
|
+
`AMMCreate: TradingFee must be between 0 and ${AMM_MAX_TRADING_FEE}`,
|
78
|
+
)
|
79
|
+
}
|
80
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import { ValidationError } from '../../errors'
|
2
|
+
import { Currency } from '../common'
|
3
|
+
|
4
|
+
import { BaseTransaction, isCurrency, validateBaseTransaction } from './common'
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Delete an empty Automated Market Maker (AMM) instance that could not be fully deleted automatically.
|
8
|
+
*
|
9
|
+
* Tip: The AMMWithdraw transaction automatically tries to delete an AMM, along with associated ledger
|
10
|
+
* entries such as empty trust lines, if it withdrew all the assets from the AMM's pool.
|
11
|
+
* However, if there are too many trust lines to the AMM account to remove in one transaction,
|
12
|
+
* it may stop before fully removing the AMM. Similarly, an AMMDelete transaction removes up to
|
13
|
+
* a maximum number of trust lines; in extreme cases, it may take several AMMDelete transactions
|
14
|
+
* to fully delete the trust lines and the associated AMM.
|
15
|
+
* In all cases, the AMM ledger entry and AMM account are deleted by the last such transaction.
|
16
|
+
*/
|
17
|
+
export interface AMMDelete extends BaseTransaction {
|
18
|
+
TransactionType: 'AMMDelete'
|
19
|
+
|
20
|
+
/**
|
21
|
+
* The definition for one of the assets in the AMM's pool.
|
22
|
+
*/
|
23
|
+
Asset: Currency
|
24
|
+
|
25
|
+
/**
|
26
|
+
* The definition for the other asset in the AMM's pool.
|
27
|
+
*/
|
28
|
+
Asset2: Currency
|
29
|
+
}
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Verify the form and type of an AMMDelete at runtime.
|
33
|
+
*
|
34
|
+
* @param tx - An AMMDelete Transaction.
|
35
|
+
* @throws When the AMMDelete is Malformed.
|
36
|
+
*/
|
37
|
+
export function validateAMMDelete(tx: Record<string, unknown>): void {
|
38
|
+
validateBaseTransaction(tx)
|
39
|
+
|
40
|
+
if (tx.Asset == null) {
|
41
|
+
throw new ValidationError('AMMDelete: missing field Asset')
|
42
|
+
}
|
43
|
+
|
44
|
+
if (!isCurrency(tx.Asset)) {
|
45
|
+
throw new ValidationError('AMMDelete: Asset must be a Currency')
|
46
|
+
}
|
47
|
+
|
48
|
+
if (tx.Asset2 == null) {
|
49
|
+
throw new ValidationError('AMMDelete: missing field Asset2')
|
50
|
+
}
|
51
|
+
|
52
|
+
if (!isCurrency(tx.Asset2)) {
|
53
|
+
throw new ValidationError('AMMDelete: Asset2 must be a Currency')
|
54
|
+
}
|
55
|
+
}
|
@@ -0,0 +1,130 @@
|
|
1
|
+
/* eslint-disable complexity -- required for validateAMMDeposit */
|
2
|
+
import { ValidationError } from '../../errors'
|
3
|
+
import { Amount, Currency, IssuedCurrencyAmount } from '../common'
|
4
|
+
|
5
|
+
import {
|
6
|
+
BaseTransaction,
|
7
|
+
GlobalFlags,
|
8
|
+
isAmount,
|
9
|
+
isCurrency,
|
10
|
+
isIssuedCurrency,
|
11
|
+
validateBaseTransaction,
|
12
|
+
} from './common'
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Enum representing values for AMMDeposit Transaction Flags.
|
16
|
+
*
|
17
|
+
* @category Transaction Flags
|
18
|
+
*/
|
19
|
+
export enum AMMDepositFlags {
|
20
|
+
tfLPToken = 0x00010000,
|
21
|
+
tfSingleAsset = 0x00080000,
|
22
|
+
tfTwoAsset = 0x00100000,
|
23
|
+
tfOneAssetLPToken = 0x00200000,
|
24
|
+
tfLimitLPToken = 0x00400000,
|
25
|
+
}
|
26
|
+
|
27
|
+
export interface AMMDepositFlagsInterface extends GlobalFlags {
|
28
|
+
tfLPToken?: boolean
|
29
|
+
tfSingleAsset?: boolean
|
30
|
+
tfTwoAsset?: boolean
|
31
|
+
tfOneAssetLPToken?: boolean
|
32
|
+
tfLimitLPToken?: boolean
|
33
|
+
}
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Deposit funds into an Automated Market Maker (AMM) instance
|
37
|
+
* and receive the AMM's liquidity provider tokens (LP Tokens) in exchange.
|
38
|
+
*
|
39
|
+
* You can deposit one or both of the assets in the AMM's pool.
|
40
|
+
* If successful, this transaction creates a trust line to the AMM Account (limit 0) to hold the LP Tokens.
|
41
|
+
*/
|
42
|
+
export interface AMMDeposit extends BaseTransaction {
|
43
|
+
TransactionType: 'AMMDeposit'
|
44
|
+
|
45
|
+
/**
|
46
|
+
* The definition for one of the assets in the AMM's pool.
|
47
|
+
*/
|
48
|
+
Asset: Currency
|
49
|
+
|
50
|
+
/**
|
51
|
+
* The definition for the other asset in the AMM's pool.
|
52
|
+
*/
|
53
|
+
Asset2: Currency
|
54
|
+
|
55
|
+
/**
|
56
|
+
* The amount of one asset to deposit to the AMM.
|
57
|
+
* If present, this must match the type of one of the assets (tokens or XRP) in the AMM's pool.
|
58
|
+
*/
|
59
|
+
Amount?: Amount
|
60
|
+
|
61
|
+
/**
|
62
|
+
* The amount of another asset to add to the AMM.
|
63
|
+
* If present, this must match the type of the other asset in the AMM's pool and cannot be the same asset as Amount.
|
64
|
+
*/
|
65
|
+
Amount2?: Amount
|
66
|
+
|
67
|
+
/**
|
68
|
+
* The maximum effective price, in the deposit asset, to pay for each LP Token received.
|
69
|
+
*/
|
70
|
+
EPrice?: Amount
|
71
|
+
|
72
|
+
/**
|
73
|
+
* How many of the AMM's LP Tokens to buy.
|
74
|
+
*/
|
75
|
+
LPTokenOut?: IssuedCurrencyAmount
|
76
|
+
}
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Verify the form and type of an AMMDeposit at runtime.
|
80
|
+
*
|
81
|
+
* @param tx - An AMMDeposit Transaction.
|
82
|
+
* @throws When the AMMDeposit is Malformed.
|
83
|
+
*/
|
84
|
+
export function validateAMMDeposit(tx: Record<string, unknown>): void {
|
85
|
+
validateBaseTransaction(tx)
|
86
|
+
|
87
|
+
if (tx.Asset == null) {
|
88
|
+
throw new ValidationError('AMMDeposit: missing field Asset')
|
89
|
+
}
|
90
|
+
|
91
|
+
if (!isCurrency(tx.Asset)) {
|
92
|
+
throw new ValidationError('AMMDeposit: Asset must be a Currency')
|
93
|
+
}
|
94
|
+
|
95
|
+
if (tx.Asset2 == null) {
|
96
|
+
throw new ValidationError('AMMDeposit: missing field Asset2')
|
97
|
+
}
|
98
|
+
|
99
|
+
if (!isCurrency(tx.Asset2)) {
|
100
|
+
throw new ValidationError('AMMDeposit: Asset2 must be a Currency')
|
101
|
+
}
|
102
|
+
|
103
|
+
if (tx.Amount2 != null && tx.Amount == null) {
|
104
|
+
throw new ValidationError('AMMDeposit: must set Amount with Amount2')
|
105
|
+
} else if (tx.EPrice != null && tx.Amount == null) {
|
106
|
+
throw new ValidationError('AMMDeposit: must set Amount with EPrice')
|
107
|
+
} else if (tx.LPTokenOut == null && tx.Amount == null) {
|
108
|
+
throw new ValidationError(
|
109
|
+
'AMMDeposit: must set at least LPTokenOut or Amount',
|
110
|
+
)
|
111
|
+
}
|
112
|
+
|
113
|
+
if (tx.LPTokenOut != null && !isIssuedCurrency(tx.LPTokenOut)) {
|
114
|
+
throw new ValidationError(
|
115
|
+
'AMMDeposit: LPTokenOut must be an IssuedCurrencyAmount',
|
116
|
+
)
|
117
|
+
}
|
118
|
+
|
119
|
+
if (tx.Amount != null && !isAmount(tx.Amount)) {
|
120
|
+
throw new ValidationError('AMMDeposit: Amount must be an Amount')
|
121
|
+
}
|
122
|
+
|
123
|
+
if (tx.Amount2 != null && !isAmount(tx.Amount2)) {
|
124
|
+
throw new ValidationError('AMMDeposit: Amount2 must be an Amount')
|
125
|
+
}
|
126
|
+
|
127
|
+
if (tx.EPrice != null && !isAmount(tx.EPrice)) {
|
128
|
+
throw new ValidationError('AMMDeposit: EPrice must be an Amount')
|
129
|
+
}
|
130
|
+
}
|
@@ -0,0 +1,71 @@
|
|
1
|
+
import { ValidationError } from '../../errors'
|
2
|
+
import { Currency } from '../common'
|
3
|
+
|
4
|
+
import { AMM_MAX_TRADING_FEE } from './AMMCreate'
|
5
|
+
import { BaseTransaction, isCurrency, validateBaseTransaction } from './common'
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Vote on the trading fee for an Automated Market Maker (AMM) instance.
|
9
|
+
*
|
10
|
+
* Up to 8 accounts can vote in proportion to the amount of the AMM's LP Tokens they hold.
|
11
|
+
* Each new vote re-calculates the AMM's trading fee based on a weighted average of the votes.
|
12
|
+
*/
|
13
|
+
export interface AMMVote extends BaseTransaction {
|
14
|
+
TransactionType: 'AMMVote'
|
15
|
+
|
16
|
+
/**
|
17
|
+
* The definition for one of the assets in the AMM's pool.
|
18
|
+
*/
|
19
|
+
Asset: Currency
|
20
|
+
|
21
|
+
/**
|
22
|
+
* The definition for the other asset in the AMM's pool.
|
23
|
+
*/
|
24
|
+
Asset2: Currency
|
25
|
+
|
26
|
+
/**
|
27
|
+
* The proposed fee to vote for, in units of 1/100,000; a value of 1 is equivalent to 0.001%.
|
28
|
+
* The maximum value is 1000, indicating a 1% fee.
|
29
|
+
*/
|
30
|
+
TradingFee: number
|
31
|
+
}
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Verify the form and type of an AMMVote at runtime.
|
35
|
+
*
|
36
|
+
* @param tx - An AMMVote Transaction.
|
37
|
+
* @throws When the AMMVote is Malformed.
|
38
|
+
*/
|
39
|
+
export function validateAMMVote(tx: Record<string, unknown>): void {
|
40
|
+
validateBaseTransaction(tx)
|
41
|
+
|
42
|
+
if (tx.Asset == null) {
|
43
|
+
throw new ValidationError('AMMVote: missing field Asset')
|
44
|
+
}
|
45
|
+
|
46
|
+
if (!isCurrency(tx.Asset)) {
|
47
|
+
throw new ValidationError('AMMVote: Asset must be a Currency')
|
48
|
+
}
|
49
|
+
|
50
|
+
if (tx.Asset2 == null) {
|
51
|
+
throw new ValidationError('AMMVote: missing field Asset2')
|
52
|
+
}
|
53
|
+
|
54
|
+
if (!isCurrency(tx.Asset2)) {
|
55
|
+
throw new ValidationError('AMMVote: Asset2 must be a Currency')
|
56
|
+
}
|
57
|
+
|
58
|
+
if (tx.TradingFee == null) {
|
59
|
+
throw new ValidationError('AMMVote: missing field TradingFee')
|
60
|
+
}
|
61
|
+
|
62
|
+
if (typeof tx.TradingFee !== 'number') {
|
63
|
+
throw new ValidationError('AMMVote: TradingFee must be a number')
|
64
|
+
}
|
65
|
+
|
66
|
+
if (tx.TradingFee < 0 || tx.TradingFee > AMM_MAX_TRADING_FEE) {
|
67
|
+
throw new ValidationError(
|
68
|
+
`AMMVote: TradingFee must be between 0 and ${AMM_MAX_TRADING_FEE}`,
|
69
|
+
)
|
70
|
+
}
|
71
|
+
}
|
@@ -0,0 +1,126 @@
|
|
1
|
+
/* eslint-disable complexity -- required for validateAMMWithdraw */
|
2
|
+
import { ValidationError } from '../../errors'
|
3
|
+
import { Amount, Currency, IssuedCurrencyAmount } from '../common'
|
4
|
+
|
5
|
+
import {
|
6
|
+
BaseTransaction,
|
7
|
+
GlobalFlags,
|
8
|
+
isAmount,
|
9
|
+
isCurrency,
|
10
|
+
isIssuedCurrency,
|
11
|
+
validateBaseTransaction,
|
12
|
+
} from './common'
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Enum representing values for AMMWithdrawFlags Transaction Flags.
|
16
|
+
*
|
17
|
+
* @category Transaction Flags
|
18
|
+
*/
|
19
|
+
export enum AMMWithdrawFlags {
|
20
|
+
tfLPToken = 0x00010000,
|
21
|
+
tfWithdrawAll = 0x00020000,
|
22
|
+
tfOneAssetWithdrawAll = 0x00040000,
|
23
|
+
tfSingleAsset = 0x00080000,
|
24
|
+
tfTwoAsset = 0x00100000,
|
25
|
+
tfOneAssetLPToken = 0x00200000,
|
26
|
+
tfLimitLPToken = 0x00400000,
|
27
|
+
}
|
28
|
+
|
29
|
+
export interface AMMWithdrawFlagsInterface extends GlobalFlags {
|
30
|
+
tfLPToken?: boolean
|
31
|
+
tfWithdrawAll?: boolean
|
32
|
+
tfOneAssetWithdrawAll?: boolean
|
33
|
+
tfSingleAsset?: boolean
|
34
|
+
tfTwoAsset?: boolean
|
35
|
+
tfOneAssetLPToken?: boolean
|
36
|
+
tfLimitLPToken?: boolean
|
37
|
+
}
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Withdraw assets from an Automated Market Maker (AMM) instance by returning the AMM's liquidity provider tokens (LP Tokens).
|
41
|
+
*/
|
42
|
+
export interface AMMWithdraw extends BaseTransaction {
|
43
|
+
TransactionType: 'AMMWithdraw'
|
44
|
+
|
45
|
+
/**
|
46
|
+
* The definition for one of the assets in the AMM's pool.
|
47
|
+
*/
|
48
|
+
Asset: Currency
|
49
|
+
|
50
|
+
/**
|
51
|
+
* The definition for the other asset in the AMM's pool.
|
52
|
+
*/
|
53
|
+
Asset2: Currency
|
54
|
+
|
55
|
+
/**
|
56
|
+
* The amount of one asset to withdraw from the AMM.
|
57
|
+
* This must match the type of one of the assets (tokens or XRP) in the AMM's pool.
|
58
|
+
*/
|
59
|
+
Amount?: Amount
|
60
|
+
|
61
|
+
/**
|
62
|
+
* The amount of another asset to withdraw from the AMM.
|
63
|
+
* If present, this must match the type of the other asset in the AMM's pool and cannot be the same type as Amount.
|
64
|
+
*/
|
65
|
+
Amount2?: Amount
|
66
|
+
|
67
|
+
/**
|
68
|
+
* The minimum effective price, in LP Token returned, to pay per unit of the asset to withdraw.
|
69
|
+
*/
|
70
|
+
EPrice?: Amount
|
71
|
+
|
72
|
+
/**
|
73
|
+
* How many of the AMM's LP Tokens to redeem.
|
74
|
+
*/
|
75
|
+
LPTokenIn?: IssuedCurrencyAmount
|
76
|
+
}
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Verify the form and type of an AMMWithdraw at runtime.
|
80
|
+
*
|
81
|
+
* @param tx - An AMMWithdraw Transaction.
|
82
|
+
* @throws When the AMMWithdraw is Malformed.
|
83
|
+
*/
|
84
|
+
export function validateAMMWithdraw(tx: Record<string, unknown>): void {
|
85
|
+
validateBaseTransaction(tx)
|
86
|
+
|
87
|
+
if (tx.Asset == null) {
|
88
|
+
throw new ValidationError('AMMWithdraw: missing field Asset')
|
89
|
+
}
|
90
|
+
|
91
|
+
if (!isCurrency(tx.Asset)) {
|
92
|
+
throw new ValidationError('AMMWithdraw: Asset must be a Currency')
|
93
|
+
}
|
94
|
+
|
95
|
+
if (tx.Asset2 == null) {
|
96
|
+
throw new ValidationError('AMMWithdraw: missing field Asset2')
|
97
|
+
}
|
98
|
+
|
99
|
+
if (!isCurrency(tx.Asset2)) {
|
100
|
+
throw new ValidationError('AMMWithdraw: Asset2 must be a Currency')
|
101
|
+
}
|
102
|
+
|
103
|
+
if (tx.Amount2 != null && tx.Amount == null) {
|
104
|
+
throw new ValidationError('AMMWithdraw: must set Amount with Amount2')
|
105
|
+
} else if (tx.EPrice != null && tx.Amount == null) {
|
106
|
+
throw new ValidationError('AMMWithdraw: must set Amount with EPrice')
|
107
|
+
}
|
108
|
+
|
109
|
+
if (tx.LPTokenIn != null && !isIssuedCurrency(tx.LPTokenIn)) {
|
110
|
+
throw new ValidationError(
|
111
|
+
'AMMWithdraw: LPTokenIn must be an IssuedCurrencyAmount',
|
112
|
+
)
|
113
|
+
}
|
114
|
+
|
115
|
+
if (tx.Amount != null && !isAmount(tx.Amount)) {
|
116
|
+
throw new ValidationError('AMMWithdraw: Amount must be an Amount')
|
117
|
+
}
|
118
|
+
|
119
|
+
if (tx.Amount2 != null && !isAmount(tx.Amount2)) {
|
120
|
+
throw new ValidationError('AMMWithdraw: Amount2 must be an Amount')
|
121
|
+
}
|
122
|
+
|
123
|
+
if (tx.EPrice != null && !isAmount(tx.EPrice)) {
|
124
|
+
throw new ValidationError('AMMWithdraw: EPrice must be an Amount')
|
125
|
+
}
|
126
|
+
}
|