@@ -317,6 +317,116 @@ func (e *Exchange) VaultUsdTransfer(
317317 return & result , nil
318318}
319319
320+ // CreateVault creates a new vault
321+ func (e * Exchange ) CreateVault (
322+ name string ,
323+ description string ,
324+ initialUsd int ,
325+ ) (* CreateVaultResponse , error ) {
326+ timestamp := time .Now ().UnixMilli ()
327+
328+ action := CreateVaultAction {
329+ Type : "createVault" ,
330+ Name : name ,
331+ Description : description ,
332+ InitialUsd : initialUsd ,
333+ }
334+
335+ sig , err := SignL1Action (
336+ e .privateKey ,
337+ action ,
338+ "" , // No vault address
339+ timestamp ,
340+ e .expiresAfter ,
341+ e .client .baseURL == MainnetAPIURL ,
342+ )
343+ if err != nil {
344+ return nil , err
345+ }
346+
347+ resp , err := e .postAction (action , sig , timestamp )
348+ if err != nil {
349+ return nil , err
350+ }
351+
352+ var result CreateVaultResponse
353+ if err := json .Unmarshal (resp , & result ); err != nil {
354+ return nil , err
355+ }
356+ return & result , nil
357+ }
358+
359+ func (e * Exchange ) VaultModify (
360+ vaultAddress string ,
361+ allowDeposits bool ,
362+ alwaysCloseOnWithdraw bool ,
363+ ) (* TransferResponse , error ) {
364+ timestamp := time .Now ().UnixMilli ()
365+
366+ action := VaultModifyAction {
367+ Type : "vaultModify" ,
368+ VaultAddress : vaultAddress ,
369+ AllowDeposits : allowDeposits ,
370+ AlwaysCloseOnWithdraw : alwaysCloseOnWithdraw ,
371+ }
372+
373+ sig , err := SignL1Action (
374+ e .privateKey ,
375+ action ,
376+ "" , // No vault address
377+ timestamp ,
378+ e .expiresAfter ,
379+ e .client .baseURL == MainnetAPIURL ,
380+ )
381+ if err != nil {
382+ return nil , err
383+ }
384+
385+ resp , err := e .postAction (action , sig , timestamp )
386+ if err != nil {
387+ return nil , err
388+ }
389+
390+ var result TransferResponse
391+ if err := json .Unmarshal (resp , & result ); err != nil {
392+ return nil , err
393+ }
394+ return & result , nil
395+ }
396+
397+ func (e * Exchange ) VaultDistribute (vaultAddress string , usd int ) (* TransferResponse , error ) {
398+ timestamp := time .Now ().UnixMilli ()
399+
400+ action := VaultDistributeAction {
401+ Type : "vaultDistribute" ,
402+ VaultAddress : vaultAddress ,
403+ Usd : usd ,
404+ }
405+
406+ sig , err := SignL1Action (
407+ e .privateKey ,
408+ action ,
409+ "" , // No vault address
410+ timestamp ,
411+ e .expiresAfter ,
412+ e .client .baseURL == MainnetAPIURL ,
413+ )
414+ if err != nil {
415+ return nil , err
416+ }
417+
418+ resp , err := e .postAction (action , sig , timestamp )
419+ if err != nil {
420+ return nil , err
421+ }
422+
423+ var result TransferResponse
424+ if err := json .Unmarshal (resp , & result ); err != nil {
425+ return nil , err
426+ }
427+ return & result , nil
428+ }
429+
320430// UsdTransfer transfers USD to another address
321431func (e * Exchange ) UsdTransfer (amount float64 , destination string ) (* TransferResponse , error ) {
322432 timestamp := time .Now ().UnixMilli ()
0 commit comments