From 833e0f829af40553dbc68fe5dee8bfa954356d1e Mon Sep 17 00:00:00 2001 From: vkulinich Date: Wed, 27 Nov 2024 08:41:14 +0100 Subject: [PATCH 1/3] Add additional props to omnipool tokens pool client --- packages/sdk/src/pool/omni/OmniPool.ts | 14 ++++++++------ packages/sdk/src/pool/omni/OmniPoolClient.ts | 19 +++++++++++++------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/packages/sdk/src/pool/omni/OmniPool.ts b/packages/sdk/src/pool/omni/OmniPool.ts index 5044acbc..17f09b11 100644 --- a/packages/sdk/src/pool/omni/OmniPool.ts +++ b/packages/sdk/src/pool/omni/OmniPool.ts @@ -26,8 +26,10 @@ export type OmniPoolPair = PoolPair & { }; export type OmniPoolToken = PoolToken & { - hubReserves: BigNumber; - shares: BigNumber; + hubReserves: string; + shares: string; + cap: string; + protocolShares: string; }; export type OmniPoolFees = PoolFees & { @@ -101,10 +103,10 @@ export class OmniPool implements Pool { return { assetIn: tokenIn, assetOut: tokenOut, - hubReservesIn: tokenInMeta.hubReserves, - hubReservesOut: tokenOutMeta.hubReserves, - sharesIn: tokenInMeta.shares, - sharesOut: tokenOutMeta.shares, + hubReservesIn: bnum(tokenInMeta.hubReserves), + hubReservesOut: bnum(tokenOutMeta.hubReserves), + sharesIn: bnum(tokenInMeta.shares), + sharesOut: bnum(tokenOutMeta.shares), decimalsIn: tokenInMeta.decimals, decimalsOut: tokenOutMeta.decimals, balanceIn: balanceIn, diff --git a/packages/sdk/src/pool/omni/OmniPoolClient.ts b/packages/sdk/src/pool/omni/OmniPoolClient.ts index 0617e701..fff127de 100644 --- a/packages/sdk/src/pool/omni/OmniPoolClient.ts +++ b/packages/sdk/src/pool/omni/OmniPoolClient.ts @@ -40,15 +40,22 @@ export class OmniPoolClient extends PoolClient { }, state, ]) => { - const { hubReserve, shares, tradable }: PalletOmnipoolAssetState = - state.unwrap(); + const { + hubReserve, + shares, + tradable, + cap, + protocolShares, + }: PalletOmnipoolAssetState = state.unwrap(); const balance = await this.getBalance(poolAddress, id.toString()); return { id: id.toString(), - hubReserves: bnum(hubReserve.toString()), - shares: bnum(shares.toString()), + hubReserves: hubReserve.toString(), + shares: shares.toString(), tradeable: tradable.bits.toNumber(), balance: balance.toString(), + cap: cap.toString(), + protocolShares: protocolShares.toString(), } as OmniPoolToken; } ); @@ -121,8 +128,8 @@ export class OmniPoolClient extends PoolClient { const { hubReserve, shares, tradable } = tokenState; return { ...token, - hubReserves: bnum(hubReserve.toString()), - shares: bnum(shares.toString()), + hubReserves: hubReserve.toString(), + shares: shares.toString(), tradeable: tradable.bits.toNumber(), } as OmniPoolToken; } From 9962e50312a2767e3cf1f569c084bb419f905be3 Mon Sep 17 00:00:00 2001 From: vkulinich Date: Wed, 27 Nov 2024 10:06:51 +0100 Subject: [PATCH 2/3] return big number --- packages/sdk/src/pool/omni/OmniPool.ts | 12 ++++++------ packages/sdk/src/pool/omni/OmniPoolClient.ts | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/sdk/src/pool/omni/OmniPool.ts b/packages/sdk/src/pool/omni/OmniPool.ts index 17f09b11..a7e0d975 100644 --- a/packages/sdk/src/pool/omni/OmniPool.ts +++ b/packages/sdk/src/pool/omni/OmniPool.ts @@ -26,8 +26,8 @@ export type OmniPoolPair = PoolPair & { }; export type OmniPoolToken = PoolToken & { - hubReserves: string; - shares: string; + hubReserves: BigNumber; + shares: BigNumber; cap: string; protocolShares: string; }; @@ -103,10 +103,10 @@ export class OmniPool implements Pool { return { assetIn: tokenIn, assetOut: tokenOut, - hubReservesIn: bnum(tokenInMeta.hubReserves), - hubReservesOut: bnum(tokenOutMeta.hubReserves), - sharesIn: bnum(tokenInMeta.shares), - sharesOut: bnum(tokenOutMeta.shares), + hubReservesIn: tokenInMeta.hubReserves, + hubReservesOut: tokenOutMeta.hubReserves, + sharesIn: tokenInMeta.shares, + sharesOut: tokenOutMeta.shares, decimalsIn: tokenInMeta.decimals, decimalsOut: tokenOutMeta.decimals, balanceIn: balanceIn, diff --git a/packages/sdk/src/pool/omni/OmniPoolClient.ts b/packages/sdk/src/pool/omni/OmniPoolClient.ts index fff127de..1146bd81 100644 --- a/packages/sdk/src/pool/omni/OmniPoolClient.ts +++ b/packages/sdk/src/pool/omni/OmniPoolClient.ts @@ -50,8 +50,8 @@ export class OmniPoolClient extends PoolClient { const balance = await this.getBalance(poolAddress, id.toString()); return { id: id.toString(), - hubReserves: hubReserve.toString(), - shares: shares.toString(), + hubReserves: bnum(hubReserve.toString()), + shares: bnum(shares.toString()), tradeable: tradable.bits.toNumber(), balance: balance.toString(), cap: cap.toString(), @@ -128,8 +128,8 @@ export class OmniPoolClient extends PoolClient { const { hubReserve, shares, tradable } = tokenState; return { ...token, - hubReserves: hubReserve.toString(), - shares: shares.toString(), + hubReserves: bnum(hubReserve.toString()), + shares: bnum(shares.toString()), tradeable: tradable.bits.toNumber(), } as OmniPoolToken; } From 6090286cc479050aef1de4a5c9e6ea25227a2582 Mon Sep 17 00:00:00 2001 From: vkulinich Date: Wed, 27 Nov 2024 10:15:37 +0100 Subject: [PATCH 3/3] update types --- packages/sdk/src/pool/omni/OmniPool.ts | 4 ++-- packages/sdk/src/pool/omni/OmniPoolClient.ts | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/sdk/src/pool/omni/OmniPool.ts b/packages/sdk/src/pool/omni/OmniPool.ts index a7e0d975..55a71992 100644 --- a/packages/sdk/src/pool/omni/OmniPool.ts +++ b/packages/sdk/src/pool/omni/OmniPool.ts @@ -28,8 +28,8 @@ export type OmniPoolPair = PoolPair & { export type OmniPoolToken = PoolToken & { hubReserves: BigNumber; shares: BigNumber; - cap: string; - protocolShares: string; + cap: BigNumber; + protocolShares: BigNumber; }; export type OmniPoolFees = PoolFees & { diff --git a/packages/sdk/src/pool/omni/OmniPoolClient.ts b/packages/sdk/src/pool/omni/OmniPoolClient.ts index 1146bd81..77e8dc2f 100644 --- a/packages/sdk/src/pool/omni/OmniPoolClient.ts +++ b/packages/sdk/src/pool/omni/OmniPoolClient.ts @@ -54,8 +54,8 @@ export class OmniPoolClient extends PoolClient { shares: bnum(shares.toString()), tradeable: tradable.bits.toNumber(), balance: balance.toString(), - cap: cap.toString(), - protocolShares: protocolShares.toString(), + cap: bnum(cap.toString()), + protocolShares: bnum(protocolShares.toString()), } as OmniPoolToken; } ); @@ -125,11 +125,13 @@ export class OmniPoolClient extends PoolClient { token: PoolToken, tokenState: PalletOmnipoolAssetState ) { - const { hubReserve, shares, tradable } = tokenState; + const { hubReserve, shares, tradable, cap, protocolShares } = tokenState; return { ...token, hubReserves: bnum(hubReserve.toString()), shares: bnum(shares.toString()), + cap: bnum(cap.toString()), + protocolShares: bnum(protocolShares.toString()), tradeable: tradable.bits.toNumber(), } as OmniPoolToken; }