@gearbox-protocol/sdk 14.12.0-next.31 → 14.12.0-next.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -50,23 +50,27 @@ function getKeyForPoolPointsInfo(i) {
50
50
  class PoolPointsAPI {
51
51
  constructor() {
52
52
  }
53
+ static defaultBackendUrl = "https://api.gearbox.foundation";
53
54
  static async getTotalTokensOnProtocol({
54
55
  tokensToCheck,
55
56
  tokensList,
56
- network
57
+ network,
58
+ backendUrl = PoolPointsAPI.defaultBackendUrl
57
59
  }) {
58
60
  const list = [...new Set(tokensToCheck)];
59
61
  const res = await Promise.allSettled(
60
- list.map((t) => PoolPointsAPI.getTokenTotal(t, network, tokensList))
62
+ list.map(
63
+ (t) => PoolPointsAPI.getTokenTotal(t, network, tokensList, backendUrl)
64
+ )
61
65
  );
62
66
  return res.map((r, i) => [
63
67
  list[i],
64
68
  r
65
69
  ]);
66
70
  }
67
- static async getTokenTotal(token, network, tokensList) {
71
+ static async getTokenTotal(token, network, tokensList, backendUrl) {
68
72
  const chainId = import_sdk.chains[network]?.id;
69
- const url = `https://api.gearbox.foundation/v1/getBalanceAt?asset=${token}&chainId=${chainId}`;
73
+ const url = `${backendUrl}/v1/getBalanceAt?asset=${token}&chainId=${chainId}`;
70
74
  const result = await import_axios.default.get(url);
71
75
  const balance = result.data.result.reduce(
72
76
  (sum, r) => r.effective_balance + sum,
@@ -620,10 +620,12 @@ class CreditAccountsServiceV310 extends import_base.SDKConstruct {
620
620
  assetsToWithdraw,
621
621
  to
622
622
  }) {
623
+ const unwrapCalls = await this.getRedeemDiffCalls(1n, ca.creditManager) ?? [];
623
624
  return [
624
625
  ...routerCalls,
625
626
  ...this.#prepareDisableQuotas(ca),
626
627
  ...this.#prepareDecreaseDebt(ca),
628
+ ...unwrapCalls,
627
629
  ...assetsToWithdraw.map(
628
630
  (t) => this.#prepareWithdrawToken(ca.creditFacade, t, import_constants.MAX_UINT256, to)
629
631
  )
@@ -20,23 +20,27 @@ function getKeyForPoolPointsInfo(i) {
20
20
  class PoolPointsAPI {
21
21
  constructor() {
22
22
  }
23
+ static defaultBackendUrl = "https://api.gearbox.foundation";
23
24
  static async getTotalTokensOnProtocol({
24
25
  tokensToCheck,
25
26
  tokensList,
26
- network
27
+ network,
28
+ backendUrl = PoolPointsAPI.defaultBackendUrl
27
29
  }) {
28
30
  const list = [...new Set(tokensToCheck)];
29
31
  const res = await Promise.allSettled(
30
- list.map((t) => PoolPointsAPI.getTokenTotal(t, network, tokensList))
32
+ list.map(
33
+ (t) => PoolPointsAPI.getTokenTotal(t, network, tokensList, backendUrl)
34
+ )
31
35
  );
32
36
  return res.map((r, i) => [
33
37
  list[i],
34
38
  r
35
39
  ]);
36
40
  }
37
- static async getTokenTotal(token, network, tokensList) {
41
+ static async getTokenTotal(token, network, tokensList, backendUrl) {
38
42
  const chainId = chains[network]?.id;
39
- const url = `https://api.gearbox.foundation/v1/getBalanceAt?asset=${token}&chainId=${chainId}`;
43
+ const url = `${backendUrl}/v1/getBalanceAt?asset=${token}&chainId=${chainId}`;
40
44
  const result = await axios.get(url);
41
45
  const balance = result.data.result.reduce(
42
46
  (sum, r) => r.effective_balance + sum,
@@ -616,10 +616,12 @@ class CreditAccountsServiceV310 extends SDKConstruct {
616
616
  assetsToWithdraw,
617
617
  to
618
618
  }) {
619
+ const unwrapCalls = await this.getRedeemDiffCalls(1n, ca.creditManager) ?? [];
619
620
  return [
620
621
  ...routerCalls,
621
622
  ...this.#prepareDisableQuotas(ca),
622
623
  ...this.#prepareDecreaseDebt(ca),
624
+ ...unwrapCalls,
623
625
  ...assetsToWithdraw.map(
624
626
  (t) => this.#prepareWithdrawToken(ca.creditFacade, t, MAX_UINT256, to)
625
627
  )
@@ -12,6 +12,7 @@ export interface GetTotalTokensOnProtocolProps {
12
12
  tokensToCheck: Array<Address>;
13
13
  tokensList: Record<Address, TokenData>;
14
14
  network: NetworkType;
15
+ backendUrl?: string;
15
16
  }
16
17
  export type PoolPointsBase = Record<Address, Array<{
17
18
  key: string;
@@ -21,7 +22,8 @@ export type PoolPointsBase = Record<Address, Array<{
21
22
  export declare function getKeyForPoolPointsInfo(i: PoolPointsInfo<string>): string;
22
23
  export declare class PoolPointsAPI {
23
24
  private constructor();
24
- static getTotalTokensOnProtocol({ tokensToCheck, tokensList, network, }: GetTotalTokensOnProtocolProps): Promise<[`0x${string}`, PromiseSettledResult<Asset>][]>;
25
+ private static defaultBackendUrl;
26
+ static getTotalTokensOnProtocol({ tokensToCheck, tokensList, network, backendUrl, }: GetTotalTokensOnProtocolProps): Promise<[`0x${string}`, PromiseSettledResult<Asset>][]>;
25
27
  private static getTokenTotal;
26
28
  static getPointsByPool({ poolRewards, totalTokenBalances, pools, tokensList, }: GetPointsByPoolProps): PoolPointsBase;
27
29
  private static getPoolTokenPoints;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "14.12.0-next.31",
3
+ "version": "14.12.0-next.32",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {