Skip to content

Commit

Permalink
feat: add swap adapter on polygon (#208)
Browse files Browse the repository at this point in the history
* feat: add swap adapter on polygon

* fix: update liquidityswap networks

* fix: double gas limit for polygon

* fix: decrease gas limit
  • Loading branch information
sakulstra authored Jul 27, 2021
1 parent aad2d41 commit 66cff72
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/tx-builder/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
} from '../types';

export const DEFAULT_NULL_VALUE_ON_TX = BigNumber.from(0).toHexString();
export const POLYGON_DEFAULT_GAS = BigNumber.from('1000000');
export const DEFAULT_APPROVE_AMOUNT = constants.MaxUint256.toString();
export const MAX_UINT_AMOUNT =
'115792089237316195423570985008687907853269984665640564039457584007913129639935';
Expand Down Expand Up @@ -157,7 +156,7 @@ export const enabledNetworksByService: EnabledNetworksType = {
Network.mumbai,
],
faucet: [Network.kovan],
liquiditySwapAdapter: [Network.kovan, Network.mainnet],
liquiditySwapAdapter: [Network.mainnet, Network.polygon],
repayWithCollateralAdapter: [Network.kovan, Network.mainnet],
aaveGovernanceV2: [Network.kovan, Network.mainnet],
ltaMigrator: [Network.kovan, Network.mainnet],
Expand Down
2 changes: 1 addition & 1 deletion src/tx-builder/config/v2/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const commonContractAddressBetweenMarketsV2: CommonConfigType = {
LEND_TO_AAVE_MIGRATOR: '',
WETH_GATEWAY: '0xbEadf48d62aCC944a06EEaE0A9054A90E5A7dc97',
FAUCET: '',
SWAP_COLLATERAL_ADAPTER: '',
SWAP_COLLATERAL_ADAPTER: '0x35784a624D4FfBC3594f4d16fA3801FeF063241c',
REPAY_WITH_COLLATERAL_ADAPTER: '',
FLASHLIQUIDATION: '',
INCENTIVES_CONTROLLER: '0x357d51124f59836ded84c8a1730d72b749d8bc23',
Expand Down
5 changes: 3 additions & 2 deletions src/tx-builder/utils/gasStation.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { BigNumber } from 'ethers';
import { POLYGON_DEFAULT_GAS } from '../config';
import { transactionType, Configuration, Network } from '../types';

const DEFAULT_SURPLUS = 30; // 30%
// polygon gas estimation is very off for some reason
const POLYGON_SURPLUS = 60; // 60%

export const estimateGas = async (
tx: transactionType,
Expand All @@ -24,7 +25,7 @@ export const estimateGasByNetwork = async (

const { network } = config;
if (network === Network.polygon) {
return POLYGON_DEFAULT_GAS;
return estimatedGas.add(estimatedGas.mul(POLYGON_SURPLUS).div(100));
}

return estimatedGas.add(
Expand Down

0 comments on commit 66cff72

Please sign in to comment.