Skip to content

Commit

Permalink
Merge pull request #71 from gnosis/bump-to-0.7.0-rc2
Browse files Browse the repository at this point in the history
Bump to 0.7.0-rc2, upgrade packages, update to recommended usage of m…
  • Loading branch information
cag authored Nov 24, 2017
2 parents 7be1a5a + c5fe9fa commit 6fa737a
Show file tree
Hide file tree
Showing 16 changed files with 1,707 additions and 916 deletions.
266 changes: 137 additions & 129 deletions dist/gnosis.js

Large diffs are not rendered by default.

110 changes: 101 additions & 9 deletions docs/Gnosis.html
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ <h4 class="name" id="defaultAccount"><span class="type-signature"></span>default

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line247">line 247</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line251">line 251</a>
</li></ul></dd>


Expand Down Expand Up @@ -368,7 +368,7 @@ <h4 class="name" id="etherToken"><span class="type-signature"></span>etherToken<

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line204">line 204</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line208">line 208</a>
</li></ul></dd>


Expand Down Expand Up @@ -442,7 +442,7 @@ <h4 class="name" id="lmsrMarketMaker"><span class="type-signature"></span>lmsrMa

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line218">line 218</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line222">line 222</a>
</li></ul></dd>


Expand Down Expand Up @@ -516,7 +516,7 @@ <h4 class="name" id="olympiaToken"><span class="type-signature"></span>olympiaTo

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line225">line 225</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line229">line 229</a>
</li></ul></dd>


Expand Down Expand Up @@ -590,7 +590,7 @@ <h4 class="name" id="standardMarketFactory"><span class="type-signature"></span>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line211">line 211</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line215">line 215</a>
</li></ul></dd>


