Skip to content

Commit

Permalink
Merge pull request #229 from ar-io/demand-factor-api
Browse files Browse the repository at this point in the history
fix(io): add getDemandFactor api
  • Loading branch information
dtfiedler authored Oct 15, 2024
2 parents 2dad25d + 4e9a0f4 commit 2b1227f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
- [`getGateways({ cursor, limit, sortBy, sortOrder })`](#getgateways-cursor-limit-sortby-sortorder-)
- [`getArNSRecord({ name })`](#getarnsrecord-name-)
- [`getArNSRecords({ cursor, limit, sortBy, sortOrder })`](#getarnsrecords-cursor-limit-sortby-sortorder-)
- [`getDemandFactor()`](#getdemandfactor)
- [`getObservations({ epochIndex })`](#getobservations-epochindex-)
- [`getDistributions({ epochIndex })`](#getdistributions-epochindex-)
- [`getEpoch({ epochIndex })`](#getepoch-epochindex-)
Expand Down Expand Up @@ -571,6 +572,24 @@ Available `sortBy` options are any of the keys on the record object, e.g. `name`

</details>

#### `getDemandFactor()`

Retrieves the current demand factor of the network. The demand factor is a multiplier applied to the cost of ArNS interactions based on the current network demand.

```typescript
const io = IO.init();
const demandFactor = await io.getDemandFactor();
```

<details>
<summary>Output</summary>

```json
1.05256
```

</details>

#### `getObservations({ epochIndex })`

Returns the epoch-indexed observation list.
Expand Down
6 changes: 6 additions & 0 deletions src/common/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,12 @@ export class IOReadable implements AoIORead {
tags: [{ name: 'Action', value: 'Get-Registration-Fees' }],
});
}

async getDemandFactor(): Promise<number> {
return this.process.read<number>({
tags: [{ name: 'Action', value: 'Demand-Factor' }],
});
}
}

export class IOWriteable extends IOReadable implements AoIOWrite {
Expand Down
1 change: 1 addition & 0 deletions src/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ export interface AoIORead {
quantity?: number;
}): Promise<number>;
getRegistrationFees(): Promise<AoRegistrationFees>;
getDemandFactor(): Promise<number>;
}

export interface AoIOWrite extends AoIORead {
Expand Down

0 comments on commit 2b1227f

Please sign in to comment.