Now use solana.tokenlist.json for token lookups.

This commit is contained in:
Geoff Taylor 2021-06-01 18:16:02 +01:00
parent cbd42d24ae
commit f73ee9ca19
10 changed files with 8507 additions and 335 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "fitting-ticket",
"id": "successful-ordinary",
"metadata": {},
"source": [
"# ⚠ Warning\n",
@ -16,7 +16,7 @@
},
{
"cell_type": "markdown",
"id": "historical-grace",
"id": "living-league",
"metadata": {},
"source": [
"# 🥭 Constants\n",
@ -27,7 +27,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "subtle-idaho",
"id": "spatial-korean",
"metadata": {
"jupyter": {
"source_hidden": true
@ -44,7 +44,7 @@
},
{
"cell_type": "markdown",
"id": "institutional-earthquake",
"id": "constitutional-former",
"metadata": {},
"source": [
"## SYSTEM_PROGRAM_ADDRESS\n",
@ -55,7 +55,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "everyday-donna",
"id": "undefined-majority",
"metadata": {},
"outputs": [],
"source": [
@ -64,27 +64,27 @@
},
{
"cell_type": "markdown",
"id": "motivated-northwest",
"id": "liberal-hamilton",
"metadata": {},
"source": [
"## SOL_MINT_ADDRESS\n",
"\n",
"The mint address of the SOL token."
"The fake mint address of the SOL token. **Note:** Wrapped SOL has a different mint address - it is So11111111111111111111111111111111111111112."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "speaking-homework",
"id": "accepting-circumstances",
"metadata": {},
"outputs": [],
"source": [
"SOL_MINT_ADDRESS = PublicKey(\"So11111111111111111111111111111111111111112\")"
"SOL_MINT_ADDRESS = PublicKey(\"So11111111111111111111111111111111111111111\")"
]
},
{
"cell_type": "markdown",
"id": "dated-appeal",
"id": "sacred-valve",
"metadata": {},
"source": [
"## SOL_DECIMALS\n",
@ -95,7 +95,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ready-tension",
"id": "female-customs",
"metadata": {},
"outputs": [],
"source": [
@ -104,7 +104,7 @@
},
{
"cell_type": "markdown",
"id": "artistic-batch",
"id": "excess-tyler",
"metadata": {},
"source": [
"## SOL_DECIMAL_DIVISOR decimal\n",
@ -115,7 +115,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "powerful-warrior",
"id": "divine-concord",
"metadata": {},
"outputs": [],
"source": [
@ -124,7 +124,7 @@
},
{
"cell_type": "markdown",
"id": "mathematical-gender",
"id": "western-removal",
"metadata": {},
"source": [
"## NUM_TOKENS\n",
@ -135,7 +135,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "isolated-sandwich",
"id": "hungry-disco",
"metadata": {},
"outputs": [],
"source": [
@ -144,7 +144,7 @@
},
{
"cell_type": "markdown",
"id": "marine-florist",
"id": "abroad-woman",
"metadata": {},
"source": [
"## NUM_MARKETS\n",
@ -155,7 +155,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "defensive-jewel",
"id": "flush-wages",
"metadata": {},
"outputs": [],
"source": [
@ -164,7 +164,7 @@
},
{
"cell_type": "markdown",
"id": "optimum-wagner",
"id": "pleasant-convergence",
"metadata": {},
"source": [
"# WARNING_DISCLAIMER_TEXT\n",
@ -175,7 +175,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "arranged-hypothesis",
"id": "residential-roots",
"metadata": {},
"outputs": [],
"source": [
@ -195,7 +195,7 @@
},
{
"cell_type": "markdown",
"id": "focused-electricity",
"id": "surrounded-magnet",
"metadata": {},
"source": [
"## MangoConstants\n",
@ -206,7 +206,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "otherwise-pencil",
"id": "radical-submission",
"metadata": {},
"outputs": [],
"source": [
@ -216,7 +216,7 @@
},
{
"cell_type": "markdown",
"id": "dependent-pursuit",
"id": "dutch-tension",
"metadata": {},
"source": [
"# 🏃 Running\n",
@ -227,7 +227,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "primary-graphic",
"id": "settled-clock",
"metadata": {},
"outputs": [],
"source": [

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "proud-accommodation",
"id": "artistic-cheese",
"metadata": {},
"source": [
"# ⚠ Warning\n",
@ -16,7 +16,7 @@
},
{
"cell_type": "markdown",
"id": "manufactured-subcommittee",
"id": "endless-table",
"metadata": {},
"source": [
"# 🥭 Context\n",
@ -26,7 +26,7 @@
},
{
"cell_type": "markdown",
"id": "academic-liberia",
"id": "willing-companion",
"metadata": {},
"source": [
"## Environment Variables\n",
@ -41,7 +41,7 @@
},
{
"cell_type": "markdown",
"id": "equivalent-conspiracy",
"id": "infinite-ambassador",
"metadata": {},
"source": [
"## Provided Configured Objects\n",
@ -61,7 +61,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "automotive-diamond",
"id": "suffering-soccer",
"metadata": {
"jupyter": {
"source_hidden": true
@ -86,7 +86,7 @@
},
{
"cell_type": "markdown",
"id": "private-vessel",
"id": "unlimited-plymouth",
"metadata": {},
"source": [
"## Context class"
@ -95,7 +95,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "blessed-azerbaijan",
"id": "through-factory",
"metadata": {},
"outputs": [],
"source": [
@ -172,18 +172,9 @@
" return name\n",
" return \"« Unknown Group »\"\n",
"\n",
" def lookup_market_name(self, market_address: PublicKey) -> str:\n",
" return Context._lookup_name_by_address(market_address, MangoConstants[self.cluster][\"mango_groups\"][self.group_name][\"spot_market_symbols\"]) or \"« Unknown Market »\"\n",
"\n",
" def lookup_oracle_name(self, token_address: PublicKey) -> str:\n",
" return Context._lookup_name_by_address(token_address, MangoConstants[self.cluster][\"oracles\"]) or \"« Unknown Oracle »\"\n",
"\n",
" def lookup_token_name(self, token_address: PublicKey) -> typing.Optional[str]:\n",
" return Context._lookup_name_by_address(token_address, MangoConstants[self.cluster][\"mango_groups\"][self.group_name][\"symbols\"])\n",
"\n",
" def lookup_token_address(self, token_name: str) -> typing.Optional[PublicKey]:\n",
" return Context._lookup_address_by_name(token_name, MangoConstants[self.cluster][\"mango_groups\"][self.group_name][\"symbols\"])\n",
"\n",
" def wait_for_confirmation(self, transaction_id: str, max_wait_in_seconds: int = 60) -> typing.Optional[typing.Dict]:\n",
" self.logger.info(f\"Waiting up to {max_wait_in_seconds} seconds for {transaction_id}.\")\n",
" for wait in range(0, max_wait_in_seconds):\n",
@ -253,7 +244,7 @@
},
{
"cell_type": "markdown",
"id": "guilty-conservation",
"id": "brazilian-ethnic",
"metadata": {},
"source": [
"## default_context object\n",
@ -264,7 +255,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "classified-underground",
"id": "scenic-morgan",
"metadata": {},
"outputs": [],
"source": [
@ -283,7 +274,7 @@
},
{
"cell_type": "markdown",
"id": "ceramic-nightlife",
"id": "educational-equilibrium",
"metadata": {},
"source": [
"## solana_context object\n",
@ -294,7 +285,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "animated-louisiana",
"id": "published-jordan",
"metadata": {},
"outputs": [],
"source": [
@ -306,7 +297,7 @@
},
{
"cell_type": "markdown",
"id": "thick-crash",
"id": "beautiful-coffee",
"metadata": {},
"source": [
"## serum_context object\n",
@ -317,7 +308,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "behavioral-laser",
"id": "velvet-bride",
"metadata": {},
"outputs": [],
"source": [
@ -329,7 +320,7 @@
},
{
"cell_type": "markdown",
"id": "neural-malpractice",
"id": "fiscal-contribution",
"metadata": {},
"source": [
"# 🏃 Running\n",
@ -340,7 +331,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "previous-capacity",
"id": "recovered-proceeding",
"metadata": {},
"outputs": [],
"source": [
@ -349,10 +340,6 @@
"\n",
" print(default_context)\n",
"\n",
" print(\"Lookup ETH token name result:\", default_context.lookup_token_name(PublicKey(\"2FPyTwcZLUg1MDrwsyoP4D6s1tM7hAkHYRjkNb5w6Pxk\")))\n",
" print(\"Lookup ETH token address result:\", default_context.lookup_token_address(\"ETH\"))\n",
" print(\"Lookup BTC/USDC market name result:\", default_context.lookup_market_name(PublicKey(\"CVfYa8RGXnuDBeGmniCcdkBwoLqVxh92xB1JqgRQx3F\")))\n",
"\n",
" # Fill out your account address between the quotes below\n",
" MY_ACCOUNT_ADDRESS = \"\"\n",
" # Don't edit anything beyond here.\n",

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "corresponding-metabolism",
"id": "numeric-sheep",
"metadata": {},
"source": [
"# ⚠ Warning\n",
@ -16,7 +16,7 @@
},
{
"cell_type": "markdown",
"id": "hollywood-victory",
"id": "lesser-small",
"metadata": {},
"source": [
"# 🥭 Instructions\n",
@ -27,7 +27,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "disturbed-washer",
"id": "african-picking",
"metadata": {
"jupyter": {
"source_hidden": true
@ -55,7 +55,7 @@
},
{
"cell_type": "markdown",
"id": "different-philosophy",
"id": "trained-cartridge",
"metadata": {},
"source": [
"# InstructionBuilder class\n",
@ -66,7 +66,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "secret-eugene",
"id": "apparent-plane",
"metadata": {},
"outputs": [],
"source": [
@ -85,7 +85,7 @@
},
{
"cell_type": "markdown",
"id": "accessory-drunk",
"id": "daily-dependence",
"metadata": {},
"source": [
"# ForceCancelOrdersInstructionBuilder class"
@ -93,7 +93,7 @@
},
{
"cell_type": "markdown",
"id": "touched-consideration",
"id": "ceramic-football",
"metadata": {},
"source": [
"## Rust Interface\n",
@ -125,7 +125,7 @@
},
{
"cell_type": "markdown",
"id": "blank-biodiversity",
"id": "empirical-ultimate",
"metadata": {},
"source": [
"## Client API call\n",
@ -169,7 +169,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "physical-gentleman",
"id": "eligible-madison",
"metadata": {},
"outputs": [],
"source": [
@ -200,7 +200,7 @@
" AccountMeta(is_signer=False, is_writable=True, pubkey=self.margin_account.address),\n",
" AccountMeta(is_signer=False, is_writable=True, pubkey=self.market_metadata.base.vault),\n",
" AccountMeta(is_signer=False, is_writable=True, pubkey=self.market_metadata.quote.vault),\n",
" AccountMeta(is_signer=False, is_writable=True, pubkey=self.market_metadata.spot),\n",
" AccountMeta(is_signer=False, is_writable=True, pubkey=self.market_metadata.spot.address),\n",
" AccountMeta(is_signer=False, is_writable=True, pubkey=self.market.state.bids()),\n",
" AccountMeta(is_signer=False, is_writable=True, pubkey=self.market.state.asks()),\n",
" AccountMeta(is_signer=False, is_writable=False, pubkey=self.group.signer_key),\n",
@ -224,7 +224,7 @@
" def from_margin_account_and_market(context: Context, group: Group, wallet: Wallet, margin_account: MarginAccount, market_metadata: MarketMetadata) -> \"ForceCancelOrdersInstructionBuilder\":\n",
" market = market_metadata.fetch_market(context)\n",
" nonce = struct.pack(\"<Q\", market.state.vault_signer_nonce())\n",
" dex_signer = PublicKey.create_program_address([bytes(market_metadata.spot), nonce], context.dex_program_id)\n",
" dex_signer = PublicKey.create_program_address([bytes(market_metadata.spot.address), nonce], context.dex_program_id)\n",
" oracles = list([mkt.oracle for mkt in group.markets])\n",
"\n",
" return ForceCancelOrdersInstructionBuilder(context, group, wallet, margin_account, market_metadata, market, oracles, dex_signer)\n",
@ -258,7 +258,7 @@
" liqee_margin_account_acc: &Pubkey: {self.margin_account.address},\n",
" base_vault_pk: &Pubkey: {self.market_metadata.base.vault},\n",
" quote_vault_pk: &Pubkey: {self.market_metadata.quote.vault},\n",
" spot_market_pk: &Pubkey: {self.market_metadata.spot},\n",
" spot_market_pk: &Pubkey: {self.market_metadata.spot.address},\n",
" bids_pk: &Pubkey: {self.market.state.bids()},\n",
" asks_pk: &Pubkey: {self.market.state.asks()},\n",
" signer_pk: &Pubkey: {self.group.signer_key},\n",
@ -275,7 +275,7 @@
},
{
"cell_type": "markdown",
"id": "changing-humanity",
"id": "expanded-separate",
"metadata": {},
"source": [
"# LiquidateInstructionBuilder class\n",
@ -287,7 +287,7 @@
},
{
"cell_type": "markdown",
"id": "occupational-steam",
"id": "stupid-arrest",
"metadata": {},
"source": [
"## Rust Interface\n",
@ -333,7 +333,7 @@
},
{
"cell_type": "markdown",
"id": "heard-farming",
"id": "identical-november",
"metadata": {},
"source": [
"## Client API call\n",
@ -370,7 +370,7 @@
},
{
"cell_type": "markdown",
"id": "changed-literacy",
"id": "logical-burning",
"metadata": {},
"source": [
"## from_margin_account_and_market() function\n",
@ -391,7 +391,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "former-cemetery",
"id": "pending-services",
"metadata": {},
"outputs": [],
"source": [
@ -503,7 +503,7 @@
},
{
"cell_type": "markdown",
"id": "traditional-assembly",
"id": "retired-bundle",
"metadata": {},
"source": [
"# 🏃 Running"
@ -512,7 +512,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "victorian-character",
"id": "wrong-rebel",
"metadata": {},
"outputs": [],
"source": [

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "enclosed-algebra",
"id": "ordinary-duplicate",
"metadata": {},
"source": [
"# ⚠ Warning\n",
@ -16,7 +16,7 @@
},
{
"cell_type": "markdown",
"id": "aggressive-physiology",
"id": "sound-earthquake",
"metadata": {},
"source": [
"# 🥭 Notification\n",
@ -27,7 +27,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "patient-blame",
"id": "tamil-carpet",
"metadata": {
"jupyter": {
"source_hidden": true
@ -49,7 +49,7 @@
},
{
"cell_type": "markdown",
"id": "global-feature",
"id": "brave-coordinate",
"metadata": {},
"source": [
"# NotificationTarget class\n",
@ -64,7 +64,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "noted-marking",
"id": "weekly-financing",
"metadata": {},
"outputs": [],
"source": [
@ -88,7 +88,7 @@
},
{
"cell_type": "markdown",
"id": "forward-compact",
"id": "negative-madagascar",
"metadata": {},
"source": [
"# TelegramNotificationTarget class\n",
@ -113,7 +113,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "quarterly-nothing",
"id": "binary-export",
"metadata": {},
"outputs": [],
"source": [
@ -136,7 +136,7 @@
},
{
"cell_type": "markdown",
"id": "published-ideal",
"id": "whole-design",
"metadata": {},
"source": [
"# DiscordNotificationTarget class\n",
@ -147,7 +147,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "junior-conditions",
"id": "naughty-disney",
"metadata": {},
"outputs": [],
"source": [
@ -170,7 +170,7 @@
},
{
"cell_type": "markdown",
"id": "actual-bronze",
"id": "finite-caribbean",
"metadata": {},
"source": [
"# MailjetNotificationTarget class\n",
@ -224,7 +224,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "reduced-rabbit",
"id": "daily-accreditation",
"metadata": {},
"outputs": [],
"source": [
@ -271,7 +271,7 @@
},
{
"cell_type": "markdown",
"id": "gross-stereo",
"id": "physical-norfolk",
"metadata": {},
"source": [
"# CsvFileNotificationTarget class\n",
@ -288,7 +288,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "given-african",
"id": "awful-airport",
"metadata": {},
"outputs": [],
"source": [
@ -318,7 +318,7 @@
},
{
"cell_type": "markdown",
"id": "adult-chicago",
"id": "instrumental-adams",
"metadata": {},
"source": [
"# FilteringNotificationTarget class\n",
@ -329,7 +329,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "acceptable-christopher",
"id": "iraqi-dryer",
"metadata": {},
"outputs": [],
"source": [
@ -349,7 +349,7 @@
},
{
"cell_type": "markdown",
"id": "falling-cattle",
"id": "monthly-translator",
"metadata": {},
"source": [
"# parse_subscription_target() function\n",
@ -362,7 +362,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "speaking-vocabulary",
"id": "overall-camera",
"metadata": {},
"outputs": [],
"source": [
@ -383,7 +383,7 @@
},
{
"cell_type": "markdown",
"id": "bacterial-coffee",
"id": "original-heating",
"metadata": {},
"source": [
"## NotificationHandler class\n",
@ -394,7 +394,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "norman-bruce",
"id": "different-breach",
"metadata": {},
"outputs": [],
"source": [
@ -410,7 +410,7 @@
},
{
"cell_type": "markdown",
"id": "cloudy-czech",
"id": "entertaining-mobility",
"metadata": {},
"source": [
"# ✅ Testing"
@ -419,7 +419,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "rough-structure",
"id": "animal-player",
"metadata": {},
"outputs": [],
"source": [
@ -466,7 +466,7 @@
},
{
"cell_type": "markdown",
"id": "solved-switzerland",
"id": "after-definition",
"metadata": {},
"source": [
"# 🏃 Running\n",
@ -477,7 +477,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "signed-guyana",
"id": "anticipated-destruction",
"metadata": {},
"outputs": [],
"source": [
@ -503,18 +503,21 @@
" # from Context import default_context\n",
" # from decimal import Decimal\n",
" # from Wallet import default_wallet\n",
" # token_lookup = TokenLookup.default_lookups()\n",
" # balances_before = [\n",
" # TokenValue(TokenLookup.find_by_name(default_context, \"ETH\"), Decimal(1)),\n",
" # TokenValue(TokenLookup.find_by_name(default_context, \"BTC\"), Decimal(\"0.1\")),\n",
" # TokenValue(TokenLookup.find_by_name(default_context, \"USDT\"), Decimal(1000))\n",
" # TokenValue(token_lookup.find_by_symbol(\"ETH\"), Decimal(1)),\n",
" # TokenValue(token_lookup.find_by_symbol(\"BTC\"), Decimal(\"0.1\")),\n",
" # TokenValue(token_lookup.find_by_symbol(\"USDT\"), Decimal(1000))\n",
" # ]\n",
" # balances_after = [\n",
" # TokenValue(TokenLookup.find_by_name(default_context, \"ETH\"), Decimal(1)),\n",
" # TokenValue(TokenLookup.find_by_name(default_context, \"BTC\"), Decimal(\"0.05\")),\n",
" # TokenValue(TokenLookup.find_by_name(default_context, \"USDT\"), Decimal(2000))\n",
" # TokenValue(token_lookup.find_by_symbol(\"ETH\"), Decimal(1)),\n",
" # TokenValue(token_lookup.find_by_symbol(\"BTC\"), Decimal(\"0.05\")),\n",
" # TokenValue(token_lookup.find_by_symbol(\"USDT\"), Decimal(2000))\n",
" # ]\n",
" #\n",
" # event = LiquidationEvent(datetime.datetime.now(),\n",
" # \"Liquidator Name\",\n",
" # \"GROUP_NAME\",\n",
" # True,\n",
" # \"SIGNATURE\",\n",
" # default_wallet.address,\n",
" # default_wallet.address,\n",

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "juvenile-netherlands",
"id": "french-mexico",
"metadata": {},
"source": [
"# ⚠ Warning\n",
@ -16,7 +16,7 @@
},
{
"cell_type": "markdown",
"id": "changed-correspondence",
"id": "eastern-relevance",
"metadata": {},
"source": [
"# 🥭 TradeExecutor\n",
@ -31,7 +31,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "pacific-organic",
"id": "descending-attendance",
"metadata": {
"jupyter": {
"source_hidden": true
@ -59,7 +59,7 @@
},
{
"cell_type": "markdown",
"id": "champion-wheel",
"id": "impressed-hazard",
"metadata": {},
"source": [
"# TradeExecutor class\n",
@ -77,7 +77,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "competent-former",
"id": "thirty-habitat",
"metadata": {},
"outputs": [],
"source": [
@ -104,7 +104,7 @@
},
{
"cell_type": "markdown",
"id": "latin-electronics",
"id": "possible-blank",
"metadata": {},
"source": [
"## NullTradeExecutor class\n",
@ -115,7 +115,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "accessible-decline",
"id": "subjective-violation",
"metadata": {},
"outputs": [],
"source": [
@ -144,7 +144,7 @@
},
{
"cell_type": "markdown",
"id": "noted-immunology",
"id": "paperback-america",
"metadata": {},
"source": [
"# SerumImmediateTradeExecutor class\n",
@ -174,7 +174,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "enabling-convenience",
"id": "greatest-impression",
"metadata": {},
"outputs": [],
"source": [
@ -327,7 +327,7 @@
" self.reporter(\"All settlement transaction IDs confirmed.\")\n",
"\n",
" def _tokens_and_market(self, symbol: str) -> typing.Tuple[MarketMetadata, Token, Token]:\n",
" base_token = BasketToken.find_by_name(self.group.basket_tokens, symbol).token\n",
" base_token = BasketToken.find_by_symbol(self.group.basket_tokens, symbol).token\n",
" quote_token = self.group.shared_quote_token.token\n",
" self.logger.info(f\"Base token: {base_token}\")\n",
" self.logger.info(f\"Quote token: {quote_token}\")\n",
@ -356,7 +356,7 @@
},
{
"cell_type": "markdown",
"id": "front-queens",
"id": "living-mitchell",
"metadata": {},
"source": [
"# 🏃 Running\n",
@ -369,7 +369,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "optimum-judgment",
"id": "collected-simon",
"metadata": {},
"outputs": [],
"source": [

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "corrected-sunrise",
"id": "described-pencil",
"metadata": {},
"source": [
"# ⚠ Warning\n",
@ -16,7 +16,7 @@
},
{
"cell_type": "markdown",
"id": "aware-hollywood",
"id": "nervous-bikini",
"metadata": {},
"source": [
"# 🥭 TransactionScount\n",
@ -29,7 +29,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "coastal-wilson",
"id": "fitting-andrews",
"metadata": {
"jupyter": {
"source_hidden": true
@ -54,7 +54,7 @@
},
{
"cell_type": "markdown",
"id": "indirect-mount",
"id": "weighted-annotation",
"metadata": {},
"source": [
"## Transaction Indices\n",
@ -79,7 +79,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "gothic-grace",
"id": "spiritual-buffer",
"metadata": {},
"outputs": [],
"source": [
@ -149,7 +149,7 @@
},
{
"cell_type": "markdown",
"id": "oriented-defense",
"id": "suspected-broadcasting",
"metadata": {},
"source": [
"## TransactionInstruction class\n",
@ -160,7 +160,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "entire-russian",
"id": "compact-extreme",
"metadata": {},
"outputs": [],
"source": [
@ -273,7 +273,7 @@
},
{
"cell_type": "markdown",
"id": "auburn-liability",
"id": "portuguese-implement",
"metadata": {},
"source": [
"# TransactionScout class"
@ -282,7 +282,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "strong-olive",
"id": "focused-poultry",
"metadata": {},
"outputs": [],
"source": [
@ -358,7 +358,7 @@
" decimals = Decimal(balance[\"uiTokenAmount\"][\"decimals\"])\n",
" divisor = Decimal(10) ** decimals\n",
" value = amount / divisor\n",
" token = TokenLookup.find_by_mint(context, mint)\n",
" token = TokenLookup.default_lookups().find_by_mint(mint)\n",
" return OwnedTokenValue(account, TokenValue(token, value))\n",
"\n",
" try:\n",
@ -436,7 +436,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "enormous-boxing",
"id": "electronic-cassette",
"metadata": {},
"outputs": [],
"source": [
@ -462,7 +462,7 @@
},
{
"cell_type": "markdown",
"id": "lonely-proceeding",
"id": "false-merchant",
"metadata": {},
"source": [
"# 🏃 Running\n",
@ -479,7 +479,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "static-affiliation",
"id": "recovered-times",
"metadata": {},
"outputs": [],
"source": [
@ -489,7 +489,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "quantitative-wellington",
"id": "descending-norwegian",
"metadata": {},
"outputs": [],
"source": [

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "important-firmware",
"id": "intense-illinois",
"metadata": {},
"source": [
"# ⚠ Warning\n",
@ -16,7 +16,7 @@
},
{
"cell_type": "markdown",
"id": "limited-ordering",
"id": "ceramic-smoke",
"metadata": {},
"source": [
"# 🥭 WalletBalancer\n",
@ -31,7 +31,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "immediate-berlin",
"id": "adequate-costume",
"metadata": {
"jupyter": {
"source_hidden": true
@ -54,7 +54,7 @@
},
{
"cell_type": "markdown",
"id": "atomic-studio",
"id": "special-nomination",
"metadata": {},
"source": [
"# Target Balances\n",
@ -75,7 +75,7 @@
},
{
"cell_type": "markdown",
"id": "muslim-whale",
"id": "unknown-relationship",
"metadata": {},
"source": [
"## TargetBalance class\n",
@ -86,7 +86,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "fallen-plumbing",
"id": "mighty-stock",
"metadata": {},
"outputs": [],
"source": [
@ -105,7 +105,7 @@
},
{
"cell_type": "markdown",
"id": "acting-december",
"id": "earlier-internship",
"metadata": {},
"source": [
"## FixedTargetBalance class\n",
@ -116,7 +116,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "fuzzy-laptop",
"id": "electronic-cycle",
"metadata": {},
"outputs": [],
"source": [
@ -134,7 +134,7 @@
},
{
"cell_type": "markdown",
"id": "ready-costume",
"id": "muslim-priority",
"metadata": {},
"source": [
"## PercentageTargetBalance\n",
@ -150,7 +150,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "premium-basin",
"id": "potential-mustang",
"metadata": {},
"outputs": [],
"source": [
@ -170,7 +170,7 @@
},
{
"cell_type": "markdown",
"id": "behavioral-convertible",
"id": "assigned-mississippi",
"metadata": {},
"source": [
"## TargetBalanceParser class\n",
@ -183,7 +183,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "democratic-crowd",
"id": "hired-laundry",
"metadata": {},
"outputs": [],
"source": [
@ -197,7 +197,7 @@
" except Exception as exception:\n",
" raise Exception(f\"Could not parse target balance '{to_parse}'\") from exception\n",
"\n",
" token = Token.find_by_name(self.tokens, token_name)\n",
" token = Token.find_by_symbol(self.tokens, token_name)\n",
"\n",
" # The value we have may be an int (like 27), a fraction (like 0.1) or a percentage\n",
" # (like 25%). In all cases we want the number as a number, but we also want to know if\n",
@ -221,7 +221,7 @@
},
{
"cell_type": "markdown",
"id": "supreme-kentucky",
"id": "private-colorado",
"metadata": {},
"source": [
"# sort_changes_for_trades function\n",
@ -234,7 +234,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "small-period",
"id": "signal-reputation",
"metadata": {},
"outputs": [],
"source": [
@ -244,7 +244,7 @@
},
{
"cell_type": "markdown",
"id": "significant-bearing",
"id": "regular-array",
"metadata": {},
"source": [
"# calculate_required_balance_changes function\n",
@ -255,7 +255,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "regulation-essay",
"id": "minimal-kinase",
"metadata": {},
"outputs": [],
"source": [
@ -271,7 +271,7 @@
},
{
"cell_type": "markdown",
"id": "taken-salvation",
"id": "round-appendix",
"metadata": {},
"source": [
"# FilterSmallChanges class\n",
@ -286,7 +286,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "clean-horizon",
"id": "european-ratio",
"metadata": {},
"outputs": [],
"source": [
@ -315,7 +315,7 @@
},
{
"cell_type": "markdown",
"id": "animated-switzerland",
"id": "three-shareware",
"metadata": {},
"source": [
"# WalletBalancers\n",
@ -331,7 +331,7 @@
},
{
"cell_type": "markdown",
"id": "essential-heating",
"id": "destroyed-validation",
"metadata": {},
"source": [
"## WalletBalancer class\n",
@ -342,7 +342,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "behind-product",
"id": "engaged-thunder",
"metadata": {},
"outputs": [],
"source": [
@ -354,7 +354,7 @@
},
{
"cell_type": "markdown",
"id": "mighty-minimum",
"id": "democratic-series",
"metadata": {},
"source": [
"## NullWalletBalancer class\n",
@ -365,7 +365,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "serious-ghost",
"id": "wound-flour",
"metadata": {},
"outputs": [],
"source": [
@ -376,7 +376,7 @@
},
{
"cell_type": "markdown",
"id": "metric-veteran",
"id": "painful-stake",
"metadata": {},
"source": [
"## LiveWalletBalancer class\n",
@ -387,7 +387,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "shared-craft",
"id": "south-ministry",
"metadata": {},
"outputs": [],
"source": [
@ -454,7 +454,7 @@
},
{
"cell_type": "markdown",
"id": "living-fitness",
"id": "compatible-mustang",
"metadata": {},
"source": [
"# ✅ Testing"
@ -463,7 +463,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "superb-proportion",
"id": "little-exposure",
"metadata": {},
"outputs": [],
"source": [
@ -548,7 +548,7 @@
},
{
"cell_type": "markdown",
"id": "built-evidence",
"id": "emotional-instruction",
"metadata": {},
"source": [
"# 🏃 Running\n",
@ -559,7 +559,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "welcome-secretariat",
"id": "adjusted-myrtle",
"metadata": {},
"outputs": [],
"source": [
@ -569,9 +569,9 @@
" from Context import default_context\n",
"\n",
" group = Group.load(default_context)\n",
" eth = BasketToken.find_by_name(group.basket_tokens, \"eth\").token\n",
" btc = BasketToken.find_by_name(group.basket_tokens, \"btc\").token\n",
" usdt = BasketToken.find_by_name(group.basket_tokens, \"usdt\").token\n",
" eth = BasketToken.find_by_symbol(group.basket_tokens, \"eth\").token\n",
" btc = BasketToken.find_by_symbol(group.basket_tokens, \"btc\").token\n",
" usdt = BasketToken.find_by_symbol(group.basket_tokens, \"usdt\").token\n",
"\n",
" parser = TargetBalanceParser([eth, btc])\n",
" eth_target = parser.parse(\"ETH:20%\")\n",

View File

@ -80,7 +80,7 @@ try:
logging.info(f"Wallet address: {wallet.address}")
group = Group.load(context)
group_basket_token = BasketToken.find_by_name(group.basket_tokens, args.token_symbol)
group_basket_token = BasketToken.find_by_symbol(group.basket_tokens, args.token_symbol)
group_token = group_basket_token.token
spl_token = Token(context.client, group_token.mint, TOKEN_PROGRAM_ID, wallet.account)

7996
solana.tokenlist.json Normal file

File diff suppressed because it is too large Load Diff