}
const radio = BigNumber( GetContractArgs().radio )
- const matchesAmount = radio.multipliedBy(amountBill).toNumber()
+ const profitAmount = radio.multipliedBy(amountBill).toNumber()
- const result = matchesUTXO(resp, matchesAmount)
+ const result = matchesUTXO(resp, profitAmount)
const capitalAmount = result.amount
const capitalAsset = result.asset
const utxo = result.hash
- if(matchesAmount > capitalAmount) {
+ if(profitAmount > capitalAmount) {
throw 'input amount must be smaller or equal to ' + capitalAmount/radio.toNumber() + '.'
}else{
const input = []
updateUtxo({"hash": utxo})
.then(()=>{
- window.bytom.advancedTransfer(account, input, output, GetContractArgs().gas*10000000, args, 1)
+ window.bytom.advancedTransfer(input, output, GetContractArgs().gas*10000000, args, 1)
.then((resp) => {
if(resp.action === 'reject'){
reject('user reject the request')
}else if(resp.action === 'success'){
+ const transactionHash = resp.message.result.data.transaction_hash
updateBalances({
- "tx_id": resp.message.result.data.transaction_hash,
+ "tx_id": transactionHash,
"address": saver,
"asset": GetContractArgs().assetDeposited,
- "amount": amountBill*GetContractArgs().totalAmountCapital/GetContractArgs().totalAmountBill
+ "amount": profitAmount
}).then(()=>{
updateBalances({
- "tx_id": resp.message.result.data.transaction_hash,
+ "tx_id": transactionHash,
"address": account.address,
"asset": GetContractArgs().assetBill,
"amount": -amountBill
import React from 'react'
import { FixedLimitProfit } from './action'
import GetContractArgs from "../../constants";
+import BigNumber from 'bignumber.js'
class Profit extends React.Component {
.then(()=> {
this.setState({
error:'',
- msg:`Submit success!!! you spent ${amount} bill asset, and gain ${amount*GetContractArgs().totalAmountCapital/GetContractArgs().totalAmountBill} deposit asset.`
+ msg:`Submit success!!! you spent ${amount} bill asset, and gain ${BigNumber(amount).multipliedBy(GetContractArgs().radio).toNumber()} deposit asset.`
})
}).catch(err => {
this.setState({
<h2>Profit</h2>
<div className="mt-3 mb-4">
<p className='lead'>Profit should get above the block height {GetContractArgs().dueBlockHeight}.</p>
- <p className='lead'>Send {this.state.amount} Bill Asset from your chrome extension account <b className="font-weight-bolder text-uppercase">{this.state.account && this.state.account.alias}</b>, and the address {this.state.address} will gain {this.state.amount*GetContractArgs().totalAmountCapital/GetContractArgs().totalAmountBill || ''} Deposit Asset.</p>
+ <p className='lead'>Send {this.state.amount} Bill Asset from your chrome extension account <b className="font-weight-bolder text-uppercase">{this.state.account && this.state.account.alias}</b>, and the address {this.state.address} will gain {BigNumber(this.state.amount).multipliedBy(GetContractArgs().radio).toNumber() || ''} Deposit Asset.</p>
</div>
<form onSubmit={this.handleSubmit}>
<div className="form-group">
import { matchesUTXO } from '../../filter'
import BigNumber from 'bignumber.js'
-export function FixedLimitDeposit(account, amount, address) {
+export function FixedLimitDeposit(amount, address) {
return new Promise((resolve, reject) => {
return listDappUTXO({
"program": GetContractArgs().depositProgram,
updateUtxo({"hash": utxo})
.then(()=>{
- window.bytom.advancedTransfer(account, input, output, GetContractArgs().gas*10000000, args, 1)
+ window.bytom.advancedTransfer(input, output, GetContractArgs().gas*10000000, args, 1)
.then((resp) => {
if(resp.action === 'reject'){
reject('user reject the request')
const account = this.state.account
const address = account.address
- FixedLimitDeposit(account, amount, address)
+ FixedLimitDeposit(amount, address)
.then(()=> {
this.setState({
error:'',