1
1
import { MsgCloseDeployment , MsgCreateDeployment } from "@akashnetwork/akash-api/v1beta3" ;
2
2
import { SDL } from "@akashnetwork/akashjs/build/sdl" ;
3
3
import { getAkashTypeRegistry } from "@akashnetwork/akashjs/build/stargate" ;
4
+ import { BidHttpService } from "@akashnetwork/http-sdk" ;
4
5
import { LoggerService } from "@akashnetwork/logging" ;
5
6
import { DirectSecp256k1HdWallet , EncodeObject , Registry } from "@cosmjs/proto-signing" ;
6
7
import { calculateFee , SigningStargateClient } from "@cosmjs/stargate" ;
@@ -10,7 +11,6 @@ import { singleton } from "tsyringe";
10
11
11
12
import { BillingConfigService } from "@src/billing/services/billing-config/billing-config.service" ;
12
13
import { getGpuModelsAvailability } from "@src/routes/v1/gpu" ;
13
- import { RestAkashBidListResponseType } from "@src/types/rest" ;
14
14
import { apiNodeUrl } from "@src/utils/constants" ;
15
15
import { sleep } from "@src/utils/delay" ;
16
16
import { env } from "@src/utils/env" ;
@@ -20,7 +20,10 @@ import { sdlTemplateWithRam, sdlTemplateWithRamAndInterface } from "./sdl-templa
20
20
export class GpuBidsCreatorService {
21
21
private readonly logger = LoggerService . forContext ( GpuBidsCreatorService . name ) ;
22
22
23
- constructor ( private readonly config : BillingConfigService ) { }
23
+ constructor (
24
+ private readonly config : BillingConfigService ,
25
+ private readonly bidHttpService : BidHttpService ,
26
+ ) { }
24
27
25
28
async createGpuBids ( ) {
26
29
if ( ! env . GPU_BOT_WALLET_MNEMONIC ) throw new Error ( "The env variable GPU_BOT_WALLET_MNEMONIC is not set." ) ;
@@ -107,9 +110,9 @@ export class GpuBidsCreatorService {
107
110
108
111
await sleep ( 30_000 ) ;
109
112
110
- const bids = await this . getBids ( walletAddress , dseq ) ;
113
+ const bids = await this . bidHttpService . list ( walletAddress , dseq ) ;
111
114
112
- this . logger . info ( `Got ${ bids . bids . length } bids. Closing deployment...` ) ;
115
+ this . logger . info ( { event : "DEPLOYMENT_CLOSING" , bidsCount : bids . length } ) ;
113
116
114
117
await this . closeDeployment ( client , walletAddress , dseq ) ;
115
118
@@ -163,12 +166,6 @@ export class GpuBidsCreatorService {
163
166
await this . signAndBroadcast ( owner , client , [ message ] ) ;
164
167
}
165
168
166
- private async getBids ( owner : string , dseq : string ) {
167
- const response = await axios . get < RestAkashBidListResponseType > ( `${ apiNodeUrl } /akash/market/v1beta4/bids/list?filters.owner=${ owner } &filters.dseq=${ dseq } ` ) ;
168
-
169
- return response . data ;
170
- }
171
-
172
169
private getModelSdl ( vendor : string , model : string , ram : string , gpuInterface ?: string ) {
173
170
let gpuSdl = gpuInterface ? sdlTemplateWithRamAndInterface : sdlTemplateWithRam ;
174
171
gpuSdl = gpuSdl . replace ( "<VENDOR>" , vendor ) ;
0 commit comments