Skip to content

Commit

Permalink
feat: update aura xstaxy config; add getTokens api to aura
Browse files Browse the repository at this point in the history
  • Loading branch information
fibonacci998 committed Apr 9, 2024
1 parent 24f2519 commit eda5f7a
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/chains/aura/aura-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export class AuraBase {
);
balances[token.coinDenom] = {
decimals: token.decimals,
value: BigNumber.from(parseInt(resultCw20Token.balance, 10)),
value: BigNumber.from(resultCw20Token.balance),
};
})
);
Expand Down
9 changes: 9 additions & 0 deletions src/chains/aura/aura.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
validateAuraBalanceRequest,
validateAuraPollRequest,
} from './aura.validators';
import { TokensRequest } from '../../network/network.requests';

const { decodeTxRaw } = require('@cosmjs/proto-signing');

Expand Down Expand Up @@ -74,4 +75,12 @@ export class AuraController {
txStatus: transaction.code,
};
}

static async getTokens(aura: Aura, req: TokensRequest) {
// const initTime = Date.now();
// aura.storedTokenList;
console.log(req);
const tokens = { tokens: aura.storedTokenList };
return tokens;
}
}
18 changes: 13 additions & 5 deletions src/connectors/halotrade/halotrade.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,21 @@ export async function price(
let trade;
try {
trade = await halotrade.price(req);
// trade = await halotrade.estimateTrade(req);
// trade = await halotrade.trade(
// req,
// 'aura1526yed57ss0ldhhx0qz4dgzparthuy6u20g9wy',
// false
// estimateTrade = await halotrade.estimateTrade(req);
// estimateTrade = await halotrade.trade(
// {
// address: 'aura1kku9k0652a87u8cc058z0f0wl3djk6p5l9kx5u',
// base: req.base,
// quote: req.quote,
// amount: req.amount,
// side: req.side,
// chain: req.chain,
// network: req.network,
// },
// true
// );
console.log(trade?.toString());
// console.log(estimateTrade?.toString());
} catch (e) {
if (e instanceof Error) {
throw new HttpException(
Expand Down
29 changes: 21 additions & 8 deletions src/connectors/halotrade/halotrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,17 @@ export class Halotrade {
req.side === 'SELL'
? this.tokenList[req.quote]
: this.tokenList[req.base];

const price = await this.price({
chain: req.chain,
network: req.network,
amount: req.amount,
side: req.side,
base: req.base,
quote: req.quote,
});
if (req.side === 'BUY' && price?.expectedAmount) {
req.amount = (price?.expectedAmount).toString();
}
const estimatedOutputTrade = await this.estimateTrade(req);
// let estimateInputTrade;
// if (req.side === 'BUY') {
Expand Down Expand Up @@ -219,7 +229,7 @@ export class Halotrade {
funds.push({
denom: baseToken.address,
amount: (
Number(req.amount) * Math.pow(10, quoteToken.decimals)
Number(req.amount) * Math.pow(10, baseToken.decimals)
).toString(),
});
} else if (
Expand All @@ -231,9 +241,7 @@ export class Halotrade {
msg = JSON.parse(`{
"send": {
"contract": "${this.router}",
"amount": "${
Number(req.amount) * Math.pow(10, quoteToken.decimals)
}",
"amount": "${Number(req.amount) * Math.pow(10, baseToken.decimals)}",
"msg": "${msgNestedBase64}"
}
}`);
Expand Down Expand Up @@ -301,10 +309,15 @@ export class Halotrade {
amountQuoteToken = asset.amount;
}
});
// const expectedPrice =
// req.side === 'BUY'
// ? (Number(amountQuoteToken) / Number(amountBaseToken)) *
// Math.pow(10, baseToken.decimals - quoteToken.decimals)
// : (Number(amountBaseToken) / Number(amountQuoteToken)) *
// Math.pow(10, quoteToken.decimals - baseToken.decimals);
const expectedPrice =
req.side === 'BUY'
? Number(amountBaseToken) / Number(amountQuoteToken)
: Number(amountQuoteToken) / Number(amountBaseToken);
(Number(amountQuoteToken) / Number(amountBaseToken)) *
Math.pow(10, baseToken.decimals - quoteToken.decimals);
const expectedAmount = expectedPrice * Number(req.amount);
return { expectedAmount, expectedPrice };
// return result?.amount;
Expand Down
8 changes: 4 additions & 4 deletions src/templates/aura.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ networks:
xstaxy:
nodeURL: https://rpc.aura.network
tokenListType: FILE
tokenListSource: /home/tuan1998/gateway/conf/lists/aura_xstaxy.json
tokenListSource: /home/tuan1998/hummingbot-gateway/conf/lists/aura_xstaxy.json
routerAddress: aura10lfagekpspw59za99x98tuxfsegx3v5sxycntqnfd4vj7e6xzq0skguqty
defaultGasPrice: 1uaura
defaultGasPrice: 0.00001uaura
euphoria:
nodeURL: https://rpc.euphoria.aura.network
tokenListType: FILE
tokenListSource: /home/tuan1998/gateway/conf/lists/aura_euphoria.json
tokenListSource: /home/tuan1998/hummingbot-gateway/conf/lists/aura_euphoria.json
routerAddress: aura1qa6ulm3jzlm9kzln63rmkn50xm7xmchkddvmkaj7cg0lk63tprsqalwtcj
defaultGasPrice: 1ueaura
network: euphoria
network: xstaxy
nativeCurrencySymbol: AURA
manualGasPrice: 110
18 changes: 18 additions & 0 deletions src/templates/lists/aura_xstaxy.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@
"minCoinDenom": "",
"address": "aura1fgfnuru6krewgt9zzu7nzercz007928uzrw2t2tl6hl3ec50me2q3ankr2",
"icon": "https://assets.coingecko.com/coins/images/6319/standard/usdc.png"
},
{
"name": "AURA",
"type": "native",
"decimals": 6,
"description": "AURA Token",
"coinDenom": "uaura",
"minCoinDenom": "",
"address": "uaura",
"icon": "https://assets.coingecko.com/coins/images/6319/standard/usdc.png"
}
],
"pools": [
{
"name": "AURA-USDC",
"asset1Address": "uaura",
"asset2Address": "aura1fgfnuru6krewgt9zzu7nzercz007928uzrw2t2tl6hl3ec50me2q3ankr2",
"address": "aura1urvqe5mw00ws25yqdd4c4hlh8kdyf567mpcml7cdve9w08z0ydcqz2ewn0"
}
]
}

0 comments on commit eda5f7a

Please sign in to comment.