Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect return annotation on queryLiquidationQueueBidPoolsByCollateral #64

Open
davidvuong opened this issue Apr 6, 2022 · 1 comment

Comments

@davidvuong
Copy link
Contributor

Currently:

interface Option {
    lcd: LCDClient;
    collateral_token: string;
    start_after: number | undefined;
    limit: number | undefined;
}
export interface BidPoolResponse {
    sum_snapshot: string;
    product_snapshot: string;
    total_bid_amount: string;
    premium_rate: string;
    current_epoch: string;
    current_scale: string;
}
export declare const queryLiquidationQueueBidPoolsByCollateral: ({ lcd, collateral_token, start_after, limit }: Option) => (addressProvider: AddressProvider) => Promise<BidPoolResponse[]>;

The return type of queryLiquidationQueueBidPoolsByCollateral should be:

export interface BidPoolsByCollateralResponse {
  bid_pools: BidPoolResponse[]
}

Version:

"@anchor-protocol/anchor.js": "^5.0.2"

Documentation: https://docs.anchorprotocol.com/smart-contracts/liquidations/liquidation-queue-contract#bidpoolsbycollateralresponse

Example response in documentation:

{
  "bid_pools": [
    {
      "sum_snapshot": "1.0",
      "product_snapshot": "1.0",
      "total_bid_amount": "1000000",
      "premium_rate": "0.1",
      "current_epoch": "0",
      "current_scale": "0"
    }, 
    {
      "sum_snapshot": "1.0",
      "product_snapshot": "1.0",
      "total_bid_amount": "2000000",
      "premium_rate": "0.2",
      "current_epoch": "0",
      "current_scale": "0"
    }
  ]
}
@davidvuong
Copy link
Contributor Author

Similarly, the same problem exists for queryLiquidationQueueBidByUser.

export interface QueueBidResponse {
    idx: string;
    collateral_token: string;
    premium_slot: number;
    bidder: string;
    amount: string;
    product_snapshot: string;
    sum_snapshot: string;
    pending_liquidated_collateral: string;
    wait_end: number | undefined;
    epoch_snapshot: string;
    scale_snapshot: string;
}

export declare const queryLiquidationQueueBidByUser: ({ lcd, collateral_token, bidder, start_after, limit }: Option) => (addressProvider: AddressProvider) => Promise<QueueBidResponse[]>;

When the actual response is:

{
  bids: [
    {
      idx: '1694',
      collateral_token: 'terra...',
      premium_slot: 30,
      bidder: 'terra...',
      amount: '24771388',
      product_snapshot: '1',
      sum_snapshot: '0',
      pending_liquidated_collateral: '0',
      wait_end: 1649910621,
      epoch_snapshot: '0',
      scale_snapshot: '0'
    }
  ]
}

So the response type should be wrapped. A temporary solution is:

const { bids } = (await queryLiquidationQueueBidByUser({
  lcd: this.lcd,
  collateral_token: collateral,
  bidder: wallet.key.accAddress,
  start_after: undefined,
  limit: PAGINATION_LIMIT,
})(this.addressProvider)) as unknown as { bids: QueueBidResponse[] };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@davidvuong and others