lamarge 0.9.0

Client for the LaMarge API: sign-in, takes, transfers, withdrawals and market making, each request checked before it is signed.
Documentation
//! 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;