# LayerN คืออะไร ทำไมถึงเหมาะกับ Perp DEX

By [Baalz3ro](https://paragraph.com/@baalz3ro) · 2024-05-04

---

บทความนี้จะพาทุกคนมารู้จักกับ **LayerN** ว่าคืออะไร ทำไมถึงทำได้ถึง **100k++ TPS** น่ากาวมั้ย

**Overview**
============

**LayerN** คือ **Ethereum StateNet**— **L2** ที่ถูกออกเเบบเป็น network ของ **custom VMs** (virtual machine) โดยที่จะถูกเรียกว่า **XVMs** ที่ถูกขับเคลื่อนด้วยตัวของ **shared communication** เเละ **liquidity layer** ( ถ้าสรุปสั้นๆมันคล้ายๆ superchain ของ Op ที่มี shared communication เเละ liquidity layer นั่นเเหละ)

**Developers** สามารถสร้าง **app** บน **LayerN** โดยใช้ **XVMs** ไม่ก็หรือ **N-EVM** Developers จะได้ประโยชน์ตรงที่ ultra low execution latencies, higher throughput(TPS สูง), transaction fees ต่ำมาก, full composability เเละ shared liquidity ระหว่าง XVMs ทั้งหมด

**Layer N’s Modular blockchain**
================================

*   **Data Availability layer :** เป็นตัวของ **EigenDA**
    
*   **Consensus layer** เเละ **Settlement layer:** เป็น **Ethereum**
    
*   **Execution layer : LayerN**
    

![Credit : https://twitter.com/FourPillarsFP/status/1702283439662325906/photo/1](https://storage.googleapis.com/papyrus_images/9b2ef140f42464c380df5a1bd18b00acd7e9c22b49d879289e0b8bb1e224d386.jpg)

Credit : https://twitter.com/FourPillarsFP/status/1702283439662325906/photo/1

**StateNet**
============

อย่างที่กล่าวไปใน **overview** ว่า **LayerN** คือ **Ethereum Statenet** เเล้ว **StateNet คืออะไรละ ??** **StateNet** คือ เหมือนเป็นพิมพ์เขียวสำหรับใช้ในการสร้างเชน Layer 2 โดยที่ทำให้ **generalizable VMs** เเละ **application-specific VMs** สามารถ **seamlessly integrate** เเละ **share liquidity** ระหว่างกันได้ เเละด้วยความที่ว่า StateNet นั้น **shared communication** เเละ **liquidity layer** ระหว่างกันทำให้ลดความเสี่ยงในตัวของ **third party**(**Middleware**) เช่น **bridge** ได้ เพราะเราไม่จำเป็นต้องใช้ bridge ในการเคลื่อนย้าย **fund** หากต้องการใช้เชนอื่นๆที่อยู่ใน **StateNet** เเละ ยังมอบ **UX** ที่ดีอีกด้วย

![STATENET OVERVIEW](https://storage.googleapis.com/papyrus_images/8dca488de0ba77c06f2f9892f0e420912528e28e91c30a0e817de44d91e212cd.png)

STATENET OVERVIEW

**How the StateNet works**
==========================

ในระดับสูง **StateNet** คือ **orchestration** ของหลายๆ **VMs** ที่ **share a common communication protocol** โดยที่เชื่อมต่อ **applications** ทั้งหมดพร้อมกันด้วย **Inter-VM Communication protocol** (IVC) โดยตัว IVC ทำให้ทุก XVMs ทุก application สามารถ **seamlessly transmit messages** ไป XVM อื่นๆเเละ **instantly bridge liquidity** ได้ StateNet **leverage ในส่วนของ bandwith off-chain Data Availability solutions** ให้สูงขึ้นเพื่อดึงประสิทธิภาพออกมาให้ได้สูงที่สุด ในขณะที่ **settling state เเละ running proofs** ทั้งหมดจะอยู่บน **Ethereum**

**VM บน StateNet**
==================

**VM** คือ **virtual machine** ที่**กำหนด execution environment เเละ state access rules** สำหรับโปรเเกรมที่ถูกสร้างมาบนนั้น เเต่ละ VM ถูกรันบน single rollup ใน StateNet เเละเเต่ละ VM สามารถเข้าถึง Network ของ VM ที่กว้างมากขึ้น ผ่าน **shared communication** เเละ **liquidity laye**r——— VM ของตัว **StateNet** เเบ่งออกเป็น **2** ประเภทหลักๆได้เเก่ **Generalized VMs (GVM)** เเละ **Application-specific VMs (XVMs)**

![VM on StateNet](https://storage.googleapis.com/papyrus_images/18f8c4388dac0dfef5c2c78eb996bf15360942428a99a264ba380056b825a83d.png)

VM on StateNet

**XVM**
=======

**Application-specific VMs (XVMs)** คือ **rollups nodes กับ execution engines** ที่สามารถ **custom ได้**เอง— rollups พวกนี้ **run program logic ที่เฉพาะ** เเละไม่ open ในการทำ smart contract deployment— XVMs มี inputs, outputs, เเละ APIs ที่เฉพาะสำหรับการ interacting

XVMs ให้ความ**ยืดหยุ่นที่สูง**มาก เเละ **computational freedom** สำหรับ developers — XVMs สามารถทำให้ developers สร้าง applications ที่มีความซับซ้อนที่สูงมากๆได้ซึ่งอาจจะไม่สามาถทำได้บน GVMs (GVMs ก็คือ VM ทั่วไปที่สามารถ deploy ตัวของ smart contract บน VM เเบบ **permisionless** ได้ เช่นพวก **EVM**, **SVM** เเละ **MoveVM** ซึ่ง LayerN มี GVMs ที่เรียกว่า **N-EVM** ก็คือ **EVM** ซึ่ง **fully composable** กับ VM อื่นๆบน LayerN )

LayerN XVM ยังถูกสร้างด้วยภาษา **Rust**(โดยพื้นฐานภาษา Rust เป็นภาษาที่เร็วอยู่เเล้ว) ทั้งหมดเพื่อประสิทธิภาพของ execution ที่สูงที่สุด การที่ถูกสร้างในภาษา Rust ถูกสร้างให้สำเร็จได้โดย leveraging **RiscZero** สำหรับ **ZKFPs** ที่รองรับ **RISC-V instruction set**— Layer N จะทำ ZK proofs เมื่อจำเป็นเท่านั้น(เช่น Verifier detected fraud)—ไม่เหมือนกับ zkrollups ทั่วไปที่ต้องทำ ZK proof เสมอซึ่งทำให้ค่าใช้จ่ายสูง (สรุปสั้นๆ ก็มันก็คือ Optimistic rollup นั่นละเเต่เพียงเมื่อมันเจอ fraud มันจะใช้ ZK ในการ proof )

**LayerN มีอะไรน่ากาวละ ?**
===========================

ความกาวมันอยู่ที่ XVM นี่ละเพราะว่า XVM เป็น VM ที่เฉพาะทางซึ่งบนตัวของ LayerN ได้สร้าง **NordVM** ขึ้นมาซึ่งมันคือ **VM ที่ถูก Optimize มาเพื่อทำ exchange โดยเฉพาะ** เเละ features หลักๆก็คือ **custom-built hyper-efficient Rust orderbook execution environment**(สั้นๆก็คือ feature สำหรับเเมช Orderbook โดยเฉพาะ ซึ่งเหมาะสำหรับ HFT มาก) Nord สามารถทำได้มากกว่า **100k TPS ที่ sub 50ms latency** ด้วยความเร็วระดับนี้จึงทำให้มันสามารถ**ทำ** **cross-margining เเละ cross-collateralization ที่ซับซ้อนได้**—ในขณะที่ทั้งหมดนี้สามารถ **full composability** กับ **smart contract layers** อย่าง **N-EVM** ได้

ซึ่งยังไม่มี **Perp DEX** ไหนทำได้มาก่อน เเละ Perp DEX ในปัจจุบันยังให้ประสบการณ์ที่ดีเท่า **CEX** ปัจจุบันไม่ได้เลย ดังนั้นการมาของ **NordVM** จะอาจจะ **dominate** ในส่วนของ Perp DEX ได้ด้วยให้ประสบการณ์ระดับ CEX เเถมยัง On-chain อีกด้วยนอกจาก dominate เเล้วอาจจะดึงส่วนเเบ่งจาก CEX ได้อีกด้วย upside ค่อนข้างสูงเพราะปัจจุบัน vol. จาก DEX มีเพียง 1% จาก vol. ทั้งหมดของคริปโต เเละ **liquidity** ส่วนใหญ่มาจากพวก **trading dapp** ดังนั้น ตัว **NordVM** น่าจะดึง TVL เเละ liquidity มาได้สูงเลยทีเดียว

_$$ถามว่ามันเเมตช์ Orderbook เร็วเเค่ไหนละก็ :$$_

[https://twitter.com/i/status/1778182974204486107](https://twitter.com/i/status/1778182974204486107)

**สุดท้ายนี้บทความนี้ไม่ใช่บทความเเนะนำการลงทุนใดๆทั้งสิ้นเป็นเพียงบทความให้ความรู้เพียงเท่านั้น** DYOR

---

*Originally published on [Baalz3ro](https://paragraph.com/@baalz3ro/layern-perp-dex)*
