@symmetry-hq/temp-v3-sdk 0.0.37 → 0.0.38
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/src/index.d.ts +5 -0
- package/dist/src/index.js +32 -0
- package/dist/src/instructions/management/addBounty.js +1 -1
- package/dist/test.js +13 -0
- package/package.json +1 -1
- package/src/index.ts +39 -0
- package/src/instructions/management/addBounty.ts +1 -1
- package/test.ts +14 -0
package/dist/src/index.d.ts
CHANGED
|
@@ -164,6 +164,11 @@ export declare class SymmetryCore {
|
|
|
164
164
|
keeper: string;
|
|
165
165
|
rebalance_intent: string;
|
|
166
166
|
}): Promise<TxPayloadBatchSequence>;
|
|
167
|
+
addBountyTx(params: {
|
|
168
|
+
keeper: string;
|
|
169
|
+
basket: string;
|
|
170
|
+
amount: number;
|
|
171
|
+
}): Promise<TxPayloadBatchSequence>;
|
|
167
172
|
claimBasketFeesTx(params: {
|
|
168
173
|
claimer: string;
|
|
169
174
|
basket: string;
|
package/dist/src/index.js
CHANGED
|
@@ -40,6 +40,7 @@ const claimFees_1 = require("./instructions/management/claimFees");
|
|
|
40
40
|
const jup_1 = require("./jup");
|
|
41
41
|
Object.defineProperty(exports, "getJupTokenLedgerAndSwapInstructions", { enumerable: true, get: function () { return jup_1.getJupTokenLedgerAndSwapInstructions; } });
|
|
42
42
|
const constants_1 = require("./constants");
|
|
43
|
+
const addBounty_1 = require("./instructions/management/addBounty");
|
|
43
44
|
class SymmetryCore {
|
|
44
45
|
constructor(params) {
|
|
45
46
|
var _a;
|
|
@@ -1068,6 +1069,37 @@ class SymmetryCore {
|
|
|
1068
1069
|
return txPayloadBatchSequence;
|
|
1069
1070
|
});
|
|
1070
1071
|
}
|
|
1072
|
+
addBountyTx(params) {
|
|
1073
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1074
|
+
let keeper = new web3_js_1.PublicKey(params.keeper);
|
|
1075
|
+
let basket = yield this.fetchBasket(params.basket);
|
|
1076
|
+
let globalConfig = yield this.fetchGlobalConfig();
|
|
1077
|
+
let bountyWsolAmount = 0;
|
|
1078
|
+
if (globalConfig.bountyMint.equals(constants_1.MINTS["mainnet"].WSOL)) {
|
|
1079
|
+
bountyWsolAmount = params.amount;
|
|
1080
|
+
}
|
|
1081
|
+
let wsolIxs = yield (0, txUtils_1.wrapWsolIxs)(this.sdkParams.connection, keeper, bountyWsolAmount);
|
|
1082
|
+
let ix = (0, addBounty_1.addBountyIx)({
|
|
1083
|
+
keeper: keeper,
|
|
1084
|
+
basket: basket.ownAddress,
|
|
1085
|
+
bountyMint: basket.settings.bountyMint,
|
|
1086
|
+
amount: params.amount,
|
|
1087
|
+
});
|
|
1088
|
+
let txBatchData = { batches: [[{
|
|
1089
|
+
payer: keeper,
|
|
1090
|
+
instructions: [
|
|
1091
|
+
...wsolIxs,
|
|
1092
|
+
ix,
|
|
1093
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
1094
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
1095
|
+
],
|
|
1096
|
+
lookupTables: [],
|
|
1097
|
+
}]] };
|
|
1098
|
+
let versionedTxs = yield (0, txUtils_1.prepareVersionedTxs)(this.sdkParams.connection, txBatchData);
|
|
1099
|
+
let txPayloadBatchSequence = (0, txUtils_1.prepareTxPayloadBatchSequence)(txBatchData, versionedTxs);
|
|
1100
|
+
return txPayloadBatchSequence;
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1071
1103
|
claimBasketFeesTx(params) {
|
|
1072
1104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1073
1105
|
let claimer = new web3_js_1.PublicKey(params.claimer);
|
|
@@ -12,7 +12,7 @@ function addBountyIx(params) {
|
|
|
12
12
|
let bountyVault = (0, pda_1.getBountyVaultPda)();
|
|
13
13
|
let globalConfig = (0, pda_1.getGlobalConfigPda)();
|
|
14
14
|
let keeperBountyAta = (0, pda_1.getAta)(keeper, bountyMint);
|
|
15
|
-
let bountyVaultAta = (0, pda_1.getAta)(
|
|
15
|
+
let bountyVaultAta = (0, pda_1.getAta)(bountyVault, bountyMint);
|
|
16
16
|
const data = Buffer.concat([
|
|
17
17
|
ADD_BOUNTY_DISCRIMINATOR,
|
|
18
18
|
Buffer.from(new anchor_1.BN(amount).toArray("le", 8)), // u64 LE
|
package/dist/test.js
CHANGED
|
@@ -45,12 +45,16 @@ function testStates() {
|
|
|
45
45
|
let basket = yield sdk.fetchBasket("GrBFFvtdRL25o7gcRnV1kGvz1Qc7iscUmDp1ZvyBSyUa");
|
|
46
46
|
basket = yield sdk.loadBasketPrice(basket);
|
|
47
47
|
console.log(basket.formatted);
|
|
48
|
+
// console.log(basket.composition[0].mint.toBase58(), "amount:", basket.composition[0].amount.toString(), "price:", basket.composition[0].price?.price, "value:", basket.composition[0].value);
|
|
49
|
+
// console.log(basket.composition[1].mint.toBase58(), "amount:", basket.composition[1].amount.toString(), "price:", basket.composition[1].price?.price, "value:", basket.composition[1].value);
|
|
50
|
+
// console.log(basket.composition[2].mint.toBase58(), "amount:", basket.composition[2].amount.toString(), "price:", basket.composition[2].price?.price, "value:", basket.composition[2].value);
|
|
48
51
|
// return;
|
|
49
52
|
let tests = {
|
|
50
53
|
createGlobalConfig: false, // TESTED
|
|
51
54
|
editGlobalConfig: false, // TESTED
|
|
52
55
|
createBasket: false, // TESTED
|
|
53
56
|
editPrivateBasketSettings: false, // NOT TESTED
|
|
57
|
+
addBounty: false, // TESTED
|
|
54
58
|
editCreator: false, // TESTED
|
|
55
59
|
editManagerSettings: false, // TESTED
|
|
56
60
|
editFeeSettings: false, // TESTED
|
|
@@ -99,6 +103,15 @@ function testStates() {
|
|
|
99
103
|
});
|
|
100
104
|
console.log(resCreateBasket);
|
|
101
105
|
}
|
|
106
|
+
if (tests.addBounty) {
|
|
107
|
+
let tx = yield sdk.addBountyTx({
|
|
108
|
+
keeper: wallet.publicKey.toBase58(),
|
|
109
|
+
basket: basket.ownAddress.toBase58(),
|
|
110
|
+
amount: 250 * 10 ** 6,
|
|
111
|
+
});
|
|
112
|
+
let res = yield sdk.signAndSendTxPayloadBatchSequence({ txPayloadBatchSequence: tx, wallet });
|
|
113
|
+
console.log(res);
|
|
114
|
+
}
|
|
102
115
|
let task_context = {
|
|
103
116
|
basket: basket.ownAddress.toBase58(),
|
|
104
117
|
manager: wallet.publicKey.toBase58(),
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -70,6 +70,7 @@ import { flashDepositIx, flashWithdrawIx } from './instructions/automation/flash
|
|
|
70
70
|
import { claimFeesIx } from './instructions/management/claimFees';
|
|
71
71
|
import { getJupTokenLedgerAndSwapInstructions } from './jup';
|
|
72
72
|
import { COMPUTE_UNITS, MINTS, PRIORITY_FEE } from './constants';
|
|
73
|
+
import { addBountyIx } from './instructions/management/addBounty';
|
|
73
74
|
|
|
74
75
|
export class SymmetryCore {
|
|
75
76
|
|
|
@@ -1215,6 +1216,44 @@ export class SymmetryCore {
|
|
|
1215
1216
|
return txPayloadBatchSequence;
|
|
1216
1217
|
}
|
|
1217
1218
|
|
|
1219
|
+
async addBountyTx(params: {
|
|
1220
|
+
keeper: string,
|
|
1221
|
+
basket: string,
|
|
1222
|
+
amount: number,
|
|
1223
|
+
}): Promise<TxPayloadBatchSequence> {
|
|
1224
|
+
let keeper = new PublicKey(params.keeper);
|
|
1225
|
+
let basket = await this.fetchBasket(params.basket);
|
|
1226
|
+
let globalConfig = await this.fetchGlobalConfig();
|
|
1227
|
+
let bountyWsolAmount = 0;
|
|
1228
|
+
if (globalConfig.bountyMint.equals(MINTS["mainnet"].WSOL)) {
|
|
1229
|
+
bountyWsolAmount = params.amount;
|
|
1230
|
+
}
|
|
1231
|
+
let wsolIxs = await wrapWsolIxs(
|
|
1232
|
+
this.sdkParams.connection,
|
|
1233
|
+
keeper,
|
|
1234
|
+
bountyWsolAmount,
|
|
1235
|
+
);
|
|
1236
|
+
let ix = addBountyIx({
|
|
1237
|
+
keeper: keeper,
|
|
1238
|
+
basket: basket.ownAddress,
|
|
1239
|
+
bountyMint: basket.settings.bountyMint,
|
|
1240
|
+
amount: params.amount,
|
|
1241
|
+
});
|
|
1242
|
+
let txBatchData: TxBatchData = {batches: [[{
|
|
1243
|
+
payer: keeper,
|
|
1244
|
+
instructions: [
|
|
1245
|
+
...wsolIxs,
|
|
1246
|
+
ix,
|
|
1247
|
+
ComputeBudgetProgram.setComputeUnitLimit({units: COMPUTE_UNITS}),
|
|
1248
|
+
ComputeBudgetProgram.setComputeUnitPrice({microLamports: this.sdkParams.priorityFee}),
|
|
1249
|
+
],
|
|
1250
|
+
lookupTables: [],
|
|
1251
|
+
}]]};
|
|
1252
|
+
let versionedTxs = await prepareVersionedTxs(this.sdkParams.connection, txBatchData);
|
|
1253
|
+
let txPayloadBatchSequence = prepareTxPayloadBatchSequence(txBatchData, versionedTxs);
|
|
1254
|
+
return txPayloadBatchSequence;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1218
1257
|
async claimBasketFeesTx(params: {
|
|
1219
1258
|
claimer: string,
|
|
1220
1259
|
basket: string,
|
|
@@ -26,7 +26,7 @@ export function addBountyIx(params: {
|
|
|
26
26
|
let bountyVault = getBountyVaultPda();
|
|
27
27
|
let globalConfig = getGlobalConfigPda();
|
|
28
28
|
let keeperBountyAta = getAta(keeper, bountyMint);
|
|
29
|
-
let bountyVaultAta = getAta(
|
|
29
|
+
let bountyVaultAta = getAta(bountyVault, bountyMint);
|
|
30
30
|
|
|
31
31
|
const data = Buffer.concat([
|
|
32
32
|
ADD_BOUNTY_DISCRIMINATOR,
|
package/test.ts
CHANGED
|
@@ -44,6 +44,9 @@ async function testStates() {
|
|
|
44
44
|
let basket = await sdk.fetchBasket("GrBFFvtdRL25o7gcRnV1kGvz1Qc7iscUmDp1ZvyBSyUa");
|
|
45
45
|
basket = await sdk.loadBasketPrice(basket);
|
|
46
46
|
console.log(basket.formatted);
|
|
47
|
+
// console.log(basket.composition[0].mint.toBase58(), "amount:", basket.composition[0].amount.toString(), "price:", basket.composition[0].price?.price, "value:", basket.composition[0].value);
|
|
48
|
+
// console.log(basket.composition[1].mint.toBase58(), "amount:", basket.composition[1].amount.toString(), "price:", basket.composition[1].price?.price, "value:", basket.composition[1].value);
|
|
49
|
+
// console.log(basket.composition[2].mint.toBase58(), "amount:", basket.composition[2].amount.toString(), "price:", basket.composition[2].price?.price, "value:", basket.composition[2].value);
|
|
47
50
|
// return;
|
|
48
51
|
|
|
49
52
|
let tests = {
|
|
@@ -53,6 +56,7 @@ async function testStates() {
|
|
|
53
56
|
|
|
54
57
|
createBasket: false, // TESTED
|
|
55
58
|
editPrivateBasketSettings: false, // NOT TESTED
|
|
59
|
+
addBounty: false, // TESTED
|
|
56
60
|
|
|
57
61
|
editCreator: false, // TESTED
|
|
58
62
|
editManagerSettings: false, // TESTED
|
|
@@ -113,6 +117,16 @@ async function testStates() {
|
|
|
113
117
|
console.log(resCreateBasket);
|
|
114
118
|
}
|
|
115
119
|
|
|
120
|
+
if (tests.addBounty) {
|
|
121
|
+
let tx = await sdk.addBountyTx({
|
|
122
|
+
keeper: wallet.publicKey.toBase58(),
|
|
123
|
+
basket: basket.ownAddress.toBase58(),
|
|
124
|
+
amount: 250 * 10 ** 6,
|
|
125
|
+
});
|
|
126
|
+
let res = await sdk.signAndSendTxPayloadBatchSequence({txPayloadBatchSequence: tx, wallet});
|
|
127
|
+
console.log(res);
|
|
128
|
+
}
|
|
129
|
+
|
|
116
130
|
let task_context: TaskContext = {
|
|
117
131
|
basket: basket.ownAddress.toBase58(),
|
|
118
132
|
manager: wallet.publicKey.toBase58(),
|