Skip to content

Commit 6194bf2

Browse files
Changes result to string
1 parent bc0d130 commit 6194bf2

4 files changed

Lines changed: 55 additions & 16 deletions

File tree

.pnp.cjs

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/sources/decibel-vault-adapter/src/endpoint/share-price.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ export const inputParameters = new InputParameters(
2828
export type BaseEndpointTypes = {
2929
Parameters: typeof inputParameters.definition
3030
Response: {
31-
Result: number
31+
Result: string | null
3232
Data: {
33-
result: number
33+
result: string
3434
share_price: string
3535
vault_nav: string
3636
vault_total_shares: string

packages/sources/decibel-vault-adapter/src/transport/share-price.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,16 @@ class SharePriceTransport extends SubscriptionTransport<BaseEndpointTypes> {
9191
})
9292
}
9393

94-
let sharePrice: string
95-
if (nav === 0n) {
96-
sharePrice = '0'
97-
} else {
98-
sharePrice = ((nav * 10n ** BigInt(output_decimals)) / shares).toString()
99-
}
94+
const sharePrice = ((nav * 10n ** BigInt(output_decimals)) / shares).toString()
10095

10196
return {
10297
data: {
103-
result: Number(sharePrice),
98+
result: sharePrice,
10499
share_price: sharePrice,
105100
vault_nav: navResult,
106101
vault_total_shares: sharesResult,
107102
},
108-
result: Number(sharePrice),
103+
result: sharePrice,
109104
timestamps: {
110105
providerDataRequestedUnixMs,
111106
providerDataReceivedUnixMs: Date.now(),

packages/sources/decibel-vault-adapter/test/integration/__snapshots__/adapter.test.ts.snap

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
exports[`Decibel Vault Adapter share-price endpoint should return error when vault total shares is zero 1`] = `
44
{
55
"errorMessage": "INVALID_SHARES: vault total shares is zero",
6+
"meta": {
7+
"adapterName": "DECIBEL_VAULT",
8+
"metrics": {
9+
"feedId": "{"vault_object_id":"0x3333333333333333333333333333333333333333333333333333333333333333","output_decimals":18}",
10+
},
11+
},
612
"statusCode": 502,
713
"timestamps": {
814
"providerDataReceivedUnixMs": 0,
@@ -25,12 +31,18 @@ exports[`Decibel Vault Adapter share-price endpoint should return error when vau
2531
exports[`Decibel Vault Adapter share-price endpoint should return share_price = 0 when vault NAV is zero 1`] = `
2632
{
2733
"data": {
28-
"result": 0,
34+
"result": "0",
2935
"share_price": "0",
3036
"vault_nav": "0",
3137
"vault_total_shares": "1000000",
3238
},
33-
"result": 0,
39+
"meta": {
40+
"adapterName": "DECIBEL_VAULT",
41+
"metrics": {
42+
"feedId": "{"vault_object_id":"0x2222222222222222222222222222222222222222222222222222222222222222","output_decimals":18}",
43+
},
44+
},
45+
"result": "0",
3446
"statusCode": 200,
3547
"timestamps": {
3648
"providerDataReceivedUnixMs": 1704067200000,
@@ -42,12 +54,18 @@ exports[`Decibel Vault Adapter share-price endpoint should return share_price =
4254
exports[`Decibel Vault Adapter share-price endpoint should return the correct share price for default decimals (18) 1`] = `
4355
{
4456
"data": {
45-
"result": 1056761456089666200,
57+
"result": "1056761456089666181",
4658
"share_price": "1056761456089666181",
4759
"vault_nav": "41230251777103",
4860
"vault_total_shares": "39015665777277",
4961
},
50-
"result": 1056761456089666200,
62+
"meta": {
63+
"adapterName": "DECIBEL_VAULT",
64+
"metrics": {
65+
"feedId": "{"vault_object_id":"0x06ad70a9a4f30349b489791e2f2bcf58363dad30e54a9d2d4095d6213d7a9bf9","output_decimals":18}",
66+
},
67+
},
68+
"result": "1056761456089666181",
5169
"statusCode": 200,
5270
"timestamps": {
5371
"providerDataReceivedUnixMs": 1704067200000,
@@ -59,12 +77,18 @@ exports[`Decibel Vault Adapter share-price endpoint should return the correct sh
5977
exports[`Decibel Vault Adapter share-price endpoint should return the correct share price with custom output_decimals 1`] = `
6078
{
6179
"data": {
62-
"result": 105676145,
80+
"result": "105676145",
6381
"share_price": "105676145",
6482
"vault_nav": "41230251777103",
6583
"vault_total_shares": "39015665777277",
6684
},
67-
"result": 105676145,
85+
"meta": {
86+
"adapterName": "DECIBEL_VAULT",
87+
"metrics": {
88+
"feedId": "{"vault_object_id":"0x1111111111111111111111111111111111111111111111111111111111111111","output_decimals":8}",
89+
},
90+
},
91+
"result": "105676145",
6892
"statusCode": 200,
6993
"timestamps": {
7094
"providerDataReceivedUnixMs": 1704067200000,

0 commit comments

Comments
 (0)