이 페이지는 커뮤니티 번역으로 참고용이며, 내용은 영어 원문을 우선합니다.
영어 원문 보기 ↗

USDC

CCTP는 Hyperliquid L1에서 USDC를 네이티브 방식으로 민팅하는 기본 방법입니다. Circle이 공개한 컨트랙트와 흐름은 https://github.com/circlefin/hyperevm-circle-contracts를 참조하세요.

레거시 브릿지

CCTP는 더 많은 체인과 기능을 지원합니다. 레거시 브릿지는 더 이상 사용되지 않습니다.

컨트랙트: https://arbiscan.io/address/0x2df1c51e09aecf9cacb7bc98cb1742757f163df7

소스: https://github.com/hyperliquid-dex/contracts/blob/master/Bridge2.sol

입금

브릿지의 입금 흐름은 간단합니다. 사용자가 네이티브 USDC를 브릿지로 보내면, 1분 이내에 전송한 계정에 크레딧됩니다. 최소 입금 금액은 5 USDC입니다. 이보다 적은 금액을 보내면 크레딧되지 않고 영원히 손실됩니다.

출금

출금 흐름은 Hyperliquid에서의 사용자 지갑 서명만 필요하며, Arbitrum 트랜잭션은 필요하지 않습니다. Arbitrum에서의 출금은 전적으로 밸리데이터가 처리하며, 자금은 3-4분 이내에 사용자 지갑에 도착합니다. signTypedData의 페이로드는 다음과 같습니다

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[serde(deny_unknown_fields)]
pub(crate) struct WithdrawAction3 {
    pub(crate) signature_chain_id: U256,
    pub(crate) hyperliquid_chain: Chain,
    pub(crate) destination: String,
    pub(crate) amount: String,
    pub(crate) time: u64,
}

impl Eip712 for WithdrawAction3 {
    type Error = Eip712Error;

    fn domain(&self) -> StdResult<EIP712Domain, Self::Error> {
        Ok(eip_712_domain(self.signature_chain_id))
    }

    fn type_hash() -> StdResult<[u8; 32], Self::Error> {
        Ok(eip712::make_type_hash(
            format!("{HYPERLIQUID_EIP_PREFIX}Withdraw"),
            &[
                ("hyperliquidChain".to_string(), ParamType::String),
                ("destination".to_string(), ParamType::String),
                ("amount".to_string(), ParamType::String),
                ("time".to_string(), ParamType::Uint(64)),
            ],
        ))
    }

    fn struct_hash(&self) -> StdResult<[u8; 32], Self::Error> {
        let Self { signature_chain_id: _, hyperliquid_chain, destination, amount, time } = self;
        let items = vec![
            ethers::abi::Token::Uint(Self::type_hash()?.into()),
            encode_eip712_type(hyperliquid_chain.to_string().into_token()),
            encode_eip712_type(destination.clone().into_token()),
            encode_eip712_type(amount.clone().into_token()),
            encode_eip712_type(time.into_token()),
        ];
        Ok(keccak256(encode(&items)))
    }
}

서명된 Hyperliquid 액션 예시:

{
    "action": {
        "type": "withdraw3",
        "signatureChainId": "0xa4b1",
        "hyperliquidChain": "Mainnet" or "Testnet" 
        "destination": "0x000....0",
        "amount": "12.3",
        "time": 1698693262
    },
    "nonce": 1698693262 // IMPORTANT: this must match "time",
    "signature": {"r": ..., "s": ..., "v": ... } // signedTypedData output based on Eip712 implementation above. See python sdk for equivalent python code
}

Permit를 사용한 입금

브릿지는 batchedDepositWithPermit 함수를 통해 다른 사용자를 대신하여 입금하는 것을 지원합니다. 사용자가 PermitPayload에 서명하는 방법의 예제 코드입니다

const payload: PermitPayload = {
  owner, // The address of the user with funds they want to deposit
  spender, // The address of the bridge 0x2df1c51e09aecf9cacb7bc98cb1742757f163df7 on mainnet and 0x08cfc1B6b2dCF36A1480b99353A354AA8AC56f89 on testnet
  value,
  nonce,
  deadline,
};

const isMainnet = true;

const domain = {
  name: isMainnet ? "USD Coin" : "USDC2",
  version: isMainnet ? "2" : "1",
  chainId: isMainnet ? 42161 : 421614,
  verifyingContract: isMainnet ? "0xaf88d065e77c8cC2239327C5EDb3A432268e5831" : "0x1baAbB04529D43a73232B713C0FE471f7c7334d5",
};

const permitTypes = {
  Permit: [
    { name: "owner", type: "address" },
    { name: "spender", type: "address" },
    { name: "value", type: "uint256" },
    { name: "nonce", type: "uint256" },
    { name: "deadline", type: "uint256" },
  ],
};

const dataToSign = {
  domain,
  types: permitTypes,
  primaryType: "Permit",
  message: payload,
} as const;

const data = await walletClient.signTypedData(dataToSign);
const signature = splitSig(data);
영문 공식 출처: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/usdc
원문 수집일: · 미러 빌드일: · 커뮤니티 번역이며 영문 원문 우선
비공식 커뮤니티 번역입니다. 저작권은 Hyperliquid에 있으며 영어 원문을 우선합니다. 출처: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/usdc