@gearbox-protocol/sdk 8.27.0 → 8.27.1
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.
|
@@ -175,11 +175,27 @@ class AbstractMigrateCreditAccountsService extends import_base.SDKConstruct {
|
|
|
175
175
|
});
|
|
176
176
|
return !!adapter;
|
|
177
177
|
}
|
|
178
|
-
static isSourceMigratableToTargetCM(targetTokensToMigrate, source, target, delayedPhantoms) {
|
|
179
|
-
const debt = source.borrowedAmountPlusInterestAndFees;
|
|
180
|
-
if (debt > target.maxDebt || debt < target.minDebt) return false;
|
|
178
|
+
static isSourceMigratableToTargetCM(targetTokensToMigrate, source, target, delayedPhantoms, sdk) {
|
|
181
179
|
const sourceUnderlying = source.underlying;
|
|
182
|
-
if (!target.supportedTokens[sourceUnderlying])
|
|
180
|
+
if (!target.supportedTokens[sourceUnderlying]) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
const tryConvert = () => {
|
|
184
|
+
try {
|
|
185
|
+
const market = sdk.marketRegister.findByCreditManager(target.address);
|
|
186
|
+
return market.priceOracle.convert(
|
|
187
|
+
sourceUnderlying,
|
|
188
|
+
target.underlyingToken,
|
|
189
|
+
source.borrowedAmountPlusInterestAndFees
|
|
190
|
+
);
|
|
191
|
+
} catch (e) {
|
|
192
|
+
return 0n;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
const debt = source.underlying !== target.underlyingToken ? tryConvert() : source.borrowedAmountPlusInterestAndFees;
|
|
196
|
+
if (debt === 0n || debt > target.maxDebt || debt < target.minDebt) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
183
199
|
const collateralsCheckPassed = targetTokensToMigrate.every((a) => {
|
|
184
200
|
const tokenToMigrate = AbstractMigrateCreditAccountsService.getV310TargetTokenAddress(
|
|
185
201
|
a.token,
|
|
@@ -155,11 +155,27 @@ class AbstractMigrateCreditAccountsService extends SDKConstruct {
|
|
|
155
155
|
});
|
|
156
156
|
return !!adapter;
|
|
157
157
|
}
|
|
158
|
-
static isSourceMigratableToTargetCM(targetTokensToMigrate, source, target, delayedPhantoms) {
|
|
159
|
-
const debt = source.borrowedAmountPlusInterestAndFees;
|
|
160
|
-
if (debt > target.maxDebt || debt < target.minDebt) return false;
|
|
158
|
+
static isSourceMigratableToTargetCM(targetTokensToMigrate, source, target, delayedPhantoms, sdk) {
|
|
161
159
|
const sourceUnderlying = source.underlying;
|
|
162
|
-
if (!target.supportedTokens[sourceUnderlying])
|
|
160
|
+
if (!target.supportedTokens[sourceUnderlying]) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
const tryConvert = () => {
|
|
164
|
+
try {
|
|
165
|
+
const market = sdk.marketRegister.findByCreditManager(target.address);
|
|
166
|
+
return market.priceOracle.convert(
|
|
167
|
+
sourceUnderlying,
|
|
168
|
+
target.underlyingToken,
|
|
169
|
+
source.borrowedAmountPlusInterestAndFees
|
|
170
|
+
);
|
|
171
|
+
} catch (e) {
|
|
172
|
+
return 0n;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
const debt = source.underlying !== target.underlyingToken ? tryConvert() : source.borrowedAmountPlusInterestAndFees;
|
|
176
|
+
if (debt === 0n || debt > target.maxDebt || debt < target.minDebt) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
163
179
|
const collateralsCheckPassed = targetTokensToMigrate.every((a) => {
|
|
164
180
|
const tokenToMigrate = AbstractMigrateCreditAccountsService.getV310TargetTokenAddress(
|
|
165
181
|
a.token,
|
|
@@ -35,5 +35,5 @@ export declare abstract class AbstractMigrateCreditAccountsService extends SDKCo
|
|
|
35
35
|
};
|
|
36
36
|
static getTokensAfterMigration<T extends Asset>(balances: Array<T> | Record<Address, T>, chainId: number): Array<T>;
|
|
37
37
|
static checkSourceCreditManager(sourceCreditManager: Address, migrationBot: Address, sdk: GearboxSDK): boolean;
|
|
38
|
-
static isSourceMigratableToTargetCM(targetTokensToMigrate: Array<Asset>, source: CreditAccountData_Legacy, target: CreditManagerData_Legacy, delayedPhantoms: Record<Address, object
|
|
38
|
+
static isSourceMigratableToTargetCM(targetTokensToMigrate: Array<Asset>, source: CreditAccountData_Legacy, target: CreditManagerData_Legacy, delayedPhantoms: Record<Address, object>, sdk: GearboxSDK): boolean;
|
|
39
39
|
}
|