-
-
Notifications
You must be signed in to change notification settings - Fork 142
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 #379 from hummingbot/staging
sync / Gateway staging -> master for Hummingbot version 2.2.0
- Loading branch information
Showing
36 changed files
with
4,749 additions
and
364 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
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,50 @@ | ||
import { TokenListType } from '../../services/base'; | ||
import { ConfigManagerV2 } from '../../services/config-manager-v2'; | ||
interface NetworkConfig { | ||
name: string; | ||
nodeURLs: string; | ||
tokenListType: TokenListType; | ||
tokenListSource: string; | ||
nativeCurrencySymbol: string; | ||
} | ||
|
||
export interface Config { | ||
network: NetworkConfig; | ||
tokenProgram: string; | ||
transactionLamports: number; | ||
lamportsToSol: number; | ||
timeToLive: number; | ||
} | ||
|
||
export function getSolanaConfig( | ||
chainName: string, | ||
networkName: string | ||
): Config { | ||
return { | ||
network: { | ||
name: networkName, | ||
nodeURLs: ConfigManagerV2.getInstance().get( | ||
chainName + '.networks.' + networkName + '.nodeURLs' | ||
), | ||
tokenListType: ConfigManagerV2.getInstance().get( | ||
chainName + '.networks.' + networkName + '.tokenListType' | ||
), | ||
tokenListSource: ConfigManagerV2.getInstance().get( | ||
chainName + '.networks.' + networkName + '.tokenListSource' | ||
), | ||
nativeCurrencySymbol: ConfigManagerV2.getInstance().get( | ||
chainName + '.networks.' + networkName + '.nativeCurrencySymbol' | ||
), | ||
}, | ||
tokenProgram: ConfigManagerV2.getInstance().get( | ||
chainName + '.tokenProgram' | ||
), | ||
transactionLamports: ConfigManagerV2.getInstance().get( | ||
chainName + '.transactionLamports' | ||
), | ||
lamportsToSol: ConfigManagerV2.getInstance().get( | ||
chainName + '.lamportsToSol' | ||
), | ||
timeToLive: ConfigManagerV2.getInstance().get(chainName + '.timeToLive'), | ||
}; | ||
} |
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,19 @@ | ||
export const constants = { | ||
retry: { | ||
all: { | ||
maxNumberOfRetries: 0, // 0 means no retries | ||
delayBetweenRetries: 0, // 0 means no delay (milliseconds) | ||
}, | ||
}, | ||
timeout: { | ||
all: 0, // 0 means no timeout (milliseconds) | ||
}, | ||
parallel: { | ||
all: { | ||
batchSize: 0, // 0 means no batching (group all) | ||
delayBetweenBatches: 0, // 0 means no delay (milliseconds) | ||
}, | ||
}, | ||
}; | ||
|
||
export default constants; |
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,77 @@ | ||
// import { tokenValueToString } from '../../services/base'; | ||
import { | ||
BalanceRequest, | ||
TokensRequest, | ||
PollRequest, | ||
} from '../../network/network.requests'; | ||
import { CustomTransactionResponse } from '../../services/common-interfaces'; | ||
import { | ||
HttpException, | ||
LOAD_WALLET_ERROR_CODE, | ||
LOAD_WALLET_ERROR_MESSAGE, | ||
} from '../../services/error-handler'; | ||
import { TokenInfo } from '../ethereum/ethereum-base'; | ||
|
||
import { Keypair, TransactionResponse } from '@solana/web3.js'; | ||
import { Solanaish } from './solana'; | ||
import { getNotNullOrThrowError } from './solana.helpers'; | ||
|
||
export class SolanaController { | ||
|
||
static async balances(solanaish: Solanaish, req: BalanceRequest) { | ||
let wallet: Keypair; | ||
try { | ||
wallet = await solanaish.getWallet(req.address); | ||
} catch (err) { | ||
throw new HttpException( | ||
500, | ||
LOAD_WALLET_ERROR_MESSAGE + err, | ||
LOAD_WALLET_ERROR_CODE | ||
); | ||
} | ||
|
||
const balances = await solanaish.getBalance(wallet, req.tokenSymbols); | ||
|
||
return { balances }; | ||
} | ||
|
||
static async poll(solanaish: Solanaish, req: PollRequest) { | ||
const currentBlock = await solanaish.getCurrentBlockNumber(); | ||
const txData = getNotNullOrThrowError<TransactionResponse>( | ||
await solanaish.getTransaction(req.txHash as any) | ||
); | ||
const txStatus = await solanaish.getTransactionStatusCode(txData); | ||
|
||
console.log(`Polling for transaction ${req.txHash}, Status: ${txStatus}`); | ||
|
||
return { | ||
currentBlock: currentBlock, | ||
txHash: req.txHash, | ||
txBlock: txData.slot, | ||
txStatus: txStatus, | ||
txData: txData as unknown as CustomTransactionResponse | null, | ||
}; | ||
} | ||
|
||
static async getTokens(solanaish: Solanaish, req: TokensRequest) { | ||
let tokens: TokenInfo[] = []; | ||
|
||
if (!req.tokenSymbols) { | ||
tokens = solanaish.storedTokenList; | ||
} else { | ||
for (const symbol of req.tokenSymbols as string[]) { | ||
const token = solanaish.getTokenBySymbol(symbol); | ||
if (token) { | ||
tokens.push(token); | ||
} | ||
} | ||
} | ||
|
||
return { tokens }; | ||
} | ||
} | ||
|
||
export const balances = SolanaController.balances; | ||
export const poll = SolanaController.poll; | ||
export const getTokens = SolanaController.getTokens; | ||
export let priorityFeeMultiplier: number = 1; |
Oops, something went wrong.