Skip to content

Commit

Permalink
Merge pull request #9901 from vegaprotocol/fix/9900-list-liquidity-sh…
Browse files Browse the repository at this point in the history
…ows-multiple-dups

fix: remove dups from liquidity provisions
  • Loading branch information
guoguojin authored Oct 25, 2023
2 parents 9a3747a + 9268347 commit c2cf6b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@
- [8769](https://github.com/vegaprotocol/vega/issues/8769) - Support timestamp data from different oracle types.
- [9894](https://github.com/vegaprotocol/vega/issues/9894) - Reset distress party position in market activity tracker.
- [9895](https://github.com/vegaprotocol/vega/issues/9895) - Expose discounts on trades fees.
- [9900](https://github.com/vegaprotocol/vega/issues/9900) - Fix for duplicate liquidity provisions in the `API`.

## 0.72.1

Expand Down
9 changes: 7 additions & 2 deletions datanode/sqlstore/liquidity_provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,12 @@ func (lp *LiquidityProvision) buildLiquidityProvisionsSelect(partyID entities.Pa
sourceTable = "live_liquidity_provisions"
}

selectSQL := fmt.Sprintf(`with lps as (
selectSQL := fmt.Sprintf(`with last_active as (
select distinct on (id, version) *
FROM liquidity_provisions
WHERE status = 'STATUS_ACTIVE'
order by id, version, vega_time desc
), lps as (
select llp.id, llp.party_id, llp.created_at, llp.updated_at, llp.market_id,
llp.commitment_amount, llp.fee, llp.sells, llp.buys, llp.version,
llp.status, llp.reference, llp.tx_hash, llp.vega_time,
Expand All @@ -375,7 +380,7 @@ func (lp *LiquidityProvision) buildLiquidityProvisionsSelect(partyID entities.Pa
lp.status previous_status, lp.reference previous_reference, lp.tx_hash previous_tx_hash,
lp.vega_time previous_vega_time
from %s llp
left join liquidity_provisions lp on llp.id = lp.id and llp.version - 1 = lp.version and lp.status = 'STATUS_ACTIVE'
left join last_active lp on llp.id = lp.id and llp.version - 1 = lp.version
)
select *
from lps
Expand Down

0 comments on commit c2cf6b7

Please sign in to comment.