# Subnet Liquid Stacking Design ## Problem Overview Bringing liquidity to Subnet is complex because it requires users to manage their Avalanche Native Tokens on X- and P-chains. X- and P-Chains don't support any Smart Contracts, so building a permissionless automated system is a challenge. To solve this problem, we are going to automate Token and Subnet management using leverage Avalanche Multisig support. ## Multisig There is a Multisig support in Avalanche protocol in UTXO model. `OutputOwners` model has a `threshold` and `addresses` array that can be used to create 2 of 3 Multisig, for example. Any transaction contains `inputs` and `outputs`. By default, `output` defined with single recipient address and threshold = 1. *For example*: user A owns 100 AVAX tokens and transfers 5 of them to user B and get 95 AVAX change back. In that case, we have 2 outputs with threshold = 1 and single address as a recipient. ![](https://i.imgur.com/QBrN5QA.png) Defining `threshold` and list of recipients, we are able to configure Multisig. *For example*: user A transfers 5 AVAX to users A, B, C simultaneously with threshold = 2. It means what they need to sign next outgoing transaction with 2 signatures (A or B, B or C, A or C). ![](https://i.imgur.com/hzLckyp.png) ## Problem with existing Multisig solutions Current Multisig support in JS library has some limitations. It requires placing all Private Key [together](https://github.com/ava-labs/avalanchejs/blob/13c8cb47a2497a9e32aac5a25f7e7cb88dea2873/examples/avm/baseTx-avax-send-multisig.ts#L40-L48). To solve this issue, we [implemented](https://github.com/ava-labs/avalanchejs/pull/257) changes in JS library to support distributed signature. How does it work? Each Transaction contains payload and list of signature. Payload the same for all participants of Multisig. Each user signs the transaction using their own Private Key and creates so-called Partially Signed Transaction. Once we have all parts of a partially signed transaction, we can compose signatures together and produce regular Multisig Tx. ![](https://i.imgur.com/kpf6mwE.png) ## Decentralized Permissionless Multisig Network Each Multisig Node has its own Private Key. It get current state from C-CHain Smart Contract and goes to next state regarding logic implemented in Node. Relayer receives Partially Signed Transaction, selects appropriate combinations of signers based on threshold and available partially signed transactions. Then composes these transactions into signle one with list of signatures and sends it to Avalanche RPC endpoint. ![](https://i.imgur.com/NkDbmDA.png) ## State Machine > A state machine is a behavior model. It consists of a finite number of states and is therefore also called finite-state machine (FSM). Based on the current state and a given input the machine performs state transitions and produces outputs Node has a multuple states and transition between them. * Initial state ![](https://i.imgur.com/jMUmqBQ.png) * Top-up on X-Chain ![](https://i.imgur.com/DHUHOvo.png) * Subnet Owner creates Elastic Subnet ![](https://i.imgur.com/vbG8unL.png) * User delegates to Elastic Subnet ![](https://i.imgur.com/dHrfz58.png)