Link to Trubanc 1.0b1 announcement
[loomclient.git] / vending.txt
blob34c6762a834551dda37ebcb650e7f4e01a62ce05
1 iqn = input quantity n
2 ian = input asset type n
3 oqn = output quantity n
4 oan = output asset type n
5 id = machine public id
6 key = machine private key
7 inv = inventory location
8 loc = trading location
10 Defining or changing a machine:
12 Input:
14 :function
15 =defvend
16 :inputs
18 :outputs
20 :iq1
21 =30
22 :ia1
23 =<dollars>
24 :iq2
25 =10
26 :ia2
27 =<usage tokens>
28 :oq1
30 :oa1
31 =<gold grams>
32 :id
33 =<public id>
34 :key
35 =<key>
36 :inv
37 =<inventory location>
40 Output: echo of input, plus status (OK or Error)
43 Input:
45 :function
46 =queryvend
47 :id
48 =<public id>
51 Output:
54 :function
55 =queryvend
56 :id
57 =<public id>
58 :inputs
60 :outputs
62 :iq1
63 =30
64 :ia1
65 =<dollars>
66 :iq2
67 =10
68 :ia2
69 =<usage tokens>
70 :status
71 =<OK or error type>
74 Input:
75 (:function
76 =vend
77 :inputs
79 :outputs
81 :iq1
82 =32
83 :ia1
84 =<dollars>
85 :iq2
86 =12
87 :ia2
88 =<usage tokens>
89 :oq1
91 :oa1
92 =<gold grams>
93 :id
94 =<public id>
95 :loc
96 =<trading location>
99 Output:
100 (:function
101 =vend
102 :inputs
104 :outputs
106 :iq1
108 :ia1
109 =<dollars>
110 :iq2
112 :ia2
113 =<usage tokens>
114 :oq1
116 :oa1
117 =<gold grams>
119 =<public id>
120 :loc
121 =<trading location>
122 :count
123 =<Number of quanta satisfied>
124 :status
125 =<OK or error type>
128 Fairness.
130 Ratio of input quantity to output quantity offerred has to be less than or equal to the ratio of input quantity to output quantity bid for all input/output pairs.
132 So if you're selling 1 gram of gold for 30 dollars plus 10 asset tokens, and I offer 32 dollars plus 12 asset tokens for 0.8 grams of gold, the trade would go through:
134 Offered:
135 30 / 1 = 30
136 10 / 1 = 10
138 Bid:
139 32 / 0.8 = 40
140 12 / 0.8 = 15
142 30 < 40 & 10 < 15
144 However, if I offer 32 dollars plus 7 asset tokens for 0.8 grams of gold, the trade would NOT go through.
146 32 / 0.8 = 40
147 7 / 0.8 = 8.75
149 30 < 40, but 10 > 8.75
151 Additionally, you have to be able to satisfy at least all the output amounts listed in the bid (this could be one of a chain of bids that the client has put together).
153 Different representation:
155 Input:
157 :function
158 =defvend
159 :input
160 =30:<dollars> 10:<usage tokens>
161 :output
162 =1:<gold grams>
164 =<public id>
165 :key
166 =<key>
167 :inv
168 =<inventory location>
171 Output: echo of input, plus status (OK or Error)
174 Input:
176 :function
177 =queryvend
179 =<public id>
182 Output:
185 :function
186 =queryvend
188 =<public id>
189 :input
190 =30:<dollars> 10:<usage tokens>
191 :output
192 =1:<gold grams>
193 :status
194 =<OK or error type>
197 Include the key in queryvend and you'll get the inventory location out.
199 Input:
200 (:function
201 =vend
202 :input
203 =30:<dollars> 10:<usage tokens>
204 :output
205 =1:<gold grams>
207 =<public id>
208 :loc
209 =<trading location>
212 Output:
213 (:function
214 =vend
215 :input
216 =30:<dollars> 10:<usage tokens>
217 :output
218 =1:<gold grams>
220 =<public id>
221 :loc
222 =<trading location>
223 :count
224 =<Number of quanta satisfied>
225 :status
226 =<OK or error type>