Add GST support to DFB
This commit is contained in:
parent
b09c751942
commit
282930cb9b
@ -21,6 +21,9 @@
|
||||
{
|
||||
"note": "Add `DexForwaderBridge` bridge contract.",
|
||||
"pr": 2525
|
||||
},
|
||||
{
|
||||
"note": "Add Gas Token freeing to `DexForwaderBridge` contract."
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -23,15 +23,19 @@ import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/LibERC20Token.sol";
|
||||
import "@0x/contracts-exchange-libs/contracts/src/IWallet.sol";
|
||||
import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
|
||||
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
|
||||
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
||||
import "@0x/contracts-utils/contracts/src/LibSafeMath.sol";
|
||||
import "../interfaces/IERC20Bridge.sol";
|
||||
import "./MixinGasToken.sol";
|
||||
|
||||
|
||||
// solhint-disable space-after-comma, indent
|
||||
contract DexForwarderBridge is
|
||||
IERC20Bridge,
|
||||
IWallet
|
||||
IWallet,
|
||||
DeploymentConstants,
|
||||
MixinGasToken
|
||||
{
|
||||
using LibSafeMath for uint256;
|
||||
|
||||
@ -68,6 +72,7 @@ contract DexForwarderBridge is
|
||||
bytes calldata bridgeData
|
||||
)
|
||||
external
|
||||
freesGasTokensFromCollector
|
||||
returns (bytes4 success)
|
||||
{
|
||||
TransferFromState memory state;
|
||||
@ -84,16 +89,15 @@ contract DexForwarderBridge is
|
||||
break;
|
||||
}
|
||||
|
||||
BridgeCall memory call = state.calls[i];
|
||||
// Compute token amounts.
|
||||
state.callInputTokenAmount = LibSafeMath.min256(
|
||||
call.inputTokenAmount,
|
||||
state.calls[i].inputTokenAmount,
|
||||
state.initialInputTokenBalance.safeSub(state.totalInputTokenSold)
|
||||
);
|
||||
state.callOutputTokenAmount = LibMath.getPartialAmountFloor(
|
||||
state.callInputTokenAmount,
|
||||
call.inputTokenAmount,
|
||||
call.outputTokenAmount
|
||||
state.calls[i].inputTokenAmount,
|
||||
state.calls[i].outputTokenAmount
|
||||
);
|
||||
|
||||
// Execute the call in a new context so we can recoup transferred
|
||||
@ -101,13 +105,13 @@ contract DexForwarderBridge is
|
||||
(bool didSucceed, ) = address(this)
|
||||
.call(abi.encodeWithSelector(
|
||||
this.executeBridgeCall.selector,
|
||||
call.target,
|
||||
state.calls[i].target,
|
||||
to,
|
||||
state.inputToken,
|
||||
outputToken,
|
||||
state.callInputTokenAmount,
|
||||
state.callOutputTokenAmount,
|
||||
call.bridgeData
|
||||
state.calls[i].bridgeData
|
||||
));
|
||||
|
||||
if (didSucceed) {
|
||||
|
@ -156,6 +156,7 @@ contract TestDexForwarderBridge is
|
||||
ITestDexForwarderBridge,
|
||||
DexForwarderBridge
|
||||
{
|
||||
|
||||
function createBridge(
|
||||
bytes4 returnCode,
|
||||
string memory revertError
|
||||
@ -217,4 +218,12 @@ contract TestDexForwarderBridge is
|
||||
function balanceOf(address token, address owner) public view returns (uint256) {
|
||||
return TestDexForwarderBridgeTestToken(token).balanceOf(owner);
|
||||
}
|
||||
|
||||
function _getGstAddress()
|
||||
internal
|
||||
view
|
||||
returns (address gst)
|
||||
{
|
||||
return address(0);
|
||||
}
|
||||
}
|
||||
|
@ -152,10 +152,19 @@ export function createOrdersFromPath(path: Fill[], opts: CreateOrderFromPathOpts
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
// Liquidity Provider must be called by ERC20BridgeProxy
|
||||
if (collapsedPath[i].source === ERC20BridgeSource.LiquidityProvider) {
|
||||
orders.push(createBridgeOrder(collapsedPath[i], opts));
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
// If there are contiguous bridge orders, we can batch them together.
|
||||
const contiguousBridgeFills = [collapsedPath[i]];
|
||||
for (let j = i + 1; j < collapsedPath.length; ++j) {
|
||||
if (collapsedPath[j].source === ERC20BridgeSource.Native) {
|
||||
if (
|
||||
collapsedPath[j].source === ERC20BridgeSource.Native ||
|
||||
collapsedPath[j].source === ERC20BridgeSource.LiquidityProvider
|
||||
) {
|
||||
break;
|
||||
}
|
||||
contiguousBridgeFills.push(collapsedPath[j]);
|
||||
|
@ -29,6 +29,12 @@
|
||||
{
|
||||
"note": "Redeploy `Forwarder` on all networks",
|
||||
"pr": 2521
|
||||
},
|
||||
{
|
||||
"note": "Redeploy `DexForwarderBridge` on Mainnet with Gas Token freeing"
|
||||
},
|
||||
{
|
||||
"note": "Revert to older Curve Bridge (without Gas Tokens)"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -28,9 +28,9 @@
|
||||
"godsUnchainedValidator": "0x09a379ef7218bcfd8913faa8b281ebc5a2e0bc04",
|
||||
"broker": "0xd4690a51044db77d91d7aa8f7a3a5ad5da331af0",
|
||||
"chainlinkStopLimit": "0xeb27220f95f364e1d9531992c48613f231839f53",
|
||||
"curveBridge": "0x1cf6ccc7e15d0d99a9498f37e16ba65b5c54bdd0",
|
||||
"curveBridge": "0x6dc7950423ada9f56fb2c93a23edb787f1e29088",
|
||||
"maximumGasPrice": "0xe2bfd35306495d11e3c9db0d8de390cda24563cf",
|
||||
"dexForwarderBridge": "0xa96844087062acf8556ca06a27702c6d19f87e57"
|
||||
"dexForwarderBridge": "0x2b135c732110be20db72e44ab2a4b149fa213599"
|
||||
},
|
||||
"3": {
|
||||
"erc20Proxy": "0xb1408f4c245a23c31b98d2c626777d4c0d766caa",
|
||||
|
Loading…
x
Reference in New Issue
Block a user