1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! GMX's own withdrawal: funds leave a GMX Account only by its owner's `transferOut` on GMX's
//! `MultichainTransferRouter`, which LaMarge never relays. The SDK rebuilds the call from the
//! amount alone, never from calldata the API supplies.
use alloy_primitives::{Bytes, U256};
use alloy_sol_types::SolCall;
use super::relay::GMX_ROUTER;
use crate::deployments;
alloy_sol_types::sol! {
/// GMX's `BridgeFeeParams`.
struct BridgeFeeParams {
address feeToken;
uint256 feeAmount;
address[] feeSwapPath;
uint256 minOutputAmount;
}
/// GMX's `BridgeOutParams`.
struct BridgeOutParams {
address token;
uint256 amount;
uint256 minAmountOut;
address provider;
bytes data;
BridgeFeeParams bridgeFee;
}
function transferOut(BridgeOutParams params);
}
/// GMX's `MultichainTransferRouter` on Arbitrum.
pub const TRANSFER_ROUTER: alloy_primitives::Address = GMX_ROUTER;
/// `transferOut((token, amount, 0, 0x0, 0x, (0x0, 0, [], 0)))`, with no bridge provider and no
/// bridge fee: `amount` of Arbitrum USDC from the sender's GMX Account to the sender's own address,
/// never elsewhere.
pub fn transfer_out(amount: U256) -> Bytes {
let params = BridgeOutParams {
token: deployments::GMX.token,
amount,
minAmountOut: U256::ZERO,
provider: alloy_primitives::Address::ZERO,
data: Bytes::new(),
bridgeFee: BridgeFeeParams {
feeToken: alloy_primitives::Address::ZERO,
feeAmount: U256::ZERO,
feeSwapPath: Vec::new(),
minOutputAmount: U256::ZERO,
},
};
transferOutCall { params }.abi_encode().into()
}
#[cfg(test)]
mod tests;