-
Notifications
You must be signed in to change notification settings - Fork 30
/
CombineVault.go
345 lines (308 loc) · 14.5 KB
/
CombineVault.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT.
package token_vault
import (
"errors"
ag_binary "github.com/gagliardetto/binary"
ag_solanago "github.com/gagliardetto/solana-go"
ag_format "github.com/gagliardetto/solana-go/text/format"
ag_treeout "github.com/gagliardetto/treeout"
)
// This act checks the external pricing oracle for permission to combine and the price of the circulating market cap to do so.
// If you can afford it, this amount is charged and placed into the redeem treasury for shareholders to redeem at a later time.
// The treasury then unlocks into Combine state and you can remove the tokens.
type CombineVault struct {
// [0] = [WRITE] initializedActivatedTokenVault
// ··········· Initialized activated token vault
//
// [1] = [WRITE] tokenAccount
// ··········· Token account containing your portion of the outstanding fraction shares
//
// [2] = [WRITE] redeemTreasuryMintTypeTokenAccount
// ··········· Token account of the redeem_treasury mint type that you will pay with
//
// [3] = [WRITE] fractionMint
// ··········· Fraction mint
//
// [4] = [WRITE] fractionTreasury
// ··········· Fraction treasury account
//
// [5] = [WRITE] redeemTreasury
// ··········· Redeem treasury account
//
// [6] = [] newAuthorityOnTheVault
// ··········· New authority on the vault going forward - can be same authority if you want
//
// [7] = [SIGNER] vaultAuthority
// ··········· Authority on the vault
//
// [8] = [SIGNER] transferAuthority
// ··········· Transfer authority for the token account and outstanding fractional shares account you're transferring from
//
// [9] = [] pdaBasedBurnAuthority
// ··········· PDA-based Burn authority for the fraction treasury account containing the uncirculated shares seed [PREFIX, program_id]
//
// [10] = [] externalPricingLookupAddress
// ··········· External pricing lookup address
//
// [11] = [] tokenProgram
// ··········· Token program
ag_solanago.AccountMetaSlice `bin:"-"`
}
// NewCombineVaultInstructionBuilder creates a new `CombineVault` instruction builder.
func NewCombineVaultInstructionBuilder() *CombineVault {
nd := &CombineVault{
AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 12),
}
return nd
}
// SetInitializedActivatedTokenVaultAccount sets the "initializedActivatedTokenVault" account.
// Initialized activated token vault
func (inst *CombineVault) SetInitializedActivatedTokenVaultAccount(initializedActivatedTokenVault ag_solanago.PublicKey) *CombineVault {
inst.AccountMetaSlice[0] = ag_solanago.Meta(initializedActivatedTokenVault).WRITE()
return inst
}
// GetInitializedActivatedTokenVaultAccount gets the "initializedActivatedTokenVault" account.
// Initialized activated token vault
func (inst *CombineVault) GetInitializedActivatedTokenVaultAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(0)
}
// SetTokenAccount sets the "tokenAccount" account.
// Token account containing your portion of the outstanding fraction shares
func (inst *CombineVault) SetTokenAccount(tokenAccount ag_solanago.PublicKey) *CombineVault {
inst.AccountMetaSlice[1] = ag_solanago.Meta(tokenAccount).WRITE()
return inst
}
// GetTokenAccount gets the "tokenAccount" account.
// Token account containing your portion of the outstanding fraction shares
func (inst *CombineVault) GetTokenAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(1)
}
// SetRedeemTreasuryMintTypeTokenAccount sets the "redeemTreasuryMintTypeTokenAccount" account.
// Token account of the redeem_treasury mint type that you will pay with
func (inst *CombineVault) SetRedeemTreasuryMintTypeTokenAccount(redeemTreasuryMintTypeTokenAccount ag_solanago.PublicKey) *CombineVault {
inst.AccountMetaSlice[2] = ag_solanago.Meta(redeemTreasuryMintTypeTokenAccount).WRITE()
return inst
}
// GetRedeemTreasuryMintTypeTokenAccount gets the "redeemTreasuryMintTypeTokenAccount" account.
// Token account of the redeem_treasury mint type that you will pay with
func (inst *CombineVault) GetRedeemTreasuryMintTypeTokenAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(2)
}
// SetFractionMintAccount sets the "fractionMint" account.
// Fraction mint
func (inst *CombineVault) SetFractionMintAccount(fractionMint ag_solanago.PublicKey) *CombineVault {
inst.AccountMetaSlice[3] = ag_solanago.Meta(fractionMint).WRITE()
return inst
}
// GetFractionMintAccount gets the "fractionMint" account.
// Fraction mint
func (inst *CombineVault) GetFractionMintAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(3)
}
// SetFractionTreasuryAccount sets the "fractionTreasury" account.
// Fraction treasury account
func (inst *CombineVault) SetFractionTreasuryAccount(fractionTreasury ag_solanago.PublicKey) *CombineVault {
inst.AccountMetaSlice[4] = ag_solanago.Meta(fractionTreasury).WRITE()
return inst
}
// GetFractionTreasuryAccount gets the "fractionTreasury" account.
// Fraction treasury account
func (inst *CombineVault) GetFractionTreasuryAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(4)
}
// SetRedeemTreasuryAccount sets the "redeemTreasury" account.
// Redeem treasury account
func (inst *CombineVault) SetRedeemTreasuryAccount(redeemTreasury ag_solanago.PublicKey) *CombineVault {
inst.AccountMetaSlice[5] = ag_solanago.Meta(redeemTreasury).WRITE()
return inst
}
// GetRedeemTreasuryAccount gets the "redeemTreasury" account.
// Redeem treasury account
func (inst *CombineVault) GetRedeemTreasuryAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(5)
}
// SetNewAuthorityOnTheVaultAccount sets the "newAuthorityOnTheVault" account.
// New authority on the vault going forward - can be same authority if you want
func (inst *CombineVault) SetNewAuthorityOnTheVaultAccount(newAuthorityOnTheVault ag_solanago.PublicKey) *CombineVault {
inst.AccountMetaSlice[6] = ag_solanago.Meta(newAuthorityOnTheVault)
return inst
}
// GetNewAuthorityOnTheVaultAccount gets the "newAuthorityOnTheVault" account.
// New authority on the vault going forward - can be same authority if you want
func (inst *CombineVault) GetNewAuthorityOnTheVaultAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(6)
}
// SetVaultAuthorityAccount sets the "vaultAuthority" account.
// Authority on the vault
func (inst *CombineVault) SetVaultAuthorityAccount(vaultAuthority ag_solanago.PublicKey) *CombineVault {
inst.AccountMetaSlice[7] = ag_solanago.Meta(vaultAuthority).SIGNER()
return inst
}
// GetVaultAuthorityAccount gets the "vaultAuthority" account.
// Authority on the vault
func (inst *CombineVault) GetVaultAuthorityAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(7)
}
// SetTransferAuthorityAccount sets the "transferAuthority" account.
// Transfer authority for the token account and outstanding fractional shares account you're transferring from
func (inst *CombineVault) SetTransferAuthorityAccount(transferAuthority ag_solanago.PublicKey) *CombineVault {
inst.AccountMetaSlice[8] = ag_solanago.Meta(transferAuthority).SIGNER()
return inst
}
// GetTransferAuthorityAccount gets the "transferAuthority" account.
// Transfer authority for the token account and outstanding fractional shares account you're transferring from
func (inst *CombineVault) GetTransferAuthorityAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(8)
}
// SetPdaBasedBurnAuthorityAccount sets the "pdaBasedBurnAuthority" account.
// PDA-based Burn authority for the fraction treasury account containing the uncirculated shares seed [PREFIX, program_id]
func (inst *CombineVault) SetPdaBasedBurnAuthorityAccount(pdaBasedBurnAuthority ag_solanago.PublicKey) *CombineVault {
inst.AccountMetaSlice[9] = ag_solanago.Meta(pdaBasedBurnAuthority)
return inst
}
// GetPdaBasedBurnAuthorityAccount gets the "pdaBasedBurnAuthority" account.
// PDA-based Burn authority for the fraction treasury account containing the uncirculated shares seed [PREFIX, program_id]
func (inst *CombineVault) GetPdaBasedBurnAuthorityAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(9)
}
// SetExternalPricingLookupAddressAccount sets the "externalPricingLookupAddress" account.
// External pricing lookup address
func (inst *CombineVault) SetExternalPricingLookupAddressAccount(externalPricingLookupAddress ag_solanago.PublicKey) *CombineVault {
inst.AccountMetaSlice[10] = ag_solanago.Meta(externalPricingLookupAddress)
return inst
}
// GetExternalPricingLookupAddressAccount gets the "externalPricingLookupAddress" account.
// External pricing lookup address
func (inst *CombineVault) GetExternalPricingLookupAddressAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(10)
}
// SetTokenProgramAccount sets the "tokenProgram" account.
// Token program
func (inst *CombineVault) SetTokenProgramAccount(tokenProgram ag_solanago.PublicKey) *CombineVault {
inst.AccountMetaSlice[11] = ag_solanago.Meta(tokenProgram)
return inst
}
// GetTokenProgramAccount gets the "tokenProgram" account.
// Token program
func (inst *CombineVault) GetTokenProgramAccount() *ag_solanago.AccountMeta {
return inst.AccountMetaSlice.Get(11)
}
func (inst CombineVault) Build() *Instruction {
return &Instruction{BaseVariant: ag_binary.BaseVariant{
Impl: inst,
TypeID: ag_binary.TypeIDFromUint8(Instruction_CombineVault),
}}
}
// ValidateAndBuild validates the instruction parameters and accounts;
// if there is a validation error, it returns the error.
// Otherwise, it builds and returns the instruction.
func (inst CombineVault) ValidateAndBuild() (*Instruction, error) {
if err := inst.Validate(); err != nil {
return nil, err
}
return inst.Build(), nil
}
func (inst *CombineVault) Validate() error {
// Check whether all (required) accounts are set:
{
if inst.AccountMetaSlice[0] == nil {
return errors.New("accounts.InitializedActivatedTokenVault is not set")
}
if inst.AccountMetaSlice[1] == nil {
return errors.New("accounts.TokenAccount is not set")
}
if inst.AccountMetaSlice[2] == nil {
return errors.New("accounts.RedeemTreasuryMintTypeTokenAccount is not set")
}
if inst.AccountMetaSlice[3] == nil {
return errors.New("accounts.FractionMint is not set")
}
if inst.AccountMetaSlice[4] == nil {
return errors.New("accounts.FractionTreasury is not set")
}
if inst.AccountMetaSlice[5] == nil {
return errors.New("accounts.RedeemTreasury is not set")
}
if inst.AccountMetaSlice[6] == nil {
return errors.New("accounts.NewAuthorityOnTheVault is not set")
}
if inst.AccountMetaSlice[7] == nil {
return errors.New("accounts.VaultAuthority is not set")
}
if inst.AccountMetaSlice[8] == nil {
return errors.New("accounts.TransferAuthority is not set")
}
if inst.AccountMetaSlice[9] == nil {
return errors.New("accounts.PdaBasedBurnAuthority is not set")
}
if inst.AccountMetaSlice[10] == nil {
return errors.New("accounts.ExternalPricingLookupAddress is not set")
}
if inst.AccountMetaSlice[11] == nil {
return errors.New("accounts.TokenProgram is not set")
}
}
return nil
}
func (inst *CombineVault) EncodeToTree(parent ag_treeout.Branches) {
parent.Child(ag_format.Program(ProgramName, ProgramID)).
//
ParentFunc(func(programBranch ag_treeout.Branches) {
programBranch.Child(ag_format.Instruction("CombineVault")).
//
ParentFunc(func(instructionBranch ag_treeout.Branches) {
// Parameters of the instruction:
instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {})
// Accounts of the instruction:
instructionBranch.Child("Accounts[len=12]").ParentFunc(func(accountsBranch ag_treeout.Branches) {
accountsBranch.Child(ag_format.Meta("initializedActivatedTokenVault", inst.AccountMetaSlice.Get(0)))
accountsBranch.Child(ag_format.Meta(" token", inst.AccountMetaSlice.Get(1)))
accountsBranch.Child(ag_format.Meta(" redeemTreasuryMintTypeToken", inst.AccountMetaSlice.Get(2)))
accountsBranch.Child(ag_format.Meta(" fractionMint", inst.AccountMetaSlice.Get(3)))
accountsBranch.Child(ag_format.Meta(" fractionTreasury", inst.AccountMetaSlice.Get(4)))
accountsBranch.Child(ag_format.Meta(" redeemTreasury", inst.AccountMetaSlice.Get(5)))
accountsBranch.Child(ag_format.Meta(" newAuthorityOnTheVault", inst.AccountMetaSlice.Get(6)))
accountsBranch.Child(ag_format.Meta(" vaultAuthority", inst.AccountMetaSlice.Get(7)))
accountsBranch.Child(ag_format.Meta(" transferAuthority", inst.AccountMetaSlice.Get(8)))
accountsBranch.Child(ag_format.Meta(" pdaBasedBurnAuthority", inst.AccountMetaSlice.Get(9)))
accountsBranch.Child(ag_format.Meta(" externalPricingLookupAddress", inst.AccountMetaSlice.Get(10)))
accountsBranch.Child(ag_format.Meta(" tokenProgram", inst.AccountMetaSlice.Get(11)))
})
})
})
}
func (obj CombineVault) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) {
return nil
}
func (obj *CombineVault) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) {
return nil
}
// NewCombineVaultInstruction declares a new CombineVault instruction with the provided parameters and accounts.
func NewCombineVaultInstruction(
// Accounts:
initializedActivatedTokenVault ag_solanago.PublicKey,
tokenAccount ag_solanago.PublicKey,
redeemTreasuryMintTypeTokenAccount ag_solanago.PublicKey,
fractionMint ag_solanago.PublicKey,
fractionTreasury ag_solanago.PublicKey,
redeemTreasury ag_solanago.PublicKey,
newAuthorityOnTheVault ag_solanago.PublicKey,
vaultAuthority ag_solanago.PublicKey,
transferAuthority ag_solanago.PublicKey,
pdaBasedBurnAuthority ag_solanago.PublicKey,
externalPricingLookupAddress ag_solanago.PublicKey,
tokenProgram ag_solanago.PublicKey) *CombineVault {
return NewCombineVaultInstructionBuilder().
SetInitializedActivatedTokenVaultAccount(initializedActivatedTokenVault).
SetTokenAccount(tokenAccount).
SetRedeemTreasuryMintTypeTokenAccount(redeemTreasuryMintTypeTokenAccount).
SetFractionMintAccount(fractionMint).
SetFractionTreasuryAccount(fractionTreasury).
SetRedeemTreasuryAccount(redeemTreasury).
SetNewAuthorityOnTheVaultAccount(newAuthorityOnTheVault).
SetVaultAuthorityAccount(vaultAuthority).
SetTransferAuthorityAccount(transferAuthority).
SetPdaBasedBurnAuthorityAccount(pdaBasedBurnAuthority).
SetExternalPricingLookupAddressAccount(externalPricingLookupAddress).
SetTokenProgramAccount(tokenProgram)
}