Swimlanes.io is a free webapp for making sequence diagrams. You simply edit the text on the left and the diagram is updated in real time. You can download your sequence diagrams as images or distribute with a link.
Title: Lit EVM Swap Example (mk II) Alice -> dApp: Creates an `ask` to swap `8 tokenA` for `10 nativeCurrencyB` Bob -> dApp: Accepts Alice's `ask` dApp -> Alice: Sends `swapObject` for signing dApp -> Bob: Sends `swapObject` for signing note dApp, chainA: Alice and Bob will create an Auth Sig of the hash (`swapObjectHash`) of `swapObject` to show they're agreeing to the swap. The `swapObject` looks like: ``` const swapObject = { chainA: "sepolia", chainAId: "11155111", chainB: "baseSepolia", chainBId: "84532", accountA: "0x000000000000000000000000000000000000000a", accountB: "0x000000000000000000000000000000000000000b", amountA: "8", amountB: "10", contractA: "0x0000000000000000000000000000000000000001", contractB: "", currencyAType: 'ERC20', currencyBType: 'NATIVE', expiration: "1757090845", }; ``` Alice -> dApp: Sends swap Auth Sig Bob -> dApp: Sends swap Auth Sig dApp -> Lit Action: Executes the standard Lit Swap Lit Action, passing the flag: `generate` note The params given to the Lit Action include: - `userAuthSigA` - `userAuthSigB` - `swapObject` Lit Action -> Lit Action: Checks `userAuthSigA` authorizes the given `swapObject` Lit Action -> Lit Action: Checks `userAuthSigB` authorizes the given `swapObject` Lit Action -> Lit Action: Checks `swapObject.expiration` is in the future Lit Action -> Lit Action: Generates `privateKeyA` and `privateKeyB` Lit Action -> Lit Action: Derives `swapAddressA` and `swapAddressB` from private keys Lit Action -> Lit Action: Encrypts the private keys and `swapObject` note Lit Action, Lit network: The `dataToEncrypt` would be: ``` JSON.stringify({ privateKeyA: "0x01234", privateKeyB: "0x01234", swapObject }) The data would be encrypted with the Access Control Condtions that specify decryption can only happen within the standard Lit Swap Lit Action ``` Lit Action -> dApp: Returns the encryption metadata, `swapAddressA`, and `swapAddressB` dApp -> Alice: Shares `swapAddressA` dApp -> Bob: Shares `swapAddressB` Alice -> chainA: Sends `8 tokenA` to `swapAddressA` Bob -> chainB: Sends `10 nativeCurrencyB` to `swapAddressB` dApp -> Lit Action: Executes the standard Lit Swap Lit Action, passing the flag: `execute` note The params given to the Lit Action include: - encryptionMetadata Lit Action -> Lit Action: Decrypts `encryptionMetadata` Lit Action -> Lit Action: Checks `swapObject.expiration` is in the future Lit Action -> Lit Action: Checks the balance of `address(privateKeyA) >= swapObject.amountA` on `swapObject.chainA` Lit Action -> Lit Action: Checks the balance of `address(privateKeyB) >= swapObject.amountB` on `swapObject.chainB` Lit Action -> Lit Action: Encrypts `privateKeyA` note The key would be decrypted with the Access Control Conditions that only allow `swapObject.accountB` to decrypt Lit Action -> Lit Action: Encrypts `privateKeyB` note The key would be decrypted with the Access Control Conditions that only allow `swapObject.accountA` to decrypt Lit Action -> dApp: Returns encryption metadata for `privateKeyA` and `privateKeyB` dApp -> Alice: Shares `privateKeyB` encryption metadata dApp -> Bob: Shares `privateKeyA` encryption metadata Alice -> Lit network: Decrypts `privateKeyB` using an Auth Sig Bob -> Lit network: Decrypts `privateKeyA` using an Auth Sig Alice -> chainB: Uses `privateKeyB` to transfer ownership of funds Bob -> chainA: Uses `privateKeyA` to transfer ownership of funds