-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #363 from ergolabs/dev
v1.1.0
- Loading branch information
Showing
179 changed files
with
5,319 additions
and
1,611 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { PoolId } from '@ergolabs/ergo-dex-sdk'; | ||
import { map, Observable, publishReplay, refCount, switchMap } from 'rxjs'; | ||
|
||
import { AmmPool } from '../common/models/AmmPool'; | ||
import { selectedNetwork$ } from '../network/network'; | ||
|
||
export const ammPools$ = selectedNetwork$.pipe( | ||
switchMap((network) => network.ammPools$), | ||
publishReplay(1), | ||
refCount(), | ||
); | ||
|
||
export const getAmmPoolById = ( | ||
ammPoolId: PoolId, | ||
): Observable<AmmPool | undefined> => | ||
ammPools$.pipe( | ||
map((pools) => pools.find((position) => position.id === ammPoolId)), | ||
); | ||
|
||
const byAssetPair = (xId: string, yId: string) => (p: AmmPool) => | ||
(p.x.asset.id === xId || p.y.asset.id === xId) && | ||
(p.x.asset.id === yId || p.y.asset.id === yId); | ||
export const getAmmPoolsByAssetPair = ( | ||
xId: string, | ||
yId: string, | ||
): Observable<AmmPool[]> => | ||
ammPools$.pipe( | ||
map((pools) => pools.filter(byAssetPair(xId, yId))), | ||
publishReplay(1), | ||
refCount(), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { publishReplay, refCount, switchMap } from 'rxjs'; | ||
|
||
import { useObservable } from '../common/hooks/useObservable'; | ||
import { Balance } from '../common/models/Balance'; | ||
import { selectedNetwork$ } from '../network/network'; | ||
|
||
export const assetBalance$ = selectedNetwork$.pipe( | ||
switchMap((network) => network.assetBalance$), | ||
publishReplay(1), | ||
refCount(), | ||
); | ||
|
||
export const useAssetsBalance = (): [Balance, boolean, Error] => | ||
useObservable(assetBalance$, [], new Balance([])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { | ||
from, | ||
interval, | ||
map, | ||
Observable, | ||
publishReplay, | ||
refCount, | ||
startWith, | ||
switchMap, | ||
} from 'rxjs'; | ||
|
||
import { explorer } from '../services/explorer'; | ||
|
||
const UPDATE_TIME = 1000 * 10; | ||
|
||
// @ts-ignore | ||
export const ergoExplorerContext$: Observable<{ | ||
height: number; | ||
lastBlockId: string; | ||
}> = interval(UPDATE_TIME).pipe( | ||
startWith(undefined), | ||
switchMap(() => from(explorer.getNetworkContext())), | ||
map((ctx) => ctx), | ||
publishReplay(1), | ||
refCount(), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { map, publishReplay, refCount, switchMap } from 'rxjs'; | ||
|
||
import { selectedNetwork$ } from '../network/network'; | ||
|
||
export const locks$ = selectedNetwork$.pipe( | ||
switchMap((network) => network.locks$), | ||
map((locks) => locks.filter((l) => l.active)), | ||
publishReplay(1), | ||
refCount(), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { publishReplay, refCount, switchMap } from 'rxjs'; | ||
|
||
import { selectedNetwork$ } from '../network/network'; | ||
|
||
export const networkAssetBalance$ = selectedNetwork$.pipe( | ||
switchMap((network) => network.networkAssetBalance$), | ||
publishReplay(1), | ||
refCount(), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { map, Observable, of, publishReplay, refCount, switchMap } from 'rxjs'; | ||
|
||
import { AmmPool } from '../common/models/AmmPool'; | ||
import { Position } from '../common/models/Position'; | ||
import { selectedNetwork$ } from '../network/network'; | ||
import { ammPools$ } from './ammPools'; | ||
|
||
export const positions$ = selectedNetwork$.pipe( | ||
switchMap((network) => network.positions$), | ||
publishReplay(1), | ||
refCount(), | ||
); | ||
positions$.subscribe(); | ||
|
||
export const getPositionByAmmPoolId = ( | ||
ammPoolId: string, | ||
): Observable<Position | undefined> => | ||
positions$.pipe( | ||
switchMap((positions) => { | ||
const position = positions.find((p) => p.pool.id === ammPoolId); | ||
|
||
if (position) { | ||
return of(position); | ||
} | ||
return ammPools$.pipe( | ||
map<AmmPool[], Position | undefined>((ammPools) => { | ||
const pool = ammPools.find((p) => p.id === ammPoolId); | ||
|
||
return pool ? Position.noop(pool) : undefined; | ||
}), | ||
); | ||
}), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
interface ApplicationConfig { | ||
readonly api: string; | ||
readonly social: { | ||
readonly twitter: string; | ||
readonly telegram: string; | ||
readonly discord: string; | ||
readonly medium: string; | ||
readonly reddit: string; | ||
}; | ||
readonly support: { | ||
readonly discord: string; | ||
readonly telegram: string; | ||
}; | ||
readonly applicationTick: number; | ||
} | ||
|
||
export const applicationConfig: ApplicationConfig = { | ||
api: 'https://api.ergodex.io/v1/', | ||
social: { | ||
twitter: 'https://twitter.com/ErgoDex', | ||
telegram: 'https://t.me/ergodex_community', | ||
discord: 'https://discord.com/invite/6MFFG4Fn4Y', | ||
medium: 'https://ergodex.medium.com/', | ||
reddit: 'https://www.reddit.com/r/ergodex/', | ||
}, | ||
support: { | ||
discord: 'https://discord.gg/Jya72kjDfq', | ||
telegram: 'https://t.me/ergodex_community', | ||
}, | ||
applicationTick: 10 * 1000, | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.