11import { Command } from 'commander' ;
2- import { Registrar , EarnAuthority , WinstonLogger , PROGRAM_ID , TransactionBuilder } from '@m0-foundation/solana-m-sdk' ;
2+ import { EarnAuthority , WinstonLogger , TransactionBuilder } from '@m0-foundation/solana-m-sdk' ;
33import {
44 ComputeBudgetProgram ,
55 PublicKey ,
@@ -46,13 +46,11 @@ export interface ParsedOptions extends EnvOptions {
4646
4747// all programs and extensions that require yield distribution
4848const programsMainnet = [
49- PROGRAM_ID ,
5049 new PublicKey ( 'wMXX1K1nca5W4pZr1piETe78gcAVVrEFi9f4g46uXko' ) , // wM
5150 new PublicKey ( 'extMahs9bUFMYcviKCvnSRaXgs5PcqmMzcnHRtTqE85' ) , // USDKY
5251] ;
5352
5453const programsDevnet = [
55- PROGRAM_ID ,
5654 new PublicKey ( 'wMXX1K1nca5W4pZr1piETe78gcAVVrEFi9f4g46uXko' ) , // wM
5755 new PublicKey ( '3PskKTHgboCbUSQPMcCAZdZNFHbNvSoZ8zEFYANCdob7' ) , // USDKY
5856 new PublicKey ( 'extUkDFf3HLekkxbcZ3XRUizMjbxMJgKBay3p9xGVmg' ) , // Fuse USD
@@ -81,9 +79,6 @@ export async function yieldCLI() {
8179
8280 if ( ! options . isDevnet ) await validation ( options ) ;
8381
84- // pre-yield actions
85- await removeEarners ( options ) ;
86-
8782 // distribute yield for each program
8883 for ( const pid of env . isDevnet ? programsDevnet : programsMainnet ) {
8984 logger . addMetaField ( 'programId' , pid . toBase58 ( ) ) ;
@@ -97,9 +92,6 @@ export async function yieldCLI() {
9792 // wait interval to ensure transactions from previous steps have landed
9893 await new Promise ( ( resolve ) => setTimeout ( resolve , 5000 ) ) ;
9994 }
100-
101- // post-yield actions
102- await addEarners ( options ) ;
10395 } catch ( error : any ) {
10496 logger . error ( error ) ;
10597 slackMessage . level = 'error' ;
@@ -111,12 +103,12 @@ export async function yieldCLI() {
111103}
112104
113105async function validation ( opt : ParsedOptions ) {
114- const auth = await EarnAuthority . load ( opt . connection , opt . evmClient , PROGRAM_ID , logger ) ;
106+ const auth = await EarnAuthority . load ( opt . connection , programsMainnet [ 0 ] , logger ) ;
115107 await validateDatabaseData ( auth , opt . apiEnvornment ) ;
116108}
117109
118110async function distributeYield ( opt : ParsedOptions , programID : PublicKey ) : Promise < void > {
119- const auth = await EarnAuthority . load ( opt . connection , opt . evmClient , programID , logger ) ;
111+ const auth = await EarnAuthority . load ( opt . connection , programID , logger ) ;
120112
121113 if ( auth [ 'global' ] . claimComplete ) {
122114 logger . info ( 'claim cycle already complete' ) ;
@@ -156,14 +148,9 @@ async function distributeYield(opt: ParsedOptions, programID: PublicKey): Promis
156148 } ) ;
157149 }
158150
159- // complete cycle after distribution if applicable
160- const completeClaimIx = await auth . buildCompleteClaimCycleInstruction ( ) ;
161- if ( completeClaimIx ) ixs . push ( completeClaimIx ) ;
162-
163151 logger . info ( 'distribution instructions' , {
164152 claimIxs,
165153 hasSync : ! ! syncIndexIx ,
166- hasComplete : ! ! completeClaimIx ,
167154 } ) ;
168155
169156 // send transaction
@@ -173,42 +160,6 @@ async function distributeYield(opt: ParsedOptions, programID: PublicKey): Promis
173160 return ;
174161}
175162
176- async function addEarners ( opt : ParsedOptions ) {
177- logger . info ( 'adding earners' ) ;
178- const registrar = new Registrar ( opt . connection , opt . evmClient , logger ) ;
179-
180- const signer = opt . squads ? opt . squads . squadsVault : opt . signerPubkey ;
181- const instructions = await registrar . buildMissingEarnersInstructions ( signer , opt . merkleTreeAddress ) ;
182-
183- if ( instructions . length === 0 ) {
184- logger . info ( 'no earners to add' ) ;
185- return ;
186- }
187-
188- const signature = await buildAndSendTransaction ( opt , instructions , 10 , 'adding earners' ) ;
189- logger . info ( 'added earners' , { signature, earners : instructions . length } ) ;
190- slackMessage . messages . push ( `Added ${ instructions . length } earners` ) ;
191- }
192-
193- async function removeEarners ( opt : ParsedOptions ) {
194- logger . info ( 'removing earners' ) ;
195- const registrar = new Registrar ( opt . connection , opt . evmClient , logger ) ;
196-
197- const signer = opt . squads ? opt . squads . squadsVault : opt . signerPubkey ;
198- const instructions = await registrar . buildRemovedEarnersInstructions ( signer , opt . merkleTreeAddress ) ;
199-
200- if ( instructions . length === 0 ) {
201- logger . info ( 'no earners to remove' ) ;
202- return ;
203- }
204-
205- const signature = await buildAndSendTransaction ( opt , instructions , 10 , 'removing earners' ) ;
206- logger . info ( 'removed earners' , { signature, earners : instructions . length } ) ;
207- slackMessage . messages . push ( `Removed ${ instructions . length } earners` ) ;
208-
209- return ;
210- }
211-
212163async function buildAndSendTransaction (
213164 opt : ParsedOptions ,
214165 ixs : TransactionInstruction [ ] ,
0 commit comments