DomRom
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit
      • Invitee
      • No invitee
    • Publish Note

      Publish Note

      Everyone on the web can find and read all notes of this public team.
      Once published, notes can be searched and viewed by anyone online.
      See published notes
      Please check the box to agree to the Community Guidelines.
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit
Invitee
No invitee
Publish Note

Publish Note

Everyone on the web can find and read all notes of this public team.
Once published, notes can be searched and viewed by anyone online.
See published notes
Please check the box to agree to the Community Guidelines.
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Lyra v2 liquidations ## Mainnet constants Explorer URL: https://explorer.lyra.finance RPC URL: https://rpc.lyra.finance ChainID: 957 ``` AUCTION_ADDRESS=0xC51E95b72e116020B138cd5D97Ed4A72DE8Dc48B SUBACCOUNT_ADDRESS=0xE7603DF191D699d8BD9891b821347dbAb889E5a5 AUCTION_UTILS_ADDRESS=0x69812bDf2b6466E8e40A9790105e547d9Aed77B7 ``` ## Bidding/Margin helper Helper contract to make the bidding process simpler, but this is unaudited and somewhat higher risk as you have to approve it to access your full subaccount. code can be found here: https://github.com/lyra-finance/v2-matching/blob/master/src/periphery/LyraAuctionUtils.sol This was deployed to testnet with address: 0x69812bDf2b6466E8e40A9790105e547d9Aed77B7 ## Bidding script ### Glossary - Exchange account owner - This is the key that owns all assets/subaccounts held on the exchange. It is able to add session keys to the exchange that can interact on it's behalf - https://v2-docs.lyra.finance/reference/session-keys - Trading subaccount - An account on the exchange which will receive the proceeds of the liquidation - Bidding subaccount - A subaccount that lives **off** the exchange. It holds cash that is used for collateral for auctions that are being bid on. This must be owned by the hotwallet that is used by the scripts - Session key/hotwallet - An authorised key that can make trades on behalf of the exchange account owner - This private key is used in the scripts to execute on-chain actions and to sign messages on the exchange to do transfers/deposits etc. - NOTE: currently scripts only support this being the same as the exchange account owner ### Running the liquidation scripts - Clone: https://github.com/lyra-finance/v2-scripts - Install pre-requisites - Follow installation instructions - In the v2-scripts directory - `pnpm i` - `cp .env.mainnet.example .env` - Modify SIGNING_KEY field in the .env - NOTE: only the exchange owner key is currently supported - This key will need to be a signing key for an exchange account - If not the owner of the exchange account, withdrawals from the exchange will not go to this address (they always go to the owner) - This key will also own the "bidder subaccount", which will hold funds for collateral for liquidations - For any of the following commands, run them with `--help` to see more options. E.g. `pnpm cmd liquidationFlow --help` - Run `pnpm cmd setupLiquidationAccs -t <tradingDepositAmt> -b <biddingDepositAmt>` - If TRADING_SUBACCOUNT or BIDDING_SUBBACOUNT don't exist in the .env they are created and deposited into - If they exist, then the deposit amount is added to the existing accounts - <TODO: trading account deposit not yet implemented> - `tradingDepositAmount`: Amount of total funds to deposit into the trading account. There are the funds you want to trade with. - `bidderDepositAmount`: Amount of total funds to prepare to use as collateral in bidding. These are not accessible on the exchange. - Add the generated TRADING_SUBACCOUNT and BIDDING_SUBBACOUNT ids to the .env - Run `pnpm cmd getAllCurrentAuctions` - This will list out all current auctions (based on auctionStarted events) - This will not capture accounts that are below margin requirements but have not yet been flagged - Take note of the subaccount ids for accounts that you want to bid on - Without freshly submitted feed data, these values may be innacurate. - If you have found an account that you want to bid on, then run `pnpm cmd liquidationFlow -d -p 0.1 -c <collateralAmt> <accountToLiquidate>` - This will do the following steps: - approve AuctionUtils contract to use the bidding subaccount - bid on the account, creating a new subaccount with added collateral - With the `-m` (merge) flag: - transfer all the new subaccount assets back into the bidderSubaccount - With the `-d` (deposit) flag: - deposit the newly generated subaccount to the exchange - <TODO: move assets from this new subaccount to the trading subaccount> - <TODO: delete the new subaccount reference from the exchange> ## Flagging accounts https://gist.github.com/0xdomrom/663e6a83ea08a439497c99a49770d314 Here is the logic for scraping all subaccounts + fetching balances + margin requirements (using the contract above for margin reqs). Wont work as is, has a bunch of imports I'd need to compile into a single file to work. This also: 1) doesnt do any event caching for the balance fetching 2) doesn't parallelise the margin checks which both would improve efficiency tremendously Logic starts at FlagAccounts.run_job(). Once you've figured out that an account is below margin requirements, you can atomically flag + bid using the function in the utils contract, or you can flag and then wait for a larger discount. # Testnet This whole process can be run on testnet. Follow the same instructions but use `.env.testnet.example` instead of `.env.mainnet.example` ## Testnet constants Explorer URL: https://explorerl2new-prod-testnet-0eakp60405.t.conduit.xyz/ RPC URL: https://l2-prod-testnet-0eakp60405.t.conduit.xyz ChainID: 901 ``` AUCTION_ADDRESS=0x026dD5F94275faa74E41b16fea68f664d1ec68cC SUBACCOUNT_ADDRESS=0xb9ed1cc0c50bca7a391a6819e9cAb466f5501d73 AUCTION_UTILS_ADDRESS=0x4fCc6b8F7887B39446555b5AaB0415D859d299BC ```

Import from clipboard

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template is not available.
Upgrade
All
  • All
  • Team
No template found.

Create custom template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

How to use Slide mode

API Docs

Edit in VSCode

Install browser extension

Get in Touch

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Upgrade to Prime Plan

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

No updates to save
Compare with
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Upgrade

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Upgrade

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully