Skip to content

StellarCore database connector for Reflector backend

License

Notifications You must be signed in to change notification settings

reflector-network/reflector-db-connector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@reflector/reflector-db-connector

StellarCore database connector for Reflector backend

Installation

Add package reference to the dependencies section of package.json

{
  "dependencies": {
    "@reflector/reflector-db-connector": "github:reflector-network/reflector-db-connector#v2.0.0"
  }
}

Usage

Initialize CoreDB connection to work with.

const db = createDbConnection('postgres://stellar:[email protected]:54321/futurenet')

Note: creating multiple DbConnector instances is bad idea, use singleton db connector instances locally to pass them to other functions.

Aggregate trades for a given period:

aggregateTrades({
    db,
    baseAsset: new Asset('USD', 'GBCC..'),
    assets: [
        new Asset('EUR', 'GC9L...'),
        new Asset('CHF', 'GAA0...')
    ],
    from: 1693138200,
    period: 300,
    limit: 2
}).then(res => console.log(res))

/*[
    [
        {
            quoteVolume: 5319168566n,
            volume: 10670398723n
        },
        {
            quoteVolume: 0n,
            volume: 0n
        }
    ],
    [
        {
            quoteVolume: 4239198712n,
            volume: 14068368020n
        },        
        {
            quoteVolume: 2016928760n,
            volume: 6032655521n
        }
    ]
]*/

Tests

npm run test

About

StellarCore database connector for Reflector backend

Resources

License

Stars

Watchers

Forks

Packages

No packages published