mirror of
https://github.com/Xahau/xahau.js.git
synced 2026-04-29 15:37:50 +00:00
API name changes with updated definitions.json
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
"UInt192": 21,
|
||||
"UInt384": 22,
|
||||
"UInt512": 23,
|
||||
"Issue": 24,
|
||||
"Transaction": 10001,
|
||||
"LedgerEntry": 10002,
|
||||
"Validation": 10003,
|
||||
@@ -773,7 +774,7 @@
|
||||
}
|
||||
],
|
||||
[
|
||||
"FeeVal",
|
||||
"VoteWeight",
|
||||
{
|
||||
"nth": 47,
|
||||
"isVLEncoded": false,
|
||||
@@ -782,30 +783,10 @@
|
||||
"type": "UInt32"
|
||||
}
|
||||
],
|
||||
[
|
||||
"VoteWeight",
|
||||
{
|
||||
"nth": 48,
|
||||
"isVLEncoded": false,
|
||||
"isSerialized": true,
|
||||
"isSigningField": true,
|
||||
"type": "UInt32"
|
||||
}
|
||||
],
|
||||
[
|
||||
"TimeStamp",
|
||||
{
|
||||
"nth": 49,
|
||||
"isVLEncoded": false,
|
||||
"isSerialized": true,
|
||||
"isSigningField": true,
|
||||
"type": "UInt32"
|
||||
}
|
||||
],
|
||||
[
|
||||
"DiscountedFee",
|
||||
{
|
||||
"nth": 50,
|
||||
"nth": 48,
|
||||
"isVLEncoded": false,
|
||||
"isSerialized": true,
|
||||
"isSigningField": true,
|
||||
@@ -1463,7 +1444,7 @@
|
||||
}
|
||||
],
|
||||
[
|
||||
"Asset1",
|
||||
"Amount2",
|
||||
{
|
||||
"nth": 11,
|
||||
"isVLEncoded": false,
|
||||
@@ -1473,7 +1454,7 @@
|
||||
}
|
||||
],
|
||||
[
|
||||
"Asset2",
|
||||
"MinBidPrice",
|
||||
{
|
||||
"nth": 12,
|
||||
"isVLEncoded": false,
|
||||
@@ -1483,7 +1464,7 @@
|
||||
}
|
||||
],
|
||||
[
|
||||
"MinSlotPrice",
|
||||
"MaxBidPrice",
|
||||
{
|
||||
"nth": 13,
|
||||
"isVLEncoded": false,
|
||||
@@ -1492,16 +1473,6 @@
|
||||
"type": "Amount"
|
||||
}
|
||||
],
|
||||
[
|
||||
"MaxSlotPrice",
|
||||
{
|
||||
"nth": 14,
|
||||
"isVLEncoded": false,
|
||||
"isSerialized": true,
|
||||
"isSigningField": true,
|
||||
"type": "Amount"
|
||||
}
|
||||
],
|
||||
[
|
||||
"MinimumOffer",
|
||||
{
|
||||
@@ -1543,7 +1514,7 @@
|
||||
}
|
||||
],
|
||||
[
|
||||
"Asset1In",
|
||||
"LPTokenOut",
|
||||
{
|
||||
"nth": 20,
|
||||
"isVLEncoded": false,
|
||||
@@ -1553,7 +1524,7 @@
|
||||
}
|
||||
],
|
||||
[
|
||||
"Asset2In",
|
||||
"LPTokenIn",
|
||||
{
|
||||
"nth": 21,
|
||||
"isVLEncoded": false,
|
||||
@@ -1563,7 +1534,7 @@
|
||||
}
|
||||
],
|
||||
[
|
||||
"Asset1Out",
|
||||
"EPrice",
|
||||
{
|
||||
"nth": 22,
|
||||
"isVLEncoded": false,
|
||||
@@ -1573,7 +1544,7 @@
|
||||
}
|
||||
],
|
||||
[
|
||||
"Asset2Out",
|
||||
"Price",
|
||||
{
|
||||
"nth": 23,
|
||||
"isVLEncoded": false,
|
||||
@@ -1582,40 +1553,10 @@
|
||||
"type": "Amount"
|
||||
}
|
||||
],
|
||||
[
|
||||
"LPToken",
|
||||
{
|
||||
"nth": 24,
|
||||
"isVLEncoded": false,
|
||||
"isSerialized": true,
|
||||
"isSigningField": true,
|
||||
"type": "Amount"
|
||||
}
|
||||
],
|
||||
[
|
||||
"EPrice",
|
||||
{
|
||||
"nth": 25,
|
||||
"isVLEncoded": false,
|
||||
"isSerialized": true,
|
||||
"isSigningField": true,
|
||||
"type": "Amount"
|
||||
}
|
||||
],
|
||||
[
|
||||
"Price",
|
||||
{
|
||||
"nth": 26,
|
||||
"isVLEncoded": false,
|
||||
"isSerialized": true,
|
||||
"isSigningField": true,
|
||||
"type": "Amount"
|
||||
}
|
||||
],
|
||||
[
|
||||
"LPTokenBalance",
|
||||
{
|
||||
"nth": 27,
|
||||
"nth": 24,
|
||||
"isVLEncoded": false,
|
||||
"isSerialized": true,
|
||||
"isSigningField": true,
|
||||
@@ -2022,6 +1963,26 @@
|
||||
"type": "PathSet"
|
||||
}
|
||||
],
|
||||
[
|
||||
"Asset",
|
||||
{
|
||||
"nth": 1,
|
||||
"isVLEncoded": false,
|
||||
"isSerialized": true,
|
||||
"isSigningField": true,
|
||||
"type": "Issue"
|
||||
}
|
||||
],
|
||||
[
|
||||
"Asset2",
|
||||
{
|
||||
"nth": 2,
|
||||
"isVLEncoded": false,
|
||||
"isSerialized": true,
|
||||
"isSigningField": true,
|
||||
"type": "Issue"
|
||||
}
|
||||
],
|
||||
[
|
||||
"TransactionMetaData",
|
||||
{
|
||||
@@ -2152,16 +2113,6 @@
|
||||
"type": "STObject"
|
||||
}
|
||||
],
|
||||
[
|
||||
"AMM",
|
||||
{
|
||||
"nth": 15,
|
||||
"isVLEncoded": false,
|
||||
"isSerialized": true,
|
||||
"isSigningField": true,
|
||||
"type": "STObject"
|
||||
}
|
||||
],
|
||||
[
|
||||
"Signer",
|
||||
{
|
||||
@@ -2272,36 +2223,6 @@
|
||||
"type": "STObject"
|
||||
}
|
||||
],
|
||||
[
|
||||
"AMMToken",
|
||||
{
|
||||
"nth": 29,
|
||||
"isVLEncoded": false,
|
||||
"isSerialized": true,
|
||||
"isSigningField": true,
|
||||
"type": "STObject"
|
||||
}
|
||||
],
|
||||
[
|
||||
"Token1",
|
||||
{
|
||||
"nth": 30,
|
||||
"isVLEncoded": false,
|
||||
"isSerialized": true,
|
||||
"isSigningField": true,
|
||||
"type": "STObject"
|
||||
}
|
||||
],
|
||||
[
|
||||
"Token2",
|
||||
{
|
||||
"nth": 31,
|
||||
"isVLEncoded": false,
|
||||
"isSerialized": true,
|
||||
"isSigningField": true,
|
||||
"type": "STObject"
|
||||
}
|
||||
],
|
||||
[
|
||||
"Signers",
|
||||
{
|
||||
@@ -2553,6 +2474,7 @@
|
||||
"terNO_RIPPLE": -90,
|
||||
"terQUEUED": -89,
|
||||
"terPRE_TICKET": -88,
|
||||
"terNO_AMM": -87,
|
||||
|
||||
"tesSUCCESS": 0,
|
||||
|
||||
@@ -2609,8 +2531,7 @@
|
||||
"tecAMM_INVALID_TOKENS": 166,
|
||||
"tecAMM_EXISTS": 167,
|
||||
"tecAMM_FAILED_BID": 168,
|
||||
"tecAMM_DIRECT_PAYMENT": 169,
|
||||
"tecAMM_FAILED_VOTE": 170
|
||||
"tecAMM_FAILED_VOTE": 169
|
||||
},
|
||||
"TRANSACTION_TYPES": {
|
||||
"Invalid": -1,
|
||||
@@ -2642,7 +2563,7 @@
|
||||
"NFTokenCreateOffer": 27,
|
||||
"NFTokenCancelOffer": 28,
|
||||
"NFTokenAcceptOffer": 29,
|
||||
"AMMInstanceCreate": 35,
|
||||
"AMMCreate": 35,
|
||||
"AMMDeposit": 36,
|
||||
"AMMWithdraw": 37,
|
||||
"AMMVote": 38,
|
||||
|
||||
@@ -27,17 +27,17 @@ export interface AMMBid extends BaseTransaction {
|
||||
|
||||
/**
|
||||
* This field represents the minimum price that the bidder wants to pay for the slot.
|
||||
* It is specified in units of LPToken. If specified let MinSlotPrice be X and let
|
||||
* It is specified in units of LPToken. If specified let MinBidPrice be X and let
|
||||
* the slot-price computed by price scheduling algorithm be Y, then bidder always pays
|
||||
* the max(X, Y).
|
||||
*/
|
||||
MinSlotPrice?: Amount
|
||||
MinBidPrice?: Amount
|
||||
|
||||
/**
|
||||
* This field represents the maximum price that the bidder wants to pay for the slot.
|
||||
* It is specified in units of LPToken.
|
||||
*/
|
||||
MaxSlotPrice?: Amount
|
||||
MaxBidPrice?: Amount
|
||||
|
||||
/**
|
||||
* This field represents an array of XRPL account IDs that are authorized to trade
|
||||
@@ -64,12 +64,12 @@ export function validateAMMBid(tx: Record<string, unknown>): void {
|
||||
throw new ValidationError('AMMBid: AMMID must be a string')
|
||||
}
|
||||
|
||||
if (tx.MinSlotPrice != null && !isAmount(tx.MinSlotPrice)) {
|
||||
throw new ValidationError('AMMBid: MinSlotPrice must be an Amount')
|
||||
if (tx.MinBidPrice != null && !isAmount(tx.MinBidPrice)) {
|
||||
throw new ValidationError('AMMBid: MinBidPrice must be an Amount')
|
||||
}
|
||||
|
||||
if (tx.MaxSlotPrice != null && !isAmount(tx.MaxSlotPrice)) {
|
||||
throw new ValidationError('AMMBid: MaxSlotPrice must be an Amount')
|
||||
if (tx.MaxBidPrice != null && !isAmount(tx.MaxBidPrice)) {
|
||||
throw new ValidationError('AMMBid: MaxBidPrice must be an Amount')
|
||||
}
|
||||
|
||||
if (tx.AuthAccounts != null) {
|
||||
|
||||
@@ -6,23 +6,23 @@ import { BaseTransaction, isAmount, validateBaseTransaction } from './common'
|
||||
export const AMM_MAX_TRADING_FEE = 65000
|
||||
|
||||
/**
|
||||
* AMMInstanceCreate is used to create AccountRoot and the corresponding
|
||||
* AMMCreate is used to create AccountRoot and the corresponding
|
||||
* AMM ledger entries.
|
||||
*
|
||||
* This allows for the creation of only one AMM instance per unique asset pair.
|
||||
*/
|
||||
export interface AMMInstanceCreate extends BaseTransaction {
|
||||
TransactionType: 'AMMInstanceCreate'
|
||||
export interface AMMCreate extends BaseTransaction {
|
||||
TransactionType: 'AMMCreate'
|
||||
|
||||
/**
|
||||
* Specifies one of the pool assets (XRP or token) of the AMM instance.
|
||||
*/
|
||||
Asset1: Amount
|
||||
Amount: Amount
|
||||
|
||||
/**
|
||||
* Specifies the other pool asset of the AMM instance.
|
||||
*/
|
||||
Asset2: Amount
|
||||
Amount2: Amount
|
||||
|
||||
/**
|
||||
* Specifies the fee, in basis point, to be charged
|
||||
@@ -36,41 +36,41 @@ export interface AMMInstanceCreate extends BaseTransaction {
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the form and type of an AMMInstanceCreate at runtime.
|
||||
* Verify the form and type of an AMMCreate at runtime.
|
||||
*
|
||||
* @param tx - An AMMInstanceCreate Transaction.
|
||||
* @throws When the AMMInstanceCreate is Malformed.
|
||||
* @param tx - An AMMCreate Transaction.
|
||||
* @throws When the AMMCreate is Malformed.
|
||||
*/
|
||||
export function validateAMMInstanceCreate(tx: Record<string, unknown>): void {
|
||||
export function validateAMMCreate(tx: Record<string, unknown>): void {
|
||||
validateBaseTransaction(tx)
|
||||
|
||||
if (tx.Asset1 == null) {
|
||||
throw new ValidationError('AMMInstanceCreate: missing field Asset1')
|
||||
if (tx.Amount == null) {
|
||||
throw new ValidationError('AMMCreate: missing field Amount')
|
||||
}
|
||||
|
||||
if (!isAmount(tx.Asset1)) {
|
||||
throw new ValidationError('AMMInstanceCreate: Asset1 must be an Amount')
|
||||
if (!isAmount(tx.Amount)) {
|
||||
throw new ValidationError('AMMCreate: Amount must be an Amount')
|
||||
}
|
||||
|
||||
if (tx.Asset2 == null) {
|
||||
throw new ValidationError('AMMInstanceCreate: missing field Asset2')
|
||||
if (tx.Amount2 == null) {
|
||||
throw new ValidationError('AMMCreate: missing field Amount2')
|
||||
}
|
||||
|
||||
if (!isAmount(tx.Asset2)) {
|
||||
throw new ValidationError('AMMInstanceCreate: Asset2 must be an Amount')
|
||||
if (!isAmount(tx.Amount2)) {
|
||||
throw new ValidationError('AMMCreate: Amount2 must be an Amount')
|
||||
}
|
||||
|
||||
if (tx.TradingFee == null) {
|
||||
throw new ValidationError('AMMInstanceCreate: missing field TradingFee')
|
||||
throw new ValidationError('AMMCreate: missing field TradingFee')
|
||||
}
|
||||
|
||||
if (typeof tx.TradingFee !== 'number') {
|
||||
throw new ValidationError('AMMInstanceCreate: TradingFee must be a number')
|
||||
throw new ValidationError('AMMCreate: TradingFee must be a number')
|
||||
}
|
||||
|
||||
if (tx.TradingFee < 0 || tx.TradingFee > AMM_MAX_TRADING_FEE) {
|
||||
throw new ValidationError(
|
||||
`AMMInstanceCreate: TradingFee must be between 0 and ${AMM_MAX_TRADING_FEE}`,
|
||||
`AMMCreate: TradingFee must be between 0 and ${AMM_MAX_TRADING_FEE}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -11,14 +11,14 @@ import {
|
||||
|
||||
/**
|
||||
* AMMDeposit is the deposit transaction used to add liquidity to the AMM instance pool,
|
||||
* thus obtaining some share of the instance's pools in the form of LPToken.
|
||||
* thus obtaining some share of the instance's pools in the form of LPTokenOut.
|
||||
*
|
||||
* The following are the recommended valid combinations:
|
||||
* - LPToken
|
||||
* - Asset1In
|
||||
* - Asset1In and Asset2In
|
||||
* - Asset1In and LPToken
|
||||
* - Asset1In and EPrice
|
||||
* - LPTokenOut
|
||||
* - Amount
|
||||
* - Amount and Amount2
|
||||
* - Amount and LPTokenOut
|
||||
* - Amount and EPrice
|
||||
*/
|
||||
export interface AMMDeposit extends BaseTransaction {
|
||||
TransactionType: 'AMMDeposit'
|
||||
@@ -32,22 +32,22 @@ export interface AMMDeposit extends BaseTransaction {
|
||||
* Specifies the amount of shares of the AMM instance pools that the trader
|
||||
* wants to redeem or trade in.
|
||||
*/
|
||||
LPToken?: IssuedCurrencyAmount
|
||||
LPTokenOut?: IssuedCurrencyAmount
|
||||
|
||||
/**
|
||||
* Specifies one of the pool assets (XRP or token) of the AMM instance to
|
||||
* deposit more of its value.
|
||||
*/
|
||||
Asset1In?: Amount
|
||||
Amount?: Amount
|
||||
|
||||
/**
|
||||
* Specifies the other pool asset of the AMM instance to deposit more of
|
||||
* its value.
|
||||
*/
|
||||
Asset2In?: Amount
|
||||
Amount2?: Amount
|
||||
|
||||
/**
|
||||
* Specifies the maximum effective-price that LPToken can be traded out.
|
||||
* Specifies the maximum effective-price that LPTokenOut can be traded out.
|
||||
*/
|
||||
EPrice?: Amount
|
||||
}
|
||||
@@ -69,28 +69,28 @@ export function validateAMMDeposit(tx: Record<string, unknown>): void {
|
||||
throw new ValidationError('AMMDeposit: AMMID must be a string')
|
||||
}
|
||||
|
||||
if (tx.Asset2In != null && tx.Asset1In == null) {
|
||||
throw new ValidationError('AMMDeposit: must set Asset1In with Asset2In')
|
||||
} else if (tx.EPrice != null && tx.Asset1In == null) {
|
||||
throw new ValidationError('AMMDeposit: must set Asset1In with EPrice')
|
||||
} else if (tx.LPToken == null && tx.Asset1In == null) {
|
||||
if (tx.Amount2 != null && tx.Amount == null) {
|
||||
throw new ValidationError('AMMDeposit: must set Amount with Amount2')
|
||||
} else if (tx.EPrice != null && tx.Amount == null) {
|
||||
throw new ValidationError('AMMDeposit: must set Amount with EPrice')
|
||||
} else if (tx.LPTokenOut == null && tx.Amount == null) {
|
||||
throw new ValidationError(
|
||||
'AMMDeposit: must set at least LPToken or Asset1In',
|
||||
'AMMDeposit: must set at least LPTokenOut or Amount',
|
||||
)
|
||||
}
|
||||
|
||||
if (tx.LPToken != null && !isIssuedCurrency(tx.LPToken)) {
|
||||
if (tx.LPTokenOut != null && !isIssuedCurrency(tx.LPTokenOut)) {
|
||||
throw new ValidationError(
|
||||
'AMMDeposit: LPToken must be an IssuedCurrencyAmount',
|
||||
'AMMDeposit: LPTokenOut must be an IssuedCurrencyAmount',
|
||||
)
|
||||
}
|
||||
|
||||
if (tx.Asset1In != null && !isAmount(tx.Asset1In)) {
|
||||
throw new ValidationError('AMMDeposit: Asset1In must be an Amount')
|
||||
if (tx.Amount != null && !isAmount(tx.Amount)) {
|
||||
throw new ValidationError('AMMDeposit: Amount must be an Amount')
|
||||
}
|
||||
|
||||
if (tx.Asset2In != null && !isAmount(tx.Asset2In)) {
|
||||
throw new ValidationError('AMMDeposit: Asset2In must be an Amount')
|
||||
if (tx.Amount2 != null && !isAmount(tx.Amount2)) {
|
||||
throw new ValidationError('AMMDeposit: Amount2 must be an Amount')
|
||||
}
|
||||
|
||||
if (tx.EPrice != null && !isAmount(tx.EPrice)) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ValidationError } from '../../errors'
|
||||
|
||||
import { AMM_MAX_TRADING_FEE } from './AMMInstanceCreate'
|
||||
import { AMM_MAX_TRADING_FEE } from './AMMCreate'
|
||||
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||
|
||||
/**
|
||||
@@ -23,7 +23,7 @@ export interface AMMVote extends BaseTransaction {
|
||||
* A value of 1 is equivalent to 1/10 bps or 0.001%, allowing trading fee
|
||||
* between 0% and 65%. This field is required.
|
||||
*/
|
||||
FeeVal: number
|
||||
TradingFee: number
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,17 +43,17 @@ export function validateAMMVote(tx: Record<string, unknown>): void {
|
||||
throw new ValidationError('AMMVote: AMMID must be a string')
|
||||
}
|
||||
|
||||
if (tx.FeeVal == null) {
|
||||
throw new ValidationError('AMMVote: missing field FeeVal')
|
||||
if (tx.TradingFee == null) {
|
||||
throw new ValidationError('AMMVote: missing field TradingFee')
|
||||
}
|
||||
|
||||
if (typeof tx.FeeVal !== 'number') {
|
||||
throw new ValidationError('AMMVote: FeeVal must be a number')
|
||||
if (typeof tx.TradingFee !== 'number') {
|
||||
throw new ValidationError('AMMVote: TradingFee must be a number')
|
||||
}
|
||||
|
||||
if (tx.FeeVal < 0 || tx.FeeVal > AMM_MAX_TRADING_FEE) {
|
||||
if (tx.TradingFee < 0 || tx.TradingFee > AMM_MAX_TRADING_FEE) {
|
||||
throw new ValidationError(
|
||||
`AMMVote: FeeVal must be between 0 and ${AMM_MAX_TRADING_FEE}`,
|
||||
`AMMVote: TradingFee must be between 0 and ${AMM_MAX_TRADING_FEE}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,14 +12,14 @@ import {
|
||||
/**
|
||||
* AMMWithdraw is the withdraw transaction used to remove liquidity from the AMM
|
||||
* instance pool, thus redeeming some share of the pools that one owns in the form
|
||||
* of LPToken.
|
||||
* of LPTokenIn.
|
||||
*
|
||||
* The following are the recommended valid combinations:
|
||||
* - LPToken
|
||||
* - Asset1Out
|
||||
* - Asset1Out and Asset2Out
|
||||
* - Asset1Out and LPToken
|
||||
* - Asset1Out and EPrice
|
||||
* - LPTokenIn
|
||||
* - Amount
|
||||
* - Amount and Amount2
|
||||
* - Amount and LPTokenIn
|
||||
* - Amount and EPrice
|
||||
*/
|
||||
export interface AMMWithdraw extends BaseTransaction {
|
||||
TransactionType: 'AMMWithdraw'
|
||||
@@ -33,19 +33,19 @@ export interface AMMWithdraw extends BaseTransaction {
|
||||
* Specifies the amount of shares of the AMM instance pools that the trader
|
||||
* wants to redeem or trade in.
|
||||
*/
|
||||
LPToken?: IssuedCurrencyAmount
|
||||
LPTokenIn?: IssuedCurrencyAmount
|
||||
|
||||
/**
|
||||
* Specifies one of the pools assets that the trader wants to remove.
|
||||
* If the asset is XRP, then the Asset1Out is a string specifying the number of drops.
|
||||
* If the asset is XRP, then the Amount is a string specifying the number of drops.
|
||||
* Otherwise it is an IssuedCurrencyAmount object.
|
||||
*/
|
||||
Asset1Out?: Amount
|
||||
Amount?: Amount
|
||||
|
||||
/**
|
||||
* Specifies the other pool asset that the trader wants to remove.
|
||||
*/
|
||||
Asset2Out?: Amount
|
||||
Amount2?: Amount
|
||||
|
||||
/**
|
||||
* Specifies the effective-price of the token out after successful execution of
|
||||
@@ -71,28 +71,28 @@ export function validateAMMWithdraw(tx: Record<string, unknown>): void {
|
||||
throw new ValidationError('AMMWithdraw: AMMID must be a string')
|
||||
}
|
||||
|
||||
if (tx.Asset2Out != null && tx.Asset1Out == null) {
|
||||
throw new ValidationError('AMMWithdraw: must set Asset1Out with Asset2Out')
|
||||
} else if (tx.EPrice != null && tx.Asset1Out == null) {
|
||||
throw new ValidationError('AMMWithdraw: must set Asset1Out with EPrice')
|
||||
} else if (tx.LPToken == null && tx.Asset1Out == null) {
|
||||
if (tx.Amount2 != null && tx.Amount == null) {
|
||||
throw new ValidationError('AMMWithdraw: must set Amount with Amount2')
|
||||
} else if (tx.EPrice != null && tx.Amount == null) {
|
||||
throw new ValidationError('AMMWithdraw: must set Amount with EPrice')
|
||||
} else if (tx.LPTokenIn == null && tx.Amount == null) {
|
||||
throw new ValidationError(
|
||||
'AMMWithdraw: must set at least LPToken or Asset1Out',
|
||||
'AMMWithdraw: must set at least LPTokenIn or Amount',
|
||||
)
|
||||
}
|
||||
|
||||
if (tx.LPToken != null && !isIssuedCurrency(tx.LPToken)) {
|
||||
if (tx.LPTokenIn != null && !isIssuedCurrency(tx.LPTokenIn)) {
|
||||
throw new ValidationError(
|
||||
'AMMWithdraw: LPToken must be an IssuedCurrencyAmount',
|
||||
'AMMWithdraw: LPTokenIn must be an IssuedCurrencyAmount',
|
||||
)
|
||||
}
|
||||
|
||||
if (tx.Asset1Out != null && !isAmount(tx.Asset1Out)) {
|
||||
throw new ValidationError('AMMWithdraw: Asset1Out must be an Amount')
|
||||
if (tx.Amount != null && !isAmount(tx.Amount)) {
|
||||
throw new ValidationError('AMMWithdraw: Amount must be an Amount')
|
||||
}
|
||||
|
||||
if (tx.Asset2Out != null && !isAmount(tx.Asset2Out)) {
|
||||
throw new ValidationError('AMMWithdraw: Asset2Out must be an Amount')
|
||||
if (tx.Amount2 != null && !isAmount(tx.Amount2)) {
|
||||
throw new ValidationError('AMMWithdraw: Amount2 must be an Amount')
|
||||
}
|
||||
|
||||
if (tx.EPrice != null && !isAmount(tx.EPrice)) {
|
||||
|
||||
@@ -9,7 +9,7 @@ export {
|
||||
export { AccountDelete } from './accountDelete'
|
||||
export { AMMBid } from './AMMBid'
|
||||
export { AMMDeposit } from './AMMDeposit'
|
||||
export { AMMInstanceCreate } from './AMMInstanceCreate'
|
||||
export { AMMCreate } from './AMMCreate'
|
||||
export { AMMVote } from './AMMVote'
|
||||
export { AMMWithdraw } from './AMMWithdraw'
|
||||
export { CheckCancel } from './checkCancel'
|
||||
|
||||
@@ -11,10 +11,7 @@ import { AccountDelete, validateAccountDelete } from './accountDelete'
|
||||
import { AccountSet, validateAccountSet } from './accountSet'
|
||||
import { AMMBid, validateAMMBid } from './AMMBid'
|
||||
import { AMMDeposit, validateAMMDeposit } from './AMMDeposit'
|
||||
import {
|
||||
AMMInstanceCreate,
|
||||
validateAMMInstanceCreate,
|
||||
} from './AMMInstanceCreate'
|
||||
import { AMMCreate, validateAMMCreate } from './AMMCreate'
|
||||
import { AMMVote, validateAMMVote } from './AMMVote'
|
||||
import { AMMWithdraw, validateAMMWithdraw } from './AMMWithdraw'
|
||||
import { CheckCancel, validateCheckCancel } from './checkCancel'
|
||||
@@ -67,7 +64,7 @@ export type Transaction =
|
||||
| AccountSet
|
||||
| AMMBid
|
||||
| AMMDeposit
|
||||
| AMMInstanceCreate
|
||||
| AMMCreate
|
||||
| AMMVote
|
||||
| AMMWithdraw
|
||||
| CheckCancel
|
||||
@@ -136,8 +133,8 @@ export function validate(transaction: Record<string, unknown>): void {
|
||||
validateAMMDeposit(tx)
|
||||
break
|
||||
|
||||
case 'AMMInstanceCreate':
|
||||
validateAMMInstanceCreate(tx)
|
||||
case 'AMMCreate':
|
||||
validateAMMCreate(tx)
|
||||
break
|
||||
|
||||
case 'AMMVote':
|
||||
|
||||
@@ -14,8 +14,8 @@ describe('AMMBid', function () {
|
||||
TransactionType: 'AMMBid',
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
AMMID: '24BA86F99302CF124AB27311C831F5BFAA72C4625DDA65B7EDF346A60CC19883',
|
||||
MinSlotPrice: '5',
|
||||
MaxSlotPrice: '10',
|
||||
MinBidPrice: '5',
|
||||
MaxBidPrice: '10',
|
||||
AuthAccounts: [
|
||||
{
|
||||
AuthAccount: {
|
||||
@@ -64,21 +64,21 @@ describe('AMMBid', function () {
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ MinSlotPrice must be an Amount`, function () {
|
||||
bid.MinSlotPrice = 5
|
||||
it(`throws w/ MinBidPrice must be an Amount`, function () {
|
||||
bid.MinBidPrice = 5
|
||||
assert.throws(
|
||||
() => validate(bid),
|
||||
ValidationError,
|
||||
'AMMBid: MinSlotPrice must be an Amount',
|
||||
'AMMBid: MinBidPrice must be an Amount',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ MaxSlotPrice must be an Amount`, function () {
|
||||
bid.MaxSlotPrice = 10
|
||||
it(`throws w/ MaxBidPrice must be an Amount`, function () {
|
||||
bid.MaxBidPrice = 10
|
||||
assert.throws(
|
||||
() => validate(bid),
|
||||
ValidationError,
|
||||
'AMMBid: MaxSlotPrice must be an Amount',
|
||||
'AMMBid: MaxBidPrice must be an Amount',
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
102
packages/xrpl/test/models/AMMCreate.ts
Normal file
102
packages/xrpl/test/models/AMMCreate.ts
Normal file
@@ -0,0 +1,102 @@
|
||||
import { assert } from 'chai'
|
||||
import { validate, ValidationError } from 'xrpl-local'
|
||||
|
||||
/**
|
||||
* AMMCreate Transaction Verification Testing.
|
||||
*
|
||||
* Providing runtime verification testing for each specific transaction type.
|
||||
*/
|
||||
describe('AMMCreate', function () {
|
||||
let ammCreate
|
||||
|
||||
beforeEach(function () {
|
||||
ammCreate = {
|
||||
TransactionType: 'AMMCreate',
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
Amount: '1000',
|
||||
Amount2: {
|
||||
currency: 'USD',
|
||||
issuer: 'rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9',
|
||||
value: '1000',
|
||||
},
|
||||
TradingFee: 12,
|
||||
Sequence: 1337,
|
||||
} as any
|
||||
})
|
||||
|
||||
it(`verifies valid AMMCreate`, function () {
|
||||
assert.doesNotThrow(() => validate(ammCreate))
|
||||
})
|
||||
|
||||
it(`throws w/ missing Amount`, function () {
|
||||
delete ammCreate.Amount
|
||||
assert.throws(
|
||||
() => validate(ammCreate),
|
||||
ValidationError,
|
||||
'AMMCreate: missing field Amount',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ Amount must be an Amount`, function () {
|
||||
ammCreate.Amount = 1000
|
||||
assert.throws(
|
||||
() => validate(ammCreate),
|
||||
ValidationError,
|
||||
'AMMCreate: Amount must be an Amount',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ missing Amount2`, function () {
|
||||
delete ammCreate.Amount2
|
||||
assert.throws(
|
||||
() => validate(ammCreate),
|
||||
ValidationError,
|
||||
'AMMCreate: missing field Amount2',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ Amount2 must be an Amount`, function () {
|
||||
ammCreate.Amount2 = 1000
|
||||
assert.throws(
|
||||
() => validate(ammCreate),
|
||||
ValidationError,
|
||||
'AMMCreate: Amount2 must be an Amount',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ missing TradingFee`, function () {
|
||||
delete ammCreate.TradingFee
|
||||
assert.throws(
|
||||
() => validate(ammCreate),
|
||||
ValidationError,
|
||||
'AMMCreate: missing field TradingFee',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ TradingFee must be a number`, function () {
|
||||
ammCreate.TradingFee = '12'
|
||||
assert.throws(
|
||||
() => validate(ammCreate),
|
||||
ValidationError,
|
||||
'AMMCreate: TradingFee must be a number',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws when TradingFee is greater than 65000`, function () {
|
||||
ammCreate.TradingFee = 65001
|
||||
assert.throws(
|
||||
() => validate(ammCreate),
|
||||
ValidationError,
|
||||
`AMMCreate: TradingFee must be between 0 and 65000`,
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws when TradingFee is a negative number`, function () {
|
||||
ammCreate.TradingFee = -1
|
||||
assert.throws(
|
||||
() => validate(ammCreate),
|
||||
ValidationError,
|
||||
`AMMCreate: TradingFee must be between 0 and 65000`,
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -7,7 +7,7 @@ import { validate, ValidationError } from 'xrpl-local'
|
||||
* Providing runtime verification testing for each specific transaction type.
|
||||
*/
|
||||
describe('AMMDeposit', function () {
|
||||
const LPToken = {
|
||||
const LPTokenOut = {
|
||||
currency: 'B3813FCAB4EE68B3D0D735D6849465A9113EE048',
|
||||
issuer: 'rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg',
|
||||
value: '1000',
|
||||
@@ -23,30 +23,30 @@ describe('AMMDeposit', function () {
|
||||
} as any
|
||||
})
|
||||
|
||||
it(`verifies valid AMMDeposit with LPToken`, function () {
|
||||
deposit.LPToken = LPToken
|
||||
it(`verifies valid AMMDeposit with LPTokenOut`, function () {
|
||||
deposit.LPTokenOut = LPTokenOut
|
||||
assert.doesNotThrow(() => validate(deposit))
|
||||
})
|
||||
|
||||
it(`verifies valid AMMDeposit with Asset1In`, function () {
|
||||
deposit.Asset1In = '1000'
|
||||
it(`verifies valid AMMDeposit with Amount`, function () {
|
||||
deposit.Amount = '1000'
|
||||
assert.doesNotThrow(() => validate(deposit))
|
||||
})
|
||||
|
||||
it(`verifies valid AMMDeposit with Asset1In and Asset2In`, function () {
|
||||
deposit.Asset1In = '1000'
|
||||
deposit.Asset2In = '1000'
|
||||
it(`verifies valid AMMDeposit with Amount and Amount2`, function () {
|
||||
deposit.Amount = '1000'
|
||||
deposit.Amount2 = '1000'
|
||||
assert.doesNotThrow(() => validate(deposit))
|
||||
})
|
||||
|
||||
it(`verifies valid AMMDeposit with Asset1In and LPToken`, function () {
|
||||
deposit.Asset1In = '1000'
|
||||
deposit.LPToken = LPToken
|
||||
it(`verifies valid AMMDeposit with Amount and LPTokenOut`, function () {
|
||||
deposit.Amount = '1000'
|
||||
deposit.LPTokenOut = LPTokenOut
|
||||
assert.doesNotThrow(() => validate(deposit))
|
||||
})
|
||||
|
||||
it(`verifies valid AMMDeposit with Asset1In and EPrice`, function () {
|
||||
deposit.Asset1In = '1000'
|
||||
it(`verifies valid AMMDeposit with Amount and EPrice`, function () {
|
||||
deposit.Amount = '1000'
|
||||
deposit.EPrice = '25'
|
||||
assert.doesNotThrow(() => validate(deposit))
|
||||
})
|
||||
@@ -69,62 +69,62 @@ describe('AMMDeposit', function () {
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ must set at least LPToken or Asset1In`, function () {
|
||||
it(`throws w/ must set at least LPTokenOut or Amount`, function () {
|
||||
assert.throws(
|
||||
() => validate(deposit),
|
||||
ValidationError,
|
||||
'AMMDeposit: must set at least LPToken or Asset1In',
|
||||
'AMMDeposit: must set at least LPTokenOut or Amount',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ must set Asset1In with Asset2In`, function () {
|
||||
deposit.Asset2In = '500'
|
||||
it(`throws w/ must set Amount with Amount2`, function () {
|
||||
deposit.Amount2 = '500'
|
||||
assert.throws(
|
||||
() => validate(deposit),
|
||||
ValidationError,
|
||||
'AMMDeposit: must set Asset1In with Asset2In',
|
||||
'AMMDeposit: must set Amount with Amount2',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ must set Asset1In with EPrice`, function () {
|
||||
it(`throws w/ must set Amount with EPrice`, function () {
|
||||
deposit.EPrice = '25'
|
||||
assert.throws(
|
||||
() => validate(deposit),
|
||||
ValidationError,
|
||||
'AMMDeposit: must set Asset1In with EPrice',
|
||||
'AMMDeposit: must set Amount with EPrice',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ LPToken must be an IssuedCurrencyAmount`, function () {
|
||||
deposit.LPToken = 1234
|
||||
it(`throws w/ LPTokenOut must be an IssuedCurrencyAmount`, function () {
|
||||
deposit.LPTokenOut = 1234
|
||||
assert.throws(
|
||||
() => validate(deposit),
|
||||
ValidationError,
|
||||
'AMMDeposit: LPToken must be an IssuedCurrencyAmount',
|
||||
'AMMDeposit: LPTokenOut must be an IssuedCurrencyAmount',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ Asset1In must be an Amount`, function () {
|
||||
deposit.Asset1In = 1234
|
||||
it(`throws w/ Amount must be an Amount`, function () {
|
||||
deposit.Amount = 1234
|
||||
assert.throws(
|
||||
() => validate(deposit),
|
||||
ValidationError,
|
||||
'AMMDeposit: Asset1In must be an Amount',
|
||||
'AMMDeposit: Amount must be an Amount',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ Asset2In must be an Amount`, function () {
|
||||
deposit.Asset1In = '1000'
|
||||
deposit.Asset2In = 1234
|
||||
it(`throws w/ Amount2 must be an Amount`, function () {
|
||||
deposit.Amount = '1000'
|
||||
deposit.Amount2 = 1234
|
||||
assert.throws(
|
||||
() => validate(deposit),
|
||||
ValidationError,
|
||||
'AMMDeposit: Asset2In must be an Amount',
|
||||
'AMMDeposit: Amount2 must be an Amount',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ EPrice must be an Amount`, function () {
|
||||
deposit.Asset1In = '1000'
|
||||
deposit.Amount = '1000'
|
||||
deposit.EPrice = 1234
|
||||
assert.throws(
|
||||
() => validate(deposit),
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
import { assert } from 'chai'
|
||||
import { validate, ValidationError } from 'xrpl-local'
|
||||
|
||||
/**
|
||||
* AMMInstanceCreate Transaction Verification Testing.
|
||||
*
|
||||
* Providing runtime verification testing for each specific transaction type.
|
||||
*/
|
||||
describe('AMMInstanceCreate', function () {
|
||||
let instanceCreate
|
||||
|
||||
beforeEach(function () {
|
||||
instanceCreate = {
|
||||
TransactionType: 'AMMInstanceCreate',
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
Asset1: '1000',
|
||||
Asset2: {
|
||||
currency: 'USD',
|
||||
issuer: 'rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9',
|
||||
value: '1000',
|
||||
},
|
||||
TradingFee: 12,
|
||||
Sequence: 1337,
|
||||
} as any
|
||||
})
|
||||
|
||||
it(`verifies valid AMMInstanceCreate`, function () {
|
||||
assert.doesNotThrow(() => validate(instanceCreate))
|
||||
})
|
||||
|
||||
it(`throws w/ missing Asset1`, function () {
|
||||
delete instanceCreate.Asset1
|
||||
assert.throws(
|
||||
() => validate(instanceCreate),
|
||||
ValidationError,
|
||||
'AMMInstanceCreate: missing field Asset1',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ Asset1 must be an Amount`, function () {
|
||||
instanceCreate.Asset1 = 1000
|
||||
assert.throws(
|
||||
() => validate(instanceCreate),
|
||||
ValidationError,
|
||||
'AMMInstanceCreate: Asset1 must be an Amount',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ missing Asset2`, function () {
|
||||
delete instanceCreate.Asset2
|
||||
assert.throws(
|
||||
() => validate(instanceCreate),
|
||||
ValidationError,
|
||||
'AMMInstanceCreate: missing field Asset2',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ Asset2 must be an Amount`, function () {
|
||||
instanceCreate.Asset2 = 1000
|
||||
assert.throws(
|
||||
() => validate(instanceCreate),
|
||||
ValidationError,
|
||||
'AMMInstanceCreate: Asset2 must be an Amount',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ missing TradingFee`, function () {
|
||||
delete instanceCreate.TradingFee
|
||||
assert.throws(
|
||||
() => validate(instanceCreate),
|
||||
ValidationError,
|
||||
'AMMInstanceCreate: missing field TradingFee',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ TradingFee must be a number`, function () {
|
||||
instanceCreate.TradingFee = '12'
|
||||
assert.throws(
|
||||
() => validate(instanceCreate),
|
||||
ValidationError,
|
||||
'AMMInstanceCreate: TradingFee must be a number',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws when TradingFee is greater than 65000`, function () {
|
||||
instanceCreate.TradingFee = 65001
|
||||
assert.throws(
|
||||
() => validate(instanceCreate),
|
||||
ValidationError,
|
||||
`AMMInstanceCreate: TradingFee must be between 0 and 65000`,
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws when TradingFee is a negative number`, function () {
|
||||
instanceCreate.TradingFee = -1
|
||||
assert.throws(
|
||||
() => validate(instanceCreate),
|
||||
ValidationError,
|
||||
`AMMInstanceCreate: TradingFee must be between 0 and 65000`,
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -14,7 +14,7 @@ describe('AMMVote', function () {
|
||||
TransactionType: 'AMMVote',
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
AMMID: '24BA86F99302CF124AB27311C831F5BFAA72C4625DDA65B7EDF346A60CC19883',
|
||||
FeeVal: 25,
|
||||
TradingFee: 25,
|
||||
Sequence: 1337,
|
||||
} as any
|
||||
})
|
||||
@@ -41,39 +41,39 @@ describe('AMMVote', function () {
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ missing field FeeVal`, function () {
|
||||
delete vote.FeeVal
|
||||
it(`throws w/ missing field TradingFee`, function () {
|
||||
delete vote.TradingFee
|
||||
assert.throws(
|
||||
() => validate(vote),
|
||||
ValidationError,
|
||||
'AMMVote: missing field FeeVal',
|
||||
'AMMVote: missing field TradingFee',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ FeeVal must be a number`, function () {
|
||||
vote.FeeVal = '25'
|
||||
it(`throws w/ TradingFee must be a number`, function () {
|
||||
vote.TradingFee = '25'
|
||||
assert.throws(
|
||||
() => validate(vote),
|
||||
ValidationError,
|
||||
'AMMVote: FeeVal must be a number',
|
||||
'AMMVote: TradingFee must be a number',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws when FeeVal is greater than AMM_MAX_TRADING_FEE`, function () {
|
||||
vote.FeeVal = 65001
|
||||
it(`throws when TradingFee is greater than AMM_MAX_TRADING_FEE`, function () {
|
||||
vote.TradingFee = 65001
|
||||
assert.throws(
|
||||
() => validate(vote),
|
||||
ValidationError,
|
||||
'AMMVote: FeeVal must be between 0 and 65000',
|
||||
'AMMVote: TradingFee must be between 0 and 65000',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws when FeeVal is a negative number`, function () {
|
||||
vote.FeeVal = -1
|
||||
it(`throws when TradingFee is a negative number`, function () {
|
||||
vote.TradingFee = -1
|
||||
assert.throws(
|
||||
() => validate(vote),
|
||||
ValidationError,
|
||||
'AMMVote: FeeVal must be between 0 and 65000',
|
||||
'AMMVote: TradingFee must be between 0 and 65000',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ import { validate, ValidationError } from 'xrpl-local'
|
||||
* Providing runtime verification testing for each specific transaction type.
|
||||
*/
|
||||
describe('AMMWithdraw', function () {
|
||||
const LPToken = {
|
||||
const LPTokenIn = {
|
||||
currency: 'B3813FCAB4EE68B3D0D735D6849465A9113EE048',
|
||||
issuer: 'rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg',
|
||||
value: '1000',
|
||||
@@ -23,30 +23,30 @@ describe('AMMWithdraw', function () {
|
||||
} as any
|
||||
})
|
||||
|
||||
it(`verifies valid AMMWithdraw with LPToken`, function () {
|
||||
withdraw.LPToken = LPToken
|
||||
it(`verifies valid AMMWithdraw with LPTokenIn`, function () {
|
||||
withdraw.LPTokenIn = LPTokenIn
|
||||
assert.doesNotThrow(() => validate(withdraw))
|
||||
})
|
||||
|
||||
it(`verifies valid AMMWithdraw with Asset1Out`, function () {
|
||||
withdraw.Asset1Out = '1000'
|
||||
it(`verifies valid AMMWithdraw with Amount`, function () {
|
||||
withdraw.Amount = '1000'
|
||||
assert.doesNotThrow(() => validate(withdraw))
|
||||
})
|
||||
|
||||
it(`verifies valid AMMWithdraw with Asset1Out and Asset2Out`, function () {
|
||||
withdraw.Asset1Out = '1000'
|
||||
withdraw.Asset2Out = '1000'
|
||||
it(`verifies valid AMMWithdraw with Amount and Amount2`, function () {
|
||||
withdraw.Amount = '1000'
|
||||
withdraw.Amount2 = '1000'
|
||||
assert.doesNotThrow(() => validate(withdraw))
|
||||
})
|
||||
|
||||
it(`verifies valid AMMWithdraw with Asset1Out and LPToken`, function () {
|
||||
withdraw.Asset1Out = '1000'
|
||||
withdraw.LPToken = LPToken
|
||||
it(`verifies valid AMMWithdraw with Amount and LPTokenIn`, function () {
|
||||
withdraw.Amount = '1000'
|
||||
withdraw.LPTokenIn = LPTokenIn
|
||||
assert.doesNotThrow(() => validate(withdraw))
|
||||
})
|
||||
|
||||
it(`verifies valid AMMWithdraw with Asset1Out and EPrice`, function () {
|
||||
withdraw.Asset1Out = '1000'
|
||||
it(`verifies valid AMMWithdraw with Amount and EPrice`, function () {
|
||||
withdraw.Amount = '1000'
|
||||
withdraw.EPrice = '25'
|
||||
assert.doesNotThrow(() => validate(withdraw))
|
||||
})
|
||||
@@ -69,62 +69,62 @@ describe('AMMWithdraw', function () {
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ must set at least LPToken or Asset1Out`, function () {
|
||||
it(`throws w/ must set at least LPTokenIn or Amount`, function () {
|
||||
assert.throws(
|
||||
() => validate(withdraw),
|
||||
ValidationError,
|
||||
'AMMWithdraw: must set at least LPToken or Asset1Out',
|
||||
'AMMWithdraw: must set at least LPTokenIn or Amount',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ must set Asset1Out with Asset2Out`, function () {
|
||||
withdraw.Asset2Out = '500'
|
||||
it(`throws w/ must set Amount with Amount2`, function () {
|
||||
withdraw.Amount2 = '500'
|
||||
assert.throws(
|
||||
() => validate(withdraw),
|
||||
ValidationError,
|
||||
'AMMWithdraw: must set Asset1Out with Asset2Out',
|
||||
'AMMWithdraw: must set Amount with Amount2',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ must set Asset1Out with EPrice`, function () {
|
||||
it(`throws w/ must set Amount with EPrice`, function () {
|
||||
withdraw.EPrice = '25'
|
||||
assert.throws(
|
||||
() => validate(withdraw),
|
||||
ValidationError,
|
||||
'AMMWithdraw: must set Asset1Out with EPrice',
|
||||
'AMMWithdraw: must set Amount with EPrice',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ LPToken must be an IssuedCurrencyAmount`, function () {
|
||||
withdraw.LPToken = 1234
|
||||
it(`throws w/ LPTokenIn must be an IssuedCurrencyAmount`, function () {
|
||||
withdraw.LPTokenIn = 1234
|
||||
assert.throws(
|
||||
() => validate(withdraw),
|
||||
ValidationError,
|
||||
'AMMWithdraw: LPToken must be an IssuedCurrencyAmount',
|
||||
'AMMWithdraw: LPTokenIn must be an IssuedCurrencyAmount',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ Asset1Out must be an Amount`, function () {
|
||||
withdraw.Asset1Out = 1234
|
||||
it(`throws w/ Amount must be an Amount`, function () {
|
||||
withdraw.Amount = 1234
|
||||
assert.throws(
|
||||
() => validate(withdraw),
|
||||
ValidationError,
|
||||
'AMMWithdraw: Asset1Out must be an Amount',
|
||||
'AMMWithdraw: Amount must be an Amount',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ Asset2Out must be an Amount`, function () {
|
||||
withdraw.Asset1Out = '1000'
|
||||
withdraw.Asset2Out = 1234
|
||||
it(`throws w/ Amount2 must be an Amount`, function () {
|
||||
withdraw.Amount = '1000'
|
||||
withdraw.Amount2 = 1234
|
||||
assert.throws(
|
||||
() => validate(withdraw),
|
||||
ValidationError,
|
||||
'AMMWithdraw: Asset2Out must be an Amount',
|
||||
'AMMWithdraw: Amount2 must be an Amount',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ EPrice must be an Amount`, function () {
|
||||
withdraw.Asset1Out = '1000'
|
||||
withdraw.Amount = '1000'
|
||||
withdraw.EPrice = 1234
|
||||
assert.throws(
|
||||
() => validate(withdraw),
|
||||
|
||||
Reference in New Issue
Block a user