Skip to content

Commit

Permalink
Fix Lido Por ripcord (#3541)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxiao-cll authored Nov 7, 2024
1 parent 07644a2 commit 9675ed5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/poor-lies-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/lido-por-adapter': minor
---

Throw error when ripcord is true
18 changes: 17 additions & 1 deletion packages/sources/lido-por/src/transport/reserve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,30 @@ export class BalanceTransport extends SubscriptionTransport<BaseEndpointTypes> {
const providerDataRequestedUnixMs = Date.now()

const beaconBalance = await this._getBeaconBalance(param.lidoContract)

if (beaconBalance.isNegative()) {
return {
errorMessage: `ethereum-cl-indexer balance endpoint returns negative value ${beaconBalance}`,
ripcord: true,
ripcordDetails: JSON.stringify(
`ethereum-cl-indexer balance endpoint returns negative value`,
),
statusCode: 502,
timestamps: {
providerDataRequestedUnixMs,
providerDataReceivedUnixMs: Date.now(),
providerIndicatedTimeUnixMs: undefined,
},
}
}

const buffer = await getBufferedEther(param.lidoContract, this.provider)

const balance = beaconBalance.add(buffer).toString()

return {
data: {
result: balance,
ripcord: beaconBalance.isNegative(),
},
result: balance,
timestamps: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

exports[`execute reserve endpoint should return ripcord 1`] = `
{
"data": {
"result": "499",
"ripcord": true,
},
"result": "499",
"statusCode": 200,
"errorMessage": "ethereum-cl-indexer balance endpoint returns negative value -1",
"ripcord": true,
"ripcordDetails": ""ethereum-cl-indexer balance endpoint returns negative value"",
"statusCode": 502,
"timestamps": {
"providerDataReceivedUnixMs": 978347471111,
"providerDataRequestedUnixMs": 978347471111,
Expand All @@ -19,7 +17,6 @@ exports[`execute reserve endpoint should return success 1`] = `
{
"data": {
"result": "800",
"ripcord": false,
},
"result": "800",
"statusCode": 200,
Expand Down
2 changes: 1 addition & 1 deletion packages/sources/lido-por/test/integration/adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('execute', () => {
}
mockResponseFailure()
const response = await testAdapter.request(data)
expect(response.statusCode).toBe(200)
expect(response.statusCode).toBe(502)
expect(response.json()).toMatchSnapshot()
})
})
Expand Down

0 comments on commit 9675ed5

Please sign in to comment.