Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow extended FRE #875

Merged
merged 1 commit into from
Jun 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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