Skip to content

Commit

Permalink
allow extended FRE (#875)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcos20 committed Jun 30, 2021
1 parent 293813f commit 2985518
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/exchange/FixedRateExchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,32 @@ export class OceanFixedRateExchange {
rate: string,
address: string,
amount?: string
): SubscribablePromise<FixedRateCreateProgressStep, TransactionReceipt> {
return this.createExchange(this.oceanAddress, dataToken, rate, address, amount)
}

/**
* Creates new exchange pair between Ocean Token and data token.
* @param {String} dataToken Data Token Contract Address
* @param {Number} rate exchange rate
* @param {String} address User address
* @param {String} amount Optional, amount of datatokens to be approved for the exchange
* @return {Promise<TransactionReceipt>} TransactionReceipt
*/
public createExchange(
baseToken: string,
dataToken: string,
rate: string,
address: string,
amount?: string
): SubscribablePromise<FixedRateCreateProgressStep, TransactionReceipt> {
return new SubscribablePromise(async (observer) => {
observer.next(FixedRateCreateProgressStep.CreatingExchange)
let estGas
const gasLimitDefault = this.GASLIMIT_DEFAULT
try {
estGas = await this.contract.methods
.create(this.oceanAddress, dataToken, this.web3.utils.toWei(rate))
.create(baseToken, dataToken, this.web3.utils.toWei(rate))
.estimateGas({ from: address }, (err, estGas) =>
err ? gasLimitDefault : estGas
)
Expand Down

0 comments on commit 2985518

Please sign in to comment.