Expand Down Expand Up @@ -2157,7 +2157,7 @@ <h4 class="name" id=".requireEventFromTXResult"><span class="type-signature">(st

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line264">line 264</a>
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line258">line 258</a>
</li></ul></dd>


Expand Down Expand Up @@ -2347,7 +2347,7 @@ <h4 class="name" id="buyOutcomeTokens"><span class="type-signature"></span>buyOu

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="markets.js.html">markets.js</a>, <a href="markets.js.html#line50">line 50</a>
<a href="markets.js.html">markets.js</a>, <a href="markets.js.html#line51">line 51</a>
</li></ul></dd>


Expand Down Expand Up @@ -2570,6 +2570,52 @@ <h5>Parameters:</h5>



<tr>

<td class="name"><code>opts.cost</code></td>


<td class="type">


<span class="param-type"><code>number</code></span>
|

<span class="param-type"><code>string</code></span>
|

<span class="param-type"><code>BigNumber</code></span>



</td>


<td class="attributes">

&lt;optional><br>





</td>



<td class="default">

</td>


<td class="description last">
<p>Overrides the cost limit supplied to the market contract which is derived from the latest block state of the market along with the <code>outcomeTokenCount</code> and <code>limitMargin</code> parameters.</p>

</td>
</tr>



<tr>

<td class="name"><code>opts.approvalAmount</code></td>
Expand Down Expand Up @@ -4653,7 +4699,7 @@ <h4 class="name" id="sellOutcomeTokens"><span class="type-signature"></span>sell

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="markets.js.html">markets.js</a>, <a href="markets.js.html#line143">line 143</a>
<a href="markets.js.html">markets.js</a>, <a href="markets.js.html#line147">line 147</a>
</li></ul></dd>


Expand Down Expand Up @@ -4876,6 +4922,52 @@ <h5>Parameters:</h5>



<tr>

<td class="name"><code>opts.minProfit</code></td>


<td class="type">


<span class="param-type"><code>number</code></span>
|

<span class="param-type"><code>string</code></span>
|

<span class="param-type"><code>BigNumber</code></span>



</td>


<td class="attributes">

&lt;optional><br>





</td>



<td class="default">

</td>


<td class="description last">
<p>Overrides the minimum profit limit supplied to the market contract which is derived from the latest block state of the market along with the <code>outcomeTokenCount</code> and <code>limitMargin</code> parameters.</p>

</td>
</tr>



<tr>

<td class="name"><code>opts.approvalAmount</code></td>
Expand Down Expand Up @@ -5216,7 +5308,7 @@ <h5>Parameters:</h5>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 09 2017 16:20:44 GMT-0600 (CST) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Nov 24 2017 11:06:23 GMT-0600 (CST) using the Minami theme.
</footer>

<script>hljs.initHighlightingOnLoad();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/events.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ <h1 class="page-title">events.js</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 09 2017 16:20:44 GMT-0600 (CST) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Nov 24 2017 11:06:23 GMT-0600 (CST) using the Minami theme.
</footer>

<script>hljs.initHighlightingOnLoad();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ <h3>Gas estimations</h3><p>Many of the methods on the gnosis API also have an as
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 09 2017 16:20:44 GMT-0600 (CST) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Nov 24 2017 11:06:23 GMT-0600 (CST) using the Minami theme.
</footer>

<script>hljs.initHighlightingOnLoad();</script>
Expand Down
8 changes: 6 additions & 2 deletions docs/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,11 @@ <h1 class="page-title">index.js</h1>
}
} else if (typeof provider === 'string') {
this.web3 = new Web3(new Web3.providers.HttpProvider(provider))
} else if (typeof provider === 'object' &amp;&amp; provider.constructor.name.toLowerCase().endsWith('provider')) {
} else if (
typeof provider === 'object' &amp;&amp;
typeof provider.send === 'function' &amp;&amp;
typeof provider.sendAsync === 'function'
) {
this.web3 = new Web3(provider)
} else {
throw new TypeError(`provider of type '${typeof provider}' not supported`)
Expand Down Expand Up @@ -317,7 +321,7 @@ <h1 class="page-title">index.js</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 09 2017 16:20:44 GMT-0600 (CST) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Nov 24 2017 11:06:23 GMT-0600 (CST) using the Minami theme.
</footer>

<script>hljs.initHighlightingOnLoad();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/lmsr.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ <h1 class="page-title">lmsr.js</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 09 2017 16:20:44 GMT-0600 (CST) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Nov 24 2017 11:06:23 GMT-0600 (CST) using the Minami theme.
</footer>

<script>hljs.initHighlightingOnLoad();</script>
Expand Down
36 changes: 21 additions & 15 deletions docs/markets.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ <h1 class="page-title">markets.js</h1>
* @param {(number|string|BigNumber)} opts.outcomeTokenIndex - The index of the outcome
* @param {(number|string|BigNumber)} opts.outcomeTokenCount - Number of outcome tokens to buy
* @param {(number|string|BigNumber)} [opts.limitMargin=0] - Because transactions change prices, there is a chance that the cost limit for the buy, which is set to the cost according to the latest mined block, will prevent the buy transaction from succeeding. This parameter can be used to increase the cost limit by a fixed proportion. For example, specifying `limitMargin: 0.05` will make the cost limit increase by 5%.
* @param {(number|string|BigNumber)} [opts.cost] - Overrides the cost limit supplied to the market contract which is derived from the latest block state of the market along with the `outcomeTokenCount` and `limitMargin` parameters.
* @param {(number|string|BigNumber)} [opts.approvalAmount] - Amount of collateral to allow market to spend. If unsupplied or null, allowance will be reset to the `approvalResetAmount` only if necessary. If set to 0, the approval transaction will be skipped.
* @param {(number|string|BigNumber)} [opts.approvalResetAmount] - Set to this amount when resetting market collateral allowance. If unsupplied or null, will be the cost of this transaction.
* @returns {BigNumber} How much collateral tokens caller paid
Expand All @@ -103,7 +104,7 @@ <h1 class="page-title">markets.js</h1>

const txOpts = _.pick(opts, ['from', 'to', 'value', 'gas', 'gasPrice'])

let { approvalAmount, approvalResetAmount, limitMargin } = opts || {}
let { approvalAmount, approvalResetAmount, limitMargin, cost } = opts || {}

const market = await this.contracts.Market.at(marketAddress)
const collateralToken = await this.contracts.Token.at(
Expand All @@ -112,13 +113,15 @@ <h1 class="page-title">markets.js</h1>
).collateralToken()
)

if(limitMargin == null) {
limitMargin = 0
}
if(cost == null) {
if(limitMargin == null) {
limitMargin = 0
}

const baseCost = await this.lmsrMarketMaker.calcCost(marketAddress, outcomeTokenIndex, outcomeTokenCount, txOpts)
const baseCostWithFee = baseCost.add(await market.calcMarketFee(baseCost, txOpts))
const cost = baseCostWithFee.mul(this.web3.toBigNumber(1).add(limitMargin)).round()
const baseCost = await this.lmsrMarketMaker.calcCost(marketAddress, outcomeTokenIndex, outcomeTokenCount, txOpts)
const baseCostWithFee = baseCost.add(await market.calcMarketFee(baseCost, txOpts))
cost = baseCostWithFee.mul(this.web3.toBigNumber(1).add(limitMargin)).round()
}

