@gearbox-protocol/sdk 3.0.0-next.136 → 3.0.0-next.138

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.
@@ -13,7 +13,7 @@ const CHARTS_BACKEND_ADDRESSES = {
13
13
  [exports.TESTNET_CHAINS.Mainnet]: "https://testnet.gearbox.foundation",
14
14
  // !& test server for optimism
15
15
  [exports.TESTNET_CHAINS.Optimism]: "https://testnet.gearbox.foundation",
16
- [exports.TESTNET_CHAINS.Arbitrum]: "https://testnet.gearbox.foundation",
16
+ [exports.TESTNET_CHAINS.Arbitrum]: "https://arbtest.gearbox.foundation",
17
17
  };
18
18
  class ChartsApi {
19
19
  static getUrl = (url, chainId, options, priceSource) => [
@@ -108,10 +108,16 @@ class PathFinder {
108
108
  async findBestClosePath({ creditAccount, creditManager: cm, expectedBalances, leftoverBalances, slippage, noConcurrency = false, }) {
109
109
  const loopsPerTx = Math.floor(GAS_PER_BLOCK / MAX_GAS_PER_ROUTE);
110
110
  const pathOptions = pathOptions_1.PathOptionFactory.generatePathOptions(creditAccount.allBalances, loopsPerTx);
111
- const expected = cm.collateralTokens.map(token => ({
112
- token,
113
- balance: expectedBalances[token]?.balance || 0n,
114
- }));
111
+ const expected = cm.collateralTokens.map(token => {
112
+ // When we pass expected balances explicitly, we need to mimic router behaviour by filtering out leftover tokens
113
+ // for example, we can have stETH balance of 2, because 1 transforms to 2 because of rebasing
114
+ // https://github.com/Gearbox-protocol/router-v3/blob/c230a3aa568bb432e50463cfddc877fec8940cf5/contracts/RouterV3.sol#L222
115
+ const actual = expectedBalances[token]?.balance || 0n;
116
+ return {
117
+ token,
118
+ balance: actual > 10n ? actual : 0n,
119
+ };
120
+ });
115
121
  const leftover = cm.collateralTokens.map(token => ({
116
122
  token,
117
123
  balance: leftoverBalances[token]?.balance || 1n,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "3.0.0-next.136",
3
+ "version": "3.0.0-next.138",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",