@gearbox-protocol/sdk 3.0.0-next.68 → 3.0.0-next.69
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.
- package/lib/pathfinder/pathfinder.js +11 -4
- package/package.json +1 -1
|
@@ -75,7 +75,7 @@ class PathFinder {
|
|
|
75
75
|
* @returns PathFinderOpenStrategyResult which
|
|
76
76
|
*/
|
|
77
77
|
async findOpenStrategyPath({ creditManager: cm, expectedBalances, leftoverBalances, target, slippage, }) {
|
|
78
|
-
const
|
|
78
|
+
const input = cm.collateralTokens.map(token => ({
|
|
79
79
|
token,
|
|
80
80
|
balance: expectedBalances[token]?.balance || 0n,
|
|
81
81
|
}));
|
|
@@ -84,7 +84,7 @@ class PathFinder {
|
|
|
84
84
|
balance: leftoverBalances[token]?.balance || 1n,
|
|
85
85
|
}));
|
|
86
86
|
const connectors = this.getAvailableConnectors(cm.supportedTokens);
|
|
87
|
-
const [outBalances, result] = await this.pathFinder.callStatic.findOpenStrategyPath(cm.address,
|
|
87
|
+
const [outBalances, result] = await this.pathFinder.callStatic.findOpenStrategyPath(cm.address, input, leftover, target, connectors, slippage, {
|
|
88
88
|
gasLimit: GAS_PER_BLOCK,
|
|
89
89
|
});
|
|
90
90
|
const balancesAfter = outBalances.reduce((acc, b) => {
|
|
@@ -92,8 +92,15 @@ class PathFinder {
|
|
|
92
92
|
return acc;
|
|
93
93
|
}, {});
|
|
94
94
|
return {
|
|
95
|
-
balances: {
|
|
96
|
-
|
|
95
|
+
balances: {
|
|
96
|
+
...balancesAfter,
|
|
97
|
+
[target]: (expectedBalances[target]?.balance || 0n) + (0, sdk_gov_1.toBigInt)(result.amount),
|
|
98
|
+
},
|
|
99
|
+
minBalances: {
|
|
100
|
+
...balancesAfter,
|
|
101
|
+
[target]: (expectedBalances[target]?.balance || 0n) +
|
|
102
|
+
(0, sdk_gov_1.toBigInt)(result.minAmount),
|
|
103
|
+
},
|
|
97
104
|
calls: result.calls,
|
|
98
105
|
minAmount: (0, sdk_gov_1.toBigInt)(result.minAmount),
|
|
99
106
|
amount: (0, sdk_gov_1.toBigInt)(result.amount),
|