@symmetry-hq/temp-v3-sdk 0.0.49 → 0.0.50
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/instructions/automation/rebalanceSwap.d.ts +11 -0
- package/dist/src/instructions/automation/rebalanceSwap.js +42 -0
- package/dist/src/instructions/management/edit.js +2 -1
- package/dist/src/layouts/intents/intent.js +6 -13
- package/dist/src/states/intents/intent.js +0 -1
- package/package.json +1 -1
- package/src/instructions/management/edit.ts +3 -2
- package/src/layouts/intents/intent.ts +6 -13
- package/src/states/intents/intent.ts +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BN } from '@coral-xyz/anchor';
|
|
2
|
+
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
3
|
+
export declare function rebalanceSwapIx(params: {
|
|
4
|
+
keeper: PublicKey;
|
|
5
|
+
basket: PublicKey;
|
|
6
|
+
mintFrom: PublicKey;
|
|
7
|
+
mintTo: PublicKey;
|
|
8
|
+
amountIn: BN;
|
|
9
|
+
amountOut: BN;
|
|
10
|
+
mode: number;
|
|
11
|
+
}): TransactionInstruction;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rebalanceSwapIx = rebalanceSwapIx;
|
|
4
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
5
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
6
|
+
const constants_1 = require("../../constants");
|
|
7
|
+
const pda_1 = require("../pda");
|
|
8
|
+
const REBALANCE_SWAP_DISCRIMINATOR = Buffer.from([101, 122, 61, 201, 21, 165, 177, 213]);
|
|
9
|
+
function rebalanceSwapIx(params) {
|
|
10
|
+
const { keeper, basket, mintFrom, mintTo, amountIn, amountOut, mode } = params;
|
|
11
|
+
let rebalanceIntent = (0, pda_1.getRebalanceIntentPda)(basket, keeper); // TODO: incorrect. Pass intent as func param
|
|
12
|
+
let keeperFromATA = (0, pda_1.getAta)(keeper, mintFrom);
|
|
13
|
+
let keeperToATA = (0, pda_1.getAta)(keeper, mintTo);
|
|
14
|
+
let basketFromATA = (0, pda_1.getAta)(basket, mintFrom);
|
|
15
|
+
let basketToATA = (0, pda_1.getAta)(basket, mintTo);
|
|
16
|
+
const keys = [
|
|
17
|
+
{ pubkey: params.keeper, isWritable: true, isSigner: true },
|
|
18
|
+
{ pubkey: params.basket, isWritable: true, isSigner: false },
|
|
19
|
+
{ pubkey: rebalanceIntent, isWritable: true, isSigner: false },
|
|
20
|
+
{ pubkey: params.mintFrom, isWritable: false, isSigner: false },
|
|
21
|
+
{ pubkey: params.mintTo, isWritable: false, isSigner: false },
|
|
22
|
+
{ pubkey: keeperFromATA, isWritable: true, isSigner: false },
|
|
23
|
+
{ pubkey: keeperToATA, isWritable: true, isSigner: false },
|
|
24
|
+
{ pubkey: basketFromATA, isWritable: true, isSigner: false },
|
|
25
|
+
{ pubkey: basketToATA, isWritable: true, isSigner: false },
|
|
26
|
+
{ pubkey: (0, pda_1.getGlobalConfigPda)(), isWritable: false, isSigner: false },
|
|
27
|
+
{ pubkey: web3_js_1.SystemProgram.programId, isWritable: false, isSigner: false },
|
|
28
|
+
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
29
|
+
{ pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
30
|
+
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
31
|
+
];
|
|
32
|
+
const discriminator = REBALANCE_SWAP_DISCRIMINATOR;
|
|
33
|
+
const amountInBuffer = Buffer.from(amountIn.toArray("le", 8));
|
|
34
|
+
const amountOutBuffer = Buffer.from(amountOut.toArray("le", 8));
|
|
35
|
+
const modeBuffer = Buffer.from([mode]);
|
|
36
|
+
const data = Buffer.concat([discriminator, amountInBuffer, amountOutBuffer, modeBuffer]);
|
|
37
|
+
return new web3_js_1.TransactionInstruction({
|
|
38
|
+
keys,
|
|
39
|
+
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
40
|
+
data,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -97,7 +97,7 @@ function createEditBasketIntentIx(params) {
|
|
|
97
97
|
let startIndex = 0;
|
|
98
98
|
for (let i = 0; i < config_1.MAX_MANAGERS_PER_BASKET; i++) {
|
|
99
99
|
editDataBuf.writeUInt16LE(managersWeights[i], startIndex);
|
|
100
|
-
if (managers[i]
|
|
100
|
+
if (!managers[i].equals(web3_js_1.PublicKey.default)) {
|
|
101
101
|
additionalAccounts.push({
|
|
102
102
|
pubkey: managers[i],
|
|
103
103
|
isWritable: true,
|
|
@@ -360,6 +360,7 @@ function createEditBasketIntentIx(params) {
|
|
|
360
360
|
amountFrom: new anchor_1.BN(makeDirectSwapData.amount_from),
|
|
361
361
|
amountTo: new anchor_1.BN(makeDirectSwapData.amount_to),
|
|
362
362
|
};
|
|
363
|
+
config_1.MakeDirectSwapLayout.encode(makeDirectSwap, editDataBuf);
|
|
363
364
|
break;
|
|
364
365
|
default:
|
|
365
366
|
break;
|
|
@@ -11,13 +11,6 @@ exports.INTENT_STATUS_STRINGS = new Map([
|
|
|
11
11
|
[3, "completed"],
|
|
12
12
|
]);
|
|
13
13
|
exports.TASK_TYPE_STRINGS = new Map([
|
|
14
|
-
[0, "unknown"],
|
|
15
|
-
[1, "edit_creator"],
|
|
16
|
-
[2, "edit_manager_settings"],
|
|
17
|
-
[3, "edit_fee_settings"],
|
|
18
|
-
[4, "edit_schedule_settings"],
|
|
19
|
-
[5, "edit_automation_settings"],
|
|
20
|
-
[6, "edit_lp_settings"],
|
|
21
14
|
[0, "unknown"],
|
|
22
15
|
[1, "edit_creator"],
|
|
23
16
|
[2, "edit_manager_settings"],
|
|
@@ -29,12 +22,12 @@ exports.TASK_TYPE_STRINGS = new Map([
|
|
|
29
22
|
[8, "edit_deposits_settings"],
|
|
30
23
|
[9, "edit_force_rebalance_settings"],
|
|
31
24
|
[10, "edit_custom_rebalance_settings"],
|
|
32
|
-
[
|
|
33
|
-
[
|
|
34
|
-
[
|
|
35
|
-
[
|
|
36
|
-
[
|
|
37
|
-
[
|
|
25
|
+
[11, "edit_add_token_delay"],
|
|
26
|
+
[12, "edit_update_weights_delay"],
|
|
27
|
+
[13, "edit_make_direct_swap_delay"],
|
|
28
|
+
[14, "add_token"],
|
|
29
|
+
[15, "update_weights"],
|
|
30
|
+
[16, "make_direct_swap"],
|
|
38
31
|
]);
|
|
39
32
|
exports.INTENT_TASK_DATA_SIZE = 600;
|
|
40
33
|
var IntentStatus;
|
|
@@ -24,7 +24,6 @@ const fraction_1 = require("../../layouts/fraction");
|
|
|
24
24
|
function decodeTaskDataForType(intent) {
|
|
25
25
|
let taskType = (0, intent_1.taskTypeFromU8)(intent.taskType);
|
|
26
26
|
let taskData = intent.taskData;
|
|
27
|
-
console.log("intent: ", intent);
|
|
28
27
|
switch (taskType) {
|
|
29
28
|
case intent_1.TaskType.EditCreator:
|
|
30
29
|
let editCreator = config_1.EditCreatorLayout.decode(Buffer.from(taskData.slice(0, config_1.EditCreatorLayout.getSpan())));
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
AuthorityBitmasks,
|
|
16
16
|
AuthorityBitmasksLayout,
|
|
17
17
|
AutomationSettings, AutomationSettingsLayout, EditAddTokenDelay, EditAddTokenDelayLayout, EditCreator, EditCreatorLayout, EditMakeDirectSwapDelay, EditMakeDirectSwapDelayLayout, EditUpdateWeightsDelay, EditUpdateWeightsDelayLayout, FeeSettings, FeeSettingsLayout, LpSettings,
|
|
18
|
-
LpSettingsLayout, MakeDirectSwap, ManagerSettings, ManagerSettingsLayout, MAX_MANAGERS_PER_BASKET,
|
|
18
|
+
LpSettingsLayout, MakeDirectSwap, MakeDirectSwapLayout, ManagerSettings, ManagerSettingsLayout, MAX_MANAGERS_PER_BASKET,
|
|
19
19
|
MetadataParams,
|
|
20
20
|
MetadataSettings, MetadataSettingsLayout, ScheduleSettings, ScheduleSettingsLayout,
|
|
21
21
|
UpdateWeights,
|
|
@@ -164,7 +164,7 @@ export function createEditBasketIntentIx(params: {
|
|
|
164
164
|
let startIndex = 0;
|
|
165
165
|
for (let i = 0; i < MAX_MANAGERS_PER_BASKET; i++) {
|
|
166
166
|
editDataBuf.writeUInt16LE(managersWeights[i], startIndex);
|
|
167
|
-
if (managers[i]
|
|
167
|
+
if (!managers[i].equals(PublicKey.default)) {
|
|
168
168
|
additionalAccounts.push({
|
|
169
169
|
pubkey: managers[i],
|
|
170
170
|
isWritable: true,
|
|
@@ -443,6 +443,7 @@ export function createEditBasketIntentIx(params: {
|
|
|
443
443
|
amountFrom: new BN(makeDirectSwapData.amount_from),
|
|
444
444
|
amountTo: new BN(makeDirectSwapData.amount_to),
|
|
445
445
|
}
|
|
446
|
+
MakeDirectSwapLayout.encode(makeDirectSwap, editDataBuf);
|
|
446
447
|
break;
|
|
447
448
|
|
|
448
449
|
default:
|
|
@@ -15,13 +15,6 @@ export const INTENT_STATUS_STRINGS: Map<number, FormattedIntentStatus> = new Map
|
|
|
15
15
|
|
|
16
16
|
export type FormattedTaskType = "unknown" | "edit_creator" | "edit_manager_settings" | "edit_fee_settings" | "edit_schedule_settings" | "edit_automation_settings" | "edit_lp_settings" | "edit_metadata_settings" | "edit_deposits_settings" | "edit_force_rebalance_settings" | "edit_custom_rebalance_settings" | "edit_add_token_delay" | "edit_update_weights_delay" | "edit_make_direct_swap_delay" | "add_token" | "update_weights" | "make_direct_swap";
|
|
17
17
|
export const TASK_TYPE_STRINGS: Map<number, FormattedTaskType> = new Map([
|
|
18
|
-
[0, "unknown"],
|
|
19
|
-
[1, "edit_creator"],
|
|
20
|
-
[2, "edit_manager_settings"],
|
|
21
|
-
[3, "edit_fee_settings"],
|
|
22
|
-
[4, "edit_schedule_settings"],
|
|
23
|
-
[5, "edit_automation_settings"],
|
|
24
|
-
[6, "edit_lp_settings"],
|
|
25
18
|
[0, "unknown"],
|
|
26
19
|
[1, "edit_creator"],
|
|
27
20
|
[2, "edit_manager_settings"],
|
|
@@ -33,12 +26,12 @@ export const TASK_TYPE_STRINGS: Map<number, FormattedTaskType> = new Map([
|
|
|
33
26
|
[8, "edit_deposits_settings"],
|
|
34
27
|
[9, "edit_force_rebalance_settings"],
|
|
35
28
|
[10, "edit_custom_rebalance_settings"],
|
|
36
|
-
[
|
|
37
|
-
[
|
|
38
|
-
[
|
|
39
|
-
[
|
|
40
|
-
[
|
|
41
|
-
[
|
|
29
|
+
[11, "edit_add_token_delay"],
|
|
30
|
+
[12, "edit_update_weights_delay"],
|
|
31
|
+
[13, "edit_make_direct_swap_delay"],
|
|
32
|
+
[14, "add_token"],
|
|
33
|
+
[15, "update_weights"],
|
|
34
|
+
[16, "make_direct_swap"],
|
|
42
35
|
]);
|
|
43
36
|
|
|
44
37
|
export interface FormattedBountySchedule {
|
|
@@ -16,7 +16,6 @@ import { fractionToDecimal } from '../../layouts/fraction';
|
|
|
16
16
|
function decodeTaskDataForType(intent: Intent): Settings {
|
|
17
17
|
let taskType = taskTypeFromU8(intent.taskType);
|
|
18
18
|
let taskData = intent.taskData;
|
|
19
|
-
console.log("intent: ", intent);
|
|
20
19
|
switch (taskType) {
|
|
21
20
|
case TaskType.EditCreator:
|
|
22
21
|
let editCreator: EditCreator = EditCreatorLayout.decode(Buffer.from(taskData.slice(0, EditCreatorLayout.getSpan())));
|