rippled
Taker_test.cpp
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #include <ripple/app/tx/impl/Taker.h>
21 #include <ripple/beast/core/LexicalCast.h>
22 #include <ripple/beast/unit_test.h>
23 #include <type_traits>
24 
25 namespace ripple {
26 
27 class Taker_test : public beast::unit_test::suite
28 {
29  static bool const Buy = false;
30  static bool const Sell = true;
31 
32  class TestTaker : public BasicTaker
33  {
36 
37  public:
40  Amounts const& amount,
41  Quality const& quality,
42  STAmount const& funds,
43  std::uint32_t flags,
44  Rate const& rate_in,
45  Rate const& rate_out)
46  : BasicTaker(
47  cross_type,
48  AccountID(0x4701),
49  amount,
50  quality,
51  flags,
52  rate_in,
53  rate_out)
54  , funds_(funds)
55  {
56  }
57 
58  void
59  set_funds(STAmount const& funds)
60  {
61  cross_funds = funds;
62  }
63 
64  STAmount
65  get_funds(AccountID const& owner, STAmount const& funds) const override
66  {
67  if (owner == account())
68  return funds_;
69 
70  return cross_funds;
71  }
72 
73  Amounts
74  cross(Amounts offer, Quality quality)
75  {
76  if (reject(quality))
77  return Amounts(offer.in.zeroed(), offer.out.zeroed());
78 
79  // we need to emulate "unfunded offers" behavior
80  if (get_funds(AccountID(0x4702), offer.out) == beast::zero)
81  return Amounts(offer.in.zeroed(), offer.out.zeroed());
82 
83  if (done())
84  return Amounts(offer.in.zeroed(), offer.out.zeroed());
85 
86  auto result = do_cross(offer, quality, AccountID(0x4702));
87 
88  funds_ -= result.order.in;
89 
90  return result.order;
91  }
92 
95  Amounts offer1,
96  Quality quality1,
97  Amounts offer2,
98  Quality quality2)
99  {
100  /* check if composed quality should be rejected */
101  Quality const quality(composed_quality(quality1, quality2));
102 
103  if (reject(quality))
104  return std::make_pair(
105  Amounts{offer1.in.zeroed(), offer1.out.zeroed()},
106  Amounts{offer2.in.zeroed(), offer2.out.zeroed()});
107 
108  if (done())
109  return std::make_pair(
110  Amounts{offer1.in.zeroed(), offer1.out.zeroed()},
111  Amounts{offer2.in.zeroed(), offer2.out.zeroed()});
112 
113  auto result = do_cross(
114  offer1,
115  quality1,
116  AccountID(0x4703),
117  offer2,
118  quality2,
119  AccountID(0x4704));
120 
121  return std::make_pair(result.first.order, result.second.order);
122  }
123  };
124 
125 private:
126  Issue const&
127  usd() const
128  {
129  static Issue const issue(
130  Currency(0x5553440000000000), AccountID(0x4985601));
131  return issue;
132  }
133 
134  Issue const&
135  eur() const
136  {
137  static Issue const issue(
138  Currency(0x4555520000000000), AccountID(0x4985602));
139  return issue;
140  }
141 
142  Issue const&
143  xrp() const
144  {
145  static Issue const issue(xrpCurrency(), xrpAccount());
146  return issue;
147  }
148 
149  STAmount
150  parse_amount(std::string const& amount, Issue const& issue)
151  {
152  return amountFromString(issue, amount);
153  }
154 
155  Amounts
157  std::string const& amount_in,
158  Issue const& issue_in,
159  std::string const& amount_out,
160  Issue const& issue_out)
161  {
162  STAmount const in(parse_amount(amount_in, issue_in));
163  STAmount const out(parse_amount(amount_out, issue_out));
164 
165  return {in, out};
166  }
167 
169  {
170  cross_attempt_offer(std::string const& in_, std::string const& out_)
171  : in(in_), out(out_)
172  {
173  }
174 
177  };
178 
179 private:
181  format_amount(STAmount const& amount)
182  {
183  std::string txt = amount.getText();
184  txt += "/";
185  txt += to_string(amount.issue().currency);
186  return txt;
187  }
188 
189  void
191  bool sell,
192  std::string name,
193  Quality taker_quality,
194  cross_attempt_offer const offer,
195  std::string const funds,
196  Quality cross_quality,
197  cross_attempt_offer const cross,
198  std::string const cross_funds,
200  Issue const& issue_in,
201  Issue const& issue_out,
202  Rate rate_in = parityRate,
203  Rate rate_out = parityRate)
204  {
205  Amounts taker_offer(
206  parse_amounts(offer.in, issue_in, offer.out, issue_out));
207 
208  Amounts cross_offer(
209  parse_amounts(cross.in, issue_in, cross.out, issue_out));
210 
211  CrossType cross_type;
212 
213  if (isXRP(issue_out))
214  cross_type = CrossType::IouToXrp;
215  else if (isXRP(issue_in))
216  cross_type = CrossType::XrpToIou;
217  else
218  cross_type = CrossType::IouToIou;
219 
220  // FIXME: We are always invoking the IOU-to-IOU taker. We should select
221  // the correct type dynamically.
222  TestTaker taker(
223  cross_type,
224  taker_offer,
225  taker_quality,
226  parse_amount(funds, issue_in),
227  sell ? tfSell : 0,
228  rate_in,
229  rate_out);
230 
231  taker.set_funds(parse_amount(cross_funds, issue_out));
232 
233  auto result = taker.cross(cross_offer, cross_quality);
234 
235  Amounts const expected(
236  parse_amounts(flow.in, issue_in, flow.out, issue_out));
237 
238  BEAST_EXPECT(expected == result);
239 
240  if (expected != result)
241  {
242  log << "Expected: " << format_amount(expected.in) << " : "
243  << format_amount(expected.out) << '\n'
244  << " Actual: " << format_amount(result.in) << " : "
245  << format_amount(result.out) << std::endl;
246  }
247  }
248 
249  Quality
251  {
252  return Quality(parse_amounts(in, xrp(), out, xrp()));
253  }
254 
255 public:
256  // Notation for clamp scenario descriptions:
257  //
258  // IN:OUT (with the last in the list being limiting factor)
259  // N = Nothing
260  // T = Taker Offer Balance
261  // A = Taker Account Balance
262  // B = Owner Account Balance
263  //
264  // (s) = sell semantics: taker wants unlimited output
265  // (b) = buy semantics: taker wants a limited amount out
266 
267  // NIKB TODO: Augment TestTaker so currencies and rates can be specified
268  // once without need for repetition.
269  void
271  {
272  testcase("XRP Quantization: input");
273 
274  Quality q1 = get_quality("1", "1");
275 
276  // TAKER OWNER
277  // QUAL OFFER FUNDS QUAL OFFER FUNDS
278  // EXPECTED
279  // XRP USD
280  attempt(
281  Sell,
282  "N:N",
283  q1,
284  {"2", "2"},
285  "2",
286  q1,
287  {"2", "2"},
288  "2",
289  {"2", "2"},
290  xrp(),
291  usd());
292  attempt(
293  Sell,
294  "N:B",
295  q1,
296  {"2", "2"},
297  "2",
298  q1,
299  {"2", "2"},
300  "1.8",
301  {"1", "1.8"},
302  xrp(),
303  usd());
304  attempt(
305  Buy,
306  "N:T",
307  q1,
308  {"1", "1"},
309  "2",
310  q1,
311  {"2", "2"},
312  "2",
313  {"1", "1"},
314  xrp(),
315  usd());
316  attempt(
317  Buy,
318  "N:BT",
319  q1,
320  {"1", "1"},
321  "2",
322  q1,
323  {"2", "2"},
324  "1.8",
325  {"1", "1"},
326  xrp(),
327  usd());
328  attempt(
329  Buy,
330  "N:TB",
331  q1,
332  {"1", "1"},
333  "2",
334  q1,
335  {"2", "2"},
336  "0.8",
337  {"0", "0.8"},
338  xrp(),
339  usd());
340 
341  attempt(
342  Sell,
343  "T:N",
344  q1,
345  {"1", "1"},
346  "2",
347  q1,
348  {"2", "2"},
349  "2",
350  {"1", "1"},
351  xrp(),
352  usd());
353  attempt(
354  Sell,
355  "T:B",
356  q1,
357  {"1", "1"},
358  "2",
359  q1,
360  {"2", "2"},
361  "1.8",
362  {"1", "1.8"},
363  xrp(),
364  usd());
365  attempt(
366  Buy,
367  "T:T",
368  q1,
369  {"1", "1"},
370  "2",
371  q1,
372  {"2", "2"},
373  "2",
374  {"1", "1"},
375  xrp(),
376  usd());
377  attempt(
378  Buy,
379  "T:BT",
380  q1,
381  {"1", "1"},
382  "2",
383  q1,
384  {"2", "2"},
385  "1.8",
386  {"1", "1"},
387  xrp(),
388  usd());
389  attempt(
390  Buy,
391  "T:TB",
392  q1,
393  {"1", "1"},
394  "2",
395  q1,
396  {"2", "2"},
397  "0.8",
398  {"0", "0.8"},
399  xrp(),
400  usd());
401 
402  attempt(
403  Sell,
404  "A:N",
405  q1,
406  {"2", "2"},
407  "1",
408  q1,
409  {"2", "2"},
410  "2",
411  {"1", "1"},
412  xrp(),
413  usd());
414  attempt(
415  Sell,
416  "A:B",
417  q1,
418  {"2", "2"},
419  "1",
420  q1,
421  {"2", "2"},
422  "1.8",
423  {"1", "1.8"},
424  xrp(),
425  usd());
426  attempt(
427  Buy,
428  "A:T",
429  q1,
430  {"2", "2"},
431  "1",
432  q1,
433  {"3", "3"},
434  "3",
435  {"1", "1"},
436  xrp(),
437  usd());
438  attempt(
439  Buy,
440  "A:BT",
441  q1,
442  {"2", "2"},
443  "1",
444  q1,
445  {"3", "3"},
446  "2.4",
447  {"1", "1"},
448  xrp(),
449  usd());
450  attempt(
451  Buy,
452  "A:TB",
453  q1,
454  {"2", "2"},
455  "1",
456  q1,
457  {"3", "3"},
458  "0.8",
459  {"0", "0.8"},
460  xrp(),
461  usd());
462 
463  attempt(
464  Sell,
465  "TA:N",
466  q1,
467  {"2", "2"},
468  "1",
469  q1,
470  {"2", "2"},
471  "2",
472  {"1", "1"},
473  xrp(),
474  usd());
475  attempt(
476  Sell,
477  "TA:B",
478  q1,
479  {"2", "2"},
480  "1",
481  q1,
482  {"3", "3"},
483  "1.8",
484  {"1", "1.8"},
485  xrp(),
486  usd());
487  attempt(
488  Buy,
489  "TA:T",
490  q1,
491  {"2", "2"},
492  "1",
493  q1,
494  {"3", "3"},
495  "3",
496  {"1", "1"},
497  xrp(),
498  usd());
499  attempt(
500  Buy,
501  "TA:BT",
502  q1,
503  {"2", "2"},
504  "1",
505  q1,
506  {"3", "3"},
507  "1.8",
508  {"1", "1.8"},
509  xrp(),
510  usd());
511  attempt(
512  Buy,
513  "TA:TB",
514  q1,
515  {"2", "2"},
516  "1",
517  q1,
518  {"3", "3"},
519  "1.8",
520  {"1", "1.8"},
521  xrp(),
522  usd());
523 
524  attempt(
525  Sell,
526  "AT:N",
527  q1,
528  {"2", "2"},
529  "1",
530  q1,
531  {"3", "3"},
532  "3",
533  {"1", "1"},
534  xrp(),
535  usd());
536  attempt(
537  Sell,
538  "AT:B",
539  q1,
540  {"2", "2"},
541  "1",
542  q1,
543  {"3", "3"},
544  "1.8",
545  {"1", "1.8"},
546  xrp(),
547  usd());
548  attempt(
549  Buy,
550  "AT:T",
551  q1,
552  {"2", "2"},
553  "1",
554  q1,
555  {"3", "3"},
556  "3",
557  {"1", "1"},
558  xrp(),
559  usd());
560  attempt(
561  Buy,
562  "AT:BT",
563  q1,
564  {"2", "2"},
565  "1",
566  q1,
567  {"3", "3"},
568  "1.8",
569  {"1", "1.8"},
570  xrp(),
571  usd());
572  attempt(
573  Buy,
574  "AT:TB",
575  q1,
576  {"2", "2"},
577  "1",
578  q1,
579  {"3", "3"},
580  "0.8",
581  {"0", "0.8"},
582  xrp(),
583  usd());
584  }
585 
586  void
588  {
589  testcase("XRP Quantization: output");
590 
591  Quality q1 = get_quality("1", "1");
592 
593  // TAKER OWNER
594  // QUAL OFFER FUNDS QUAL OFFER FUNDS
595  // EXPECTED
596  // USD XRP
597  attempt(
598  Sell,
599  "N:N",
600  q1,
601  {"3", "3"},
602  "3",
603  q1,
604  {"3", "3"},
605  "3",
606  {"3", "3"},
607  usd(),
608  xrp());
609  attempt(
610  Sell,
611  "N:B",
612  q1,
613  {"3", "3"},
614  "3",
615  q1,
616  {"3", "3"},
617  "2",
618  {"2", "2"},
619  usd(),
620  xrp());
621  attempt(
622  Buy,
623  "N:T",
624  q1,
625  {"3", "3"},
626  "2.5",
627  q1,
628  {"5", "5"},
629  "5",
630  {"2.5", "2"},
631  usd(),
632  xrp());
633  attempt(
634  Buy,
635  "N:BT",
636  q1,
637  {"3", "3"},
638  "1.5",
639  q1,
640  {"5", "5"},
641  "4",
642  {"1.5", "1"},
643  usd(),
644  xrp());
645  attempt(
646  Buy,
647  "N:TB",
648  q1,
649  {"3", "3"},
650  "2.2",
651  q1,
652  {"5", "5"},
653  "1",
654  {"1", "1"},
655  usd(),
656  xrp());
657 
658  attempt(
659  Sell,
660  "T:N",
661  q1,
662  {"1", "1"},
663  "2",
664  q1,
665  {"2", "2"},
666  "2",
667  {"1", "1"},
668  usd(),
669  xrp());
670  attempt(
671  Sell,
672  "T:B",
673  q1,
674  {"2", "2"},
675  "2",
676  q1,
677  {"3", "3"},
678  "1",
679  {"1", "1"},
680  usd(),
681  xrp());
682  attempt(
683  Buy,
684  "T:T",
685  q1,
686  {"1", "1"},
687  "2",
688  q1,
689  {"2", "2"},
690  "2",
691  {"1", "1"},
692  usd(),
693  xrp());
694  attempt(
695  Buy,
696  "T:BT",
697  q1,
698  {"1", "1"},
699  "2",
700  q1,
701  {"3", "3"},
702  "2",
703  {"1", "1"},
704  usd(),
705  xrp());
706  attempt(
707  Buy,
708  "T:TB",
709  q1,
710  {"2", "2"},
711  "2",
712  q1,
713  {"3", "3"},
714  "1",
715  {"1", "1"},
716  usd(),
717  xrp());
718 
719  attempt(
720  Sell,
721  "A:N",
722  q1,
723  {"2", "2"},
724  "1.5",
725  q1,
726  {"2", "2"},
727  "2",
728  {"1.5", "1"},
729  usd(),
730  xrp());
731  attempt(
732  Sell,
733  "A:B",
734  q1,
735  {"2", "2"},
736  "1.8",
737  q1,
738  {"3", "3"},
739  "2",
740  {"1.8", "1"},
741  usd(),
742  xrp());
743  attempt(
744  Buy,
745  "A:T",
746  q1,
747  {"2", "2"},
748  "1.2",
749  q1,
750  {"3", "3"},
751  "3",
752  {"1.2", "1"},
753  usd(),
754  xrp());
755  attempt(
756  Buy,
757  "A:BT",
758  q1,
759  {"2", "2"},
760  "1.5",
761  q1,
762  {"4", "4"},
763  "3",
764  {"1.5", "1"},
765  usd(),
766  xrp());
767  attempt(
768  Buy,
769  "A:TB",
770  q1,
771  {"2", "2"},
772  "1.5",
773  q1,
774  {"4", "4"},
775  "1",
776  {"1", "1"},
777  usd(),
778  xrp());
779 
780  attempt(
781  Sell,
782  "TA:N",
783  q1,
784  {"2", "2"},
785  "1.5",
786  q1,
787  {"2", "2"},
788  "2",
789  {"1.5", "1"},
790  usd(),
791  xrp());
792  attempt(
793  Sell,
794  "TA:B",
795  q1,
796  {"2", "2"},
797  "1.5",
798  q1,
799  {"3", "3"},
800  "1",
801  {"1", "1"},
802  usd(),
803  xrp());
804  attempt(
805  Buy,
806  "TA:T",
807  q1,
808  {"2", "2"},
809  "1.5",
810  q1,
811  {"3", "3"},
812  "3",
813  {"1.5", "1"},
814  usd(),
815  xrp());
816  attempt(
817  Buy,
818  "TA:BT",
819  q1,
820  {"2", "2"},
821  "1.8",
822  q1,
823  {"4", "4"},
824  "3",
825  {"1.8", "1"},
826  usd(),
827  xrp());
828  attempt(
829  Buy,
830  "TA:TB",
831  q1,
832  {"2", "2"},
833  "1.2",
834  q1,
835  {"3", "3"},
836  "1",
837  {"1", "1"},
838  usd(),
839  xrp());
840 
841  attempt(
842  Sell,
843  "AT:N",
844  q1,
845  {"2", "2"},
846  "2.5",
847  q1,
848  {"4", "4"},
849  "4",
850  {"2", "2"},
851  usd(),
852  xrp());
853  attempt(
854  Sell,
855  "AT:B",
856  q1,
857  {"2", "2"},
858  "2.5",
859  q1,
860  {"3", "3"},
861  "1",
862  {"1", "1"},
863  usd(),
864  xrp());
865  attempt(
866  Buy,
867  "AT:T",
868  q1,
869  {"2", "2"},
870  "2.5",
871  q1,
872  {"3", "3"},
873  "3",
874  {"2", "2"},
875  usd(),
876  xrp());
877  attempt(
878  Buy,
879  "AT:BT",
880  q1,
881  {"2", "2"},
882  "2.5",
883  q1,
884  {"4", "4"},
885  "3",
886  {"2", "2"},
887  usd(),
888  xrp());
889  attempt(
890  Buy,
891  "AT:TB",
892  q1,
893  {"2", "2"},
894  "2.5",
895  q1,
896  {"3", "3"},
897  "1",
898  {"1", "1"},
899  usd(),
900  xrp());
901  }
902 
903  void
905  {
906  testcase("IOU to IOU");
907 
908  Quality q1 = get_quality("1", "1");
909 
910  // Highly exaggerated 50% transfer rate for the input and output:
911  Rate const rate{parityRate.value + (parityRate.value / 2)};
912 
913  // TAKER OWNER
914  // QUAL OFFER FUNDS QUAL OFFER FUNDS
915  // EXPECTED
916  // EUR USD
917  attempt(
918  Sell,
919  "N:N",
920  q1,
921  {"2", "2"},
922  "10",
923  q1,
924  {"2", "2"},
925  "10",
926  {"2", "2"},
927  eur(),
928  usd(),
929  rate,
930  rate);
931  attempt(
932  Sell,
933  "N:B",
934  q1,
935  {"4", "4"},
936  "10",
937  q1,
938  {"4", "4"},
939  "4",
940  {"2.666666666666666", "2.666666666666666"},
941  eur(),
942  usd(),
943  rate,
944  rate);
945  attempt(
946  Buy,
947  "N:T",
948  q1,
949  {"1", "1"},
950  "10",
951  q1,
952  {"2", "2"},
953  "10",
954  {"1", "1"},
955  eur(),
956  usd(),
957  rate,
958  rate);
959  attempt(
960  Buy,
961  "N:BT",
962  q1,
963  {"2", "2"},
964  "10",
965  q1,
966  {"6", "6"},
967  "5",
968  {"2", "2"},
969  eur(),
970  usd(),
971  rate,
972  rate);
973  attempt(
974  Buy,
975  "N:TB",
976  q1,
977  {"2", "2"},
978  "2",
979  q1,
980  {"6", "6"},
981  "1",
982  {"0.6666666666666667", "0.6666666666666667"},
983  eur(),
984  usd(),
985  rate,
986  rate);
987  attempt(
988  Sell,
989  "A:N",
990  q1,
991  {"2", "2"},
992  "2.5",
993  q1,
994  {"2", "2"},
995  "10",
996  {"1.666666666666666", "1.666666666666666"},
997  eur(),
998  usd(),
999  rate,
1000  rate);
1001  }
1002 
1003  void
1004  run() override
1005  {
1006  test_xrp_to_iou();
1007  test_iou_to_xrp();
1008  test_iou_to_iou();
1009  }
1010 };
1011 
1012 BEAST_DEFINE_TESTSUITE(Taker, tx, ripple);
1013 
1014 } // namespace ripple
ripple::Taker_test::TestTaker::set_funds
void set_funds(STAmount const &funds)
Definition: Taker_test.cpp:59
ripple::Issue
A currency issued by an account.
Definition: Issue.h:34
std::string
STL class.
ripple::BEAST_DEFINE_TESTSUITE
BEAST_DEFINE_TESTSUITE(AccountTxPaging, app, ripple)
ripple::Rate
Represents a transfer rate.
Definition: Rate.h:37
ripple::composed_quality
Quality composed_quality(Quality const &lhs, Quality const &rhs)
Definition: Quality.cpp:101
ripple::STAmount::issue
Issue const & issue() const
Definition: STAmount.h:339
ripple::Taker_test::xrp
Issue const & xrp() const
Definition: Taker_test.cpp:143
std::pair
ripple::Taker_test::attempt
void attempt(bool sell, std::string name, Quality taker_quality, cross_attempt_offer const offer, std::string const funds, Quality cross_quality, cross_attempt_offer const cross, std::string const cross_funds, cross_attempt_offer const flow, Issue const &issue_in, Issue const &issue_out, Rate rate_in=parityRate, Rate rate_out=parityRate)
Definition: Taker_test.cpp:190
ripple::Taker_test::Sell
static const bool Sell
Definition: Taker_test.cpp:30
ripple::BasicTaker::do_cross
BasicTaker::Flow do_cross(Amounts offer, Quality quality, AccountID const &owner)
Perform direct crossing through given offer.
Definition: Taker.cpp:385
ripple::Taker_test::TestTaker::funds_
STAmount funds_
Definition: Taker_test.cpp:34
ripple::BasicTaker::reject
bool reject(Quality const &quality) const noexcept
Returns true if the quality does not meet the taker's requirements.
Definition: Taker.h:179
ripple::STAmount::getText
std::string getText() const override
Definition: STAmount.cpp:530
ripple::CrossType::XrpToIou
@ XrpToIou
ripple::Issue::currency
Currency currency
Definition: Issue.h:37
ripple::CrossType::IouToXrp
@ IouToXrp
ripple::QualityDirection::in
@ in
ripple::BasicTaker
State for the active party during order book or payment operations.
Definition: Taker.h:39
ripple::Taker_test
Definition: Taker_test.cpp:27
ripple::Taker_test::eur
Issue const & eur() const
Definition: Taker_test.cpp:135
ripple::Taker_test::TestTaker::cross
Amounts cross(Amounts offer, Quality quality)
Definition: Taker_test.cpp:74
ripple::Taker_test::cross_attempt_offer::out
std::string out
Definition: Taker_test.cpp:176
ripple::BasicTaker::cross_type
CrossType cross_type() const
Returns the type of crossing that is being performed.
Definition: Taker.h:186
ripple::parityRate
const Rate parityRate(QUALITY_ONE)
A transfer rate signifying a 1:1 exchange.
Definition: Rate.h:101
ripple::Taker_test::parse_amounts
Amounts parse_amounts(std::string const &amount_in, Issue const &issue_in, std::string const &amount_out, Issue const &issue_out)
Definition: Taker_test.cpp:156
ripple::Taker_test::format_amount
std::string format_amount(STAmount const &amount)
Definition: Taker_test.cpp:181
ripple::Taker_test::TestTaker
Definition: Taker_test.cpp:32
ripple::base_uint< 160, detail::AccountIDTag >
ripple::flow
path::RippleCalc::Output flow(PaymentSandbox &view, STAmount const &deliver, AccountID const &src, AccountID const &dst, STPathSet const &paths, bool defaultPaths, bool partialPayment, bool ownerPaysTransferFee, bool offerCrossing, std::optional< Quality > const &limitQuality, std::optional< STAmount > const &sendMax, beast::Journal j, path::detail::FlowDebugInfo *flowDebugInfo=nullptr)
Make a payment from the src account to the dst account.
ripple::CrossType
CrossType
The flavor of an offer crossing.
Definition: Taker.h:36
ripple::CrossType::IouToIou
@ IouToIou
ripple::QualityDirection::out
@ out
ripple::Taker_test::test_xrp_to_iou
void test_xrp_to_iou()
Definition: Taker_test.cpp:270
ripple::Taker_test::cross_attempt_offer::in
std::string in
Definition: Taker_test.cpp:175
ripple::Taker_test::TestTaker::get_funds
STAmount get_funds(AccountID const &owner, STAmount const &funds) const override
Definition: Taker_test.cpp:65
ripple::STAmount
Definition: STAmount.h:44
ripple::xrpAccount
AccountID const & xrpAccount()
Compute AccountID from public key.
Definition: AccountID.cpp:90
ripple::isXRP
bool isXRP(AccountID const &c)
Definition: AccountID.h:89
ripple::Taker_test::test_iou_to_iou
void test_iou_to_iou()
Definition: Taker_test.cpp:904
ripple::Taker_test::cross_attempt_offer::cross_attempt_offer
cross_attempt_offer(std::string const &in_, std::string const &out_)
Definition: Taker_test.cpp:170
std::uint32_t
ripple::Taker_test::test_iou_to_xrp
void test_iou_to_xrp()
Definition: Taker_test.cpp:587
ripple::Taker_test::TestTaker::TestTaker
TestTaker(CrossType cross_type, Amounts const &amount, Quality const &quality, STAmount const &funds, std::uint32_t flags, Rate const &rate_in, Rate const &rate_out)
Definition: Taker_test.cpp:38
ripple::Taker_test::usd
Issue const & usd() const
Definition: Taker_test.cpp:127
ripple::Taker_test::parse_amount
STAmount parse_amount(std::string const &amount, Issue const &issue)
Definition: Taker_test.cpp:150
ripple::BasicTaker::done
bool done() const
Returns true if order crossing should not continue.
Definition: Taker.cpp:112
ripple::Currency
base_uint< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Definition: UintTypes.h:56
ripple::Rate::value
std::uint32_t value
Definition: Rate.h:39
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::amountFromString
STAmount amountFromString(Issue const &issue, std::string const &amount)
Definition: STAmount.cpp:805
ripple::tfSell
constexpr std::uint32_t tfSell
Definition: TxFlags.h:87
std::endl
T endl(T... args)
ripple::Taker_test::cross_attempt_offer
Definition: Taker_test.cpp:168
ripple::Taker_test::Buy
static const bool Buy
Definition: Taker_test.cpp:29
ripple::Taker_test::TestTaker::cross_funds
STAmount cross_funds
Definition: Taker_test.cpp:35
ripple::Taker_test::TestTaker::cross
std::pair< Amounts, Amounts > cross(Amounts offer1, Quality quality1, Amounts offer2, Quality quality2)
Definition: Taker_test.cpp:94
ripple::to_string
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
Definition: app/misc/impl/Manifest.cpp:41
std::make_pair
T make_pair(T... args)
ripple::Taker_test::get_quality
Quality get_quality(std::string in, std::string out)
Definition: Taker_test.cpp:250
ripple::BasicTaker::account
AccountID const & account() const noexcept
Returns the account identifier of the taker.
Definition: Taker.h:172
type_traits
ripple::xrpCurrency
Currency const & xrpCurrency()
XRP currency.
Definition: UintTypes.cpp:121
ripple::AccountID
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition: AccountID.h:47
ripple::Taker_test::run
void run() override
Definition: Taker_test.cpp:1004