@haven-fi/solauto-sdk 1.0.78 → 1.0.80
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/constants/tokenConstants.d.ts +1 -0
- package/dist/constants/tokenConstants.d.ts.map +1 -1
- package/dist/constants/tokenConstants.js +9 -0
- package/dist/utils/numberUtils.d.ts +1 -1
- package/dist/utils/numberUtils.d.ts.map +1 -1
- package/dist/utils/numberUtils.js +4 -4
- package/package.json +1 -1
- package/src/constants/tokenConstants.ts +10 -0
- package/src/utils/numberUtils.ts +7 -4
@@ -3,6 +3,7 @@ export declare const B_SOL = "bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1";
|
|
3
3
|
export declare const JUP = "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN";
|
4
4
|
export declare const ALL_SUPPORTED_TOKENS: string[];
|
5
5
|
interface TokenInfo {
|
6
|
+
ticker: string;
|
6
7
|
decimals: number;
|
7
8
|
isStableCoin?: boolean;
|
8
9
|
isLST?: boolean;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"tokenConstants.d.ts","sourceRoot":"","sources":["../../src/constants/tokenConstants.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"tokenConstants.d.ts","sourceRoot":"","sources":["../../src/constants/tokenConstants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,SAAS,iDAAiD,CAAC;AACxE,eAAO,MAAM,KAAK,gDAAgD,CAAC;AACnE,eAAO,MAAM,GAAG,gDAAgD,CAAC;AAGjE,eAAO,MAAM,oBAAoB,UAKhC,CAAC;AAEF,UAAU,SAAS;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,UAAU,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAuBlD,CAAC"}
|
@@ -2,6 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.TOKEN_INFO = exports.ALL_SUPPORTED_TOKENS = exports.JUP = exports.B_SOL = exports.USDC_MINT = void 0;
|
4
4
|
const spl_token_1 = require("@solana/spl-token");
|
5
|
+
const web3_js_1 = require("@solana/web3.js");
|
5
6
|
// When adding token ensure a price feed is provided in pythConstants.ts & the token is in TOKEN_INFO
|
6
7
|
exports.USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
7
8
|
exports.B_SOL = "bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1";
|
@@ -13,18 +14,26 @@ exports.ALL_SUPPORTED_TOKENS = [
|
|
13
14
|
exports.JUP,
|
14
15
|
];
|
15
16
|
exports.TOKEN_INFO = {
|
17
|
+
[web3_js_1.PublicKey.default.toString()]: {
|
18
|
+
ticker: "",
|
19
|
+
decimals: 1
|
20
|
+
},
|
16
21
|
[spl_token_1.NATIVE_MINT.toString()]: {
|
22
|
+
ticker: "SOL",
|
17
23
|
decimals: 9,
|
18
24
|
},
|
19
25
|
[exports.USDC_MINT]: {
|
26
|
+
ticker: "USDC",
|
20
27
|
decimals: 6,
|
21
28
|
isStableCoin: true
|
22
29
|
},
|
23
30
|
[exports.B_SOL]: {
|
31
|
+
ticker: "BSOL",
|
24
32
|
decimals: 9,
|
25
33
|
isLST: true
|
26
34
|
},
|
27
35
|
[exports.JUP]: {
|
36
|
+
ticker: "JUP",
|
28
37
|
decimals: 6
|
29
38
|
}
|
30
39
|
};
|
@@ -13,7 +13,7 @@ export declare function getSolautoFeesBps(isReferred: boolean, feeType: FeeType,
|
|
13
13
|
total: number;
|
14
14
|
};
|
15
15
|
export declare function getMaxLiqUtilizationRateBps(maxLtvBps: number, liqThresholdBps: number, offsetFromMaxLtv: number): number;
|
16
|
-
export declare function maxBoostToBps(maxLtvBps: number, liqThresholdBps: number): number;
|
17
16
|
export declare function maxRepayFromBps(maxLtvBps: number, liqThresholdBps: number): number;
|
18
17
|
export declare function maxRepayToBps(maxLtvBps: number, liqThresholdBps: number): number;
|
18
|
+
export declare function maxBoostToBps(maxLtvBps: number, liqThresholdBps: number): number;
|
19
19
|
//# sourceMappingURL=numberUtils.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"numberUtils.d.ts","sourceRoot":"","sources":["../../src/utils/numberUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,GACtB,MAAM,CAMR;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAqBrD;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAejE;AAED,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,2BAA2B,EAAE,MAAM,EACnC,gBAAgB,CAAC,EAAE,MAAM,UAW1B;AAED,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,OAAO,EACnB,OAAO,EAAE,OAAO,EAChB,mBAAmB,EAAE,MAAM,GAC1B;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CA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,EAAE,MAAM,EACvB,gBAAgB,EAAE,MAAM,GACvB,MAAM,CAER;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAKzE;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAKvE;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAKvE"}
|
@@ -10,9 +10,9 @@ exports.uint8ArrayToBigInt = uint8ArrayToBigInt;
|
|
10
10
|
exports.getDebtAdjustmentUsd = getDebtAdjustmentUsd;
|
11
11
|
exports.getSolautoFeesBps = getSolautoFeesBps;
|
12
12
|
exports.getMaxLiqUtilizationRateBps = getMaxLiqUtilizationRateBps;
|
13
|
-
exports.maxBoostToBps = maxBoostToBps;
|
14
13
|
exports.maxRepayFromBps = maxRepayFromBps;
|
15
14
|
exports.maxRepayToBps = maxRepayToBps;
|
15
|
+
exports.maxBoostToBps = maxBoostToBps;
|
16
16
|
const constants_1 = require("../constants");
|
17
17
|
const generated_1 = require("../generated");
|
18
18
|
function getLiqUtilzationRateBps(supplyUsd, debtUsd, liqThresholdBps) {
|
@@ -100,12 +100,12 @@ function getSolautoFeesBps(isReferred, feeType, positionNetWorthUsd) {
|
|
100
100
|
function getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, offsetFromMaxLtv) {
|
101
101
|
return toBps((fromBps(maxLtvBps) - offsetFromMaxLtv) / fromBps(liqThresholdBps)) - 1; // -1 to account for any rounding issues
|
102
102
|
}
|
103
|
-
function maxBoostToBps(maxLtvBps, liqThresholdBps) {
|
104
|
-
return getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.015);
|
105
|
-
}
|
106
103
|
function maxRepayFromBps(maxLtvBps, liqThresholdBps) {
|
107
104
|
return Math.min(9000, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.005));
|
108
105
|
}
|
109
106
|
function maxRepayToBps(maxLtvBps, liqThresholdBps) {
|
110
107
|
return Math.min(maxRepayFromBps(maxLtvBps, liqThresholdBps) - constants_1.MIN_REPAY_GAP_BPS, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.005));
|
111
108
|
}
|
109
|
+
function maxBoostToBps(maxLtvBps, liqThresholdBps) {
|
110
|
+
return Math.min(maxRepayToBps(maxLtvBps, liqThresholdBps), getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.015));
|
111
|
+
}
|
package/package.json
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { NATIVE_MINT } from "@solana/spl-token";
|
2
|
+
import { PublicKey } from "@solana/web3.js";
|
2
3
|
|
3
4
|
// When adding token ensure a price feed is provided in pythConstants.ts & the token is in TOKEN_INFO
|
4
5
|
export const USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
@@ -14,24 +15,33 @@ export const ALL_SUPPORTED_TOKENS = [
|
|
14
15
|
];
|
15
16
|
|
16
17
|
interface TokenInfo {
|
18
|
+
ticker: string;
|
17
19
|
decimals: number;
|
18
20
|
isStableCoin?: boolean;
|
19
21
|
isLST?: boolean;
|
20
22
|
}
|
21
23
|
|
22
24
|
export const TOKEN_INFO: { [key: string]: TokenInfo } = {
|
25
|
+
[PublicKey.default.toString()]: {
|
26
|
+
ticker: "",
|
27
|
+
decimals: 1
|
28
|
+
},
|
23
29
|
[NATIVE_MINT.toString()]: {
|
30
|
+
ticker: "SOL",
|
24
31
|
decimals: 9,
|
25
32
|
},
|
26
33
|
[USDC_MINT]: {
|
34
|
+
ticker: "USDC",
|
27
35
|
decimals: 6,
|
28
36
|
isStableCoin: true
|
29
37
|
},
|
30
38
|
[B_SOL]: {
|
39
|
+
ticker: "BSOL",
|
31
40
|
decimals: 9,
|
32
41
|
isLST: true
|
33
42
|
},
|
34
43
|
[JUP]: {
|
44
|
+
ticker: "JUP",
|
35
45
|
decimals: 6
|
36
46
|
}
|
37
47
|
};
|
package/src/utils/numberUtils.ts
CHANGED
@@ -135,10 +135,6 @@ export function getMaxLiqUtilizationRateBps(
|
|
135
135
|
return toBps((fromBps(maxLtvBps) - offsetFromMaxLtv) / fromBps(liqThresholdBps)) - 1; // -1 to account for any rounding issues
|
136
136
|
}
|
137
137
|
|
138
|
-
export function maxBoostToBps(maxLtvBps: number, liqThresholdBps: number) {
|
139
|
-
return getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.015);
|
140
|
-
}
|
141
|
-
|
142
138
|
export function maxRepayFromBps(maxLtvBps: number, liqThresholdBps: number) {
|
143
139
|
return Math.min(
|
144
140
|
9000,
|
@@ -152,3 +148,10 @@ export function maxRepayToBps(maxLtvBps: number, liqThresholdBps: number) {
|
|
152
148
|
getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.005)
|
153
149
|
);
|
154
150
|
}
|
151
|
+
|
152
|
+
export function maxBoostToBps(maxLtvBps: number, liqThresholdBps: number) {
|
153
|
+
return Math.min(
|
154
|
+
maxRepayToBps(maxLtvBps, liqThresholdBps),
|
155
|
+
getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.015)
|
156
|
+
);
|
157
|
+
}
|