@gearbox-protocol/sdk 11.1.1 → 11.1.3
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/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +1 -0
- package/dist/cjs/sdk/market/loss-policy/AliasLossPolicyV310Contract.js +5 -1
- package/dist/cjs/sdk/market/oracle/PriceFeedAnswerMap.js +2 -2
- package/dist/cjs/sdk/utils/isDust.js +5 -1
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +1 -0
- package/dist/esm/sdk/market/loss-policy/AliasLossPolicyV310Contract.js +5 -1
- package/dist/esm/sdk/market/oracle/PriceFeedAnswerMap.js +2 -2
- package/dist/esm/sdk/utils/isDust.js +5 -1
- package/package.json +1 -1
|
@@ -290,6 +290,7 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
290
290
|
lossPolicyData = await market.lossPolicy.getLiquidationData(
|
|
291
291
|
account.creditAccount
|
|
292
292
|
);
|
|
293
|
+
this.#logger?.debug({ lossPolicyData }, "loss policy data");
|
|
293
294
|
}
|
|
294
295
|
const tx = cm.creditFacade.liquidateCreditAccount(
|
|
295
296
|
account.creditAccount,
|
|
@@ -66,7 +66,7 @@ class AliasLossPolicyV310Contract extends import_base.BaseContract {
|
|
|
66
66
|
args: [creditAccount],
|
|
67
67
|
blockNumber
|
|
68
68
|
});
|
|
69
|
-
this.logger?.debug({ feeds: pfs }, "
|
|
69
|
+
this.logger?.debug({ feeds: pfs }, "required alias price feeds");
|
|
70
70
|
if (pfs.length === 0) {
|
|
71
71
|
return "0x";
|
|
72
72
|
}
|
|
@@ -74,6 +74,10 @@ class AliasLossPolicyV310Contract extends import_base.BaseContract {
|
|
|
74
74
|
[...pfs],
|
|
75
75
|
blockNumber ? { blockNumber } : void 0
|
|
76
76
|
);
|
|
77
|
+
this.logger?.debug(
|
|
78
|
+
{ updates: updates.map((u) => this.sdk.labelAddress(u.priceFeed)) },
|
|
79
|
+
"encoding alias price feeds updates"
|
|
80
|
+
);
|
|
77
81
|
return (0, import_viem.encodeAbiParameters)(
|
|
78
82
|
[
|
|
79
83
|
{
|
|
@@ -26,11 +26,11 @@ class PriceFeedAnswerMap extends import_utils.AddressMap {
|
|
|
26
26
|
price(token) {
|
|
27
27
|
const answer = this.get(token);
|
|
28
28
|
if (!answer) {
|
|
29
|
-
throw new Error(`no answer found`);
|
|
29
|
+
throw new Error(`no answer found for token ${token}`);
|
|
30
30
|
}
|
|
31
31
|
const { success, price } = answer;
|
|
32
32
|
if (!success) {
|
|
33
|
-
throw new Error(`answer is not successful`);
|
|
33
|
+
throw new Error(`answer (${price}) is not successful for token ${token}`);
|
|
34
34
|
}
|
|
35
35
|
return price;
|
|
36
36
|
}
|
|
@@ -33,7 +33,11 @@ function isDust(opts) {
|
|
|
33
33
|
try {
|
|
34
34
|
balanceUSD = priceOracle.convertToUSD(token, balance);
|
|
35
35
|
} catch {
|
|
36
|
-
|
|
36
|
+
try {
|
|
37
|
+
balanceUSD = priceOracle.convertToUSD(token, balance, true);
|
|
38
|
+
} catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
37
41
|
}
|
|
38
42
|
return balanceUSD < minBalanceUSD;
|
|
39
43
|
}
|
|
@@ -280,6 +280,7 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
280
280
|
lossPolicyData = await market.lossPolicy.getLiquidationData(
|
|
281
281
|
account.creditAccount
|
|
282
282
|
);
|
|
283
|
+
this.#logger?.debug({ lossPolicyData }, "loss policy data");
|
|
283
284
|
}
|
|
284
285
|
const tx = cm.creditFacade.liquidateCreditAccount(
|
|
285
286
|
account.creditAccount,
|
|
@@ -46,7 +46,7 @@ class AliasLossPolicyV310Contract extends BaseContract {
|
|
|
46
46
|
args: [creditAccount],
|
|
47
47
|
blockNumber
|
|
48
48
|
});
|
|
49
|
-
this.logger?.debug({ feeds: pfs }, "
|
|
49
|
+
this.logger?.debug({ feeds: pfs }, "required alias price feeds");
|
|
50
50
|
if (pfs.length === 0) {
|
|
51
51
|
return "0x";
|
|
52
52
|
}
|
|
@@ -54,6 +54,10 @@ class AliasLossPolicyV310Contract extends BaseContract {
|
|
|
54
54
|
[...pfs],
|
|
55
55
|
blockNumber ? { blockNumber } : void 0
|
|
56
56
|
);
|
|
57
|
+
this.logger?.debug(
|
|
58
|
+
{ updates: updates.map((u) => this.sdk.labelAddress(u.priceFeed)) },
|
|
59
|
+
"encoding alias price feeds updates"
|
|
60
|
+
);
|
|
57
61
|
return encodeAbiParameters(
|
|
58
62
|
[
|
|
59
63
|
{
|
|
@@ -3,11 +3,11 @@ class PriceFeedAnswerMap extends AddressMap {
|
|
|
3
3
|
price(token) {
|
|
4
4
|
const answer = this.get(token);
|
|
5
5
|
if (!answer) {
|
|
6
|
-
throw new Error(`no answer found`);
|
|
6
|
+
throw new Error(`no answer found for token ${token}`);
|
|
7
7
|
}
|
|
8
8
|
const { success, price } = answer;
|
|
9
9
|
if (!success) {
|
|
10
|
-
throw new Error(`answer is not successful`);
|
|
10
|
+
throw new Error(`answer (${price}) is not successful for token ${token}`);
|
|
11
11
|
}
|
|
12
12
|
return price;
|
|
13
13
|
}
|
|
@@ -10,7 +10,11 @@ function isDust(opts) {
|
|
|
10
10
|
try {
|
|
11
11
|
balanceUSD = priceOracle.convertToUSD(token, balance);
|
|
12
12
|
} catch {
|
|
13
|
-
|
|
13
|
+
try {
|
|
14
|
+
balanceUSD = priceOracle.convertToUSD(token, balance, true);
|
|
15
|
+
} catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
14
18
|
}
|
|
15
19
|
return balanceUSD < minBalanceUSD;
|
|
16
20
|
}
|