@triadxyz/triad-protocol 1.4.8-beta → 1.5.0-beta
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/LICENSE +183 -183
- package/dist/index.d.ts +21 -296
- package/dist/index.js +51 -215
- package/dist/stake.d.ts +36 -25
- package/dist/stake.js +43 -39
- package/dist/trade.d.ts +41 -41
- package/dist/trade.js +55 -83
- package/dist/types/idl_triad_protocol.json +299 -1174
- package/dist/types/stake.d.ts +0 -1
- package/dist/types/trade.d.ts +1 -2
- package/dist/types/triad_protocol.d.ts +281 -1328
- package/dist/utils/helpers.d.ts +1 -1
- package/dist/utils/helpers.js +5 -5
- package/dist/utils/pda/index.d.ts +1 -0
- package/dist/utils/pda/index.js +5 -1
- package/package.json +1 -1
- package/dist/local-test.d.ts +0 -1
- package/dist/local-test.js +0 -538
- package/dist/utils/jup-swap.d.ts +0 -15
- package/dist/utils/jup-swap.js +0 -66
package/dist/utils/jup-swap.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getAddressLookupTableAccounts = exports.jupSwap = void 0;
|
|
16
|
-
const axios_1 = __importDefault(require("axios"));
|
|
17
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
18
|
-
const jupSwap = ({ connection, wallet, inToken, outToken, amount }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
-
var _a;
|
|
20
|
-
try {
|
|
21
|
-
const quoteResponse = yield axios_1.default.get(`https://quote-api.jup.ag/v6/quote?inputMint=${inToken}&outputMint=${outToken}&amount=${amount}&slippageBps=100`);
|
|
22
|
-
const { data: quoteData } = quoteResponse;
|
|
23
|
-
const swapResponse = yield axios_1.default.post('https://quote-api.jup.ag/v6/swap-instructions', {
|
|
24
|
-
userPublicKey: wallet,
|
|
25
|
-
quoteResponse: quoteData
|
|
26
|
-
});
|
|
27
|
-
const { setupInstructions, swapInstruction, addressLookupTableAddresses, cleanupInstruction } = swapResponse.data;
|
|
28
|
-
return {
|
|
29
|
-
swapIxs: [deserializeInstruction(swapInstruction)],
|
|
30
|
-
addressLookupTableAccounts: yield (0, exports.getAddressLookupTableAccounts)(connection, addressLookupTableAddresses),
|
|
31
|
-
setupInstructions: setupInstructions.map(deserializeInstruction),
|
|
32
|
-
cleanupInstruction: deserializeInstruction(cleanupInstruction),
|
|
33
|
-
otherAmountThreshold: quoteData.otherAmountThreshold
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
catch (e) {
|
|
37
|
-
console.log((_a = e === null || e === void 0 ? void 0 : e.response) === null || _a === void 0 ? void 0 : _a.data);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
exports.jupSwap = jupSwap;
|
|
41
|
-
const deserializeInstruction = (instruction) => {
|
|
42
|
-
return new web3_js_1.TransactionInstruction({
|
|
43
|
-
programId: new web3_js_1.PublicKey(instruction.programId),
|
|
44
|
-
keys: instruction.accounts.map((key) => ({
|
|
45
|
-
pubkey: new web3_js_1.PublicKey(key.pubkey),
|
|
46
|
-
isSigner: key.isSigner,
|
|
47
|
-
isWritable: key.isWritable
|
|
48
|
-
})),
|
|
49
|
-
data: Buffer.from(instruction.data, 'base64')
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
const getAddressLookupTableAccounts = (connection, keys) => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
-
const addressLookupTableAccountInfos = yield connection.getMultipleAccountsInfo(keys.map((key) => new web3_js_1.PublicKey(key)));
|
|
54
|
-
return addressLookupTableAccountInfos.reduce((acc, accountInfo, index) => {
|
|
55
|
-
const addressLookupTableAddress = keys[index];
|
|
56
|
-
if (accountInfo) {
|
|
57
|
-
const addressLookupTableAccount = new web3_js_1.AddressLookupTableAccount({
|
|
58
|
-
key: new web3_js_1.PublicKey(addressLookupTableAddress),
|
|
59
|
-
state: web3_js_1.AddressLookupTableAccount.deserialize(accountInfo.data)
|
|
60
|
-
});
|
|
61
|
-
acc.push(addressLookupTableAccount);
|
|
62
|
-
}
|
|
63
|
-
return acc;
|
|
64
|
-
}, new Array());
|
|
65
|
-
});
|
|
66
|
-
exports.getAddressLookupTableAccounts = getAddressLookupTableAccounts;
|