Skip to content

Commit

Permalink
update gas limits (#1864)
Browse files Browse the repository at this point in the history
* update gas limits

* add new rinkeby mastercopy + getGas for xdai

* default gas for safe apps

* return missing networkId

* update target safe addresses

Co-authored-by: Thomas Pulber <[email protected]>
  • Loading branch information
hexyls and pimato authored Apr 29, 2021
1 parent 185498f commit 1d833f6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ const MarketSellWrapper: React.FC<Props> = (props: Props) => {
/>
<GridTransactionDetails>
<div>
<TokenBalance text="Your Shares" value={formatNumber(displaySelectedOutcomeBalance)} />
<TokenBalance text="Your Shares" value={displaySelectedOutcomeBalance} />
<ReactTooltip id="walletBalanceTooltip" />
<TextfieldCustomPlaceholder
formField={
Expand Down
43 changes: 19 additions & 24 deletions app/src/services/cpk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,12 @@ class CPKService {
return tx
}

getGas = async (gas: number): Promise<number> => {
const deployed = await this.cpk.isProxyDeployed()
if (deployed) {
return gas
getGas = async (txOptions: TxOptions): Promise<void> => {
const network = await this.provider.getNetwork()
const networkId = network.chainId
if (networkId === networkIds.XDAI || this.isSafeApp) {
txOptions.gas = defaultGas
}
const addProxyDeploymentGas = 500000
return gas + addProxyDeploymentGas
}

buyOutcomes = async ({
Expand All @@ -282,7 +281,7 @@ class CPKService {
const transactions: Transaction[] = []

const txOptions: TxOptions = {}
txOptions.gas = defaultGas
await this.getGas(txOptions)

const buyAmount = this.cpk.relay ? amount.sub(RELAY_FEE) : amount

Expand Down Expand Up @@ -434,7 +433,7 @@ class CPKService {

const transactions: Transaction[] = []
const txOptions: TxOptions = {}
txOptions.gas = defaultGas
await this.getGas(txOptions)

let collateral
const fundingAmount = this.cpk.relay ? marketData.funding.sub(RELAY_FEE) : marketData.funding
Expand Down Expand Up @@ -661,7 +660,7 @@ class CPKService {

const transactions: Transaction[] = []
const txOptions: TxOptions = {}
txOptions.gas = defaultGas
await this.getGas(txOptions)

let collateral

Expand All @@ -682,7 +681,6 @@ class CPKService {
value: fundingAmount.toString(),
})
} else if (useCompoundReserve && compoundTokenDetails) {
txOptions.gas = defaultGas
if (userInputCollateral.address === pseudoNativeAssetAddress) {
// If user chosen collateral is ETH
collateral = marketData.collateral
Expand Down Expand Up @@ -861,16 +859,15 @@ class CPKService {
try {
const signer = this.provider.getSigner()
const account = await signer.getAddress()
const network = await this.provider.getNetwork()
const networkId = network.chainId

const outcomeTokensToSell = await marketMaker.calcSellAmount(amount, outcomeIndex)
const collateralAddress = await marketMaker.getCollateralToken()

const transactions: Transaction[] = []
const txOptions: TxOptions = {}
txOptions.gas = defaultGas

const network = await this.provider.getNetwork()
const networkId = network.chainId
await this.getGas(txOptions)

const collateralToken = getTokenFromAddress(networkId, collateralAddress)
const collateralSymbol = collateralToken.symbol.toLowerCase()
Expand Down Expand Up @@ -977,7 +974,7 @@ class CPKService {
const transactions: Transaction[] = []

const txOptions: TxOptions = {}
txOptions.gas = defaultGas
await this.getGas(txOptions)

let collateralSymbol = ''
let userInputCollateralSymbol: KnownToken
Expand Down Expand Up @@ -1124,7 +1121,7 @@ class CPKService {
transactions.push(mergePositionsTx)

const txOptions: TxOptions = {}
txOptions.gas = defaultGas
await this.getGas(txOptions)

const collateralToken = getTokenFromAddress(networkId, collateralAddress)
const collateralSymbol = collateralToken.symbol.toLowerCase()
Expand Down Expand Up @@ -1249,7 +1246,7 @@ class CPKService {

const transactions: Transaction[] = []
const txOptions: TxOptions = {}
txOptions.gas = defaultGas
await this.getGas(txOptions)

if (!isConditionResolved) {
transactions.push({
Expand Down Expand Up @@ -1337,7 +1334,7 @@ class CPKService {
try {
const transactions: Transaction[] = []
const txOptions: TxOptions = {}
txOptions.gas = defaultGas
await this.getGas(txOptions)

if (isScalar && scalarLow && scalarHigh) {
transactions.push({
Expand Down Expand Up @@ -1368,7 +1365,7 @@ class CPKService {
},
]
const txOptions: TxOptions = {}
txOptions.gas = defaultGas
await this.getGas(txOptions)
return this.execTransactions(transactions, txOptions, setTxHash, setTxState)
}
const txObject = await realitio.submitAnswer(question.id, answer, amount)
Expand All @@ -1385,7 +1382,7 @@ class CPKService {

proxyIsUpToDate = async (): Promise<boolean> => {
const network = await this.provider.getNetwork()
if (network.chainId === networkIds.XDAI) {
if (network.chainId === networkIds.XDAI || this.isSafeApp) {
return true
}
const deployed = await this.cpk.isProxyDeployed()
Expand All @@ -1401,8 +1398,8 @@ class CPKService {
upgradeProxyImplementation = async (): Promise<TransactionReceipt> => {
try {
const txOptions: TxOptions = {}
txOptions.gas = defaultGas
const network = await this.provider.getNetwork()
await this.getGas(txOptions)
const targetGnosisSafeImplementation = getTargetSafeImplementation(network.chainId)
const transactions: Transaction[] = [
{
Expand Down Expand Up @@ -1447,7 +1444,7 @@ class CPKService {
if (this.cpk.relay) {
const transactions: Transaction[] = []
const txOptions: TxOptions = {}
txOptions.gas = defaultGas
await this.getGas(txOptions)

// get mainnet relay signer
const to = await this.cpk.ethLibAdapter.signer.signer.getAddress()
Expand Down Expand Up @@ -1485,8 +1482,6 @@ class CPKService {

claimDaiTokens = async () => {
try {
const txOptions: TxOptions = {}
txOptions.gas = defaultGas
const xDaiService = new XdaiService(this.provider)

const transactions = await this.fetchLatestUnclaimedTransactions()
Expand Down
4 changes: 2 additions & 2 deletions app/src/util/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const networks: { [K in NetworkId]: Network } = {
symbol: 'ETH',
decimals: 18,
},
targetSafeImplementation: '0x6851D6fDFAfD08c0295C392436245E5bc78B0185',
targetSafeImplementation: '0xCB2E9FA32603Cdc2740b82a9A67ED3e977C33416',
defaultToken: 'dai',
blockExplorer: 'etherscan',
blockExplorerURL: 'https://etherscan.io',
Expand Down Expand Up @@ -184,7 +184,7 @@ const networks: { [K in NetworkId]: Network } = {
symbol: 'ETH',
decimals: 18,
},
targetSafeImplementation: '0x6851D6fDFAfD08c0295C392436245E5bc78B0185',
targetSafeImplementation: '0xcb05C7D28766e4fFB71ccbdAf6Ae1Cec555D61f8',
defaultToken: 'dai',
blockExplorer: 'etherscan',
blockExplorerURL: 'https://rinkeby.etherscan.io',
Expand Down

0 comments on commit 1d833f6

Please sign in to comment.