This repository has been archived by the owner on Jul 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@0x/asset-swapper
: Rebase against development and pay protocol fees.
- Loading branch information
1 parent
1252045
commit c3a4b7e
Showing
41 changed files
with
5,566 additions
and
3,059 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,68 @@ | ||
import { SignedOrder } from '@0x/types'; | ||
import { BigNumber } from '@0x/utils'; | ||
|
||
import { | ||
ForwarderSwapQuoteExecutionOpts, | ||
ForwarderSwapQuoteGetOutputOpts, | ||
OrdersAndFillableAmounts, | ||
ForwarderExtensionContractOpts, | ||
OrderPrunerOpts, | ||
OrderPrunerPermittedFeeTypes, | ||
SwapQuoteExecutionOpts, | ||
SwapQuoteGetOutputOpts, | ||
SwapQuoteRequestOpts, | ||
SwapQuoterOpts, | ||
} from './types'; | ||
|
||
const ETH_GAS_STATION_API_BASE_URL = 'https://ethgasstation.info'; | ||
const NULL_BYTES = '0x'; | ||
const NULL_ERC20_ASSET_DATA = '0xf47261b00000000000000000000000000000000000000000000000000000000000000000'; | ||
const NULL_ADDRESS = '0x0000000000000000000000000000000000000000'; | ||
const MAINNET_CHAIN_ID = 1; | ||
const ONE_SECOND_MS = 1000; | ||
const DEFAULT_PER_PAGE = 1000; | ||
const PROTOCOL_FEE_MULTIPLIER = 150000; | ||
|
||
const DEFAULT_SWAP_QUOTER_OPTS: SwapQuoterOpts = { | ||
chainId: MAINNET_CHAIN_ID, | ||
orderRefreshIntervalMs: 10000, // 10 seconds | ||
const DEFAULT_ORDER_PRUNER_OPTS: OrderPrunerOpts = { | ||
expiryBufferMs: 120000, // 2 minutes | ||
permittedOrderFeeTypes: new Set<OrderPrunerPermittedFeeTypes>([ | ||
OrderPrunerPermittedFeeTypes.NoFees, | ||
OrderPrunerPermittedFeeTypes.MakerDenominatedTakerFee, | ||
]), // Default asset-swapper for CFL oriented fee types | ||
}; | ||
|
||
const DEFAULT_SWAP_QUOTER_OPTS: SwapQuoterOpts = { | ||
...{ | ||
chainId: MAINNET_CHAIN_ID, | ||
orderRefreshIntervalMs: 10000, // 10 seconds | ||
}, | ||
...DEFAULT_ORDER_PRUNER_OPTS, | ||
}; | ||
|
||
const DEFAULT_FORWARDER_SWAP_QUOTE_GET_OPTS: ForwarderSwapQuoteGetOutputOpts = { | ||
const DEFAULT_FORWARDER_SWAP_QUOTE_GET_OPTS: SwapQuoteGetOutputOpts & ForwarderExtensionContractOpts = { | ||
feePercentage: 0, | ||
feeRecipient: NULL_ADDRESS, | ||
}; | ||
|
||
const DEFAULT_FORWARDER_SWAP_QUOTE_EXECUTE_OPTS: ForwarderSwapQuoteExecutionOpts = DEFAULT_FORWARDER_SWAP_QUOTE_GET_OPTS; | ||
const DEFAULT_FORWARDER_SWAP_QUOTE_EXECUTE_OPTS: SwapQuoteExecutionOpts & | ||
ForwarderExtensionContractOpts = DEFAULT_FORWARDER_SWAP_QUOTE_GET_OPTS; | ||
|
||
const DEFAULT_SWAP_QUOTE_REQUEST_OPTS: SwapQuoteRequestOpts = { | ||
shouldDisableRequestingFeeOrders: false, | ||
slippagePercentage: 0.2, // 20% slippage protection, | ||
}; | ||
|
||
const EMPTY_ORDERS_AND_FILLABLE_AMOUNTS: OrdersAndFillableAmounts = { | ||
orders: [] as SignedOrder[], | ||
remainingFillableMakerAssetAmounts: [] as BigNumber[], | ||
}; | ||
|
||
export const constants = { | ||
ETH_GAS_STATION_API_BASE_URL, | ||
NULL_BYTES, | ||
ZERO_AMOUNT: new BigNumber(0), | ||
NULL_ADDRESS, | ||
MAINNET_CHAIN_ID, | ||
DEFAULT_ORDER_PRUNER_OPTS, | ||
ETHER_TOKEN_DECIMALS: 18, | ||
ONE_AMOUNT: new BigNumber(1), | ||
MAX_AFFILIATE_FEE_PERCENTAGE: 0.05, | ||
ONE_SECOND_MS, | ||
DEFAULT_SWAP_QUOTER_OPTS, | ||
DEFAULT_FORWARDER_SWAP_QUOTE_GET_OPTS, | ||
DEFAULT_FORWARDER_SWAP_QUOTE_EXECUTE_OPTS, | ||
DEFAULT_SWAP_QUOTE_REQUEST_OPTS, | ||
EMPTY_ORDERS_AND_FILLABLE_AMOUNTS, | ||
DEFAULT_PER_PAGE, | ||
PROTOCOL_FEE_MULTIPLIER, | ||
NULL_ERC20_ASSET_DATA, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.