Skip to content

Commit

Permalink
SERVICES-1902: add more stub values for pair constants
Browse files Browse the repository at this point in the history
Signed-off-by: Claudiu Lataretu <[email protected]>
  • Loading branch information
claudiulataretu committed Nov 6, 2023
1 parent e59e057 commit e01d7b4
Show file tree
Hide file tree
Showing 3 changed files with 218 additions and 6 deletions.
179 changes: 179 additions & 0 deletions src/modules/pair/mocks/pair.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,35 @@ export const Tokens = (tokenID: string): EsdtToken => {
price: '1',
roles: new RolesModel(),
});
case 'USDT-123456':
return new EsdtToken({
identifier: 'USDT-123456',
name: 'TetherUSD',
ticker: 'USDT',
owner: Address.fromHex(
'0000000000000000000000000000000000000000000000000000000000000001',
).bech32(),
supply: '1000000000000',
decimals: 6,
isPaused: false,
canUpgrade: true,
canMint: true,
canBurn: true,
canChangeOwner: true,
canPause: true,
canFreeze: true,
canWipe: true,
type: 'Core',
minted: '1',
burnt: '1',
circulatingSupply: '1',
accounts: 1,
transactions: 1,
assets: new AssetsModel(),
initialMinted: '1',
price: '1',
roles: new RolesModel(),
});
case 'TOK4-123456':
return new EsdtToken({
identifier: 'TOK4-123456',
Expand Down Expand Up @@ -304,6 +333,87 @@ export const Tokens = (tokenID: string): EsdtToken => {
price: '10',
roles: new RolesModel(),
});
case 'TOK5USDCLP-abcdef':
return new EsdtToken({
identifier: 'TOK5USDCLP-abcdef',
name: 'TOK5USDCLP',
ticker: 'TOK5USDCLP',
type: 'FungibleESDT',
owner: scAddress.routerAddress,
supply: '1000000000000000000000000',
decimals: 18,
isPaused: false,
canUpgrade: true,
canMint: true,
canBurn: true,
canChangeOwner: true,
canPause: true,
canFreeze: true,
canWipe: true,
minted: '900000000000000000000000',
burnt: '1',
circulatingSupply: '1',
accounts: 1,
transactions: 1,
assets: new AssetsModel(),
initialMinted: '1',
price: '10',
roles: new RolesModel(),
});
case 'TOK5USDTLP-abcdef':
return new EsdtToken({
identifier: 'TOK5USDTLP-abcdef',
name: 'TOK5USDTLP',
ticker: 'TOK5USDTLP',
type: 'FungibleESDT',
owner: scAddress.routerAddress,
supply: '1000000000000000000000000',
decimals: 18,
isPaused: false,
canUpgrade: true,
canMint: true,
canBurn: true,
canChangeOwner: true,
canPause: true,
canFreeze: true,
canWipe: true,
minted: '900000000000000000000000',
burnt: '1',
circulatingSupply: '1',
accounts: 1,
transactions: 1,
assets: new AssetsModel(),
initialMinted: '1',
price: '10',
roles: new RolesModel(),
});
case 'EGLDUSDTLP-abcdef':
return new EsdtToken({
identifier: 'EGLDUSDTLP-abcdef',
name: 'EGLDUSDTLP',
ticker: 'EGLDUSDTLP',
type: 'FungibleESDT',
owner: scAddress.routerAddress,
supply: '1000000000000000000000000',
decimals: 18,
isPaused: false,
canUpgrade: true,
canMint: true,
canBurn: true,
canChangeOwner: true,
canPause: true,
canFreeze: true,
canWipe: true,
minted: '900000000000000000000000',
burnt: '1',
circulatingSupply: '1',
accounts: 1,
transactions: 1,
assets: new AssetsModel(),
initialMinted: '1',
price: '10',
roles: new RolesModel(),
});
case 'EGLDMEXFL-abcdef':
return {
identifier: 'EGLDMEXFL-abcdef',
Expand Down Expand Up @@ -545,6 +655,75 @@ export const pairs = [
totalFeePercent: 0.003,
state: 'Active',
},
{
address: Address.fromHex(
'0000000000000000000000000000000000000000000000000000000000000017',
).bech32(),
firstToken: Tokens('TOK5-123456'),
secondToken: Tokens('USDC-123456'),
liquidityPoolToken: Tokens('TOK5USDCLP-abcdef'),
info: {
reserves0: '10000000000000000000',
reserves1: '1000000',
totalSupply: '1000000000000000000000',
},
firstTokenPrice: '0.1',
firstTokenPriceUSD: '0.1',
secondTokenPrice: '10',
secondTokenPriceUSD: '1',
liquidityPoolTokenPriceUSD: '20',
firstTokenLockedValueUSD: '10000',
secondTokenLockedValueUSD: '10000',
lockedValueUSD: '20000',
totalFeePercent: 0.003,
state: 'Active',
},
{
address: Address.fromHex(
'0000000000000000000000000000000000000000000000000000000000000018',
).bech32(),
firstToken: Tokens('TOK5-123456'),
secondToken: Tokens('USDT-123456'),
liquidityPoolToken: Tokens('TOK5USDTLP-abcdef'),
info: {
reserves0: '990000000000000000000000',
reserves1: '100000000000',
totalSupply: '1000000000000000000000',
},
firstTokenPrice: '0.1010101010101010101010101',
firstTokenPriceUSD: '0.101',
secondTokenPrice: '9.9',
secondTokenPriceUSD: '1',
liquidityPoolTokenPriceUSD: '20',
firstTokenLockedValueUSD: '10000',
secondTokenLockedValueUSD: '10000',
lockedValueUSD: '20000',
totalFeePercent: 0.003,
state: 'Active',
},
{
address: Address.fromHex(
'0000000000000000000000000000000000000000000000000000000000000019',
).bech32(),
firstToken: Tokens('WEGLD-123456'),
secondToken: Tokens('USDT-123456'),
liquidityPoolToken: Tokens('EGLDUSDTLP-abcdef'),
info: {
reserves0: '1000000000000000000000',
reserves1: '10000000000',
totalSupply: '10000000000',
},
firstTokenPrice: '10',
firstTokenPriceUSD: '10',
secondTokenPrice: '0.1',
secondTokenPriceUSD: '1',
liquidityPoolTokenPriceUSD: '20',
firstTokenLockedValueUSD: '10000',
secondTokenLockedValueUSD: '10000',
lockedValueUSD: '20000',
totalFeePercent: 0.003,
state: 'Active',
},
];

export async function PairsMap(): Promise<Map<string, string[]>> {
Expand Down
20 changes: 20 additions & 0 deletions src/modules/router/specs/router.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ describe('RouterService', () => {
'0000000000000000000000000000000000000000000000000000000000000016',
).bech32(),
}),
new PairModel({
address: Address.fromHex(
'0000000000000000000000000000000000000000000000000000000000000017',
).bech32(),
}),
new PairModel({
address: Address.fromHex(
'0000000000000000000000000000000000000000000000000000000000000018',
).bech32(),
}),
new PairModel({
address: Address.fromHex(
'0000000000000000000000000000000000000000000000000000000000000019',
).bech32(),
}),
]);
});

Expand Down Expand Up @@ -100,6 +115,11 @@ describe('RouterService', () => {
'0000000000000000000000000000000000000000000000000000000000000015',
).bech32(),
}),
new PairModel({
address: Address.fromHex(
'0000000000000000000000000000000000000000000000000000000000000019',
).bech32(),
}),
]);
});
});
25 changes: 19 additions & 6 deletions src/modules/tokens/specs/token.compute.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,35 +53,48 @@ describe('TokenComputeService', () => {
module.get<TokenComputeService>(TokenComputeService);
const price = await service.computeTokenPriceDerivedEGLD(
tokenProviderUSD,
[],
);
expect(price).toEqual('1');
});

it('should compute token price derived EGLD for MEX-123456', async () => {
const service: TokenComputeService =
module.get<TokenComputeService>(TokenComputeService);
const price = await service.computeTokenPriceDerivedEGLD('MEX-123456');
const price = await service.computeTokenPriceDerivedEGLD(
'MEX-123456',
[],
);
expect(price).toEqual('0.001');
});

it('should compute token price derived EGLD for TOK4-123456', async () => {
const service: TokenComputeService =
module.get<TokenComputeService>(TokenComputeService);
const price = await service.computeTokenPriceDerivedEGLD('TOK4-123456');
const price = await service.computeTokenPriceDerivedEGLD(
'TOK4-123456',
[],
);
expect(price).toEqual('0.01');
});

it('should compute token price derived EGLD for TOK5-123456', async () => {
const service: TokenComputeService =
module.get<TokenComputeService>(TokenComputeService);
const price = await service.computeTokenPriceDerivedEGLD('TOK5-123456');
expect(price).toEqual('0.01');
const price = await service.computeTokenPriceDerivedEGLD(
'TOK5-123456',
[],
);
expect(price).toEqual('0.01010101010101010101010101');
});

it('should compute token price derived EGLD for TOK6-123456', async () => {
const service: TokenComputeService =
module.get<TokenComputeService>(TokenComputeService);
const price = await service.computeTokenPriceDerivedEGLD('TOK6-123456');
expect(price).toEqual('0.01');
const price = await service.computeTokenPriceDerivedEGLD(
'TOK6-123456',
[],
);
expect(price).toEqual('0.01010101010101010101010101');
});
});

0 comments on commit e01d7b4

Please sign in to comment.