if(approvalResetAmount == null) {
approvalResetAmount = cost
Expand Down Expand Up @@ -178,6 +181,7 @@ <h1 class="page-title">markets.js</h1>
* @param {(number|string|BigNumber)} opts.outcomeTokenIndex - The index of the outcome
* @param {(number|string|BigNumber)} opts.outcomeTokenCount - Number of outcome tokens to sell
* @param {(number|string|BigNumber)} [opts.limitMargin=0] - Because transactions change profits, there is a chance that the profit limit for the sell, which is set to the profit according to the latest mined block, will prevent the sell transaction from succeeding. This parameter can be used to decrease the profit limit by a fixed proportion. For example, specifying `limitMargin: 0.05` will make the profit limit decrease by 5%.
* @param {(number|string|BigNumber)} [opts.minProfit] - Overrides the minimum profit limit supplied to the market contract which is derived from the latest block state of the market along with the `outcomeTokenCount` and `limitMargin` parameters.
* @param {(number|string|BigNumber)} [opts.approvalAmount] - Amount of outcome tokens to allow market to handle. If unsupplied or null, allowance will be reset to the `approvalResetAmount` only if necessary. If set to 0, the approval transaction will be skipped.
* @param {(number|string|BigNumber)} [opts.approvalResetAmount] - Set to this amount when resetting market outcome token allowance. If unsupplied or null, will be the sale amount specified by `outcomeTokenCount`.
* @returns {BigNumber} How much collateral tokens caller received from sale
Expand All @@ -196,7 +200,7 @@ <h1 class="page-title">markets.js</h1>

const txOpts = _.pick(opts, ['from', 'to', 'value', 'gas', 'gasPrice'])

let { approvalAmount, approvalResetAmount, limitMargin } = opts || {}
let { approvalAmount, approvalResetAmount, limitMargin, minProfit } = opts || {}

const market = await this.contracts.Market.at(marketAddress)
const outcomeToken = await this.contracts.Token.at(
Expand All @@ -205,13 +209,15 @@ <h1 class="page-title">markets.js</h1>
).outcomeTokens(outcomeTokenIndex)
)

if(limitMargin == null) {
limitMargin = 0
}
if(minProfit == null) {
if(limitMargin == null) {
limitMargin = 0
}

const baseProfit = await this.lmsrMarketMaker.calcProfit(marketAddress, outcomeTokenIndex, outcomeTokenCount, txOpts)
const baseProfitWithFee = baseProfit.sub(await market.calcMarketFee(baseProfit, txOpts))
const minProfit = baseProfitWithFee.mul(this.web3.toBigNumber(1).sub(limitMargin)).round()
const baseProfit = await this.lmsrMarketMaker.calcProfit(marketAddress, outcomeTokenIndex, outcomeTokenCount, txOpts)
const baseProfitWithFee = baseProfit.sub(await market.calcMarketFee(baseProfit, txOpts))
minProfit = baseProfitWithFee.mul(this.web3.toBigNumber(1).sub(limitMargin)).round()
}

if(approvalResetAmount == null) {
approvalResetAmount = outcomeTokenCount
Expand Down Expand Up @@ -270,7 +276,7 @@ <h1 class="page-title">markets.js</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 09 2017 16:20:44 GMT-0600 (CST) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Nov 24 2017 11:06:23 GMT-0600 (CST) using the Minami theme.
</footer>

<script>hljs.initHighlightingOnLoad();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/oracles.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ <h1 class="page-title">oracles.js</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 09 2017 16:20:44 GMT-0600 (CST) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Nov 24 2017 11:06:23 GMT-0600 (CST) using the Minami theme.
</footer>

<script>hljs.initHighlightingOnLoad();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial-api-overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ <h1 class="page-title">API Overview</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 09 2017 16:20:44 GMT-0600 (CST) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Nov 24 2017 11:06:23 GMT-0600 (CST) using the Minami theme.
</footer>

<script>hljs.initHighlightingOnLoad();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial-developer-guide.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ <h1 class="page-title">Developer Guide</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 09 2017 16:20:44 GMT-0600 (CST) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Nov 24 2017 11:06:23 GMT-0600 (CST) using the Minami theme.
</footer>

<script>hljs.initHighlightingOnLoad();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial-events-oracles-and-markets.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ <h3>Events and Collateral</h3><p>Once an oracle is created, an event contract ma
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 09 2017 16:20:44 GMT-0600 (CST) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Nov 24 2017 11:06:23 GMT-0600 (CST) using the Minami theme.
</footer>

<script>hljs.initHighlightingOnLoad();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial-installation.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ <h4>MetaMask</h4><p><a href="https://metamask.io/">MetaMask</a> is a Chrome brow
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 09 2017 16:20:44 GMT-0600 (CST) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Nov 24 2017 11:06:23 GMT-0600 (CST) using the Minami theme.
</footer>

<script>hljs.initHighlightingOnLoad();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial-lmsr-primer.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ <h3>LMSR Calculation Functions</h3><p>The functions <a href="Gnosis.html#.calcLM
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 09 2017 16:20:44 GMT-0600 (CST) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Nov 24 2017 11:06:23 GMT-0600 (CST) using the Minami theme.
</footer>

<script>hljs.initHighlightingOnLoad();</script>
Expand Down
Loading

0 comments on commit 6fa737a

Please sign in to comment.