@haven-fi/solauto-sdk 1.0.201 → 1.0.203
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 +2 -1
- package/dist/utils/marginfiUtils.d.ts.map +1 -1
- package/dist/utils/marginfiUtils.js +16 -12
- 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 +14 -19
- 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.M_SOL]: {
|
47
|
+
bank: "22DcjMZrMwC5Bpa5AGBsmjc5V9VuQrXG6N9ZtdUNyYGE",
|
48
|
+
liquidityVault: "B6HqNn83a2bLqo4i5ygjLHJgD11ePtQksUyx4MjD55DV",
|
49
|
+
vaultAuthority: "6YxGd65JbXzgFGWjE44jsyVeCnZp7Bb1wfL9jDia1n8w",
|
50
|
+
priceOracle: "5CKzb9j4ChgLUt8Gfm5CNGLN6khXKiqMbnGAW4cgXgxK",
|
51
|
+
},
|
52
|
+
[tokens.JITO_SOL]: {
|
53
|
+
bank: "Bohoc1ikHLD7xKJuzTyiTyCwzaL5N7ggJQu75A8mKYM8",
|
54
|
+
liquidityVault: "38VGtXd2pDPq9FMh1z6AVjcHCoHgvWyMhdNyamDTeeks",
|
55
|
+
vaultAuthority: "7Ng54qf7BrCcZLqXmKA9WSR7SVRn4q6RX1YpLksBQ21A",
|
56
|
+
priceOracle: "AxaxyeDT8JnWERSaTKvFXvPKkEdxnamKSqpWbsSjYg1g",
|
57
|
+
},
|
58
|
+
[tokens.LST]: {
|
59
|
+
bank: "DMoqjmsuoru986HgfjqrKEvPv8YBufvBGADHUonkadC5",
|
60
|
+
liquidityVault: "DMQUXpb6K5L8osgV4x3NeEPUoJCf2VBgnA8FQusDjSou",
|
61
|
+
vaultAuthority: "6PWVauGLhBFHUJspsnBVZHr56ZnbvmhSD2gS7czBHGpE",
|
62
|
+
priceOracle: "7aT9A5knp62jVvnEW33xaWopaPHa3Y7ggULyYiUsDhu8",
|
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
|
+
mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So: string;
|
5
|
+
J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn: string;
|
6
|
+
LSTxxxnJzKDFSLr4dUkPcmCf5VyryEqzPLz5j4bpxFp: 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.M_SOL]: "0xc2289a6a43d2ce91c6f55caec370f4acc38a2ed477f58813334c6d03749ff2a4",
|
34
|
+
[tokens.JITO_SOL]: "0x67be9f519b95cf24338801051f9a808eff0a578ccb388db73b7f6fe1de019ffb",
|
35
|
+
[tokens.LST]: "0x12fb674ee496045b1d9cf7d5e65379acb026133c2ad69f3ed996fb9fe68e3a37",
|
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.M_SOL,
|
27
|
+
exports.JITO_SOL,
|
28
|
+
exports.LST,
|
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.M_SOL]: {
|
57
|
+
ticker: "mSOL",
|
58
|
+
decimals: 9,
|
59
|
+
isLST: true,
|
60
|
+
},
|
61
|
+
[exports.JITO_SOL]: {
|
62
|
+
ticker: "JitoSOL",
|
32
63
|
decimals: 9,
|
33
|
-
isLST: true
|
64
|
+
isLST: true,
|
65
|
+
},
|
66
|
+
[exports.LST]: {
|
67
|
+
ticker: "LST",
|
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
|
};
|
@@ -19,5 +19,6 @@ export declare function getAllMarginfiAccountsByAuthority(umi: Umi, authority: P
|
|
19
19
|
debtMint?: PublicKey;
|
20
20
|
}[]>;
|
21
21
|
export declare function getMarginfiAccountPositionState(umi: Umi, marginfiAccountPk: PublicKey, marginfiGroup?: PublicKey, supplyMint?: PublicKey, debtMint?: PublicKey, livePositionUpdates?: LivePositionUpdates): Promise<PositionState | undefined>;
|
22
|
-
export declare function
|
22
|
+
export declare function calculateAnnualAPYs(bank: Bank): [number, number];
|
23
|
+
export declare function getUpToDateShareValues(bank: Bank): Promise<[number, number]>;
|
23
24
|
//# sourceMappingURL=marginfiUtils.d.ts.map
|
@@ -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;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;
|
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;AA6DD,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,CA+KpC;AA+DD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,oBAU7C;AAED,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAgB3B"}
|
@@ -5,6 +5,7 @@ exports.marginfiMaxLtvAndLiqThresholdBps = marginfiMaxLtvAndLiqThresholdBps;
|
|
5
5
|
exports.getMaxLtvAndLiqThreshold = getMaxLtvAndLiqThreshold;
|
6
6
|
exports.getAllMarginfiAccountsByAuthority = getAllMarginfiAccountsByAuthority;
|
7
7
|
exports.getMarginfiAccountPositionState = getMarginfiAccountPositionState;
|
8
|
+
exports.calculateAnnualAPYs = calculateAnnualAPYs;
|
8
9
|
exports.getUpToDateShareValues = getUpToDateShareValues;
|
9
10
|
const web3_js_1 = require("@solana/web3.js");
|
10
11
|
const umi_1 = require("@metaplex-foundation/umi");
|
@@ -103,13 +104,13 @@ async function getAllMarginfiAccountsByAuthority(umi, authority, compatibleWithS
|
|
103
104
|
}));
|
104
105
|
}
|
105
106
|
}
|
106
|
-
async function getTokenUsage(
|
107
|
+
async function getTokenUsage(bank, isAsset, shares, amountUsedAdjustment) {
|
107
108
|
let amountUsed = 0;
|
108
109
|
let amountCanBeUsed = 0;
|
109
110
|
let marketPrice = 0;
|
110
111
|
if (bank !== null) {
|
111
112
|
[marketPrice] = await (0, generalUtils_1.fetchTokenPrices)([(0, umi_web3js_adapters_1.toWeb3JsPublicKey)(bank.mint)]);
|
112
|
-
const [assetShareValue, liabilityShareValue] = await getUpToDateShareValues(
|
113
|
+
const [assetShareValue, liabilityShareValue] = await getUpToDateShareValues(bank);
|
113
114
|
const shareValue = isAsset ? assetShareValue : liabilityShareValue;
|
114
115
|
amountUsed = shares * shareValue + Number(amountUsedAdjustment ?? 0);
|
115
116
|
const totalDeposited = (0, numberUtils_1.bytesToI80F48)(bank.totalAssetShares.value) * assetShareValue;
|
@@ -172,7 +173,7 @@ async function getMarginfiAccountPositionState(umi, marginfiAccountPk, marginfiG
|
|
172
173
|
if (!supplyMint) {
|
173
174
|
supplyMint = (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(supplyBank.mint);
|
174
175
|
}
|
175
|
-
supplyUsage = await getTokenUsage(
|
176
|
+
supplyUsage = await getTokenUsage(supplyBank, true, (0, numberUtils_1.bytesToI80F48)(supplyBalances[0].assetShares.value), livePositionUpdates?.supplyAdjustment);
|
176
177
|
}
|
177
178
|
if (debtBalances.length > 0) {
|
178
179
|
if (debtBank === null) {
|
@@ -183,7 +184,7 @@ async function getMarginfiAccountPositionState(umi, marginfiAccountPk, marginfiG
|
|
183
184
|
if (!debtMint) {
|
184
185
|
debtMint = (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(debtBank.mint);
|
185
186
|
}
|
186
|
-
debtUsage = await getTokenUsage(
|
187
|
+
debtUsage = await getTokenUsage(debtBank, false, (0, numberUtils_1.bytesToI80F48)(debtBalances[0].liabilityShares.value), livePositionUpdates?.debtAdjustment);
|
187
188
|
}
|
188
189
|
}
|
189
190
|
if (supplyBank === null) {
|
@@ -194,14 +195,14 @@ async function getMarginfiAccountPositionState(umi, marginfiAccountPk, marginfiG
|
|
194
195
|
return undefined;
|
195
196
|
}
|
196
197
|
if (!supplyUsage) {
|
197
|
-
supplyUsage = await getTokenUsage(
|
198
|
+
supplyUsage = await getTokenUsage(supplyBank, true, 0, livePositionUpdates?.supplyAdjustment);
|
198
199
|
}
|
199
200
|
if (constants_1.TOKEN_INFO[supplyBank.mint.toString()].isStableCoin &&
|
200
201
|
(debtBank === null || constants_1.TOKEN_INFO[debtBank.mint.toString()].isStableCoin)) {
|
201
202
|
return undefined;
|
202
203
|
}
|
203
204
|
if (!debtUsage) {
|
204
|
-
debtUsage = await getTokenUsage(
|
205
|
+
debtUsage = await getTokenUsage(debtBank, false, 0, livePositionUpdates?.debtAdjustment);
|
205
206
|
}
|
206
207
|
const supplyPrice = (0, generalUtils_1.safeGetPrice)(supplyMint);
|
207
208
|
let [maxLtv, liqThreshold] = await getMaxLtvAndLiqThreshold(umi, marginfiGroup ?? new web3_js_1.PublicKey(marginfiAccounts_1.DEFAULT_MARGINFI_GROUP), {
|
@@ -234,10 +235,10 @@ function marginfiInterestRateCurve(bank, utilizationRatio) {
|
|
234
235
|
const plateauIr = (0, numberUtils_1.bytesToI80F48)(bank.config.interestRateConfig.plateauInterestRate.value);
|
235
236
|
const maxIr = (0, numberUtils_1.bytesToI80F48)(bank.config.interestRateConfig.maxInterestRate.value);
|
236
237
|
if (utilizationRatio <= optimalUr) {
|
237
|
-
return (utilizationRatio
|
238
|
+
return (utilizationRatio * plateauIr) / optimalUr;
|
238
239
|
}
|
239
240
|
else {
|
240
|
-
return (((utilizationRatio - optimalUr) / (1 - optimalUr)) * (maxIr - plateauIr) +
|
241
|
+
return ((((utilizationRatio - optimalUr) / (1 - optimalUr)) * (maxIr - plateauIr)) +
|
241
242
|
plateauIr);
|
242
243
|
}
|
243
244
|
}
|
@@ -250,7 +251,7 @@ function calcInterestRate(bank, utilizationRatio) {
|
|
250
251
|
const insuranceFixedFeeApr = (0, numberUtils_1.bytesToI80F48)(bank.config.interestRateConfig.insuranceFeeFixedApr.value);
|
251
252
|
const rateFee = protocolIrFee + insuranceIrFee;
|
252
253
|
const totalFixedFeeApr = protocolFixedFeeApr + insuranceFixedFeeApr;
|
253
|
-
const borrowingRate = baseRate * (1 + rateFee)
|
254
|
+
const borrowingRate = (baseRate * (1 + rateFee)) + totalFixedFeeApr;
|
254
255
|
return [lendingRate, borrowingRate];
|
255
256
|
}
|
256
257
|
function calcAccruedInterestPaymentPerPeriod(apr, timeDelta, shareValue) {
|
@@ -258,14 +259,17 @@ function calcAccruedInterestPaymentPerPeriod(apr, timeDelta, shareValue) {
|
|
258
259
|
const newValue = shareValue * (1 + irPerPeriod);
|
259
260
|
return newValue;
|
260
261
|
}
|
261
|
-
|
262
|
-
let timeDelta = (0, generalUtils_1.currentUnixSeconds)() - Number(bank.lastUpdate);
|
262
|
+
function calculateAnnualAPYs(bank) {
|
263
263
|
const totalAssets = (0, numberUtils_1.bytesToI80F48)(bank.totalAssetShares.value) *
|
264
264
|
(0, numberUtils_1.bytesToI80F48)(bank.assetShareValue.value);
|
265
265
|
const totalLiabilities = (0, numberUtils_1.bytesToI80F48)(bank.totalLiabilityShares.value) *
|
266
266
|
(0, numberUtils_1.bytesToI80F48)(bank.liabilityShareValue.value);
|
267
267
|
const utilizationRatio = totalLiabilities / totalAssets;
|
268
|
-
|
268
|
+
return calcInterestRate(bank, utilizationRatio);
|
269
|
+
}
|
270
|
+
async function getUpToDateShareValues(bank) {
|
271
|
+
let timeDelta = (0, generalUtils_1.currentUnixSeconds)() - Number(bank.lastUpdate);
|
272
|
+
const [lendingApr, borrowingApr] = calculateAnnualAPYs(bank);
|
269
273
|
return [
|
270
274
|
calcAccruedInterestPaymentPerPeriod(lendingApr, timeDelta, (0, numberUtils_1.bytesToI80F48)(bank.assetShareValue.value)),
|
271
275
|
calcAccruedInterestPaymentPerPeriod(borrowingApr, timeDelta, (0, numberUtils_1.bytesToI80F48)(bank.liabilityShareValue.value)),
|
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.203",
|
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.M_SOL]: {
|
28
|
+
bank: "22DcjMZrMwC5Bpa5AGBsmjc5V9VuQrXG6N9ZtdUNyYGE",
|
29
|
+
liquidityVault: "B6HqNn83a2bLqo4i5ygjLHJgD11ePtQksUyx4MjD55DV",
|
30
|
+
vaultAuthority: "6YxGd65JbXzgFGWjE44jsyVeCnZp7Bb1wfL9jDia1n8w",
|
31
|
+
priceOracle: "5CKzb9j4ChgLUt8Gfm5CNGLN6khXKiqMbnGAW4cgXgxK",
|
32
|
+
},
|
33
|
+
[tokens.JITO_SOL]: {
|
34
|
+
bank: "Bohoc1ikHLD7xKJuzTyiTyCwzaL5N7ggJQu75A8mKYM8",
|
35
|
+
liquidityVault: "38VGtXd2pDPq9FMh1z6AVjcHCoHgvWyMhdNyamDTeeks",
|
36
|
+
vaultAuthority: "7Ng54qf7BrCcZLqXmKA9WSR7SVRn4q6RX1YpLksBQ21A",
|
37
|
+
priceOracle: "AxaxyeDT8JnWERSaTKvFXvPKkEdxnamKSqpWbsSjYg1g",
|
38
|
+
},
|
39
|
+
[tokens.LST]: {
|
40
|
+
bank: "DMoqjmsuoru986HgfjqrKEvPv8YBufvBGADHUonkadC5",
|
41
|
+
liquidityVault: "DMQUXpb6K5L8osgV4x3NeEPUoJCf2VBgnA8FQusDjSou",
|
42
|
+
vaultAuthority: "6PWVauGLhBFHUJspsnBVZHr56ZnbvmhSD2gS7czBHGpE",
|
43
|
+
priceOracle: "7aT9A5knp62jVvnEW33xaWopaPHa3Y7ggULyYiUsDhu8",
|
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.M_SOL]:
|
11
|
+
"0xc2289a6a43d2ce91c6f55caec370f4acc38a2ed477f58813334c6d03749ff2a4",
|
12
|
+
[tokens.JITO_SOL]:
|
13
|
+
"0x67be9f519b95cf24338801051f9a808eff0a578ccb388db73b7f6fe1de019ffb",
|
14
|
+
[tokens.LST]:
|
15
|
+
"0x12fb674ee496045b1d9cf7d5e65379acb026133c2ad69f3ed996fb9fe68e3a37",
|
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
|
+
M_SOL,
|
26
|
+
JITO_SOL,
|
27
|
+
LST,
|
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
|
+
[M_SOL]: {
|
64
|
+
ticker: "mSOL",
|
65
|
+
decimals: 9,
|
66
|
+
isLST: true,
|
67
|
+
},
|
68
|
+
[JITO_SOL]: {
|
69
|
+
ticker: "JitoSOL",
|
70
|
+
decimals: 9,
|
71
|
+
isLST: true,
|
72
|
+
},
|
73
|
+
[LST]: {
|
74
|
+
ticker: "LST",
|
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
|
+
};
|
@@ -198,7 +198,6 @@ export async function getAllMarginfiAccountsByAuthority(
|
|
198
198
|
}
|
199
199
|
|
200
200
|
async function getTokenUsage(
|
201
|
-
umi: Umi,
|
202
201
|
bank: Bank | null,
|
203
202
|
isAsset: boolean,
|
204
203
|
shares: number,
|
@@ -210,10 +209,8 @@ async function getTokenUsage(
|
|
210
209
|
|
211
210
|
if (bank !== null) {
|
212
211
|
[marketPrice] = await fetchTokenPrices([toWeb3JsPublicKey(bank.mint)]);
|
213
|
-
const [assetShareValue, liabilityShareValue] =
|
214
|
-
|
215
|
-
bank
|
216
|
-
);
|
212
|
+
const [assetShareValue, liabilityShareValue] =
|
213
|
+
await getUpToDateShareValues(bank);
|
217
214
|
const shareValue = isAsset ? assetShareValue : liabilityShareValue;
|
218
215
|
amountUsed = shares * shareValue + Number(amountUsedAdjustment ?? 0);
|
219
216
|
|
@@ -333,7 +330,6 @@ export async function getMarginfiAccountPositionState(
|
|
333
330
|
supplyMint = toWeb3JsPublicKey(supplyBank!.mint);
|
334
331
|
}
|
335
332
|
supplyUsage = await getTokenUsage(
|
336
|
-
umi,
|
337
333
|
supplyBank!,
|
338
334
|
true,
|
339
335
|
bytesToI80F48(supplyBalances[0].assetShares.value),
|
@@ -351,7 +347,6 @@ export async function getMarginfiAccountPositionState(
|
|
351
347
|
debtMint = toWeb3JsPublicKey(debtBank!.mint);
|
352
348
|
}
|
353
349
|
debtUsage = await getTokenUsage(
|
354
|
-
umi,
|
355
350
|
debtBank!,
|
356
351
|
false,
|
357
352
|
bytesToI80F48(debtBalances[0].liabilityShares.value),
|
@@ -375,7 +370,6 @@ export async function getMarginfiAccountPositionState(
|
|
375
370
|
|
376
371
|
if (!supplyUsage) {
|
377
372
|
supplyUsage = await getTokenUsage(
|
378
|
-
umi,
|
379
373
|
supplyBank,
|
380
374
|
true,
|
381
375
|
0,
|
@@ -392,7 +386,6 @@ export async function getMarginfiAccountPositionState(
|
|
392
386
|
|
393
387
|
if (!debtUsage) {
|
394
388
|
debtUsage = await getTokenUsage(
|
395
|
-
umi,
|
396
389
|
debtBank,
|
397
390
|
false,
|
398
391
|
0,
|
@@ -462,10 +455,10 @@ function marginfiInterestRateCurve(
|
|
462
455
|
);
|
463
456
|
|
464
457
|
if (utilizationRatio <= optimalUr) {
|
465
|
-
return (utilizationRatio
|
458
|
+
return (utilizationRatio * plateauIr) / optimalUr;
|
466
459
|
} else {
|
467
460
|
return (
|
468
|
-
((utilizationRatio - optimalUr) / (1 - optimalUr)) * (maxIr - plateauIr) +
|
461
|
+
(((utilizationRatio - optimalUr) / (1 - optimalUr)) * (maxIr - plateauIr)) +
|
469
462
|
plateauIr
|
470
463
|
);
|
471
464
|
}
|
@@ -493,7 +486,7 @@ function calcInterestRate(
|
|
493
486
|
);
|
494
487
|
const rateFee = protocolIrFee + insuranceIrFee;
|
495
488
|
const totalFixedFeeApr = protocolFixedFeeApr + insuranceFixedFeeApr;
|
496
|
-
const borrowingRate = baseRate * (1 + rateFee)
|
489
|
+
const borrowingRate = (baseRate * (1 + rateFee)) + totalFixedFeeApr;
|
497
490
|
|
498
491
|
return [lendingRate, borrowingRate];
|
499
492
|
}
|
@@ -508,12 +501,7 @@ function calcAccruedInterestPaymentPerPeriod(
|
|
508
501
|
return newValue;
|
509
502
|
}
|
510
503
|
|
511
|
-
export
|
512
|
-
umi: Umi,
|
513
|
-
bank: Bank
|
514
|
-
): Promise<[number, number]> {
|
515
|
-
let timeDelta = currentUnixSeconds() - Number(bank.lastUpdate);
|
516
|
-
|
504
|
+
export function calculateAnnualAPYs(bank: Bank) {
|
517
505
|
const totalAssets =
|
518
506
|
bytesToI80F48(bank.totalAssetShares.value) *
|
519
507
|
bytesToI80F48(bank.assetShareValue.value);
|
@@ -522,7 +510,14 @@ export async function getUpToDateShareValues(
|
|
522
510
|
bytesToI80F48(bank.liabilityShareValue.value);
|
523
511
|
|
524
512
|
const utilizationRatio = totalLiabilities / totalAssets;
|
525
|
-
|
513
|
+
return calcInterestRate(bank, utilizationRatio);
|
514
|
+
}
|
515
|
+
|
516
|
+
export async function getUpToDateShareValues(
|
517
|
+
bank: Bank
|
518
|
+
): Promise<[number, number]> {
|
519
|
+
let timeDelta = currentUnixSeconds() - Number(bank.lastUpdate);
|
520
|
+
const [lendingApr, borrowingApr] = calculateAnnualAPYs(bank);
|
526
521
|
|
527
522
|
return [
|
528
523
|
calcAccruedInterestPaymentPerPeriod(
|
@@ -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
|
|