Skip to content

Commit 9675ed5

Browse files
authored
Fix Lido Por ripcord (#3541)
1 parent 07644a2 commit 9675ed5

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

.changeset/poor-lies-tickle.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@chainlink/lido-por-adapter': minor
3+
---
4+
5+
Throw error when ripcord is true

packages/sources/lido-por/src/transport/reserve.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,30 @@ export class BalanceTransport extends SubscriptionTransport<BaseEndpointTypes> {
7676
const providerDataRequestedUnixMs = Date.now()
7777

7878
const beaconBalance = await this._getBeaconBalance(param.lidoContract)
79+
80+
if (beaconBalance.isNegative()) {
81+
return {
82+
errorMessage: `ethereum-cl-indexer balance endpoint returns negative value ${beaconBalance}`,
83+
ripcord: true,
84+
ripcordDetails: JSON.stringify(
85+
`ethereum-cl-indexer balance endpoint returns negative value`,
86+
),
87+
statusCode: 502,
88+
timestamps: {
89+
providerDataRequestedUnixMs,
90+
providerDataReceivedUnixMs: Date.now(),
91+
providerIndicatedTimeUnixMs: undefined,
92+
},
93+
}
94+
}
95+
7996
const buffer = await getBufferedEther(param.lidoContract, this.provider)
8097

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

83100
return {
84101
data: {
85102
result: balance,
86-
ripcord: beaconBalance.isNegative(),
87103
},
88104
result: balance,
89105
timestamps: {

packages/sources/lido-por/test/integration/__snapshots__/adapter.test.ts.snap

+4-7
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
exports[`execute reserve endpoint should return ripcord 1`] = `
44
{
5-
"data": {
6-
"result": "499",
7-
"ripcord": true,
8-
},
9-
"result": "499",
10-
"statusCode": 200,
5+
"errorMessage": "ethereum-cl-indexer balance endpoint returns negative value -1",
6+
"ripcord": true,
7+
"ripcordDetails": ""ethereum-cl-indexer balance endpoint returns negative value"",
8+
"statusCode": 502,
119
"timestamps": {
1210
"providerDataReceivedUnixMs": 978347471111,
1311
"providerDataRequestedUnixMs": 978347471111,
@@ -19,7 +17,6 @@ exports[`execute reserve endpoint should return success 1`] = `
1917
{
2018
"data": {
2119
"result": "800",
22-
"ripcord": false,
2320
},
2421
"result": "800",
2522
"statusCode": 200,

packages/sources/lido-por/test/integration/adapter.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('execute', () => {
8383
}
8484
mockResponseFailure()
8585
const response = await testAdapter.request(data)
86-
expect(response.statusCode).toBe(200)
86+
expect(response.statusCode).toBe(502)
8787
expect(response.json()).toMatchSnapshot()
8888
})
8989
})

0 commit comments

Comments
 (0)