code.vegaprotocol.io/vega@v0.79.0/datanode/sqlstore/migrations/0109_amm_pools.sql (about)

     1  -- +goose Up
     2  
     3  -- +goose StatementBegin
     4  do $$
     5  begin
     6      if not exists (select 1 from pg_type where typname = 'amm_status') then
     7          create type amm_status as enum(
     8              'STATUS_UNSPECIFIED', 'STATUS_ACTIVE', 'STATUS_REJECTED', 'STATUS_CANCELLED', 'STATUS_STOPPED', 'STATUS_REDUCE_ONLY'
     9          );
    10      end if;
    11  end $$;
    12  -- +goose StatementEnd
    13  
    14  -- +goose StatementBegin
    15  do $$
    16  begin
    17      if not exists (select 1 from pg_type where typname = 'amm_status_reason') then
    18          create type amm_status_reason as enum(
    19              'STATUS_REASON_UNSPECIFIED', 'STATUS_REASON_CANCELLED_BY_PARTY', 'STATUS_REASON_CANNOT_FILL_COMMITMENT',
    20              'STATUS_REASON_PARTY_ALREADY_OWNS_AMM_FOR_MARKET', 'STATUS_REASON_PARTY_CLOSED_OUT', 'STATUS_REASON_MARKET_CLOSED',
    21              'STATUS_REASON_COMMITMENT_TOO_LOW', 'STATUS_REASON_CANNOT_REBASE'
    22          );
    23      end if;
    24  end $$;
    25  -- +goose StatementEnd
    26  
    27  create table if not exists amms (
    28      id bytea not null,
    29      party_id bytea not null,
    30      market_id bytea not null,
    31      amm_party_id bytea not null,
    32      commitment numeric not null,
    33      status amm_status not null,
    34      status_reason amm_status_reason not null,
    35      parameters_base numeric not null,
    36      parameters_lower_bound numeric,
    37      parameters_upper_bound numeric,
    38      parameters_leverage_at_upper_bound numeric,
    39      parameters_leverage_at_lower_bound numeric,
    40      created_at timestamp with time zone not null,
    41      last_updated timestamp with time zone not null,
    42      primary key (party_id, market_id, id, amm_party_id)
    43  );
    44  
    45  -- +goose Down
    46  drop table if exists amms;
    47  drop type if exists amm_status_reason;
    48  drop type if exists amm_status;