@helium/helium-admin-cli 0.1.2 → 0.1.3
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/lib/cjs/close-buffers.js +131 -0
- package/lib/cjs/close-buffers.js.map +1 -0
- package/lib/cjs/create-dao.js +5 -5
- package/lib/cjs/create-dao.js.map +1 -1
- package/lib/cjs/create-price-oracle.js +4 -0
- package/lib/cjs/create-price-oracle.js.map +1 -1
- package/lib/cjs/create-subdao.js +20 -17
- package/lib/cjs/create-subdao.js.map +1 -1
- package/lib/cjs/log-hotspot.js +2 -1
- package/lib/cjs/log-hotspot.js.map +1 -1
- package/lib/cjs/setup-hst.js +8 -1
- package/lib/cjs/setup-hst.js.map +1 -1
- package/lib/cjs/update-lazy-transactions.js +116 -0
- package/lib/cjs/update-lazy-transactions.js.map +1 -0
- package/lib/cjs/update-registrar-authorities.js +92 -0
- package/lib/cjs/update-registrar-authorities.js.map +1 -0
- package/lib/cjs/update-subdao-vehnt.js +109 -84
- package/lib/cjs/update-subdao-vehnt.js.map +1 -1
- package/lib/cjs/upgrade-idl.js +108 -0
- package/lib/cjs/upgrade-idl.js.map +1 -0
- package/lib/cjs/utils.js +88 -4
- package/lib/cjs/utils.js.map +1 -1
- package/lib/esm/src/close-buffers.js +90 -0
- package/lib/esm/src/close-buffers.js.map +1 -0
- package/lib/esm/src/create-dao.js +5 -5
- package/lib/esm/src/create-dao.js.map +1 -1
- package/lib/esm/src/create-price-oracle.js +5 -1
- package/lib/esm/src/create-price-oracle.js.map +1 -1
- package/lib/esm/src/create-subdao.js +20 -17
- package/lib/esm/src/create-subdao.js.map +1 -1
- package/lib/esm/src/log-hotspot.js +3 -2
- package/lib/esm/src/log-hotspot.js.map +1 -1
- package/lib/esm/src/setup-hst.js +8 -2
- package/lib/esm/src/setup-hst.js.map +1 -1
- package/lib/esm/src/update-lazy-transactions.js +75 -0
- package/lib/esm/src/update-lazy-transactions.js.map +1 -0
- package/lib/esm/src/update-registrar-authorities.js +51 -0
- package/lib/esm/src/update-registrar-authorities.js.map +1 -0
- package/lib/esm/src/update-subdao-vehnt.js +109 -84
- package/lib/esm/src/update-subdao-vehnt.js.map +1 -1
- package/lib/esm/src/upgrade-idl.js +67 -0
- package/lib/esm/src/upgrade-idl.js.map +1 -0
- package/lib/esm/src/utils.js +81 -5
- package/lib/esm/src/utils.js.map +1 -1
- package/lib/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/types/src/close-buffers.d.ts +2 -0
- package/lib/types/src/close-buffers.d.ts.map +1 -0
- package/lib/types/src/create-price-oracle.d.ts.map +1 -1
- package/lib/types/src/create-subdao.d.ts.map +1 -1
- package/lib/types/src/log-hotspot.d.ts.map +1 -1
- package/lib/types/src/setup-hst.d.ts.map +1 -1
- package/lib/types/src/update-lazy-transactions.d.ts +2 -0
- package/lib/types/src/update-lazy-transactions.d.ts.map +1 -0
- package/lib/types/src/update-registrar-authorities.d.ts +2 -0
- package/lib/types/src/update-registrar-authorities.d.ts.map +1 -0
- package/lib/types/src/update-subdao-vehnt.d.ts.map +1 -1
- package/lib/types/src/upgrade-idl.d.ts +2 -0
- package/lib/types/src/upgrade-idl.d.ts.map +1 -0
- package/lib/types/src/utils.d.ts +3 -1
- package/lib/types/src/utils.d.ts.map +1 -1
- package/package.json +11 -11
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as anchor from "@coral-xyz/anchor";
|
|
2
|
+
import { init as initLazy, lazyTransactionsKey, } from "@helium/lazy-transactions-sdk";
|
|
3
|
+
import { PublicKey } from "@solana/web3.js";
|
|
4
|
+
import Squads from "@sqds/sdk";
|
|
5
|
+
import os from "os";
|
|
6
|
+
import yargs from "yargs/yargs";
|
|
7
|
+
import { sendInstructionsOrSquads } from "./utils";
|
|
8
|
+
export async function run(args = process.argv) {
|
|
9
|
+
const yarg = yargs(args).options({
|
|
10
|
+
wallet: {
|
|
11
|
+
alias: "k",
|
|
12
|
+
describe: "Anchor wallet keypair",
|
|
13
|
+
default: `${os.homedir()}/.config/solana/id.json`,
|
|
14
|
+
},
|
|
15
|
+
url: {
|
|
16
|
+
alias: "u",
|
|
17
|
+
default: "http://127.0.0.1:8899",
|
|
18
|
+
describe: "The solana url",
|
|
19
|
+
},
|
|
20
|
+
executeTransaction: {
|
|
21
|
+
type: "boolean",
|
|
22
|
+
},
|
|
23
|
+
multisig: {
|
|
24
|
+
type: "string",
|
|
25
|
+
describe: "Address of the squads multisig to be authority. If not provided, your wallet will be the authority",
|
|
26
|
+
},
|
|
27
|
+
authorityIndex: {
|
|
28
|
+
type: "number",
|
|
29
|
+
describe: "Authority index for squads. Defaults to 1",
|
|
30
|
+
default: 1,
|
|
31
|
+
},
|
|
32
|
+
newAuthority: {
|
|
33
|
+
type: "string",
|
|
34
|
+
},
|
|
35
|
+
name: {
|
|
36
|
+
required: true,
|
|
37
|
+
type: "string",
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
const argv = await yarg.argv;
|
|
41
|
+
process.env.ANCHOR_WALLET = argv.wallet;
|
|
42
|
+
process.env.ANCHOR_PROVIDER_URL = argv.url;
|
|
43
|
+
anchor.setProvider(anchor.AnchorProvider.local(argv.url));
|
|
44
|
+
const provider = anchor.getProvider();
|
|
45
|
+
const lazyTrProgram = await initLazy(provider);
|
|
46
|
+
const [lazyTransactions] = lazyTransactionsKey(argv.name);
|
|
47
|
+
const lazyTrAcc = await lazyTrProgram.account.lazyTransactionsV0.fetch(lazyTransactions);
|
|
48
|
+
const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, provider.wallet, {
|
|
49
|
+
commitmentOrConfig: "finalized",
|
|
50
|
+
});
|
|
51
|
+
console.log(lazyTransactions.toBase58());
|
|
52
|
+
const ix = await lazyTrProgram.methods
|
|
53
|
+
.updateLazyTransactionsV0({
|
|
54
|
+
authority: argv.newAuthority
|
|
55
|
+
? new PublicKey(argv.newAuthority)
|
|
56
|
+
: lazyTrAcc.authority,
|
|
57
|
+
root: null,
|
|
58
|
+
})
|
|
59
|
+
.accounts({
|
|
60
|
+
lazyTransactions,
|
|
61
|
+
authority: lazyTrAcc.authority,
|
|
62
|
+
canopy: lazyTrAcc.canopy,
|
|
63
|
+
})
|
|
64
|
+
.instruction();
|
|
65
|
+
await sendInstructionsOrSquads({
|
|
66
|
+
provider,
|
|
67
|
+
instructions: [ix],
|
|
68
|
+
executeTransaction: argv.executeTransaction,
|
|
69
|
+
squads,
|
|
70
|
+
multisig: argv.multisig ? new PublicKey(argv.multisig) : undefined,
|
|
71
|
+
authorityIndex: argv.authorityIndex,
|
|
72
|
+
signers: [],
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=update-lazy-transactions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-lazy-transactions.js","sourceRoot":"","sources":["../../../src/update-lazy-transactions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EACL,IAAI,IAAI,QAAQ,EAChB,mBAAmB,GACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,OAAY,OAAO,CAAC,IAAI;IAChD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;QAC/B,MAAM,EAAE;YACN,KAAK,EAAE,GAAG;YACV,QAAQ,EAAE,uBAAuB;YACjC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,yBAAyB;SAClD;QACD,GAAG,EAAE;YACH,KAAK,EAAE,GAAG;YACV,OAAO,EAAE,uBAAuB;YAChC,QAA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M,aAAa,CAAC,OAAO;SACnC,wBAAwB,CAAC;QACxB,SAAS,EAAE,IAAI,CAAC,YAAY;YAC1B,CAAC,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC;YAClC,CAAC,CAAC,SAAS,CAAC,SAAS;QACvB,IAAI,EAAE,IAAI;KACX,CAAC;SACD,QAAQ,CAAC;QACR,gBAAgB;QAChB,SAAS,EAAE,SAAS,CAAC,SAAS;QAC9B,MAAM,EAAE,SAAS,CAAC,MAAM;KACzB,CAAC;SACD,WAAW,EAAE,CAAC;IAEjB,MAAM,wBAAwB,CAAC;QAC7B,QAAQ;QACR,YAAY,EAAE,CAAC,EAAE,CAAC;QAClB,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;QAC3C,MAAM;QACN,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS;QAClE,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,OAAO,EAAE,EAAE;KACZ,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as anchor from "@coral-xyz/anchor";
|
|
2
|
+
import { init } from "@helium/voter-stake-registry-sdk";
|
|
3
|
+
import { PublicKey } from "@solana/web3.js";
|
|
4
|
+
import Squads from "@sqds/sdk";
|
|
5
|
+
import os from "os";
|
|
6
|
+
import yargs from "yargs/yargs";
|
|
7
|
+
import { sendInstructionsOrSquads } from "./utils";
|
|
8
|
+
export async function run(args = process.argv) {
|
|
9
|
+
const yarg = yargs(args).options({
|
|
10
|
+
wallet: {
|
|
11
|
+
alias: "k",
|
|
12
|
+
describe: "Anchor wallet keypair",
|
|
13
|
+
default: `${os.homedir()}/.config/solana/id.json`,
|
|
14
|
+
},
|
|
15
|
+
url: {
|
|
16
|
+
alias: "u",
|
|
17
|
+
default: "http://127.0.0.1:8899",
|
|
18
|
+
describe: "The solana url",
|
|
19
|
+
},
|
|
20
|
+
registrar: {
|
|
21
|
+
type: "string",
|
|
22
|
+
required: true,
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const argv = await yarg.argv;
|
|
26
|
+
process.env.ANCHOR_WALLET = argv.wallet;
|
|
27
|
+
process.env.ANCHOR_PROVIDER_URL = argv.url;
|
|
28
|
+
anchor.setProvider(anchor.AnchorProvider.local(argv.url));
|
|
29
|
+
const provider = anchor.getProvider();
|
|
30
|
+
const vsrProgram = await init(provider);
|
|
31
|
+
const registrar = new PublicKey(argv.registrar);
|
|
32
|
+
const registrarAcc = await vsrProgram.account.registrar.fetch(registrar);
|
|
33
|
+
const instructions = [
|
|
34
|
+
await vsrProgram.methods.updateRegistrarAuthorityV0().accounts({
|
|
35
|
+
registrar,
|
|
36
|
+
realm: registrarAcc.realm,
|
|
37
|
+
realmAuthority: registrarAcc.realmAuthority,
|
|
38
|
+
}).instruction(),
|
|
39
|
+
];
|
|
40
|
+
const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, provider.wallet, {
|
|
41
|
+
commitmentOrConfig: "finalized"
|
|
42
|
+
});
|
|
43
|
+
await sendInstructionsOrSquads({
|
|
44
|
+
provider,
|
|
45
|
+
instructions,
|
|
46
|
+
executeTransaction: true,
|
|
47
|
+
squads,
|
|
48
|
+
signers: [],
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=update-registrar-authorities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-registrar-authorities.js","sourceRoot":"","sources":["../../../src/update-registrar-authorities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,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;YACT,KAAK,EAAE,YAAY,CAAC,KAAK;YACzB,cAAc,EAAE,YAAY,CAAC,cAAc;SAC5C,CAAC,CAAC,WAAW,EAAE;KACjB,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAC5B,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAC/B,QAAQ,CAAC,MAAM,EAAE;QACf,kBAAkB,EAAE,WAAW;KAChC,CACF,CAAC;IACF,MAAM,wBAAwB,CAAC;QAC7B,QAAQ;QACR,YAAY;QACZ,kBAAkB,EAAE,IAAI;QACxB,MAAM;QACN,OAAO,EAAE,EAAE;KACZ,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -2,12 +2,12 @@ import * as anchor from "@coral-xyz/anchor";
|
|
|
2
2
|
import { init as initHsd, subDaoKey } from "@helium/helium-sub-daos-sdk";
|
|
3
3
|
import { PublicKey } from "@solana/web3.js";
|
|
4
4
|
import Squads from "@sqds/sdk";
|
|
5
|
+
import AWS from "aws-sdk";
|
|
5
6
|
import { BN } from "bn.js";
|
|
6
7
|
import os from "os";
|
|
8
|
+
import { Client } from "pg";
|
|
7
9
|
import yargs from "yargs/yargs";
|
|
8
10
|
import { sendInstructionsOrSquads } from "./utils";
|
|
9
|
-
import { Client } from "pg";
|
|
10
|
-
import AWS from "aws-sdk";
|
|
11
11
|
export async function run(args = process.argv) {
|
|
12
12
|
const yarg = yargs(args).options({
|
|
13
13
|
wallet: {
|
|
@@ -47,10 +47,10 @@ export async function run(args = process.argv) {
|
|
|
47
47
|
default: "postgres",
|
|
48
48
|
},
|
|
49
49
|
pgPassword: {
|
|
50
|
-
type: "string"
|
|
50
|
+
type: "string",
|
|
51
51
|
},
|
|
52
52
|
pgDatabase: {
|
|
53
|
-
type: "string"
|
|
53
|
+
type: "string",
|
|
54
54
|
},
|
|
55
55
|
pgHost: {
|
|
56
56
|
default: "localhost",
|
|
@@ -63,8 +63,8 @@ export async function run(args = process.argv) {
|
|
|
63
63
|
},
|
|
64
64
|
noSsl: {
|
|
65
65
|
type: "boolean",
|
|
66
|
-
default: false
|
|
67
|
-
}
|
|
66
|
+
default: false,
|
|
67
|
+
},
|
|
68
68
|
});
|
|
69
69
|
const argv = await yarg.argv;
|
|
70
70
|
process.env.ANCHOR_WALLET = argv.wallet;
|
|
@@ -103,84 +103,110 @@ export async function run(args = process.argv) {
|
|
|
103
103
|
});
|
|
104
104
|
await client.connect();
|
|
105
105
|
const response = (await client.query(`WITH
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
readable_positions AS (
|
|
107
|
+
SELECT p.*,
|
|
108
|
+
r.realm_governing_token_mint,
|
|
109
|
+
cast(r.voting_mints[p.voting_mint_config_idx + 1]->>'lockupSaturationSecs' as numeric) as lockup_saturation_seconds,
|
|
110
|
+
cast(r.voting_mints[p.voting_mint_config_idx + 1]->>'maxExtraLockupVoteWeightScaledFactor' as numeric) / 1000000000 as max_extra_lockup_vote_weight_scaled_factor,
|
|
111
|
+
CASE WHEN p.genesis_end > current_ts THEN cast(r.voting_mints[p.voting_mint_config_idx + 1]->>'genesisVotePowerMultiplier' as numeric) ELSE 1 END as genesis_multiplier,
|
|
112
|
+
GREATEST(
|
|
112
113
|
cast(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
114
|
+
p.end_ts -
|
|
115
|
+
CASE WHEN lockup_kind = 'constant' THEN start_ts ELSE current_ts END
|
|
116
|
+
as numeric
|
|
117
|
+
),
|
|
118
|
+
0
|
|
119
|
+
)
|
|
120
|
+
as seconds_remaining
|
|
121
|
+
FROM (
|
|
122
|
+
SELECT *,
|
|
123
|
+
lockup->>'kind' as lockup_kind,
|
|
124
|
+
cast(lockup->>'endTs' as numeric) as end_ts,
|
|
125
|
+
cast(lockup->>'startTs' as numeric) as start_ts,
|
|
126
|
+
-- 1682373334 as current_ts
|
|
127
|
+
FLOOR(EXTRACT(EPOCH FROM CURRENT_TIMESTAMP)) as current_ts
|
|
128
|
+
FROM positions
|
|
129
|
+
) p
|
|
130
|
+
JOIN registrars r on p.registrar = r.address
|
|
131
|
+
),
|
|
132
|
+
positions_with_vehnt AS (
|
|
133
|
+
SELECT realm_governing_token_mint as mint,
|
|
134
|
+
address,
|
|
135
|
+
num_active_votes,
|
|
136
|
+
registrar,
|
|
137
|
+
refreshed_at,
|
|
138
|
+
created_at,
|
|
139
|
+
amount_deposited_native,
|
|
140
|
+
ve_tokens,
|
|
141
|
+
initial_ve_tokens,
|
|
142
|
+
CASE WHEN lockup_kind = 'constant' THEN
|
|
143
|
+
0
|
|
144
|
+
ELSE
|
|
145
|
+
CASE WHEN current_ts < genesis_end THEN
|
|
146
|
+
-- genesis
|
|
147
|
+
(ve_tokens - (
|
|
148
|
+
amount_deposited_native * (
|
|
149
|
+
LEAST(
|
|
150
|
+
(end_ts - genesis_end) / lockup_saturation_seconds,
|
|
151
|
+
1
|
|
152
|
+
) * (
|
|
153
|
+
max_extra_lockup_vote_weight_scaled_factor
|
|
154
|
+
) * genesis_multiplier
|
|
155
|
+
)
|
|
156
|
+
)
|
|
157
|
+
) / (genesis_end - current_ts)
|
|
158
|
+
ELSE
|
|
159
|
+
-- normal
|
|
160
|
+
ve_tokens / (end_ts - current_ts)
|
|
161
|
+
END
|
|
162
|
+
END as fall_rate,
|
|
163
|
+
start_ts,
|
|
164
|
+
end_ts,
|
|
165
|
+
current_ts,
|
|
166
|
+
seconds_remaining
|
|
167
|
+
FROM (
|
|
168
|
+
SELECT *,
|
|
169
|
+
amount_deposited_native * (
|
|
170
|
+
(
|
|
171
|
+
max_extra_lockup_vote_weight_scaled_factor
|
|
172
|
+
) * genesis_multiplier * LEAST(
|
|
173
|
+
seconds_remaining / lockup_saturation_seconds,
|
|
174
|
+
1
|
|
175
|
+
)
|
|
176
|
+
) as ve_tokens,
|
|
177
|
+
amount_deposited_native * (
|
|
178
|
+
(
|
|
179
|
+
max_extra_lockup_vote_weight_scaled_factor
|
|
180
|
+
) * genesis_multiplier * LEAST(
|
|
181
|
+
(end_ts - start_ts) / lockup_saturation_seconds,
|
|
182
|
+
1
|
|
175
183
|
)
|
|
176
|
-
)
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
+
) as initial_ve_tokens
|
|
185
|
+
FROM readable_positions
|
|
186
|
+
) a
|
|
187
|
+
),
|
|
188
|
+
subdao_delegations AS (
|
|
189
|
+
SELECT
|
|
190
|
+
count(*) as delegations,
|
|
191
|
+
min(current_ts) as current_ts,
|
|
192
|
+
sum(p.fall_rate) as real_fall_rate,
|
|
193
|
+
s.vehnt_fall_rate / 1000000000000 as approx_fall_rate,
|
|
194
|
+
s.dnt_mint as mint,
|
|
195
|
+
SUM(ve_tokens) as real_ve_tokens,
|
|
196
|
+
(
|
|
197
|
+
s.vehnt_delegated - (
|
|
198
|
+
(min(current_ts) - s.vehnt_last_calculated_ts)
|
|
199
|
+
* s.vehnt_fall_rate
|
|
200
|
+
)
|
|
201
|
+
) / 1000000000000 as approx_ve_tokens,
|
|
202
|
+
s.vehnt_delegated as vehnt_delegated_snapshot,
|
|
203
|
+
s.vehnt_last_calculated_ts as vehnt_last_calculated_ts
|
|
204
|
+
FROM positions_with_vehnt p
|
|
205
|
+
JOIN delegated_positions d on d.position = p.address
|
|
206
|
+
JOIN sub_daos s on s.address = d.sub_dao
|
|
207
|
+
WHERE end_ts > (floor(current_ts / (60 * 60 * 24)) * (60 * 60 * 24)) + 60 * 60 * 24
|
|
208
|
+
GROUP BY s.dnt_mint, s.vehnt_fall_rate, s.vehnt_delegated, s.vehnt_last_calculated_ts, s.vehnt_last_calculated_ts
|
|
209
|
+
)
|
|
184
210
|
SELECT
|
|
185
211
|
mint,
|
|
186
212
|
current_ts,
|
|
@@ -193,7 +219,6 @@ export async function run(args = process.argv) {
|
|
|
193
219
|
approx_ve_tokens - real_ve_tokens as ve_tokens_diff
|
|
194
220
|
FROM subdao_delegations`)).rows;
|
|
195
221
|
const row = response.find((x) => x.mint == argv.dntMint);
|
|
196
|
-
console.log("Setting", row);
|
|
197
222
|
const instructions = [];
|
|
198
223
|
const subDao = subDaoKey(new PublicKey(argv.dntMint))[0];
|
|
199
224
|
const subDaoAcc = await program.account.subDaoV0.fetch(subDao);
|
|
@@ -210,7 +235,7 @@ export async function run(args = process.argv) {
|
|
|
210
235
|
})
|
|
211
236
|
.instruction());
|
|
212
237
|
const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, provider.wallet, {
|
|
213
|
-
commitmentOrConfig: "finalized"
|
|
238
|
+
commitmentOrConfig: "finalized",
|
|
214
239
|
});
|
|
215
240
|
await sendInstructionsOrSquads({
|
|
216
241
|
provider,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-subdao-vehnt.js","sourceRoot":"","sources":["../../../src/update-subdao-vehnt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EACL,IAAI,IAAI,OAAO,EACf,SAAS,EACV,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,
|
|
1
|
+
{"version":3,"file":"update-subdao-vehnt.js","sourceRoot":"","sources":["../../../src/update-subdao-vehnt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EACL,IAAI,IAAI,OAAO,EACf,SAAS,EACV,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,GAAG,MAAM,SAAS,CAAC;AAC1B,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAGnD,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,OAAY,OAAO,CAAC,IAAI;IAChD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;QAC/B,MAAM,EAAE;YACN,KAAK,EAAE,GAAG;YACV,QAAQ,EAAE,uBAAuB;YACjC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,yBAAyB;SAClD;QACD,GAAG,EAAE;YACH,KAAK,EAAE,GAAG;YACV,OA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,CACF,CAAC;IACF,MAAM,wBAAwB,CAAC;QAC7B,QAAQ;QACR,YAAY;QACZ,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;QAC3C,MAAM;QACN,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS;QAClE,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,OAAO,EAAE,EAAE;KACZ,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as anchor from "@coral-xyz/anchor";
|
|
2
|
+
import { PublicKey } from "@solana/web3.js";
|
|
3
|
+
import Squads from "@sqds/sdk";
|
|
4
|
+
import os from "os";
|
|
5
|
+
import yargs from "yargs/yargs";
|
|
6
|
+
import { createIdlUpgradeInstruction, sendInstructionsOrSquads, } from "./utils";
|
|
7
|
+
export async function run(args = process.argv) {
|
|
8
|
+
const yarg = yargs(args).options({
|
|
9
|
+
wallet: {
|
|
10
|
+
alias: "k",
|
|
11
|
+
describe: "Anchor wallet keypair",
|
|
12
|
+
default: `${os.homedir()}/.config/solana/id.json`,
|
|
13
|
+
},
|
|
14
|
+
url: {
|
|
15
|
+
alias: "u",
|
|
16
|
+
default: "http://127.0.0.1:8899",
|
|
17
|
+
describe: "The solana url",
|
|
18
|
+
},
|
|
19
|
+
executeTransaction: {
|
|
20
|
+
type: "boolean",
|
|
21
|
+
},
|
|
22
|
+
multisig: {
|
|
23
|
+
type: "string",
|
|
24
|
+
describe: "Address of the squads multisig to be authority. If not provided, your wallet will be the authority",
|
|
25
|
+
},
|
|
26
|
+
authorityIndex: {
|
|
27
|
+
type: "number",
|
|
28
|
+
describe: "Authority index for squads. Defaults to 1",
|
|
29
|
+
default: 1,
|
|
30
|
+
},
|
|
31
|
+
programId: {
|
|
32
|
+
type: "string",
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
bufferId: {
|
|
36
|
+
type: "string",
|
|
37
|
+
required: true
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const argv = await yarg.argv;
|
|
41
|
+
process.env.ANCHOR_WALLET = argv.wallet;
|
|
42
|
+
process.env.ANCHOR_PROVIDER_URL = argv.url;
|
|
43
|
+
anchor.setProvider(anchor.AnchorProvider.local(argv.url));
|
|
44
|
+
const provider = anchor.getProvider();
|
|
45
|
+
const connection = provider.connection;
|
|
46
|
+
const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, provider.wallet, {
|
|
47
|
+
commitmentOrConfig: "finalized",
|
|
48
|
+
});
|
|
49
|
+
let authority = provider.wallet.publicKey;
|
|
50
|
+
let multisig = argv.multisig ? new PublicKey(argv.multisig) : null;
|
|
51
|
+
if (multisig) {
|
|
52
|
+
authority = squads.getAuthorityPDA(multisig, argv.authorityIndex);
|
|
53
|
+
}
|
|
54
|
+
console.log(authority.toBase58());
|
|
55
|
+
await sendInstructionsOrSquads({
|
|
56
|
+
provider,
|
|
57
|
+
instructions: [
|
|
58
|
+
await createIdlUpgradeInstruction(new PublicKey(argv.programId), new PublicKey(argv.bufferId), authority)
|
|
59
|
+
],
|
|
60
|
+
executeTransaction: argv.executeTransaction,
|
|
61
|
+
squads,
|
|
62
|
+
multisig: argv.multisig ? new PublicKey(argv.multisig) : undefined,
|
|
63
|
+
authorityIndex: argv.authorityIndex,
|
|
64
|
+
signers: [],
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=upgrade-idl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade-idl.js","sourceRoot":"","sources":["../../../src/upgrade-idl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,CAAC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,UAAU,CAAC;IACvC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAC5B,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAC/B,QAAQ,CAAC,MAAM,EACf;QACE,kBAAkB,EAAE,WAAW;KAChC,CACF,CAAC;IACF,IAAI,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC;IAC1C,IAAI,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACnE,IAAI,QAAQ,EAAE;QACZ,SAAS,GAAG,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;KACnE;IACD,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;IAClC,MAAM,wBAAwB,CAAC;QAC7B,QAAQ;QACR,YAAY,EAAE;YACZ,MAAM,2BAA2B,CAC/B,IAAI,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,EAC7B,IAAI,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAC5B,SAAS,CACV;SACF;QACD,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;QAC3C,MAAM;QACN,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS;QAClE,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,OAAO,EAAE,EAAE;KACZ,CAAC,CAAC;AACL,CAAC"}
|
package/lib/esm/src/utils.js
CHANGED
|
@@ -1,15 +1,44 @@
|
|
|
1
1
|
import * as anchor from "@coral-xyz/anchor";
|
|
2
|
+
import { idlAddress } from "@coral-xyz/anchor/dist/cjs/idl";
|
|
2
3
|
import { createAtaAndMintInstructions, createMintInstructions, sendInstructions, toBN, } from "@helium/spl-utils";
|
|
3
4
|
import { createCreateMetadataAccountV3Instruction, PROGRAM_ID as METADATA_PROGRAM_ID, } from "@metaplex-foundation/mpl-token-metadata";
|
|
4
|
-
import { AccountMetaData, getGovernanceProgramVersion, getProposalTransactionAddress, getTokenOwnerRecordAddress, Governance, GovernanceAccountParser, InstructionData, ProposalTransaction, Realm, Vote, VoteType, withAddSignatory, withCastVote, withCreateProposal, withCreateTokenOwnerRecord, withDepositGoverningTokens, withExecuteTransaction, withInsertTransaction, withRelinquishVote, withSignOffProposal, withWithdrawGoverningTokens, YesNoVote, } from "@solana/spl-governance";
|
|
5
|
+
import { AccountMetaData, BPF_UPGRADE_LOADER_ID, getGovernanceProgramVersion, getProposalTransactionAddress, getTokenOwnerRecordAddress, Governance, GovernanceAccountParser, InstructionData, ProposalTransaction, Realm, Vote, VoteType, withAddSignatory, withCastVote, withCreateProposal, withCreateTokenOwnerRecord, withDepositGoverningTokens, withExecuteTransaction, withInsertTransaction, withRelinquishVote, withSignOffProposal, withWithdrawGoverningTokens, YesNoVote, } from "@solana/spl-governance";
|
|
5
6
|
import { AuthorityType, createSetAuthorityInstruction, getAssociatedTokenAddress, } from "@solana/spl-token";
|
|
6
|
-
import { AddressLookupTableProgram, ComputeBudgetProgram, Keypair, PublicKey, SYSVAR_CLOCK_PUBKEY, TransactionMessage, VersionedTransaction, } from "@solana/web3.js";
|
|
7
|
+
import { AddressLookupTableProgram, ComputeBudgetProgram, Keypair, PublicKey, SYSVAR_CLOCK_PUBKEY, SYSVAR_RENT_PUBKEY, TransactionInstruction, TransactionMessage, VersionedTransaction, } from "@solana/web3.js";
|
|
7
8
|
import { OracleJob, sleep } from "@switchboard-xyz/common";
|
|
8
9
|
import { AggregatorHistoryBuffer, QueueAccount, SwitchboardProgram, } from "@switchboard-xyz/solana.js";
|
|
9
10
|
import { BN } from "bn.js";
|
|
10
11
|
import fs from "fs";
|
|
11
12
|
import fetch from "node-fetch";
|
|
12
13
|
const SECONDS_PER_DAY = 86400;
|
|
14
|
+
export async function createIdlUpgradeInstruction(programId, bufferAddress, upgradeAuthority) {
|
|
15
|
+
const prefix = Buffer.from("0a69e9a778bcf440", "hex");
|
|
16
|
+
const ixn = Buffer.from("03", "hex");
|
|
17
|
+
const data = Buffer.concat([prefix.reverse(), ixn]);
|
|
18
|
+
const idlAddr = await idlAddress(programId);
|
|
19
|
+
const keys = [
|
|
20
|
+
{
|
|
21
|
+
pubkey: bufferAddress,
|
|
22
|
+
isWritable: true,
|
|
23
|
+
isSigner: false,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
pubkey: idlAddr,
|
|
27
|
+
isWritable: true,
|
|
28
|
+
isSigner: false,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
pubkey: upgradeAuthority,
|
|
32
|
+
isWritable: true,
|
|
33
|
+
isSigner: true,
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
return new TransactionInstruction({
|
|
37
|
+
keys,
|
|
38
|
+
programId,
|
|
39
|
+
data,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
13
42
|
export const getTimestampFromDays = (days) => days * SECONDS_PER_DAY;
|
|
14
43
|
export const getUnixTimestamp = async (provider) => {
|
|
15
44
|
const clock = await provider.connection.getAccountInfo(SYSVAR_CLOCK_PUBKEY);
|
|
@@ -19,6 +48,17 @@ export const getUnixTimestamp = async (provider) => {
|
|
|
19
48
|
export async function exists(connection, account) {
|
|
20
49
|
return Boolean(await connection.getAccountInfo(account));
|
|
21
50
|
}
|
|
51
|
+
async function withRetries(tries, input) {
|
|
52
|
+
for (let i = 0; i < tries; i++) {
|
|
53
|
+
try {
|
|
54
|
+
return await input();
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
console.log(`Retrying ${i}...`, e);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
throw new Error("Failed after retries");
|
|
61
|
+
}
|
|
22
62
|
export async function createAndMint({ provider, mintKeypair = Keypair.generate(), amount, metadataUrl, decimals = 8, to, mintAuthority = provider.wallet.publicKey, freezeAuthority = provider.wallet.publicKey, updateAuthority = provider.wallet.publicKey, }) {
|
|
23
63
|
const mintTo = to || provider.wallet.publicKey;
|
|
24
64
|
const metadata = await fetch(metadataUrl).then((r) => r.json());
|
|
@@ -252,6 +292,42 @@ export async function createSwitchboardAggregator({ provider, aggKeypair, url, s
|
|
|
252
292
|
}
|
|
253
293
|
return aggKeypair.publicKey;
|
|
254
294
|
}
|
|
295
|
+
export async function createCloseBufferInstruction(programId, bufferAddress, upgradeAuthority, recipientAddress) {
|
|
296
|
+
const bpfUpgradableLoaderId = BPF_UPGRADE_LOADER_ID;
|
|
297
|
+
const [programDataAddress] = await PublicKey.findProgramAddress([programId.toBuffer()], bpfUpgradableLoaderId);
|
|
298
|
+
const keys = [
|
|
299
|
+
{
|
|
300
|
+
pubkey: bufferAddress,
|
|
301
|
+
isWritable: true,
|
|
302
|
+
isSigner: false,
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
pubkey: recipientAddress,
|
|
306
|
+
isWritable: true,
|
|
307
|
+
isSigner: false,
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
pubkey: upgradeAuthority,
|
|
311
|
+
isWritable: false,
|
|
312
|
+
isSigner: true,
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
pubkey: programDataAddress,
|
|
316
|
+
isWritable: false,
|
|
317
|
+
isSigner: false,
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
pubkey: SYSVAR_RENT_PUBKEY,
|
|
321
|
+
isWritable: false,
|
|
322
|
+
isSigner: false,
|
|
323
|
+
},
|
|
324
|
+
];
|
|
325
|
+
return new TransactionInstruction({
|
|
326
|
+
keys,
|
|
327
|
+
programId: bpfUpgradableLoaderId,
|
|
328
|
+
data: Buffer.from([5, 0, 0, 0]), // Upgrade instruction bincode
|
|
329
|
+
});
|
|
330
|
+
}
|
|
255
331
|
export async function sendInstructionsOrSquads({ provider, instructions, signers = [], payer = provider.wallet.publicKey, commitment = "confirmed", idlErrors = new Map(), executeTransaction = false, squads, multisig, authorityIndex, }) {
|
|
256
332
|
if (!multisig) {
|
|
257
333
|
return await sendInstructions(provider, instructions, signers, payer, commitment, idlErrors);
|
|
@@ -271,11 +347,11 @@ export async function sendInstructionsOrSquads({ provider, instructions, signers
|
|
|
271
347
|
}
|
|
272
348
|
const tx = await squads.createTransaction(multisig, authorityIndex);
|
|
273
349
|
for (const ix of instructions.filter(ix => !ix.programId.equals(ComputeBudgetProgram.programId))) {
|
|
274
|
-
await squads.addInstruction(tx.publicKey, ix);
|
|
350
|
+
await withRetries(3, async () => await squads.addInstruction(tx.publicKey, ix));
|
|
275
351
|
}
|
|
276
|
-
await squads.activateTransaction(tx.publicKey);
|
|
352
|
+
await withRetries(3, async () => await squads.activateTransaction(tx.publicKey));
|
|
353
|
+
await withRetries(3, async () => await squads.approveTransaction(tx.publicKey));
|
|
277
354
|
if (executeTransaction) {
|
|
278
|
-
await squads.approveTransaction(tx.publicKey);
|
|
279
355
|
const ix = await squads.buildExecuteTransaction(tx.publicKey, provider.wallet.publicKey);
|
|
280
356
|
await sendInstructions(provider, [ComputeBudgetProgram.setComputeUnitLimit({ units: 800000 }), ix], signers);
|
|
281
357
|
}
|