flash-sdk 2.0.34 → 2.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PerpetualsClient.d.ts +16 -1
- package/dist/PerpetualsClient.js +167 -13
- package/dist/PoolConfig.d.ts +2 -1
- package/dist/PoolConfig.js +3 -2
- package/dist/PoolConfig.json +4 -0
- package/dist/idl/fbnft_rewards.d.ts +285 -0
- package/dist/idl/fbnft_rewards.js +287 -0
- package/dist/test2.d.ts +1 -0
- package/dist/test2.js +175 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +4 -0
- package/package.json +1 -1
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IDL = void 0;
|
|
4
|
+
exports.IDL = {
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"name": "fbnft_rewards",
|
|
7
|
+
"instructions": [
|
|
8
|
+
{
|
|
9
|
+
"name": "initRewardVault",
|
|
10
|
+
"accounts": [
|
|
11
|
+
{
|
|
12
|
+
"name": "admin",
|
|
13
|
+
"isMut": true,
|
|
14
|
+
"isSigner": true
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "transferAuthority",
|
|
18
|
+
"isMut": true,
|
|
19
|
+
"isSigner": false
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "rewardVault",
|
|
23
|
+
"isMut": true,
|
|
24
|
+
"isSigner": false
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "rewardMint",
|
|
28
|
+
"isMut": false,
|
|
29
|
+
"isSigner": false
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "rewardTokenAccount",
|
|
33
|
+
"isMut": true,
|
|
34
|
+
"isSigner": false
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "collectionMint",
|
|
38
|
+
"isMut": false,
|
|
39
|
+
"isSigner": false
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "programData",
|
|
43
|
+
"isMut": false,
|
|
44
|
+
"isSigner": false
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "systemProgram",
|
|
48
|
+
"isMut": false,
|
|
49
|
+
"isSigner": false
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "tokenProgram",
|
|
53
|
+
"isMut": false,
|
|
54
|
+
"isSigner": false
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"name": "rent",
|
|
58
|
+
"isMut": false,
|
|
59
|
+
"isSigner": false
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"args": [
|
|
63
|
+
{
|
|
64
|
+
"name": "params",
|
|
65
|
+
"type": {
|
|
66
|
+
"defined": "InitRewardVaultParams"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"name": "distributeRewards",
|
|
73
|
+
"accounts": [
|
|
74
|
+
{
|
|
75
|
+
"name": "admin",
|
|
76
|
+
"isMut": false,
|
|
77
|
+
"isSigner": true
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "fundingAccount",
|
|
81
|
+
"isMut": true,
|
|
82
|
+
"isSigner": false
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"name": "rewardVault",
|
|
86
|
+
"isMut": true,
|
|
87
|
+
"isSigner": false
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"name": "rewardTokenAccount",
|
|
91
|
+
"isMut": true,
|
|
92
|
+
"isSigner": false
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "tokenProgram",
|
|
96
|
+
"isMut": false,
|
|
97
|
+
"isSigner": false
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
"args": [
|
|
101
|
+
{
|
|
102
|
+
"name": "params",
|
|
103
|
+
"type": {
|
|
104
|
+
"defined": "DistributeRewardsParams"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"name": "collectReward",
|
|
111
|
+
"accounts": [
|
|
112
|
+
{
|
|
113
|
+
"name": "owner",
|
|
114
|
+
"isMut": true,
|
|
115
|
+
"isSigner": true
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"name": "feePayer",
|
|
119
|
+
"isMut": true,
|
|
120
|
+
"isSigner": true
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"name": "nftMint",
|
|
124
|
+
"isMut": true,
|
|
125
|
+
"isSigner": false
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"name": "nftTokenAccount",
|
|
129
|
+
"isMut": false,
|
|
130
|
+
"isSigner": false
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"name": "metadataAccount",
|
|
134
|
+
"isMut": true,
|
|
135
|
+
"isSigner": false
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"name": "receivingAccount",
|
|
139
|
+
"isMut": true,
|
|
140
|
+
"isSigner": false
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"name": "rewardRecord",
|
|
144
|
+
"isMut": true,
|
|
145
|
+
"isSigner": false
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"name": "rewardVault",
|
|
149
|
+
"isMut": true,
|
|
150
|
+
"isSigner": false
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"name": "rewardTokenAccount",
|
|
154
|
+
"isMut": true,
|
|
155
|
+
"isSigner": false
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"name": "transferAuthority",
|
|
159
|
+
"isMut": false,
|
|
160
|
+
"isSigner": false
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"name": "systemProgram",
|
|
164
|
+
"isMut": false,
|
|
165
|
+
"isSigner": false
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"name": "tokenProgram",
|
|
169
|
+
"isMut": false,
|
|
170
|
+
"isSigner": false
|
|
171
|
+
}
|
|
172
|
+
],
|
|
173
|
+
"args": []
|
|
174
|
+
}
|
|
175
|
+
],
|
|
176
|
+
"accounts": [
|
|
177
|
+
{
|
|
178
|
+
"name": "rewardVault",
|
|
179
|
+
"type": {
|
|
180
|
+
"kind": "struct",
|
|
181
|
+
"fields": [
|
|
182
|
+
{
|
|
183
|
+
"name": "admin",
|
|
184
|
+
"type": "publicKey"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"name": "collection",
|
|
188
|
+
"type": "publicKey"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"name": "rewardMint",
|
|
192
|
+
"type": "publicKey"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"name": "transferAuthority",
|
|
196
|
+
"type": "publicKey"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"name": "rewardTokenAccount",
|
|
200
|
+
"type": "publicKey"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"name": "lpTokenAccount",
|
|
204
|
+
"type": "publicKey"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"name": "nftCount",
|
|
208
|
+
"type": "u64"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"name": "accruedAmount",
|
|
212
|
+
"type": "u128"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"name": "paidAmount",
|
|
216
|
+
"type": "u128"
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"name": "rewardsPerNft",
|
|
220
|
+
"type": "u64"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"name": "bump",
|
|
224
|
+
"type": "u8"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"name": "transferAuthorityBump",
|
|
228
|
+
"type": "u8"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"name": "tokenAccountBump",
|
|
232
|
+
"type": "u8"
|
|
233
|
+
}
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"name": "rewardRecord",
|
|
239
|
+
"type": {
|
|
240
|
+
"kind": "struct",
|
|
241
|
+
"fields": [
|
|
242
|
+
{
|
|
243
|
+
"name": "mint",
|
|
244
|
+
"type": "publicKey"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"name": "rewardDebt",
|
|
248
|
+
"type": "u64"
|
|
249
|
+
}
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
],
|
|
254
|
+
"types": [
|
|
255
|
+
{
|
|
256
|
+
"name": "InitRewardVaultParams",
|
|
257
|
+
"type": {
|
|
258
|
+
"kind": "struct",
|
|
259
|
+
"fields": [
|
|
260
|
+
{
|
|
261
|
+
"name": "nftCount",
|
|
262
|
+
"type": "u64"
|
|
263
|
+
}
|
|
264
|
+
]
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"name": "DistributeRewardsParams",
|
|
269
|
+
"type": {
|
|
270
|
+
"kind": "struct",
|
|
271
|
+
"fields": [
|
|
272
|
+
{
|
|
273
|
+
"name": "rewardAmount",
|
|
274
|
+
"type": "u64"
|
|
275
|
+
}
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
],
|
|
280
|
+
"errors": [
|
|
281
|
+
{
|
|
282
|
+
"code": 6000,
|
|
283
|
+
"name": "InvalidCollection",
|
|
284
|
+
"msg": "Unsuppported NFT collection"
|
|
285
|
+
}
|
|
286
|
+
]
|
|
287
|
+
};
|
package/dist/test2.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'dotenv/config';
|
package/dist/test2.js
CHANGED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var _a;
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
require("dotenv/config");
|
|
41
|
+
var bn_js_1 = require("bn.js");
|
|
42
|
+
var PerpetualsClient_1 = require("./PerpetualsClient");
|
|
43
|
+
var anchor_1 = require("@coral-xyz/anchor");
|
|
44
|
+
var OraclePrice_1 = require("./OraclePrice");
|
|
45
|
+
var CustodyAccount_1 = require("./CustodyAccount");
|
|
46
|
+
var client_1 = require("@pythnetwork/client");
|
|
47
|
+
var PoolAccount_1 = require("./PoolAccount");
|
|
48
|
+
var PoolDataClient_1 = require("./PoolDataClient");
|
|
49
|
+
var spl_token_1 = require("@solana/spl-token");
|
|
50
|
+
var PoolConfig_1 = require("./PoolConfig");
|
|
51
|
+
var client;
|
|
52
|
+
var poolClient;
|
|
53
|
+
function initClient(clusterUrl, adminKeyPath, programId, composabilityProgramId, fbNftRewardProgramId) {
|
|
54
|
+
process.env["ANCHOR_WALLET"] = adminKeyPath;
|
|
55
|
+
var provider = anchor_1.AnchorProvider.local(clusterUrl, {
|
|
56
|
+
commitment: "confirmed",
|
|
57
|
+
preflightCommitment: "confirmed",
|
|
58
|
+
skipPreflight: true
|
|
59
|
+
});
|
|
60
|
+
client = new PerpetualsClient_1.PerpetualsClient(provider, programId, composabilityProgramId, fbNftRewardProgramId, null);
|
|
61
|
+
client.log("Client Initialized");
|
|
62
|
+
}
|
|
63
|
+
var prettyPrint = function (object) {
|
|
64
|
+
console.log(JSON.stringify(object, null, 2));
|
|
65
|
+
};
|
|
66
|
+
var url = 'https://flashtr-flash-885f.devnet.rpcpool.com/e0f3d11e-6673-4e02-b3f8-361d596ee7fe';
|
|
67
|
+
console.log("url:", url);
|
|
68
|
+
var adminKey = (_a = process.env["KEYPAIR_PATH"]) !== null && _a !== void 0 ? _a : "/Users/aw/.config/solana/Beta-Hcik.json";
|
|
69
|
+
console.log("adminKey path:", adminKey);
|
|
70
|
+
var main2 = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
71
|
+
var POOL_CONFIG, programId, composabilityProgramId, poolName, poolKey, poolData, poolAccount, custodyAccounts, i, custodyAccountKey, custodyAccountInfo, ca, lpTokenInfo, pythClient, pythHttpClientResult, priceDataSOL, priceOracleSOL, emaPriceOracleSOL, priceDataUSDC, priceOracleUSDC, emaPriceOracleUSDC, priceDataBTC, priceOracleBTC, emaPriceOracleBTC, priceDataETH, priceOracleETH, emaPriceOracleETH, nprices, custodyData, lpStats, apy;
|
|
72
|
+
return __generator(this, function (_a) {
|
|
73
|
+
switch (_a.label) {
|
|
74
|
+
case 0:
|
|
75
|
+
POOL_CONFIG = PoolConfig_1.PoolConfig.fromIdsByName('devnet.1', 'devnet');
|
|
76
|
+
programId = POOL_CONFIG.programId;
|
|
77
|
+
composabilityProgramId = POOL_CONFIG.perpComposibilityProgramId;
|
|
78
|
+
initClient(url, adminKey, programId, composabilityProgramId, POOL_CONFIG.fbNftRewardProgramId);
|
|
79
|
+
poolName = "devnet.1";
|
|
80
|
+
poolKey = POOL_CONFIG.poolAddress;
|
|
81
|
+
return [4, client.getPool(poolName)];
|
|
82
|
+
case 1:
|
|
83
|
+
poolData = _a.sent();
|
|
84
|
+
poolAccount = new PoolAccount_1.PoolAccount(poolKey, poolData);
|
|
85
|
+
custodyAccounts = [];
|
|
86
|
+
i = 0;
|
|
87
|
+
_a.label = 2;
|
|
88
|
+
case 2:
|
|
89
|
+
if (!(i < POOL_CONFIG.custodies.length)) return [3, 5];
|
|
90
|
+
custodyAccountKey = client.getCustodyKey(poolName, POOL_CONFIG.custodies[i].mintKey);
|
|
91
|
+
return [4, client.program.account.custody.fetch(custodyAccountKey)];
|
|
92
|
+
case 3:
|
|
93
|
+
custodyAccountInfo = _a.sent();
|
|
94
|
+
ca = new CustodyAccount_1.CustodyAccount(POOL_CONFIG.custodies[i].custodyAccount, custodyAccountInfo);
|
|
95
|
+
custodyAccounts.push(ca);
|
|
96
|
+
_a.label = 4;
|
|
97
|
+
case 4:
|
|
98
|
+
i++;
|
|
99
|
+
return [3, 2];
|
|
100
|
+
case 5: return [4, (0, spl_token_1.getMint)(client.provider.connection, POOL_CONFIG.lpTokenMint)];
|
|
101
|
+
case 6:
|
|
102
|
+
lpTokenInfo = _a.sent();
|
|
103
|
+
poolClient = new PoolDataClient_1.PoolDataClient(POOL_CONFIG, poolAccount, lpTokenInfo, custodyAccounts);
|
|
104
|
+
pythClient = new client_1.PythHttpClient(client.provider.connection, (0, client_1.getPythProgramKeyForCluster)('devnet'));
|
|
105
|
+
return [4, pythClient.getData()];
|
|
106
|
+
case 7:
|
|
107
|
+
pythHttpClientResult = _a.sent();
|
|
108
|
+
priceDataSOL = pythHttpClientResult.productPrice.get('Crypto.SOL/USD');
|
|
109
|
+
priceOracleSOL = new OraclePrice_1.OraclePrice({
|
|
110
|
+
price: new bn_js_1.BN(priceDataSOL === null || priceDataSOL === void 0 ? void 0 : priceDataSOL.aggregate.priceComponent.toString()),
|
|
111
|
+
exponent: new bn_js_1.BN(priceDataSOL === null || priceDataSOL === void 0 ? void 0 : priceDataSOL.exponent),
|
|
112
|
+
confidence: new bn_js_1.BN(priceDataSOL === null || priceDataSOL === void 0 ? void 0 : priceDataSOL.confidence),
|
|
113
|
+
timestamp: new bn_js_1.BN(priceDataSOL === null || priceDataSOL === void 0 ? void 0 : priceDataSOL.timestamp.toString()),
|
|
114
|
+
});
|
|
115
|
+
emaPriceOracleSOL = new OraclePrice_1.OraclePrice({
|
|
116
|
+
price: new bn_js_1.BN(priceDataSOL === null || priceDataSOL === void 0 ? void 0 : priceDataSOL.emaPrice.valueComponent.toString()),
|
|
117
|
+
exponent: new bn_js_1.BN(priceDataSOL === null || priceDataSOL === void 0 ? void 0 : priceDataSOL.exponent),
|
|
118
|
+
confidence: new bn_js_1.BN(priceDataSOL === null || priceDataSOL === void 0 ? void 0 : priceDataSOL.emaConfidence.valueComponent.toString()),
|
|
119
|
+
timestamp: new bn_js_1.BN(priceDataSOL === null || priceDataSOL === void 0 ? void 0 : priceDataSOL.timestamp.toString()),
|
|
120
|
+
});
|
|
121
|
+
priceDataUSDC = pythHttpClientResult.productPrice.get('Crypto.USDC/USD');
|
|
122
|
+
priceOracleUSDC = new OraclePrice_1.OraclePrice({
|
|
123
|
+
price: new bn_js_1.BN(priceDataUSDC === null || priceDataUSDC === void 0 ? void 0 : priceDataUSDC.aggregate.priceComponent.toString()),
|
|
124
|
+
exponent: new bn_js_1.BN(priceDataUSDC === null || priceDataUSDC === void 0 ? void 0 : priceDataUSDC.exponent),
|
|
125
|
+
confidence: new bn_js_1.BN(priceDataUSDC === null || priceDataUSDC === void 0 ? void 0 : priceDataUSDC.confidence),
|
|
126
|
+
timestamp: new bn_js_1.BN(priceDataUSDC === null || priceDataUSDC === void 0 ? void 0 : priceDataUSDC.timestamp.toString()),
|
|
127
|
+
});
|
|
128
|
+
emaPriceOracleUSDC = new OraclePrice_1.OraclePrice({
|
|
129
|
+
price: new bn_js_1.BN(priceDataUSDC === null || priceDataUSDC === void 0 ? void 0 : priceDataUSDC.emaPrice.valueComponent.toString()),
|
|
130
|
+
exponent: new bn_js_1.BN(priceDataUSDC === null || priceDataUSDC === void 0 ? void 0 : priceDataUSDC.exponent),
|
|
131
|
+
confidence: new bn_js_1.BN(priceDataUSDC === null || priceDataUSDC === void 0 ? void 0 : priceDataUSDC.emaConfidence.valueComponent.toString()),
|
|
132
|
+
timestamp: new bn_js_1.BN(priceDataUSDC === null || priceDataUSDC === void 0 ? void 0 : priceDataUSDC.timestamp.toString()),
|
|
133
|
+
});
|
|
134
|
+
priceDataBTC = pythHttpClientResult.productPrice.get('Crypto.BTC/USD');
|
|
135
|
+
priceOracleBTC = new OraclePrice_1.OraclePrice({
|
|
136
|
+
price: new bn_js_1.BN(priceDataBTC === null || priceDataBTC === void 0 ? void 0 : priceDataBTC.aggregate.priceComponent.toString()),
|
|
137
|
+
exponent: new bn_js_1.BN(priceDataBTC === null || priceDataBTC === void 0 ? void 0 : priceDataBTC.exponent),
|
|
138
|
+
confidence: new bn_js_1.BN(priceDataBTC === null || priceDataBTC === void 0 ? void 0 : priceDataBTC.confidence),
|
|
139
|
+
timestamp: new bn_js_1.BN(priceDataBTC === null || priceDataBTC === void 0 ? void 0 : priceDataBTC.timestamp.toString()),
|
|
140
|
+
});
|
|
141
|
+
emaPriceOracleBTC = new OraclePrice_1.OraclePrice({
|
|
142
|
+
price: new bn_js_1.BN(priceDataBTC === null || priceDataBTC === void 0 ? void 0 : priceDataBTC.emaPrice.valueComponent.toString()),
|
|
143
|
+
exponent: new bn_js_1.BN(priceDataBTC === null || priceDataBTC === void 0 ? void 0 : priceDataBTC.exponent),
|
|
144
|
+
confidence: new bn_js_1.BN(priceDataBTC === null || priceDataBTC === void 0 ? void 0 : priceDataBTC.emaConfidence.valueComponent.toString()),
|
|
145
|
+
timestamp: new bn_js_1.BN(priceDataBTC === null || priceDataBTC === void 0 ? void 0 : priceDataBTC.timestamp.toString()),
|
|
146
|
+
});
|
|
147
|
+
priceDataETH = pythHttpClientResult.productPrice.get('Crypto.ETH/USD');
|
|
148
|
+
priceOracleETH = new OraclePrice_1.OraclePrice({
|
|
149
|
+
price: new bn_js_1.BN(priceDataETH === null || priceDataETH === void 0 ? void 0 : priceDataETH.aggregate.priceComponent.toString()),
|
|
150
|
+
exponent: new bn_js_1.BN(priceDataETH === null || priceDataETH === void 0 ? void 0 : priceDataETH.exponent),
|
|
151
|
+
confidence: new bn_js_1.BN(priceDataETH === null || priceDataETH === void 0 ? void 0 : priceDataETH.confidence),
|
|
152
|
+
timestamp: new bn_js_1.BN(priceDataETH === null || priceDataETH === void 0 ? void 0 : priceDataETH.timestamp.toString()),
|
|
153
|
+
});
|
|
154
|
+
emaPriceOracleETH = new OraclePrice_1.OraclePrice({
|
|
155
|
+
price: new bn_js_1.BN(priceDataETH === null || priceDataETH === void 0 ? void 0 : priceDataETH.emaPrice.valueComponent.toString()),
|
|
156
|
+
exponent: new bn_js_1.BN(priceDataETH === null || priceDataETH === void 0 ? void 0 : priceDataETH.exponent),
|
|
157
|
+
confidence: new bn_js_1.BN(priceDataETH === null || priceDataETH === void 0 ? void 0 : priceDataETH.emaConfidence.valueComponent.toString()),
|
|
158
|
+
timestamp: new bn_js_1.BN(priceDataETH === null || priceDataETH === void 0 ? void 0 : priceDataETH.timestamp.toString()),
|
|
159
|
+
});
|
|
160
|
+
nprices = new Map();
|
|
161
|
+
nprices.set('USDC', { price: priceOracleUSDC, emaPrice: emaPriceOracleUSDC, isStale: false });
|
|
162
|
+
nprices.set('SOL', { price: priceOracleSOL, emaPrice: emaPriceOracleSOL, isStale: false });
|
|
163
|
+
nprices.set('BTC', { price: priceOracleBTC, emaPrice: emaPriceOracleBTC, isStale: false });
|
|
164
|
+
nprices.set('ETH', { price: priceOracleETH, emaPrice: emaPriceOracleETH, isStale: false });
|
|
165
|
+
custodyData = poolClient.getCustodyStats(nprices);
|
|
166
|
+
console.log("custodyData[0].availableToAddUsdUi:", custodyData[0].availableToAddUsdUi);
|
|
167
|
+
lpStats = poolClient.getLpStats(nprices);
|
|
168
|
+
console.log("lpStats:", lpStats.priceUi);
|
|
169
|
+
console.log("custodyAccounts[0].feesStats.rewardPerLpStaked:", custodyAccounts[0].feesStats.rewardPerLpStaked.toString());
|
|
170
|
+
apy = client.getApyPercentageUi(custodyAccounts[0], custodyAccounts[0].feesStats.rewardPerLpStaked.subn(3000), new bn_js_1.BN(1 * Math.pow(10, 6)));
|
|
171
|
+
console.log("apy:", apy.toString());
|
|
172
|
+
return [2];
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}); };
|