mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
fix pool pricing
This commit is contained in:
parent
a21f9e0adb
commit
c4fb445999
@ -70,6 +70,7 @@ export class OceanPool extends Pool {
|
|||||||
* @param {String} token DataToken address
|
* @param {String} token DataToken address
|
||||||
* @param {String} amount DataToken amount
|
* @param {String} amount DataToken amount
|
||||||
* @param {String} weight DataToken weight
|
* @param {String} weight DataToken weight
|
||||||
|
* @param {String} oceanAmount Ocean amount
|
||||||
* @param {String} fee Swap fee. E.g. to get a 0.1% swapFee use `0.001`. The maximum allowed swapFee is `0.1` (10%).
|
* @param {String} fee Swap fee. E.g. to get a 0.1% swapFee use `0.001`. The maximum allowed swapFee is `0.1` (10%).
|
||||||
* @return {String}
|
* @return {String}
|
||||||
*/
|
*/
|
||||||
@ -78,6 +79,7 @@ export class OceanPool extends Pool {
|
|||||||
token: string,
|
token: string,
|
||||||
amount: string,
|
amount: string,
|
||||||
weight: string,
|
weight: string,
|
||||||
|
oceanAmount: string,
|
||||||
fee: string
|
fee: string
|
||||||
): SubscribablePromise<PoolCreateProgressStep, TransactionReceipt> {
|
): SubscribablePromise<PoolCreateProgressStep, TransactionReceipt> {
|
||||||
if (this.oceanAddress == null) {
|
if (this.oceanAddress == null) {
|
||||||
@ -101,7 +103,6 @@ export class OceanPool extends Pool {
|
|||||||
}
|
}
|
||||||
const address = createTxid.events.BPoolRegistered.returnValues[0]
|
const address = createTxid.events.BPoolRegistered.returnValues[0]
|
||||||
const oceanWeight = 10 - parseFloat(weight)
|
const oceanWeight = 10 - parseFloat(weight)
|
||||||
const oceanAmount = (parseFloat(amount) * oceanWeight) / parseFloat(weight)
|
|
||||||
this.dtAddress = token
|
this.dtAddress = token
|
||||||
observer.next(PoolCreateProgressStep.ApprovingDatatoken)
|
observer.next(PoolCreateProgressStep.ApprovingDatatoken)
|
||||||
let txid
|
let txid
|
||||||
|
@ -125,7 +125,19 @@ describe('Balancer flow', () => {
|
|||||||
})
|
})
|
||||||
it('Alice creates a new OceanPool pool', async () => {
|
it('Alice creates a new OceanPool pool', async () => {
|
||||||
/// new pool with total DT = 45 , dt weight=90% with swap fee 2%
|
/// new pool with total DT = 45 , dt weight=90% with swap fee 2%
|
||||||
const createTx = await Pool.create(alice, tokenAddress, '45', '9', '0.02')
|
const dtAmount = '45'
|
||||||
|
const dtWeight = '9'
|
||||||
|
const oceanAmount =
|
||||||
|
(parseFloat(dtAmount) * (10 - parseFloat(dtWeight))) / parseFloat(dtWeight)
|
||||||
|
const fee = '0.02'
|
||||||
|
const createTx = await Pool.create(
|
||||||
|
alice,
|
||||||
|
tokenAddress,
|
||||||
|
dtAmount,
|
||||||
|
dtWeight,
|
||||||
|
String(oceanAmount),
|
||||||
|
fee
|
||||||
|
)
|
||||||
alicePoolAddress = createTx.events.BPoolRegistered.returnValues[0]
|
alicePoolAddress = createTx.events.BPoolRegistered.returnValues[0]
|
||||||
const s = await Pool.getPoolSharesTotalSupply(alicePoolAddress)
|
const s = await Pool.getPoolSharesTotalSupply(alicePoolAddress)
|
||||||
assert(String(s) === '100', 'totalSupply does not match: ' + s)
|
assert(String(s) === '100', 'totalSupply does not match: ' + s)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user