@@ -89,72 +89,123 @@ export abstract class BackstopContract extends Contract {
8989 donate : ( ) => { } ,
9090 } ;
9191
92+ /**
93+ * Deposits backstop tokens from an address into the backstop of a pool.
94+ *
95+ * @param contractArgs - The arguments required for the deposit.
96+ * @param contractArgs.from - The address depositing into the backstop.
97+ * @param contractArgs.pool_address - The address of the pool.
98+ * @param contractArgs.amount - The amount of tokens to deposit.
99+ *
100+ * @returns A base64-encoded string representing the operation that must be submitted in a transaction.
101+ */
92102 deposit ( contractArgs : PoolBackstopActionArgs ) : string {
93103 return this . call (
94104 'deposit' ,
95105 ...BackstopContract . spec . funcArgsToScVals ( 'deposit' , contractArgs )
96106 ) . toXDR ( 'base64' ) ;
97107 }
98108
109+ /**
110+ * Queues deposited pool shares for withdrawal from a backstop of a pool.
111+ *
112+ * @param contractArgs - The arguments required for queuing a withdrawal.
113+ * @param contractArgs.from - The address whose deposits are being queued for withdrawal.
114+ * @param contractArgs.pool_address - The address of the pool.
115+ * @param contractArgs.amount - The amount of shares to queue for withdrawal.
116+ *
117+ * @returns A base64-encoded string representing the operation.
118+ */
99119 queueWithdrawal ( contractArgs : PoolBackstopActionArgs ) : string {
100120 return this . call (
101121 'queue_withdrawal' ,
102122 ...BackstopContract . spec . funcArgsToScVals ( 'queue_withdrawal' , contractArgs )
103123 ) . toXDR ( 'base64' ) ;
104124 }
105125
126+ /**
127+ * Dequeues a currently queued pool share withdrawal from the backstop of a pool.
128+ *
129+ * @param contractArgs - The arguments required for dequeuing a withdrawal.
130+ * @param contractArgs.from - The address whose deposits are being dequeued.
131+ * @param contractArgs.pool_address - The address of the pool.
132+ * @param contractArgs.amount - The amount of shares to dequeue.
133+ *
134+ * @returns A base64-encoded string representing the operation.
135+ */
106136 dequeueWithdrawal ( contractArgs : PoolBackstopActionArgs ) : string {
107137 return this . call (
108138 'dequeue_withdrawal' ,
109139 ...BackstopContract . spec . funcArgsToScVals ( 'dequeue_withdrawal' , contractArgs )
110140 ) . toXDR ( 'base64' ) ;
111141 }
112142
143+ /**
144+ * Withdraws shares from a user's withdraw queue for a backstop of a pool.
145+ *
146+ * @param contractArgs - The arguments required for withdrawing shares.
147+ * @param contractArgs.from - The address whose shares are being withdrawn.
148+ * @param contractArgs.pool_address - The address of the pool.
149+ * @param contractArgs.amount - The amount of shares to withdraw.
150+ *
151+ * @returns A base64-encoded string representing the operation.
152+ */
113153 withdraw ( contractArgs : PoolBackstopActionArgs ) : string {
114154 return this . call (
115155 'withdraw' ,
116156 ...BackstopContract . spec . funcArgsToScVals ( 'withdraw' , contractArgs )
117157 ) . toXDR ( 'base64' ) ;
118158 }
119159
120- draw ( contractArgs : DrawArgs ) : string {
121- return this . call ( 'draw' , ...BackstopContract . spec . funcArgsToScVals ( 'draw' , contractArgs ) ) . toXDR (
122- 'base64'
123- ) ;
124- }
125-
160+ /**
161+ * Sends backstop tokens from an address to a pool's backstop. Can only be called by the pool.
162+ * Note: This is not a deposit, and the sender will permanently lose access to the funds.
163+ *
164+ * @param contractArgs - The arguments required for donating to the backstop.
165+ * @param contractArgs.from - The address donating tokens to the backstop.
166+ * @param contractArgs.pool_address - The address of the pool.
167+ * @param contractArgs.amount - The amount of tokens to donate.
168+ *
169+ * @throws Will throw an error if the pool_address is not valid or if the pool does not authorize the call.
170+ *
171+ * @returns A base64-encoded string representing the operation.
172+ */
126173 donate ( contractArgs : PoolBackstopActionArgs ) : string {
127174 return this . call (
128175 'donate' ,
129176 ...BackstopContract . spec . funcArgsToScVals ( 'donate' , contractArgs )
130177 ) . toXDR ( 'base64' ) ;
131178 }
132179
133- donateUSDC ( contractArgs : PoolBackstopActionArgs ) : string {
134- return this . call (
135- 'donate_usdc' ,
136- ...BackstopContract . spec . funcArgsToScVals ( 'donate_usdc' , contractArgs )
137- ) . toXDR ( 'base64' ) ;
138- }
139-
140- gulpUSDC ( pool_address : Address | string ) : string {
141- return this . call (
142- 'gulp_usdc' ,
143- ...BackstopContract . spec . funcArgsToScVals ( 'gulp_usdc' , { pool_address } )
144- ) . toXDR ( 'base64' ) ;
145- }
146-
180+ /**
181+ * Drops initial BLND to a list of addresses through the emitter.
182+ *
183+ * @returns A base64-encoded string representing the operation.
184+ */
147185 drop ( ) : string {
148186 return this . call ( 'drop' , ...BackstopContract . spec . funcArgsToScVals ( 'drop' , { } ) ) . toXDR ( 'base64' ) ;
149187 }
150188
189+ /**
190+ * Fetches the balance of backstop shares of a pool for a user.
191+ *
192+ * @param pool - The address of the pool.
193+ * @param user - The user to fetch the balance for.
194+ *
195+ * @returns A base64-encoded string representing the operation.
196+ */
151197 userBalance ( pool : Address | string , user : Address | string ) : string {
152198 return this . call (
153199 'user_balance' ,
154200 ...BackstopContract . spec . funcArgsToScVals ( 'user_balance' , { pool, user } )
155201 ) . toXDR ( 'base64' ) ;
156202 }
157203
204+ /**
205+ * Fetches the backstop token for the backstop.
206+ *
207+ * @returns A base64-encoded string representing the operation.
208+ */
158209 backstopToken ( ) : string {
159210 return this . call (
160211 'backstop_token' ,
@@ -208,32 +259,81 @@ export class BackstopContractV1 extends BackstopContract {
208259 BackstopContractV1 . spec . funcResToNative ( 'update_tkn_val' , result ) ,
209260 } ;
210261
262+ /**
263+ * Initializes the backstop contract. This function requires that the Emitter has already been initialized.
264+ *
265+ * @param contractArgs - The arguments required for initialization.
266+ * @param contractArgs.backstop_token - The backstop token ID - an LP token with the pair BLND:USDC.
267+ * @param contractArgs.emitter - The Emitter contract ID.
268+ * @param contractArgs.usdc_token - The USDC token ID.
269+ * @param contractArgs.blnd_token - The BLND token ID.
270+ * @param contractArgs.pool_factory - The pool factory ID.
271+ * @param contractArgs.drop_list - The list of addresses to distribute initial BLND to and the percent of the distribution they should receive.
272+ *
273+ * @throws Will throw an error if initialize has already been called.
274+ *
275+ * @returns A base64-encoded string representing the operation.
276+ */
211277 initialize ( contractArgs : BackstopConstructorArgs ) : string {
212278 return this . call (
213279 'initialize' ,
214280 ...BackstopContractV1 . spec . funcArgsToScVals ( 'initialize' , contractArgs )
215281 ) . toXDR ( 'base64' ) ;
216282 }
217283
284+ /**
285+ * Consumes emissions from the Emitter and distributes them to backstops and pools in the reward zone.
286+ *
287+ * @returns A base64-encoded string representing the operation.
288+ */
218289 gulpEmissions ( ) : string {
219290 return this . call (
220291 'gulp_emissions' ,
221292 ...BackstopContractV1 . spec . funcArgsToScVals ( 'gulp_emissions' , { } )
222293 ) . toXDR ( 'base64' ) ;
223294 }
295+
296+ /**
297+ * Adds a pool to the reward zone, and if the reward zone is full, removes another pool.
298+ *
299+ * @param to_add - The address of the pool to add.
300+ * @param to_remove - The address of the pool to remove.
301+ *
302+ * @throws Will throw an error if the pool to remove has more tokens, or if distribution occurred in the last 48 hours.
303+ *
304+ * @returns A base64-encoded string representing the operation.
305+ */
224306 addReward ( to_add : string , to_remove : string ) : string {
225307 return this . call (
226308 'add_reward' ,
227309 ...BackstopContractV1 . spec . funcArgsToScVals ( 'add_reward' , { to_add, to_remove } )
228310 ) . toXDR ( 'base64' ) ;
229311 }
230312
313+ /**
314+ * Updates the underlying value of 1 backstop token.
315+ *
316+ * @returns A base64-encoded string representing the operation.
317+ */
231318 updateTokenValue ( ) : string {
232319 return this . call (
233320 'update_tkn_val' ,
234321 ...BackstopContractV1 . spec . funcArgsToScVals ( 'update_tkn_val' , { } )
235322 ) . toXDR ( 'base64' ) ;
236323 }
324+
325+ /**
326+ * Claims backstop deposit emissions from a list of pools for a user.
327+ *
328+ * @param contractArgs - The arguments required for claiming emissions.
329+ * @param contractArgs.from - The address of the user claiming emissions.
330+ * @param contractArgs.pool_addresses - The list of addresses to claim backstop deposit emissions from.
331+ * @param contractArgs.to - The address to send the emissions to.
332+ *
333+ * @throws Will throw an error if an invalid pool address is included.
334+ *
335+ * @returns A base64-encoded string representing the operation.
336+ */
237337 claim ( contractArgs : BackstopClaimV1Args ) : string {
238338 return this . call (
239339 'claim' ,
@@ -287,6 +387,23 @@ export class BackstopContractV2 extends BackstopContract {
287387 removeReward : ( ) => { } ,
288388 } ;
289389
390+ /**
391+ * Deploys a new instance of the Backstop V2 contract.
392+ *
393+ * @param deployer - The address of the deployer.
394+ * @param wasmHash - The hash of the WASM contract code.
395+ * @param args - The constructor arguments for the contract.
396+ * @param args.backstop_token - The backstop token ID - an LP token with the pair BLND:USDC.
397+ * @param args.emitter - The Emitter contract ID.
398+ * @param args.blnd_token - The BLND token ID.
399+ * @param args.usdc_token - The USDC token ID.
400+ * @param args.pool_factory - The pool factory ID.
401+ * @param args.drop_list - The list of addresses to distribute initial BLND to and the percent of the distribution they should receive.
402+ * @param salt - Optional salt for the contract deployment.
403+ * @param format - Optional format for the WASM hash (hex or base64).
404+ *
405+ * @returns A base64-encoded string representing the contract deployment operation.
406+ */
290407 static deploy (
291408 deployer : string ,
292409 wasmHash : Buffer | string ,
@@ -305,34 +422,75 @@ export class BackstopContractV2 extends BackstopContract {
305422 } ) . toXDR ( 'base64' ) ;
306423 }
307424
425+ /**
426+ * Updates the backstop with new emissions for all reward zone pools.
427+ *
428+ * @returns A base64-encoded string representing the operation.
429+ */
308430 distribute ( ) : string {
309431 return this . call (
310432 'distribute' ,
311433 ...BackstopContractV2 . spec . funcArgsToScVals ( 'distribute' , { } )
312434 ) . toXDR ( 'base64' ) ;
313435 }
314436
437+ /**
438+ * Adds a pool to the reward zone, and if the reward zone is full, can optionally remove another pool.
439+ *
440+ * @param to_add - The address of the pool to add.
441+ * @param to_remove - The address of the pool to remove (Optional - Used if the reward zone is full).
442+ *
443+ * @throws Will throw an error if the pool to remove has more tokens, or if distribution occurred in the last 48 hours.
444+ *
445+ * @returns A base64-encoded string representing the operation.
446+ */
315447 addReward ( to_add : string , to_remove : string | undefined ) : string {
316448 return this . call (
317449 'add_reward' ,
318450 ...BackstopContractV2 . spec . funcArgsToScVals ( 'add_reward' , { to_add, to_remove } )
319451 ) . toXDR ( 'base64' ) ;
320452 }
321453
454+ /**
455+ * Removes a pool from the reward zone.
456+ *
457+ * @param poolToRemove - The address of the pool to remove.
458+ *
459+ * @throws Will throw an error if the pool is not below the threshold or if the pool is not in the reward zone.
460+ *
461+ * @returns A base64-encoded string representing the operation.
462+ */
322463 removeReward ( poolToRemove : string ) : string {
323464 return this . call (
324465 'remove_reward' ,
325466 ...BackstopContractV2 . spec . funcArgsToScVals ( 'remove_reward' , { poolToRemove } )
326467 ) . toXDR ( 'base64' ) ;
327468 }
328469
470+ /**
471+ * Claims backstop deposit emissions from a list of pools for a user.
472+ *
473+ * @param contractArgs - The arguments required for claiming emissions.
474+ * @param contractArgs.from - The address of the user claiming emissions.
475+ * @param contractArgs.pool_addresses - The list of addresses to claim backstop deposit emissions from.
476+ * @param contractArgs.min_lp_tokens_out - The minimum amount of LP tokens to mint with the claimed BLND.
477+ *
478+ * @throws Will throw an error if an invalid pool address is included.
479+ *
480+ * @returns A base64-encoded string representing the operation.
481+ */
329482 claim ( contractArgs : BackstopClaimV2Args ) : string {
330483 return this . call (
331484 'claim' ,
332485 ...BackstopContractV2 . spec . funcArgsToScVals ( 'claim' , contractArgs )
333486 ) . toXDR ( 'base64' ) ;
334487 }
335488
489+ /**
490+ * Fetches the reward zone for the backstop.
491+ *
492+ * @returns A base64-encoded string representing the operation.
493+ */
336494 rewardZone ( ) : string {
337495 return this . call (
338496 'reward_zone' ,
0 commit comments