@gearbox-protocol/sdk 14.12.0-next.49 → 14.12.0-next.50
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.
|
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var helpers_exports = {};
|
|
20
20
|
__export(helpers_exports, {
|
|
21
21
|
DUST_THRESHOLD: () => DUST_THRESHOLD,
|
|
22
|
+
LIQUIDATION_APPROVAL_BUFFER: () => LIQUIDATION_APPROVAL_BUFFER,
|
|
22
23
|
calcEstimatedProfit: () => calcEstimatedProfit,
|
|
23
24
|
calcRepaymentAmount: () => calcRepaymentAmount,
|
|
24
25
|
liquidationCallToRawTx: () => liquidationCallToRawTx,
|
|
@@ -32,6 +33,7 @@ var import_viem = require("viem");
|
|
|
32
33
|
var import_constants = require("../../constants/index.js");
|
|
33
34
|
var import_utils = require("../../utils/index.js");
|
|
34
35
|
const DUST_THRESHOLD = 10n;
|
|
36
|
+
const LIQUIDATION_APPROVAL_BUFFER = 50n;
|
|
35
37
|
function calcRepaymentAmount(totalValue, liquidationDiscount) {
|
|
36
38
|
return totalValue * BigInt(liquidationDiscount) / import_constants.PERCENTAGE_FACTOR;
|
|
37
39
|
}
|
|
@@ -106,7 +108,7 @@ function toLiquidationApproval(props) {
|
|
|
106
108
|
return {
|
|
107
109
|
spender: (0, import_utils.hexEq)(target, creditFacade) ? creditManager : target,
|
|
108
110
|
token,
|
|
109
|
-
amount
|
|
111
|
+
amount: amount * (import_constants.PERCENTAGE_FACTOR + LIQUIDATION_APPROVAL_BUFFER) / import_constants.PERCENTAGE_FACTOR
|
|
110
112
|
};
|
|
111
113
|
}
|
|
112
114
|
function liquidationCallToRawTx(call, description) {
|
|
@@ -127,6 +129,7 @@ function liquidationCallToRawTx(call, description) {
|
|
|
127
129
|
// Annotate the CommonJS export names for ESM import in node:
|
|
128
130
|
0 && (module.exports = {
|
|
129
131
|
DUST_THRESHOLD,
|
|
132
|
+
LIQUIDATION_APPROVAL_BUFFER,
|
|
130
133
|
calcEstimatedProfit,
|
|
131
134
|
calcRepaymentAmount,
|
|
132
135
|
liquidationCallToRawTx,
|
|
@@ -2,6 +2,7 @@ import { slice } from "viem";
|
|
|
2
2
|
import { ADDRESS_0X0, PERCENTAGE_FACTOR } from "../../constants/index.js";
|
|
3
3
|
import { hexEq } from "../../utils/index.js";
|
|
4
4
|
const DUST_THRESHOLD = 10n;
|
|
5
|
+
const LIQUIDATION_APPROVAL_BUFFER = 50n;
|
|
5
6
|
function calcRepaymentAmount(totalValue, liquidationDiscount) {
|
|
6
7
|
return totalValue * BigInt(liquidationDiscount) / PERCENTAGE_FACTOR;
|
|
7
8
|
}
|
|
@@ -76,7 +77,7 @@ function toLiquidationApproval(props) {
|
|
|
76
77
|
return {
|
|
77
78
|
spender: hexEq(target, creditFacade) ? creditManager : target,
|
|
78
79
|
token,
|
|
79
|
-
amount
|
|
80
|
+
amount: amount * (PERCENTAGE_FACTOR + LIQUIDATION_APPROVAL_BUFFER) / PERCENTAGE_FACTOR
|
|
80
81
|
};
|
|
81
82
|
}
|
|
82
83
|
function liquidationCallToRawTx(call, description) {
|
|
@@ -96,6 +97,7 @@ function liquidationCallToRawTx(call, description) {
|
|
|
96
97
|
}
|
|
97
98
|
export {
|
|
98
99
|
DUST_THRESHOLD,
|
|
100
|
+
LIQUIDATION_APPROVAL_BUFFER,
|
|
99
101
|
calcEstimatedProfit,
|
|
100
102
|
calcRepaymentAmount,
|
|
101
103
|
liquidationCallToRawTx,
|
|
@@ -22,6 +22,12 @@ export type OnchainLiquidationCall = OnchainLiquidationData["liquidationCall"];
|
|
|
22
22
|
* consistent with the rest of the SDK (see `filterDust`).
|
|
23
23
|
**/
|
|
24
24
|
export declare const DUST_THRESHOLD = 10n;
|
|
25
|
+
/**
|
|
26
|
+
* Headroom (in bps) added on top of the amount the liquidation pulls when
|
|
27
|
+
* building the liquidator's approval, so that the transaction does not revert
|
|
28
|
+
* when prices move between the preview and the execution.
|
|
29
|
+
**/
|
|
30
|
+
export declare const LIQUIDATION_APPROVAL_BUFFER = 50n;
|
|
25
31
|
/**
|
|
26
32
|
* Estimated amount (in underlying) the liquidator pays to fully liquidate an
|
|
27
33
|
* account: the part of total value used to repay debt and protocol fees.
|
|
@@ -99,6 +105,9 @@ export interface ToLiquidationApprovalProps {
|
|
|
99
105
|
* dedicated liquidator contract (Midas / Securitize) that pulls the token to
|
|
100
106
|
* itself and re-approves the credit manager, so it is the spender itself.
|
|
101
107
|
*
|
|
108
|
+
* The approved amount includes {@link LIQUIDATION_APPROVAL_BUFFER} of headroom
|
|
109
|
+
* over the pulled amount to tolerate price movements.
|
|
110
|
+
*
|
|
102
111
|
* @param props - See {@link ToLiquidationApprovalProps}
|
|
103
112
|
* @returns The approval, or `undefined` when the call pulls nothing
|
|
104
113
|
**/
|
|
@@ -252,9 +252,9 @@ export interface LiquidationApproval {
|
|
|
252
252
|
**/
|
|
253
253
|
token: Address;
|
|
254
254
|
/**
|
|
255
|
-
* Amount to approve
|
|
256
|
-
* The Securitize liquidator recomputes
|
|
257
|
-
*
|
|
255
|
+
* Amount to approve: the amount the liquidation transaction pulls plus 0.5%
|
|
256
|
+
* of headroom. The Securitize liquidator recomputes the amount on-chain, so
|
|
257
|
+
* the approval must survive price movements after the preview.
|
|
258
258
|
**/
|
|
259
259
|
amount: bigint;
|
|
260
260
|
}
|