Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable express in AxelarAdapter #29

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 27 additions & 11 deletions src/adapters/AxelarAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "../interfaces/IRouteProcessor.sol";
import "../interfaces/IWETH.sol";

import "axelar-gmp-sdk-solidity/contracts/executable/AxelarExecutable.sol";
import "axelar-gmp-sdk-solidity/contracts/express/ExpressExecutable.sol";
import "axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGasService.sol";
import "axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGateway.sol";
import "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
Expand All @@ -30,6 +31,7 @@ contract AxelarAdapter is ISushiXSwapV2Adapter, AxelarExecutable {
bytes32 symbol; // bridged token symbol
uint256 amount; // amount to bridge
address to; // address for fallback transfers on _execute call
bool useExpress;
}

error RpSentNativeIn();
Expand Down Expand Up @@ -123,17 +125,31 @@ contract AxelarAdapter is ISushiXSwapV2Adapter, AxelarExecutable {
bytes memory payload = abi.encode(params.to, _swapData, _payloadData);

// pay native gas to gasService
axelarGasService.payNativeGasForContractCallWithToken{
value: address(this).balance
}(
address(this),
Bytes32ToString.toTrimmedString(params.destinationChain),
AddressToString.toString(params.destinationAddress),
payload,
Bytes32ToString.toTrimmedString(params.symbol),
params.amount,
payable(_refundAddress) // refund address
);
if (params.useExpress) {
axelarGasService.payNativeGasForExpressCallWithToken{
value: address(this).balance
}(
address(this),
Bytes32ToString.toTrimmedString(params.destinationChain),
AddressToString.toString(params.destinationAddress),
payload,
Bytes32ToString.toTrimmedString(params.symbol),
params.amount,
payable(_refundAddress) // refund address
);
} else {
axelarGasService.payNativeGasForContractCallWithToken{
value: address(this).balance
}(
address(this),
Bytes32ToString.toTrimmedString(params.destinationChain),
AddressToString.toString(params.destinationAddress),
payload,
Bytes32ToString.toTrimmedString(params.symbol),
params.amount,
payable(_refundAddress) // refund address
);
}

// sendToken and message w/ payload to the gateway contract
gateway.callContractWithToken(
Expand Down