@haven-fi/solauto-sdk 1.0.200 → 1.0.202
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/constants/marginfiAccounts.d.ts.map +1 -1
- package/dist/constants/marginfiAccounts.js +113 -12
- package/dist/constants/pythConstants.d.ts +14 -1
- package/dist/constants/pythConstants.d.ts.map +1 -1
- package/dist/constants/pythConstants.js +40 -4
- package/dist/constants/tokenConstants.d.ts +14 -1
- package/dist/constants/tokenConstants.d.ts.map +1 -1
- package/dist/constants/tokenConstants.js +95 -12
- package/dist/utils/marginfiUtils.d.ts +1 -0
- package/dist/utils/marginfiUtils.d.ts.map +1 -1
- package/dist/utils/marginfiUtils.js +17 -13
- package/package.json +2 -2
- package/src/constants/marginfiAccounts.ts +97 -15
- package/src/constants/pythConstants.ts +32 -4
- package/src/constants/tokenConstants.ts +115 -33
- package/src/utils/marginfiUtils.ts +61 -34
- package/tests/transactions/solautoMarginfi.ts +2 -2
- package/tests/unit/rebalanceCalculations.ts +4 -4
- package/tsconfig.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"marginfiAccounts.d.ts","sourceRoot":"","sources":["../../src/constants/marginfiAccounts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,eAAO,MAAM,sBAAsB,
|
1
|
+
{"version":3,"file":"marginfiAccounts.d.ts","sourceRoot":"","sources":["../../src/constants/marginfiAccounts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,eAAO,MAAM,sBAAsB,iDACa,CAAC;AAEjD,eAAO,MAAM,cAAc,QAA+B,CAAC;AAE3D,eAAO,MAAM,iBAAiB,EAAE;IAC9B,CAAC,KAAK,EAAE,MAAM,GAAG;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,qBAAqB,CAAA;KAAE,CAAC;CA0G7D,CAAC;AAEF,eAAO,MAAM,8BAA8B,iDACK,CAAC"}
|
@@ -1,8 +1,31 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
26
|
exports.MARGINFI_ACCOUNTS_LOOKUP_TABLE = exports.MARGINFI_ACCOUNTS = exports.DEFAULT_PUBKEY = exports.DEFAULT_MARGINFI_GROUP = void 0;
|
4
27
|
const spl_token_1 = require("@solana/spl-token");
|
5
|
-
const
|
28
|
+
const tokens = __importStar(require("./tokenConstants"));
|
6
29
|
const web3_js_1 = require("@solana/web3.js");
|
7
30
|
exports.DEFAULT_MARGINFI_GROUP = "4qp6Fx6tnZkY5Wropq9wUYgtFxXKwE6viZxFHg3rdAG8";
|
8
31
|
exports.DEFAULT_PUBKEY = web3_js_1.PublicKey.default.toString();
|
@@ -12,26 +35,104 @@ exports.MARGINFI_ACCOUNTS = {
|
|
12
35
|
bank: "CCKtUs6Cgwo4aaQUmBPmyoApH2gUDErxNZCAntD6LYGh",
|
13
36
|
liquidityVault: "2eicbpitfJXDwqCuFAmPgDP7t2oUotnAzbGzRKLMgSLe",
|
14
37
|
vaultAuthority: "DD3AeAssFvjqTvRTrRAtpfjkBF8FpVKnFuwnMLN9haXD",
|
15
|
-
priceOracle: "7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE"
|
38
|
+
priceOracle: "7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE",
|
16
39
|
},
|
17
|
-
[
|
18
|
-
bank: "2s37akK2eyBbp8DZgCm7RtsaEz8eJP3Nxd4urLHQv7yB",
|
19
|
-
liquidityVault: "7jaiZR5Sk8hdYN9MxTpczTcwbWpb5WEoxSANuUwveuat",
|
20
|
-
vaultAuthority: "3uxNepDbmkDNq6JhRja5Z8QwbTrfmkKP8AKZV5chYDGG",
|
21
|
-
priceOracle: "Dpw1EAVrSB1ibxiDQyTAW6Zip3J4Btk2x4SgApQCeFbX"
|
22
|
-
},
|
23
|
-
[tokenConstants_1.B_SOL]: {
|
40
|
+
[tokens.B_SOL]: {
|
24
41
|
bank: "6hS9i46WyTq1KXcoa2Chas2Txh9TJAVr6n1t3tnrE23K",
|
25
42
|
liquidityVault: "2WMipeKDB2CENxbzdmnVrRbsxCA2LY6kCtBe6AAqDP9p",
|
26
43
|
vaultAuthority: "8RcZHucpVHkHWRRdMhJZsxBK9mqKSYnMKGqtF84U8YEo",
|
27
44
|
priceOracle: "5cN76Xm2Dtx9MnrQqBDeZZRsWruTTcw37UruznAdSvvE",
|
28
45
|
},
|
29
|
-
[
|
46
|
+
[tokens.JITO_SOL]: {
|
47
|
+
bank: "Bohoc1ikHLD7xKJuzTyiTyCwzaL5N7ggJQu75A8mKYM8",
|
48
|
+
liquidityVault: "38VGtXd2pDPq9FMh1z6AVjcHCoHgvWyMhdNyamDTeeks",
|
49
|
+
vaultAuthority: "7Ng54qf7BrCcZLqXmKA9WSR7SVRn4q6RX1YpLksBQ21A",
|
50
|
+
priceOracle: "AxaxyeDT8JnWERSaTKvFXvPKkEdxnamKSqpWbsSjYg1g",
|
51
|
+
},
|
52
|
+
[tokens.LST]: {
|
53
|
+
bank: "DMoqjmsuoru986HgfjqrKEvPv8YBufvBGADHUonkadC5",
|
54
|
+
liquidityVault: "DMQUXpb6K5L8osgV4x3NeEPUoJCf2VBgnA8FQusDjSou",
|
55
|
+
vaultAuthority: "6PWVauGLhBFHUJspsnBVZHr56ZnbvmhSD2gS7czBHGpE",
|
56
|
+
priceOracle: "7aT9A5knp62jVvnEW33xaWopaPHa3Y7ggULyYiUsDhu8",
|
57
|
+
},
|
58
|
+
[tokens.M_SOL]: {
|
59
|
+
bank: "22DcjMZrMwC5Bpa5AGBsmjc5V9VuQrXG6N9ZtdUNyYGE",
|
60
|
+
liquidityVault: "B6HqNn83a2bLqo4i5ygjLHJgD11ePtQksUyx4MjD55DV",
|
61
|
+
vaultAuthority: "6YxGd65JbXzgFGWjE44jsyVeCnZp7Bb1wfL9jDia1n8w",
|
62
|
+
priceOracle: "5CKzb9j4ChgLUt8Gfm5CNGLN6khXKiqMbnGAW4cgXgxK",
|
63
|
+
},
|
64
|
+
[tokens.INF]: {
|
65
|
+
bank: "AwLRW3aPMMftXEjgWhTkYwM9CGBHdtKecvahCJZBwAqY",
|
66
|
+
liquidityVault: "HQ1CGcqRshMhuonTGTnnmgw9ffcXxizGdZ6F6PKffWWi",
|
67
|
+
vaultAuthority: "AEZb1XH5bfLwqk3hBKDuLfWyJKdLTgDPCkgn64BJKcvV",
|
68
|
+
priceOracle: "DCNeMcAZGU7pAsqu5q2xMKerq35BnUuTkagt1dkR1xB",
|
69
|
+
},
|
70
|
+
[tokens.JUP]: {
|
30
71
|
bank: "Guu5uBc8k1WK1U2ihGosNaCy57LSgCkpWAabtzQqrQf8",
|
31
72
|
liquidityVault: "4w49W4fNDn778wsBa6TNq9hvebZKU17ymsptrEZ8zrsm",
|
32
73
|
vaultAuthority: "2MBwwAhL3c73Jy7HkWd9ofzh1bU39JBabrZCFQR2tUof",
|
33
74
|
priceOracle: "7dbob1psH1iZBS7qPsm3Kwbf5DzSXK8Jyg31CTgTnxH5",
|
34
|
-
}
|
35
|
-
|
75
|
+
},
|
76
|
+
[tokens.BONK]: {
|
77
|
+
bank: "DeyH7QxWvnbbaVB4zFrf4hoq7Q8z1ZT14co42BGwGtfM",
|
78
|
+
liquidityVault: "7FdQsXmCW3N5JQbknj3F9Yqq73er9VZJjGhEEMS8Ct2A",
|
79
|
+
vaultAuthority: "26kcZkdjJc94PdhqiLiEaGiLCYgAVVUfpDaZyK4cqih3",
|
80
|
+
priceOracle: "DBE3N8uNjhKPRHfANdwGvCZghWXyLPdqdSbEW2XFwBiX",
|
81
|
+
},
|
82
|
+
[tokens.WIF]: {
|
83
|
+
bank: "9dpu8KL5ABYiD3WP2Cnajzg1XaotcJvZspv29Y1Y3tn1",
|
84
|
+
liquidityVault: "4kT3EXc5dDVndUU9mV6EH3Jh3CSEvpcCZjuMkwqrtxUy",
|
85
|
+
vaultAuthority: "9gNrvvZ9RuTyRWooiEEypwcXU6kyXW8yWuhXU8tWUH5L",
|
86
|
+
priceOracle: "6B23K3tkb51vLZA14jcEQVCA1pfHptzEHFA93V5dYwbT",
|
87
|
+
},
|
88
|
+
[tokens.JTO]: {
|
89
|
+
bank: "EdB7YADw4XUt6wErT8kHGCUok4mnTpWGzPUU9rWDebzb",
|
90
|
+
liquidityVault: "3bY1DEkXodGmPMG5f7ABA12228MBG5JdAAKf5cgkB6G1",
|
91
|
+
vaultAuthority: "H2b4f2fGSKFortxwzrMZBnYVfr2yrKVUakg4Md9be3Wv",
|
92
|
+
priceOracle: "7ajR2zA4MGMMTqRAVjghTKqPPn4kbrj3pYkAVRVwTGzP",
|
93
|
+
},
|
94
|
+
[tokens.JLP]: {
|
95
|
+
bank: "Amtw3n7GZe5SWmyhMhaFhDTi39zbTkLeWErBsmZXwpDa",
|
96
|
+
liquidityVault: "9xfyL8gxbV77VvhdgFmacHyLEG4h7d2eDWkSMfhXUPQ",
|
97
|
+
vaultAuthority: "F4RSGd4BRXscCqAVG3rFLiPVpo7v6j1drVqnvSM3rBKH",
|
98
|
+
priceOracle: "B1wxT1VK3i6DqCeXNdTHT5hBAJkLa3rxuTqBc7E7XRXV",
|
99
|
+
},
|
100
|
+
[tokens.WBTC]: {
|
101
|
+
bank: "BKsfDJCMbYep6gr9pq8PsmJbb5XGLHbAJzUV8vmorz7a",
|
102
|
+
liquidityVault: "CMNdnjfaDQZo3VMoX31wZQBnSGu5FMmb1CnBaU4tApZk",
|
103
|
+
vaultAuthority: "7P2TQHYgVJkXv1VPaREsL5Pi1gnNjVif5aF3pJewZ9kj",
|
104
|
+
priceOracle: "4cSM2e6rvbGQUFiJbqytoVMi5GgghSMr8LwVrT9VPSPo",
|
105
|
+
},
|
106
|
+
[tokens.WETH]: {
|
107
|
+
bank: "BkUyfXjbBBALcfZvw76WAFRvYQ21xxMWWeoPtJrUqG3z",
|
108
|
+
liquidityVault: "AxPJtiTEDksJWvCqNHCziK4uUcabqfmwW41dqtZrPFkp",
|
109
|
+
vaultAuthority: "ELXogWuyXrFyUG1vevffVbEhVxdFrHf2GCJTtRGKBWdM",
|
110
|
+
priceOracle: "42amVS4KgzR9rA28tkVYqVXjq9Qa8dcZQMbH5EYFX6XC",
|
111
|
+
},
|
112
|
+
[tokens.HNT]: {
|
113
|
+
bank: "JBcir4DPRPYVUpks9hkS1jtHMXejfeBo4xJGv3AYYHg6",
|
114
|
+
liquidityVault: "E8Q7u5e9L9Uykx16em75ERT9wfbBPtkNL8gsRjoP8GB9",
|
115
|
+
vaultAuthority: "AjsyrYpgaH275DBSnvNWdGK33hVycSFuXN87FKnX6fVY",
|
116
|
+
priceOracle: "4DdmDswskDxXGpwHrXUfn2CNUm9rt21ac79GHNTN3J33",
|
117
|
+
},
|
118
|
+
[tokens.PYTH]: {
|
119
|
+
bank: "E4td8i8PT2BZkMygzW4MGHCv2KPPs57dvz5W2ZXf9Twu",
|
120
|
+
liquidityVault: "DUrAkkaMAckzes7so9T5frXm9YFFgjAAm3MMwHwTfVJq",
|
121
|
+
vaultAuthority: "9b5KdVnbbfEQ2qhLeFjWvcAx2VWe9XHx7ZgayZyL9a6C",
|
122
|
+
priceOracle: "8vjchtMuJNY4oFQdTi8yCe6mhCaNBFaUbktT482TpLPS",
|
123
|
+
},
|
124
|
+
[tokens.USDC]: {
|
125
|
+
bank: "2s37akK2eyBbp8DZgCm7RtsaEz8eJP3Nxd4urLHQv7yB",
|
126
|
+
liquidityVault: "7jaiZR5Sk8hdYN9MxTpczTcwbWpb5WEoxSANuUwveuat",
|
127
|
+
vaultAuthority: "3uxNepDbmkDNq6JhRja5Z8QwbTrfmkKP8AKZV5chYDGG",
|
128
|
+
priceOracle: "Dpw1EAVrSB1ibxiDQyTAW6Zip3J4Btk2x4SgApQCeFbX",
|
129
|
+
},
|
130
|
+
[tokens.USDT]: {
|
131
|
+
bank: "HmpMfL8942u22htC4EMiWgLX931g3sacXFR6KjuLgKLV",
|
132
|
+
liquidityVault: "77t6Fi9qj4s4z22K1toufHtstM8rEy7Y3ytxik7mcsTy",
|
133
|
+
vaultAuthority: "9r6z6KgkEytHCdQWNxvDQH98PsfU98f1m5PCg47mY2XE",
|
134
|
+
priceOracle: "HT2PLQBcG5EiCcNSaMHAjSgd9F98ecpATbk4Sk5oYuM",
|
135
|
+
},
|
136
|
+
},
|
36
137
|
};
|
37
138
|
exports.MARGINFI_ACCOUNTS_LOOKUP_TABLE = "GAjmWmBPcH5Gxbiykasydj6RsCEaCLyHEvK6kHdFigc6";
|
@@ -1,7 +1,20 @@
|
|
1
1
|
export declare const PYTH_PRICE_FEED_IDS: {
|
2
2
|
[x: string]: string;
|
3
|
-
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v: string;
|
4
3
|
bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1: string;
|
4
|
+
J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn: string;
|
5
|
+
LSTxxxnJzKDFSLr4dUkPcmCf5VyryEqzPLz5j4bpxFp: string;
|
6
|
+
mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So: string;
|
7
|
+
"5oVNBeEEQvYi1cX3ir8Dx5n1P7pdxydbGF2X4TxVusJm": string;
|
5
8
|
JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN: string;
|
9
|
+
DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263: string;
|
10
|
+
EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm: string;
|
11
|
+
jtojtomepa8beP8AuQc6eXt5FriJwfFMwQx2v2f9mCL: string;
|
12
|
+
"27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4": string;
|
13
|
+
"3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh": string;
|
14
|
+
"7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs": string;
|
15
|
+
hntyVP6YFm1Hg25TN9WGLqM12b8TQmcknKrdu1oxWux: string;
|
16
|
+
HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3: string;
|
17
|
+
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v: string;
|
18
|
+
Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB: string;
|
6
19
|
};
|
7
20
|
//# sourceMappingURL=pythConstants.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pythConstants.d.ts","sourceRoot":"","sources":["../../src/constants/pythConstants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB
|
1
|
+
{"version":3,"file":"pythConstants.d.ts","sourceRoot":"","sources":["../../src/constants/pythConstants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;CAmC/B,CAAC"}
|
@@ -1,12 +1,48 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
26
|
exports.PYTH_PRICE_FEED_IDS = void 0;
|
4
27
|
const spl_token_1 = require("@solana/spl-token");
|
5
|
-
const
|
28
|
+
const tokens = __importStar(require("./tokenConstants"));
|
6
29
|
// https://pyth.network/developers/price-feed-ids#solana-stable
|
7
30
|
exports.PYTH_PRICE_FEED_IDS = {
|
8
31
|
[spl_token_1.NATIVE_MINT.toString()]: "0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
|
9
|
-
[
|
10
|
-
[
|
11
|
-
[
|
32
|
+
[tokens.B_SOL]: "0x89875379e70f8fbadc17aef315adf3a8d5d160b811435537e03c97e8aac97d9c",
|
33
|
+
[tokens.JITO_SOL]: "0x67be9f519b95cf24338801051f9a808eff0a578ccb388db73b7f6fe1de019ffb",
|
34
|
+
[tokens.LST]: "0x12fb674ee496045b1d9cf7d5e65379acb026133c2ad69f3ed996fb9fe68e3a37",
|
35
|
+
[tokens.M_SOL]: "0xc2289a6a43d2ce91c6f55caec370f4acc38a2ed477f58813334c6d03749ff2a4",
|
36
|
+
[tokens.INF]: "0xf51570985c642c49c2d6e50156390fdba80bb6d5f7fa389d2f012ced4f7d208f",
|
37
|
+
[tokens.JUP]: "0x0a0408d619e9380abad35060f9192039ed5042fa6f82301d0e48bb52be830996",
|
38
|
+
[tokens.BONK]: "0x72b021217ca3fe68922a19aaf990109cb9d84e9ad004b4d2025ad6f529314419",
|
39
|
+
[tokens.WIF]: "0x4ca4beeca86f0d164160323817a4e42b10010a724c2217c6ee41b54cd4cc61fc",
|
40
|
+
[tokens.JTO]: "0xb43660a5f790c69354b0729a5ef9d50d68f1df92107540210b9cccba1f947cc2",
|
41
|
+
[tokens.JLP]: "0xc811abc82b4bad1f9bd711a2773ccaa935b03ecef974236942cec5e0eb845a3a",
|
42
|
+
[tokens.WBTC]: "0xc9d8b075a5c69303365ae23633d4e085199bf5c520a3b90fed1322a0342ffc33",
|
43
|
+
[tokens.WETH]: "0x9d4294bbcd1174d6f2003ec365831e64cc31d9f6f15a2b85399db8d5000960f6",
|
44
|
+
[tokens.HNT]: "0x649fdd7ec08e8e2a20f425729854e90293dcbe2376abc47197a14da6ff339756",
|
45
|
+
[tokens.PYTH]: "0x0bbf28e9a841a1cc788f6a361b17ca072d0ea3098a1e5df1c3922d06719579ff",
|
46
|
+
[tokens.USDC]: "0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
47
|
+
[tokens.USDT]: "0x2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b",
|
12
48
|
};
|
@@ -1,6 +1,19 @@
|
|
1
|
-
export declare const USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
2
1
|
export declare const B_SOL = "bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1";
|
2
|
+
export declare const JITO_SOL = "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn";
|
3
|
+
export declare const LST = "LSTxxxnJzKDFSLr4dUkPcmCf5VyryEqzPLz5j4bpxFp";
|
4
|
+
export declare const M_SOL = "mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So";
|
5
|
+
export declare const INF = "5oVNBeEEQvYi1cX3ir8Dx5n1P7pdxydbGF2X4TxVusJm";
|
3
6
|
export declare const JUP = "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN";
|
7
|
+
export declare const BONK = "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263";
|
8
|
+
export declare const WIF = "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm";
|
9
|
+
export declare const JTO = "jtojtomepa8beP8AuQc6eXt5FriJwfFMwQx2v2f9mCL";
|
10
|
+
export declare const JLP = "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4";
|
11
|
+
export declare const WBTC = "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh";
|
12
|
+
export declare const WETH = "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs";
|
13
|
+
export declare const HNT = "hntyVP6YFm1Hg25TN9WGLqM12b8TQmcknKrdu1oxWux";
|
14
|
+
export declare const PYTH = "HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3";
|
15
|
+
export declare const USDC = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
16
|
+
export declare const USDT = "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB";
|
4
17
|
export declare const ALL_SUPPORTED_TOKENS: string[];
|
5
18
|
interface TokenInfo {
|
6
19
|
ticker: string;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"tokenConstants.d.ts","sourceRoot":"","sources":["../../src/constants/tokenConstants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,
|
1
|
+
{"version":3,"file":"tokenConstants.d.ts","sourceRoot":"","sources":["../../src/constants/tokenConstants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,KAAK,gDAAgD,CAAC;AACnE,eAAO,MAAM,QAAQ,iDAAiD,CAAC;AACvE,eAAO,MAAM,GAAG,gDAAgD,CAAC;AACjE,eAAO,MAAM,KAAK,gDAAgD,CAAC;AACnE,eAAO,MAAM,GAAG,iDAAiD,CAAC;AAClE,eAAO,MAAM,GAAG,gDAAgD,CAAC;AACjE,eAAO,MAAM,IAAI,iDAAiD,CAAC;AACnE,eAAO,MAAM,GAAG,iDAAiD,CAAC;AAClE,eAAO,MAAM,GAAG,gDAAgD,CAAC;AACjE,eAAO,MAAM,GAAG,iDAAiD,CAAC;AAClE,eAAO,MAAM,IAAI,iDAAiD,CAAC;AACnE,eAAO,MAAM,IAAI,iDAAiD,CAAC;AACnE,eAAO,MAAM,GAAG,gDAAgD,CAAC;AACjE,eAAO,MAAM,IAAI,iDAAiD,CAAC;AACnE,eAAO,MAAM,IAAI,iDAAiD,CAAC;AACnE,eAAO,MAAM,IAAI,iDAAiD,CAAC;AAEnE,eAAO,MAAM,oBAAoB,UAkBhC,CAAC;AAEF,UAAU,SAAS;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,eAAO,MAAM,UAAU,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAgFlD,CAAC"}
|
@@ -1,39 +1,122 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.TOKEN_INFO = exports.ALL_SUPPORTED_TOKENS = exports.JUP = exports.
|
3
|
+
exports.TOKEN_INFO = exports.ALL_SUPPORTED_TOKENS = exports.USDT = exports.USDC = exports.PYTH = exports.HNT = exports.WETH = exports.WBTC = exports.JLP = exports.JTO = exports.WIF = exports.BONK = exports.JUP = exports.INF = exports.M_SOL = exports.LST = exports.JITO_SOL = exports.B_SOL = void 0;
|
4
4
|
const spl_token_1 = require("@solana/spl-token");
|
5
5
|
const web3_js_1 = require("@solana/web3.js");
|
6
6
|
// When adding token ensure a price feed is provided in pythConstants.ts & the token is in TOKEN_INFO
|
7
|
-
exports.USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
8
7
|
exports.B_SOL = "bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1";
|
8
|
+
exports.JITO_SOL = "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn";
|
9
|
+
exports.LST = "LSTxxxnJzKDFSLr4dUkPcmCf5VyryEqzPLz5j4bpxFp";
|
10
|
+
exports.M_SOL = "mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So";
|
11
|
+
exports.INF = "5oVNBeEEQvYi1cX3ir8Dx5n1P7pdxydbGF2X4TxVusJm";
|
9
12
|
exports.JUP = "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN";
|
13
|
+
exports.BONK = "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263";
|
14
|
+
exports.WIF = "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm";
|
15
|
+
exports.JTO = "jtojtomepa8beP8AuQc6eXt5FriJwfFMwQx2v2f9mCL";
|
16
|
+
exports.JLP = "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4";
|
17
|
+
exports.WBTC = "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh";
|
18
|
+
exports.WETH = "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs";
|
19
|
+
exports.HNT = "hntyVP6YFm1Hg25TN9WGLqM12b8TQmcknKrdu1oxWux";
|
20
|
+
exports.PYTH = "HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3";
|
21
|
+
exports.USDC = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
22
|
+
exports.USDT = "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB";
|
10
23
|
exports.ALL_SUPPORTED_TOKENS = [
|
11
24
|
spl_token_1.NATIVE_MINT.toString(),
|
12
|
-
exports.USDC_MINT,
|
13
25
|
exports.B_SOL,
|
26
|
+
exports.JITO_SOL,
|
27
|
+
exports.LST,
|
28
|
+
exports.M_SOL,
|
29
|
+
exports.INF,
|
14
30
|
exports.JUP,
|
31
|
+
exports.BONK,
|
32
|
+
exports.WIF,
|
33
|
+
exports.JTO,
|
34
|
+
exports.JLP,
|
35
|
+
exports.WBTC,
|
36
|
+
exports.WETH,
|
37
|
+
exports.HNT,
|
38
|
+
exports.PYTH,
|
39
|
+
exports.USDC,
|
40
|
+
exports.USDT,
|
15
41
|
];
|
16
42
|
exports.TOKEN_INFO = {
|
17
43
|
[web3_js_1.PublicKey.default.toString()]: {
|
18
44
|
ticker: "",
|
19
|
-
decimals: 1
|
45
|
+
decimals: 1,
|
20
46
|
},
|
21
47
|
[spl_token_1.NATIVE_MINT.toString()]: {
|
22
48
|
ticker: "SOL",
|
23
49
|
decimals: 9,
|
24
50
|
},
|
25
|
-
[exports.USDC_MINT]: {
|
26
|
-
ticker: "USDC",
|
27
|
-
decimals: 6,
|
28
|
-
isStableCoin: true
|
29
|
-
},
|
30
51
|
[exports.B_SOL]: {
|
31
|
-
ticker: "
|
52
|
+
ticker: "bSOL",
|
53
|
+
decimals: 9,
|
54
|
+
isLST: true,
|
55
|
+
},
|
56
|
+
[exports.JITO_SOL]: {
|
57
|
+
ticker: "JitoSOL",
|
58
|
+
decimals: 9,
|
59
|
+
isLST: true,
|
60
|
+
},
|
61
|
+
[exports.LST]: {
|
62
|
+
ticker: "LST",
|
32
63
|
decimals: 9,
|
33
|
-
isLST: true
|
64
|
+
isLST: true,
|
65
|
+
},
|
66
|
+
[exports.M_SOL]: {
|
67
|
+
ticker: "mSOL",
|
68
|
+
decimals: 9,
|
69
|
+
isLST: true,
|
70
|
+
},
|
71
|
+
[exports.INF]: {
|
72
|
+
ticker: "INF",
|
73
|
+
decimals: 9,
|
74
|
+
isLST: true,
|
34
75
|
},
|
35
76
|
[exports.JUP]: {
|
36
77
|
ticker: "JUP",
|
78
|
+
decimals: 6,
|
79
|
+
},
|
80
|
+
[exports.BONK]: {
|
81
|
+
ticker: "BONK",
|
82
|
+
decimals: 5,
|
83
|
+
},
|
84
|
+
[exports.WIF]: {
|
85
|
+
ticker: "WIF",
|
37
86
|
decimals: 6
|
38
|
-
}
|
87
|
+
},
|
88
|
+
[exports.JTO]: {
|
89
|
+
ticker: "JTO",
|
90
|
+
decimals: 9,
|
91
|
+
},
|
92
|
+
[exports.JLP]: {
|
93
|
+
ticker: "JLP",
|
94
|
+
decimals: 6,
|
95
|
+
},
|
96
|
+
[exports.WBTC]: {
|
97
|
+
ticker: "WBTC",
|
98
|
+
decimals: 8,
|
99
|
+
},
|
100
|
+
[exports.WETH]: {
|
101
|
+
ticker: "WETH",
|
102
|
+
decimals: 8
|
103
|
+
},
|
104
|
+
[exports.HNT]: {
|
105
|
+
ticker: "HNT",
|
106
|
+
decimals: 8
|
107
|
+
},
|
108
|
+
[exports.PYTH]: {
|
109
|
+
ticker: "PYTH",
|
110
|
+
decimals: 6
|
111
|
+
},
|
112
|
+
[exports.USDC]: {
|
113
|
+
ticker: "USDC",
|
114
|
+
decimals: 6,
|
115
|
+
isStableCoin: true,
|
116
|
+
},
|
117
|
+
[exports.USDT]: {
|
118
|
+
ticker: "USDT",
|
119
|
+
decimals: 6,
|
120
|
+
isStableCoin: true,
|
121
|
+
},
|
39
122
|
};
|
@@ -5,6 +5,7 @@ import { MarginfiAssetAccounts } from "../types/accounts";
|
|
5
5
|
import { PositionState } from "../generated";
|
6
6
|
import { LivePositionUpdates } from "./solauto/generalUtils";
|
7
7
|
export declare function findMarginfiAccounts(bank: PublicKey): MarginfiAssetAccounts;
|
8
|
+
export declare function marginfiMaxLtvAndLiqThresholdBps(supplyBank: Bank, debtBank: Bank, supplyPrice: number): [number, number];
|
8
9
|
export declare function getMaxLtvAndLiqThreshold(umi: Umi, marginfiGroup: PublicKey, supply: {
|
9
10
|
mint: PublicKey;
|
10
11
|
bank?: Bank | null;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"marginfiUtils.d.ts","sourceRoot":"","sources":["../../src/utils/marginfiUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EACL,IAAI,EAKL,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"marginfiUtils.d.ts","sourceRoot":"","sources":["../../src/utils/marginfiUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EACL,IAAI,EAKL,MAAM,iBAAiB,CAAC;AAiBzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAsB,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,GAAG,qBAAqB,CAY3E;AAED,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,IAAI,EAChB,QAAQ,EAAE,IAAI,EACd,WAAW,EAAE,MAAM,GAClB,CAAC,MAAM,EAAE,MAAM,CAAC,CA6BlB;AAED,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,SAAS,EACxB,MAAM,EAAE;IACN,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB,EACD,IAAI,EAAE;IACJ,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB,EACD,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAwC3B;AAED,wBAAsB,iCAAiC,CACrD,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,qBAAqB,CAAC,EAAE,OAAO,GAC9B,OAAO,CACR;IAAE,eAAe,EAAE,SAAS,CAAC;IAAC,UAAU,CAAC,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,EAAE,CAC/E,CAwDA;AAgED,wBAAsB,+BAA+B,CACnD,GAAG,EAAE,GAAG,EACR,iBAAiB,EAAE,SAAS,EAC5B,aAAa,CAAC,EAAE,SAAS,EACzB,UAAU,CAAC,EAAE,SAAS,EACtB,QAAQ,CAAC,EAAE,SAAS,EACpB,mBAAmB,CAAC,EAAE,mBAAmB,GACxC,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAmLpC;AA+DD,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAyB3B"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.findMarginfiAccounts = findMarginfiAccounts;
|
4
|
+
exports.marginfiMaxLtvAndLiqThresholdBps = marginfiMaxLtvAndLiqThresholdBps;
|
4
5
|
exports.getMaxLtvAndLiqThreshold = getMaxLtvAndLiqThreshold;
|
5
6
|
exports.getAllMarginfiAccountsByAuthority = getAllMarginfiAccountsByAuthority;
|
6
7
|
exports.getMarginfiAccountPositionState = getMarginfiAccountPositionState;
|
@@ -25,6 +26,21 @@ function findMarginfiAccounts(bank) {
|
|
25
26
|
}
|
26
27
|
throw new Error(`Marginfi accounts not found by the bank: ${bank}`);
|
27
28
|
}
|
29
|
+
function marginfiMaxLtvAndLiqThresholdBps(supplyBank, debtBank, supplyPrice) {
|
30
|
+
let maxLtv = (0, numberUtils_1.bytesToI80F48)(supplyBank.config.assetWeightInit.value) /
|
31
|
+
(0, numberUtils_1.bytesToI80F48)(debtBank.config.liabilityWeightInit.value);
|
32
|
+
const liqThreshold = (0, numberUtils_1.bytesToI80F48)(supplyBank.config.assetWeightMaint.value) /
|
33
|
+
(0, numberUtils_1.bytesToI80F48)(debtBank.config.liabilityWeightMaint.value);
|
34
|
+
const totalDepositedUsdValue = (0, numberUtils_1.fromBaseUnit)(BigInt(Math.round((0, numberUtils_1.bytesToI80F48)(supplyBank.totalAssetShares.value) *
|
35
|
+
(0, numberUtils_1.bytesToI80F48)(supplyBank.assetShareValue.value))), supplyBank.mintDecimals) * supplyPrice;
|
36
|
+
if (supplyBank.config.totalAssetValueInitLimit !== BigInt(0) &&
|
37
|
+
totalDepositedUsdValue > supplyBank.config.totalAssetValueInitLimit) {
|
38
|
+
const discount = Number(supplyBank.config.totalAssetValueInitLimit) /
|
39
|
+
totalDepositedUsdValue;
|
40
|
+
maxLtv = Math.round(maxLtv * Number(discount));
|
41
|
+
}
|
42
|
+
return [maxLtv, liqThreshold];
|
43
|
+
}
|
28
44
|
async function getMaxLtvAndLiqThreshold(umi, marginfiGroup, supply, debt, supplyPrice) {
|
29
45
|
if (!supply.bank && supply.mint.equals(web3_js_1.PublicKey.default)) {
|
30
46
|
return [0, 0];
|
@@ -45,19 +61,7 @@ async function getMaxLtvAndLiqThreshold(umi, marginfiGroup, supply, debt, supply
|
|
45
61
|
if (!debt.bank || debt.bank === null) {
|
46
62
|
return [0, 0];
|
47
63
|
}
|
48
|
-
|
49
|
-
(0, numberUtils_1.bytesToI80F48)(debt.bank.config.liabilityWeightInit.value);
|
50
|
-
const liqThreshold = (0, numberUtils_1.bytesToI80F48)(supply.bank.config.assetWeightMaint.value) /
|
51
|
-
(0, numberUtils_1.bytesToI80F48)(debt.bank.config.liabilityWeightMaint.value);
|
52
|
-
const totalDepositedUsdValue = (0, numberUtils_1.fromBaseUnit)(BigInt(Math.round((0, numberUtils_1.bytesToI80F48)(supply.bank.totalAssetShares.value) *
|
53
|
-
(0, numberUtils_1.bytesToI80F48)(supply.bank.assetShareValue.value))), supply.bank.mintDecimals) * supplyPrice;
|
54
|
-
if (supply.bank.config.totalAssetValueInitLimit !== BigInt(0) &&
|
55
|
-
totalDepositedUsdValue > supply.bank.config.totalAssetValueInitLimit) {
|
56
|
-
const discount = Number(supply.bank.config.totalAssetValueInitLimit) /
|
57
|
-
totalDepositedUsdValue;
|
58
|
-
maxLtv = Math.round(maxLtv * Number(discount));
|
59
|
-
}
|
60
|
-
return [maxLtv, liqThreshold];
|
64
|
+
return marginfiMaxLtvAndLiqThresholdBps(supply.bank, debt.bank, supplyPrice);
|
61
65
|
}
|
62
66
|
async function getAllMarginfiAccountsByAuthority(umi, authority, compatibleWithSolauto) {
|
63
67
|
const marginfiAccounts = await umi.rpc.getProgramAccounts(marginfi_sdk_1.MARGINFI_PROGRAM_ID, {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@haven-fi/solauto-sdk",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.202",
|
4
4
|
"main": "dist/index.js",
|
5
5
|
"types": "dist/index.d.ts",
|
6
6
|
"description": "Typescript SDK for the Solauto program on the Solana blockchain",
|
@@ -23,7 +23,6 @@
|
|
23
23
|
"@solana/spl-token": "^0.4.0",
|
24
24
|
"@solana/web3.js": "^1.92.1",
|
25
25
|
"@sqds/multisig": "^2.1.3",
|
26
|
-
"@types/node": "^20.14.8",
|
27
26
|
"bs58": "^5.0.0",
|
28
27
|
"cross-fetch": "^4.0.0",
|
29
28
|
"rpc-websockets": "7.11.0"
|
@@ -31,6 +30,7 @@
|
|
31
30
|
"devDependencies": {
|
32
31
|
"@types/chai": "^4.3.0",
|
33
32
|
"@types/mocha": "^9.1.1",
|
33
|
+
"@types/node": "^20.16.11",
|
34
34
|
"chai": "^4.3.4",
|
35
35
|
"mocha": "^9.2.2",
|
36
36
|
"ts-mocha": "^10.0.0",
|
@@ -1,39 +1,121 @@
|
|
1
1
|
import { NATIVE_MINT } from "@solana/spl-token";
|
2
|
-
import
|
2
|
+
import * as tokens from "./tokenConstants";
|
3
3
|
import { MarginfiAssetAccounts } from "../types/accounts";
|
4
4
|
import { PublicKey } from "@solana/web3.js";
|
5
5
|
|
6
|
-
export const DEFAULT_MARGINFI_GROUP =
|
6
|
+
export const DEFAULT_MARGINFI_GROUP =
|
7
|
+
"4qp6Fx6tnZkY5Wropq9wUYgtFxXKwE6viZxFHg3rdAG8";
|
7
8
|
|
8
9
|
export const DEFAULT_PUBKEY = PublicKey.default.toString();
|
9
10
|
|
10
|
-
export const MARGINFI_ACCOUNTS: {
|
11
|
+
export const MARGINFI_ACCOUNTS: {
|
12
|
+
[group: string]: { [token: string]: MarginfiAssetAccounts };
|
13
|
+
} = {
|
11
14
|
[DEFAULT_MARGINFI_GROUP.toString()]: {
|
12
15
|
[NATIVE_MINT.toString()]: {
|
13
16
|
bank: "CCKtUs6Cgwo4aaQUmBPmyoApH2gUDErxNZCAntD6LYGh",
|
14
17
|
liquidityVault: "2eicbpitfJXDwqCuFAmPgDP7t2oUotnAzbGzRKLMgSLe",
|
15
18
|
vaultAuthority: "DD3AeAssFvjqTvRTrRAtpfjkBF8FpVKnFuwnMLN9haXD",
|
16
|
-
priceOracle: "7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE"
|
19
|
+
priceOracle: "7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE",
|
17
20
|
},
|
18
|
-
[
|
19
|
-
bank: "2s37akK2eyBbp8DZgCm7RtsaEz8eJP3Nxd4urLHQv7yB",
|
20
|
-
liquidityVault: "7jaiZR5Sk8hdYN9MxTpczTcwbWpb5WEoxSANuUwveuat",
|
21
|
-
vaultAuthority: "3uxNepDbmkDNq6JhRja5Z8QwbTrfmkKP8AKZV5chYDGG",
|
22
|
-
priceOracle: "Dpw1EAVrSB1ibxiDQyTAW6Zip3J4Btk2x4SgApQCeFbX"
|
23
|
-
},
|
24
|
-
[B_SOL]: {
|
21
|
+
[tokens.B_SOL]: {
|
25
22
|
bank: "6hS9i46WyTq1KXcoa2Chas2Txh9TJAVr6n1t3tnrE23K",
|
26
23
|
liquidityVault: "2WMipeKDB2CENxbzdmnVrRbsxCA2LY6kCtBe6AAqDP9p",
|
27
24
|
vaultAuthority: "8RcZHucpVHkHWRRdMhJZsxBK9mqKSYnMKGqtF84U8YEo",
|
28
25
|
priceOracle: "5cN76Xm2Dtx9MnrQqBDeZZRsWruTTcw37UruznAdSvvE",
|
29
26
|
},
|
30
|
-
[
|
27
|
+
[tokens.JITO_SOL]: {
|
28
|
+
bank: "Bohoc1ikHLD7xKJuzTyiTyCwzaL5N7ggJQu75A8mKYM8",
|
29
|
+
liquidityVault: "38VGtXd2pDPq9FMh1z6AVjcHCoHgvWyMhdNyamDTeeks",
|
30
|
+
vaultAuthority: "7Ng54qf7BrCcZLqXmKA9WSR7SVRn4q6RX1YpLksBQ21A",
|
31
|
+
priceOracle: "AxaxyeDT8JnWERSaTKvFXvPKkEdxnamKSqpWbsSjYg1g",
|
32
|
+
},
|
33
|
+
[tokens.LST]: {
|
34
|
+
bank: "DMoqjmsuoru986HgfjqrKEvPv8YBufvBGADHUonkadC5",
|
35
|
+
liquidityVault: "DMQUXpb6K5L8osgV4x3NeEPUoJCf2VBgnA8FQusDjSou",
|
36
|
+
vaultAuthority: "6PWVauGLhBFHUJspsnBVZHr56ZnbvmhSD2gS7czBHGpE",
|
37
|
+
priceOracle: "7aT9A5knp62jVvnEW33xaWopaPHa3Y7ggULyYiUsDhu8",
|
38
|
+
},
|
39
|
+
[tokens.M_SOL]: {
|
40
|
+
bank: "22DcjMZrMwC5Bpa5AGBsmjc5V9VuQrXG6N9ZtdUNyYGE",
|
41
|
+
liquidityVault: "B6HqNn83a2bLqo4i5ygjLHJgD11ePtQksUyx4MjD55DV",
|
42
|
+
vaultAuthority: "6YxGd65JbXzgFGWjE44jsyVeCnZp7Bb1wfL9jDia1n8w",
|
43
|
+
priceOracle: "5CKzb9j4ChgLUt8Gfm5CNGLN6khXKiqMbnGAW4cgXgxK",
|
44
|
+
},
|
45
|
+
[tokens.INF]: {
|
46
|
+
bank: "AwLRW3aPMMftXEjgWhTkYwM9CGBHdtKecvahCJZBwAqY",
|
47
|
+
liquidityVault: "HQ1CGcqRshMhuonTGTnnmgw9ffcXxizGdZ6F6PKffWWi",
|
48
|
+
vaultAuthority: "AEZb1XH5bfLwqk3hBKDuLfWyJKdLTgDPCkgn64BJKcvV",
|
49
|
+
priceOracle: "DCNeMcAZGU7pAsqu5q2xMKerq35BnUuTkagt1dkR1xB",
|
50
|
+
},
|
51
|
+
[tokens.JUP]: {
|
31
52
|
bank: "Guu5uBc8k1WK1U2ihGosNaCy57LSgCkpWAabtzQqrQf8",
|
32
53
|
liquidityVault: "4w49W4fNDn778wsBa6TNq9hvebZKU17ymsptrEZ8zrsm",
|
33
54
|
vaultAuthority: "2MBwwAhL3c73Jy7HkWd9ofzh1bU39JBabrZCFQR2tUof",
|
34
55
|
priceOracle: "7dbob1psH1iZBS7qPsm3Kwbf5DzSXK8Jyg31CTgTnxH5",
|
35
|
-
}
|
36
|
-
|
56
|
+
},
|
57
|
+
[tokens.BONK]: {
|
58
|
+
bank: "DeyH7QxWvnbbaVB4zFrf4hoq7Q8z1ZT14co42BGwGtfM",
|
59
|
+
liquidityVault: "7FdQsXmCW3N5JQbknj3F9Yqq73er9VZJjGhEEMS8Ct2A",
|
60
|
+
vaultAuthority: "26kcZkdjJc94PdhqiLiEaGiLCYgAVVUfpDaZyK4cqih3",
|
61
|
+
priceOracle: "DBE3N8uNjhKPRHfANdwGvCZghWXyLPdqdSbEW2XFwBiX",
|
62
|
+
},
|
63
|
+
[tokens.WIF]: {
|
64
|
+
bank: "9dpu8KL5ABYiD3WP2Cnajzg1XaotcJvZspv29Y1Y3tn1",
|
65
|
+
liquidityVault: "4kT3EXc5dDVndUU9mV6EH3Jh3CSEvpcCZjuMkwqrtxUy",
|
66
|
+
vaultAuthority: "9gNrvvZ9RuTyRWooiEEypwcXU6kyXW8yWuhXU8tWUH5L",
|
67
|
+
priceOracle: "6B23K3tkb51vLZA14jcEQVCA1pfHptzEHFA93V5dYwbT",
|
68
|
+
},
|
69
|
+
[tokens.JTO]: {
|
70
|
+
bank: "EdB7YADw4XUt6wErT8kHGCUok4mnTpWGzPUU9rWDebzb",
|
71
|
+
liquidityVault: "3bY1DEkXodGmPMG5f7ABA12228MBG5JdAAKf5cgkB6G1",
|
72
|
+
vaultAuthority: "H2b4f2fGSKFortxwzrMZBnYVfr2yrKVUakg4Md9be3Wv",
|
73
|
+
priceOracle: "7ajR2zA4MGMMTqRAVjghTKqPPn4kbrj3pYkAVRVwTGzP",
|
74
|
+
},
|
75
|
+
[tokens.JLP]: {
|
76
|
+
bank: "Amtw3n7GZe5SWmyhMhaFhDTi39zbTkLeWErBsmZXwpDa",
|
77
|
+
liquidityVault: "9xfyL8gxbV77VvhdgFmacHyLEG4h7d2eDWkSMfhXUPQ",
|
78
|
+
vaultAuthority: "F4RSGd4BRXscCqAVG3rFLiPVpo7v6j1drVqnvSM3rBKH",
|
79
|
+
priceOracle: "B1wxT1VK3i6DqCeXNdTHT5hBAJkLa3rxuTqBc7E7XRXV",
|
80
|
+
},
|
81
|
+
[tokens.WBTC]: {
|
82
|
+
bank: "BKsfDJCMbYep6gr9pq8PsmJbb5XGLHbAJzUV8vmorz7a",
|
83
|
+
liquidityVault: "CMNdnjfaDQZo3VMoX31wZQBnSGu5FMmb1CnBaU4tApZk",
|
84
|
+
vaultAuthority: "7P2TQHYgVJkXv1VPaREsL5Pi1gnNjVif5aF3pJewZ9kj",
|
85
|
+
priceOracle: "4cSM2e6rvbGQUFiJbqytoVMi5GgghSMr8LwVrT9VPSPo",
|
86
|
+
},
|
87
|
+
[tokens.WETH]: {
|
88
|
+
bank: "BkUyfXjbBBALcfZvw76WAFRvYQ21xxMWWeoPtJrUqG3z",
|
89
|
+
liquidityVault: "AxPJtiTEDksJWvCqNHCziK4uUcabqfmwW41dqtZrPFkp",
|
90
|
+
vaultAuthority: "ELXogWuyXrFyUG1vevffVbEhVxdFrHf2GCJTtRGKBWdM",
|
91
|
+
priceOracle: "42amVS4KgzR9rA28tkVYqVXjq9Qa8dcZQMbH5EYFX6XC",
|
92
|
+
},
|
93
|
+
[tokens.HNT]: {
|
94
|
+
bank: "JBcir4DPRPYVUpks9hkS1jtHMXejfeBo4xJGv3AYYHg6",
|
95
|
+
liquidityVault: "E8Q7u5e9L9Uykx16em75ERT9wfbBPtkNL8gsRjoP8GB9",
|
96
|
+
vaultAuthority: "AjsyrYpgaH275DBSnvNWdGK33hVycSFuXN87FKnX6fVY",
|
97
|
+
priceOracle: "4DdmDswskDxXGpwHrXUfn2CNUm9rt21ac79GHNTN3J33",
|
98
|
+
},
|
99
|
+
[tokens.PYTH]: {
|
100
|
+
bank: "E4td8i8PT2BZkMygzW4MGHCv2KPPs57dvz5W2ZXf9Twu",
|
101
|
+
liquidityVault: "DUrAkkaMAckzes7so9T5frXm9YFFgjAAm3MMwHwTfVJq",
|
102
|
+
vaultAuthority: "9b5KdVnbbfEQ2qhLeFjWvcAx2VWe9XHx7ZgayZyL9a6C",
|
103
|
+
priceOracle: "8vjchtMuJNY4oFQdTi8yCe6mhCaNBFaUbktT482TpLPS",
|
104
|
+
},
|
105
|
+
[tokens.USDC]: {
|
106
|
+
bank: "2s37akK2eyBbp8DZgCm7RtsaEz8eJP3Nxd4urLHQv7yB",
|
107
|
+
liquidityVault: "7jaiZR5Sk8hdYN9MxTpczTcwbWpb5WEoxSANuUwveuat",
|
108
|
+
vaultAuthority: "3uxNepDbmkDNq6JhRja5Z8QwbTrfmkKP8AKZV5chYDGG",
|
109
|
+
priceOracle: "Dpw1EAVrSB1ibxiDQyTAW6Zip3J4Btk2x4SgApQCeFbX",
|
110
|
+
},
|
111
|
+
[tokens.USDT]: {
|
112
|
+
bank: "HmpMfL8942u22htC4EMiWgLX931g3sacXFR6KjuLgKLV",
|
113
|
+
liquidityVault: "77t6Fi9qj4s4z22K1toufHtstM8rEy7Y3ytxik7mcsTy",
|
114
|
+
vaultAuthority: "9r6z6KgkEytHCdQWNxvDQH98PsfU98f1m5PCg47mY2XE",
|
115
|
+
priceOracle: "HT2PLQBcG5EiCcNSaMHAjSgd9F98ecpATbk4Sk5oYuM",
|
116
|
+
},
|
117
|
+
},
|
37
118
|
};
|
38
119
|
|
39
|
-
export const MARGINFI_ACCOUNTS_LOOKUP_TABLE =
|
120
|
+
export const MARGINFI_ACCOUNTS_LOOKUP_TABLE =
|
121
|
+
"GAjmWmBPcH5Gxbiykasydj6RsCEaCLyHEvK6kHdFigc6";
|
@@ -1,12 +1,40 @@
|
|
1
1
|
import { NATIVE_MINT } from "@solana/spl-token";
|
2
|
-
import
|
2
|
+
import * as tokens from "./tokenConstants";
|
3
3
|
|
4
4
|
// https://pyth.network/developers/price-feed-ids#solana-stable
|
5
5
|
export const PYTH_PRICE_FEED_IDS = {
|
6
6
|
[NATIVE_MINT.toString()]:
|
7
7
|
"0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
|
8
|
-
[
|
8
|
+
[tokens.B_SOL]:
|
9
|
+
"0x89875379e70f8fbadc17aef315adf3a8d5d160b811435537e03c97e8aac97d9c",
|
10
|
+
[tokens.JITO_SOL]:
|
11
|
+
"0x67be9f519b95cf24338801051f9a808eff0a578ccb388db73b7f6fe1de019ffb",
|
12
|
+
[tokens.LST]:
|
13
|
+
"0x12fb674ee496045b1d9cf7d5e65379acb026133c2ad69f3ed996fb9fe68e3a37",
|
14
|
+
[tokens.M_SOL]:
|
15
|
+
"0xc2289a6a43d2ce91c6f55caec370f4acc38a2ed477f58813334c6d03749ff2a4",
|
16
|
+
[tokens.INF]:
|
17
|
+
"0xf51570985c642c49c2d6e50156390fdba80bb6d5f7fa389d2f012ced4f7d208f",
|
18
|
+
[tokens.JUP]:
|
19
|
+
"0x0a0408d619e9380abad35060f9192039ed5042fa6f82301d0e48bb52be830996",
|
20
|
+
[tokens.BONK]:
|
21
|
+
"0x72b021217ca3fe68922a19aaf990109cb9d84e9ad004b4d2025ad6f529314419",
|
22
|
+
[tokens.WIF]:
|
23
|
+
"0x4ca4beeca86f0d164160323817a4e42b10010a724c2217c6ee41b54cd4cc61fc",
|
24
|
+
[tokens.JTO]:
|
25
|
+
"0xb43660a5f790c69354b0729a5ef9d50d68f1df92107540210b9cccba1f947cc2",
|
26
|
+
[tokens.JLP]:
|
27
|
+
"0xc811abc82b4bad1f9bd711a2773ccaa935b03ecef974236942cec5e0eb845a3a",
|
28
|
+
[tokens.WBTC]:
|
29
|
+
"0xc9d8b075a5c69303365ae23633d4e085199bf5c520a3b90fed1322a0342ffc33",
|
30
|
+
[tokens.WETH]:
|
31
|
+
"0x9d4294bbcd1174d6f2003ec365831e64cc31d9f6f15a2b85399db8d5000960f6",
|
32
|
+
[tokens.HNT]:
|
33
|
+
"0x649fdd7ec08e8e2a20f425729854e90293dcbe2376abc47197a14da6ff339756",
|
34
|
+
[tokens.PYTH]:
|
35
|
+
"0x0bbf28e9a841a1cc788f6a361b17ca072d0ea3098a1e5df1c3922d06719579ff",
|
36
|
+
[tokens.USDC]:
|
9
37
|
"0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
10
|
-
[
|
11
|
-
|
38
|
+
[tokens.USDT]:
|
39
|
+
"0x2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b",
|
12
40
|
};
|
@@ -2,46 +2,128 @@ import { NATIVE_MINT } from "@solana/spl-token";
|
|
2
2
|
import { PublicKey } from "@solana/web3.js";
|
3
3
|
|
4
4
|
// When adding token ensure a price feed is provided in pythConstants.ts & the token is in TOKEN_INFO
|
5
|
-
export const USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
6
5
|
export const B_SOL = "bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1";
|
6
|
+
export const JITO_SOL = "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn";
|
7
|
+
export const LST = "LSTxxxnJzKDFSLr4dUkPcmCf5VyryEqzPLz5j4bpxFp";
|
8
|
+
export const M_SOL = "mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So";
|
9
|
+
export const INF = "5oVNBeEEQvYi1cX3ir8Dx5n1P7pdxydbGF2X4TxVusJm";
|
7
10
|
export const JUP = "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN";
|
8
|
-
|
11
|
+
export const BONK = "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263";
|
12
|
+
export const WIF = "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm";
|
13
|
+
export const JTO = "jtojtomepa8beP8AuQc6eXt5FriJwfFMwQx2v2f9mCL";
|
14
|
+
export const JLP = "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4";
|
15
|
+
export const WBTC = "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh";
|
16
|
+
export const WETH = "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs";
|
17
|
+
export const HNT = "hntyVP6YFm1Hg25TN9WGLqM12b8TQmcknKrdu1oxWux";
|
18
|
+
export const PYTH = "HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3";
|
19
|
+
export const USDC = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
20
|
+
export const USDT = "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB";
|
9
21
|
|
10
22
|
export const ALL_SUPPORTED_TOKENS = [
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
23
|
+
NATIVE_MINT.toString(),
|
24
|
+
B_SOL,
|
25
|
+
JITO_SOL,
|
26
|
+
LST,
|
27
|
+
M_SOL,
|
28
|
+
INF,
|
29
|
+
JUP,
|
30
|
+
BONK,
|
31
|
+
WIF,
|
32
|
+
JTO,
|
33
|
+
JLP,
|
34
|
+
WBTC,
|
35
|
+
WETH,
|
36
|
+
HNT,
|
37
|
+
PYTH,
|
38
|
+
USDC,
|
39
|
+
USDT,
|
15
40
|
];
|
16
41
|
|
17
42
|
interface TokenInfo {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
43
|
+
ticker: string;
|
44
|
+
decimals: number;
|
45
|
+
isStableCoin?: boolean;
|
46
|
+
isLST?: boolean;
|
22
47
|
}
|
23
48
|
|
24
49
|
export const TOKEN_INFO: { [key: string]: TokenInfo } = {
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
}
|
50
|
+
[PublicKey.default.toString()]: {
|
51
|
+
ticker: "",
|
52
|
+
decimals: 1,
|
53
|
+
},
|
54
|
+
[NATIVE_MINT.toString()]: {
|
55
|
+
ticker: "SOL",
|
56
|
+
decimals: 9,
|
57
|
+
},
|
58
|
+
[B_SOL]: {
|
59
|
+
ticker: "bSOL",
|
60
|
+
decimals: 9,
|
61
|
+
isLST: true,
|
62
|
+
},
|
63
|
+
[JITO_SOL]: {
|
64
|
+
ticker: "JitoSOL",
|
65
|
+
decimals: 9,
|
66
|
+
isLST: true,
|
67
|
+
},
|
68
|
+
[LST]: {
|
69
|
+
ticker: "LST",
|
70
|
+
decimals: 9,
|
71
|
+
isLST: true,
|
72
|
+
},
|
73
|
+
[M_SOL]: {
|
74
|
+
ticker: "mSOL",
|
75
|
+
decimals: 9,
|
76
|
+
isLST: true,
|
77
|
+
},
|
78
|
+
[INF]: {
|
79
|
+
ticker: "INF",
|
80
|
+
decimals: 9,
|
81
|
+
isLST: true,
|
82
|
+
},
|
83
|
+
[JUP]: {
|
84
|
+
ticker: "JUP",
|
85
|
+
decimals: 6,
|
86
|
+
},
|
87
|
+
[BONK]: {
|
88
|
+
ticker: "BONK",
|
89
|
+
decimals: 5,
|
90
|
+
},
|
91
|
+
[WIF]: {
|
92
|
+
ticker: "WIF",
|
93
|
+
decimals: 6
|
94
|
+
},
|
95
|
+
[JTO]: {
|
96
|
+
ticker: "JTO",
|
97
|
+
decimals: 9,
|
98
|
+
},
|
99
|
+
[JLP]: {
|
100
|
+
ticker: "JLP",
|
101
|
+
decimals: 6,
|
102
|
+
},
|
103
|
+
[WBTC]: {
|
104
|
+
ticker: "WBTC",
|
105
|
+
decimals: 8,
|
106
|
+
},
|
107
|
+
[WETH]: {
|
108
|
+
ticker: "WETH",
|
109
|
+
decimals: 8
|
110
|
+
},
|
111
|
+
[HNT]: {
|
112
|
+
ticker: "HNT",
|
113
|
+
decimals: 8
|
114
|
+
},
|
115
|
+
[PYTH]: {
|
116
|
+
ticker: "PYTH",
|
117
|
+
decimals: 6
|
118
|
+
},
|
119
|
+
[USDC]: {
|
120
|
+
ticker: "USDC",
|
121
|
+
decimals: 6,
|
122
|
+
isStableCoin: true,
|
123
|
+
},
|
124
|
+
[USDT]: {
|
125
|
+
ticker: "USDT",
|
126
|
+
decimals: 6,
|
127
|
+
isStableCoin: true,
|
128
|
+
},
|
129
|
+
};
|
@@ -20,7 +20,10 @@ import {
|
|
20
20
|
toBaseUnit,
|
21
21
|
toBps,
|
22
22
|
} from "./numberUtils";
|
23
|
-
import {
|
23
|
+
import {
|
24
|
+
DEFAULT_MARGINFI_GROUP,
|
25
|
+
MARGINFI_ACCOUNTS,
|
26
|
+
} from "../constants/marginfiAccounts";
|
24
27
|
import { MarginfiAssetAccounts } from "../types/accounts";
|
25
28
|
import { PositionState, PositionTokenUsage } from "../generated";
|
26
29
|
import { USD_DECIMALS } from "../constants/generalAccounts";
|
@@ -41,6 +44,41 @@ export function findMarginfiAccounts(bank: PublicKey): MarginfiAssetAccounts {
|
|
41
44
|
throw new Error(`Marginfi accounts not found by the bank: ${bank}`);
|
42
45
|
}
|
43
46
|
|
47
|
+
export function marginfiMaxLtvAndLiqThresholdBps(
|
48
|
+
supplyBank: Bank,
|
49
|
+
debtBank: Bank,
|
50
|
+
supplyPrice: number
|
51
|
+
): [number, number] {
|
52
|
+
let maxLtv =
|
53
|
+
bytesToI80F48(supplyBank.config.assetWeightInit.value) /
|
54
|
+
bytesToI80F48(debtBank.config.liabilityWeightInit.value);
|
55
|
+
const liqThreshold =
|
56
|
+
bytesToI80F48(supplyBank.config.assetWeightMaint.value) /
|
57
|
+
bytesToI80F48(debtBank.config.liabilityWeightMaint.value);
|
58
|
+
|
59
|
+
const totalDepositedUsdValue =
|
60
|
+
fromBaseUnit(
|
61
|
+
BigInt(
|
62
|
+
Math.round(
|
63
|
+
bytesToI80F48(supplyBank.totalAssetShares.value) *
|
64
|
+
bytesToI80F48(supplyBank.assetShareValue.value)
|
65
|
+
)
|
66
|
+
),
|
67
|
+
supplyBank.mintDecimals
|
68
|
+
) * supplyPrice!;
|
69
|
+
if (
|
70
|
+
supplyBank.config.totalAssetValueInitLimit !== BigInt(0) &&
|
71
|
+
totalDepositedUsdValue > supplyBank.config.totalAssetValueInitLimit
|
72
|
+
) {
|
73
|
+
const discount =
|
74
|
+
Number(supplyBank.config.totalAssetValueInitLimit) /
|
75
|
+
totalDepositedUsdValue;
|
76
|
+
maxLtv = Math.round(maxLtv * Number(discount));
|
77
|
+
}
|
78
|
+
|
79
|
+
return [maxLtv, liqThreshold];
|
80
|
+
}
|
81
|
+
|
44
82
|
export async function getMaxLtvAndLiqThreshold(
|
45
83
|
umi: Umi,
|
46
84
|
marginfiGroup: PublicKey,
|
@@ -61,7 +99,9 @@ export async function getMaxLtvAndLiqThreshold(
|
|
61
99
|
if (!supply.bank || supply.bank === null) {
|
62
100
|
supply.bank = await safeFetchBank(
|
63
101
|
umi,
|
64
|
-
publicKey(
|
102
|
+
publicKey(
|
103
|
+
MARGINFI_ACCOUNTS[marginfiGroup.toString()][supply.mint.toString()].bank
|
104
|
+
),
|
65
105
|
{ commitment: "confirmed" }
|
66
106
|
);
|
67
107
|
}
|
@@ -72,7 +112,9 @@ export async function getMaxLtvAndLiqThreshold(
|
|
72
112
|
) {
|
73
113
|
debt.bank = await safeFetchBank(
|
74
114
|
umi,
|
75
|
-
publicKey(
|
115
|
+
publicKey(
|
116
|
+
MARGINFI_ACCOUNTS[marginfiGroup.toString()][debt.mint.toString()].bank
|
117
|
+
),
|
76
118
|
{ commitment: "confirmed" }
|
77
119
|
);
|
78
120
|
}
|
@@ -88,34 +130,7 @@ export async function getMaxLtvAndLiqThreshold(
|
|
88
130
|
return [0, 0];
|
89
131
|
}
|
90
132
|
|
91
|
-
|
92
|
-
bytesToI80F48(supply.bank!.config.assetWeightInit.value) /
|
93
|
-
bytesToI80F48(debt.bank.config.liabilityWeightInit.value);
|
94
|
-
const liqThreshold =
|
95
|
-
bytesToI80F48(supply.bank!.config.assetWeightMaint.value) /
|
96
|
-
bytesToI80F48(debt.bank.config.liabilityWeightMaint.value);
|
97
|
-
|
98
|
-
const totalDepositedUsdValue =
|
99
|
-
fromBaseUnit(
|
100
|
-
BigInt(
|
101
|
-
Math.round(
|
102
|
-
bytesToI80F48(supply.bank!.totalAssetShares.value) *
|
103
|
-
bytesToI80F48(supply.bank!.assetShareValue.value)
|
104
|
-
)
|
105
|
-
),
|
106
|
-
supply.bank!.mintDecimals
|
107
|
-
) * supplyPrice!;
|
108
|
-
if (
|
109
|
-
supply.bank!.config.totalAssetValueInitLimit !== BigInt(0) &&
|
110
|
-
totalDepositedUsdValue > supply.bank!.config.totalAssetValueInitLimit
|
111
|
-
) {
|
112
|
-
const discount =
|
113
|
-
Number(supply.bank!.config.totalAssetValueInitLimit) /
|
114
|
-
totalDepositedUsdValue;
|
115
|
-
maxLtv = Math.round(maxLtv * Number(discount));
|
116
|
-
}
|
117
|
-
|
118
|
-
return [maxLtv, liqThreshold];
|
133
|
+
return marginfiMaxLtvAndLiqThresholdBps(supply.bank!, debt.bank, supplyPrice);
|
119
134
|
}
|
120
135
|
|
121
136
|
export async function getAllMarginfiAccountsByAuthority(
|
@@ -266,7 +281,11 @@ export async function getMarginfiAccountPositionState(
|
|
266
281
|
supplyMint && supplyMint !== PublicKey.default
|
267
282
|
? await safeFetchBank(
|
268
283
|
umi,
|
269
|
-
publicKey(
|
284
|
+
publicKey(
|
285
|
+
MARGINFI_ACCOUNTS[marginfiGroup?.toString() ?? ""][
|
286
|
+
supplyMint.toString()
|
287
|
+
].bank
|
288
|
+
),
|
270
289
|
{ commitment: "confirmed" }
|
271
290
|
)
|
272
291
|
: null;
|
@@ -274,7 +293,11 @@ export async function getMarginfiAccountPositionState(
|
|
274
293
|
debtMint && debtMint !== PublicKey.default
|
275
294
|
? await safeFetchBank(
|
276
295
|
umi,
|
277
|
-
publicKey(
|
296
|
+
publicKey(
|
297
|
+
MARGINFI_ACCOUNTS[marginfiGroup?.toString() ?? ""][
|
298
|
+
debtMint.toString()
|
299
|
+
].bank
|
300
|
+
),
|
278
301
|
{ commitment: "confirmed" }
|
279
302
|
)
|
280
303
|
: null;
|
@@ -341,7 +364,11 @@ export async function getMarginfiAccountPositionState(
|
|
341
364
|
return undefined;
|
342
365
|
}
|
343
366
|
|
344
|
-
if (
|
367
|
+
if (
|
368
|
+
!toWeb3JsPublicKey(supplyBank.group).equals(
|
369
|
+
new PublicKey(DEFAULT_MARGINFI_GROUP)
|
370
|
+
)
|
371
|
+
) {
|
345
372
|
// Temporarily disabled for now
|
346
373
|
return undefined;
|
347
374
|
}
|
@@ -17,7 +17,7 @@ import {
|
|
17
17
|
TransactionsManager,
|
18
18
|
} from "../../src/transactions/transactionsManager";
|
19
19
|
import { PublicKey } from "@solana/web3.js";
|
20
|
-
import {
|
20
|
+
import { USDC } from "../../src/constants";
|
21
21
|
import { buildHeliusApiUrl, getMarginfiAccountPositionState } from "../../src/utils";
|
22
22
|
|
23
23
|
describe("Solauto Marginfi tests", async () => {
|
@@ -48,7 +48,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
48
48
|
// "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
|
49
49
|
// ),
|
50
50
|
// supplyMint: NATIVE_MINT,
|
51
|
-
// debtMint: new PublicKey(
|
51
|
+
// debtMint: new PublicKey(USDC),
|
52
52
|
}
|
53
53
|
);
|
54
54
|
|
@@ -35,7 +35,7 @@ import {
|
|
35
35
|
fetchTokenPrices,
|
36
36
|
safeGetPrice,
|
37
37
|
} from "../../src/utils/generalUtils";
|
38
|
-
import {
|
38
|
+
import { USDC } from "../../src/constants/tokenConstants";
|
39
39
|
|
40
40
|
const signer = setupTest(undefined, true);
|
41
41
|
|
@@ -115,7 +115,7 @@ async function getFakePosition(
|
|
115
115
|
positionId: 1,
|
116
116
|
signer,
|
117
117
|
supplyMint: new PublicKey(NATIVE_MINT),
|
118
|
-
debtMint: new PublicKey(
|
118
|
+
debtMint: new PublicKey(USDC),
|
119
119
|
});
|
120
120
|
|
121
121
|
const supplyUsd = 1000;
|
@@ -135,7 +135,7 @@ async function getFakePosition(
|
|
135
135
|
fromBps(fakeLiqUtilizationRateBps)) /
|
136
136
|
debtPrice,
|
137
137
|
price: 1,
|
138
|
-
mint: new PublicKey(
|
138
|
+
mint: new PublicKey(USDC),
|
139
139
|
},
|
140
140
|
maxLtvBps,
|
141
141
|
liqThresholdBps
|
@@ -284,7 +284,7 @@ describe("Rebalance tests", async () => {
|
|
284
284
|
before(async () => {
|
285
285
|
[supplyPrice, debtPrice] = await fetchTokenPrices([
|
286
286
|
NATIVE_MINT,
|
287
|
-
new PublicKey(
|
287
|
+
new PublicKey(USDC),
|
288
288
|
]);
|
289
289
|
});
|
290
290
|
|