Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add print for classes, fix decimal import #35

Open
wants to merge 4 commits into
base: abstract_agent_class
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 91 additions & 45 deletions delegator_portfolio.ipynb

Large diffs are not rendered by default.

135 changes: 64 additions & 71 deletions getAgent.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
"name": "stdout",
"output_type": "stream",
"text": [
"stakeDelegateds: 154 events\n",
"stakeDelegatedLockeds: 14 events\n",
"stakeDelegatedWithdrawns: 0 events\n",
"allocationCloseds: 6 events\n",
"allocationCollecteds: 0 events\n",
"stakeDepositeds: 7 events\n",
"rewardsAssigneds: 6 events\n",
"delegationParametersUpdateds: 5 events\n",
"allocationCreateds: 8 events\n",
"TOTAL NUMBER OF EVENTS: 200\n",
"You should set SIMULATION_TIME_STEPS in config.py to a minimum of 200 to capture all events.\n",
"stakeDelegateds: 605 events\n",
"stakeDelegatedLockeds: 375 events\n",
"stakeDelegatedWithdrawns: 326 events\n",
"allocationCloseds: 47 events\n",
"allocationCollecteds: 16 events\n",
"stakeDepositeds: 25 events\n",
"rewardsAssigneds: 47 events\n",
"delegationParametersUpdateds: 6 events\n",
"allocationCreateds: 51 events\n",
"TOTAL NUMBER OF EVENTS: 1529\n",
"You should set SIMULATION_TIME_STEPS in config.py to a minimum of 1529 to capture all events.\n",
"\n"
]
}
Expand Down Expand Up @@ -89,131 +89,111 @@
" <th>indexers</th>\n",
" <th>delegator_portfolios</th>\n",
" <th>block_number</th>\n",
" <th>epoch</th>\n",
" <th>injected_event_shift</th>\n",
" <th>simulation</th>\n",
" <th>subset</th>\n",
" <th>run</th>\n",
" <th>substep</th>\n",
" <th>timestep</th>\n",
" <th>cumulative_indexing_revenue</th>\n",
" <th>cumulative_query_revenue</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>15</td>\n",
" <td>6</td>\n",
" <td>{'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':...</td>\n",
" <td>{}</td>\n",
" <td>11474009</td>\n",
" <td>4</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>15</td>\n",
" <td>6</td>\n",
" <td>1</td>\n",
" <td>{'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':...</td>\n",
" <td>{'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>30</td>\n",
" <td>12</td>\n",
" <td>{'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':...</td>\n",
" <td>{}</td>\n",
" <td>11474009</td>\n",
" <td>4</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>15</td>\n",
" <td>6</td>\n",
" <td>2</td>\n",
" <td>{'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':...</td>\n",
" <td>{'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>45</td>\n",
" <td>18</td>\n",
" <td>{'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':...</td>\n",
" <td>{'0x9fe0a203e190d87cef6b4b80b24fae73f243b3ea':...</td>\n",
" <td>{}</td>\n",
" <td>11474307</td>\n",
" <td>4</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>15</td>\n",
" <td>6</td>\n",
" <td>3</td>\n",
" <td>{'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':...</td>\n",
" <td>{'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>60</td>\n",
" <td>24</td>\n",
" <td>{'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':...</td>\n",
" <td>{'0x9fe0a203e190d87cef6b4b80b24fae73f243b3ea':...</td>\n",
" <td>{'0xd776a7306ee6a060cebb46b46d305e88fd39ba84':...</td>\n",
" <td>11474332</td>\n",
" <td>4</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>15</td>\n",
" <td>6</td>\n",
" <td>4</td>\n",
" <td>{'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':...</td>\n",
" <td>{'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>75</td>\n",
" <td>30</td>\n",
" <td>{'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':...</td>\n",
" <td>{'0x9fe0a203e190d87cef6b4b80b24fae73f243b3ea':...</td>\n",
" <td>{'0xd776a7306ee6a060cebb46b46d305e88fd39ba84':...</td>\n",
" <td>11474426</td>\n",
" <td>4</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>15</td>\n",
" <td>6</td>\n",
" <td>5</td>\n",
" <td>{'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':...</td>\n",
" <td>{'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" index indexers \\\n",
"0 15 {'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':... \n",
"1 30 {'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':... \n",
"2 45 {'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':... \n",
"3 60 {'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':... \n",
"4 75 {'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':... \n",
"\n",
" delegator_portfolios block_number \\\n",
"0 {} 11474009 \n",
"1 {} 11474009 \n",
"2 {'0x9fe0a203e190d87cef6b4b80b24fae73f243b3ea':... 11474307 \n",
"3 {'0x9fe0a203e190d87cef6b4b80b24fae73f243b3ea':... 11474332 \n",
"4 {'0x9fe0a203e190d87cef6b4b80b24fae73f243b3ea':... 11474426 \n",
"0 6 {'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':... \n",
"1 12 {'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':... \n",
"2 18 {'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':... \n",
"3 24 {'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':... \n",
"4 30 {'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':... \n",
"\n",
" injected_event_shift simulation subset run substep timestep \\\n",
"0 0 0 0 1 15 1 \n",
"1 0 0 0 1 15 2 \n",
"2 0 0 0 1 15 3 \n",
"3 0 0 0 1 15 4 \n",
"4 0 0 0 1 15 5 \n",
" delegator_portfolios block_number epoch \\\n",
"0 {} 11474009 4 \n",
"1 {} 11474009 4 \n",
"2 {} 11474307 4 \n",
"3 {'0xd776a7306ee6a060cebb46b46d305e88fd39ba84':... 11474332 4 \n",
"4 {'0xd776a7306ee6a060cebb46b46d305e88fd39ba84':... 11474426 4 \n",
"\n",
" cumulative_indexing_revenue \\\n",
"0 {'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':... \n",
"1 {'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':... \n",
"2 {'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':... \n",
"3 {'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':... \n",
"4 {'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':... \n",
"\n",
" cumulative_query_revenue \n",
"0 {'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':... \n",
"1 {'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':... \n",
"2 {'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':... \n",
"3 {'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':... \n",
"4 {'0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e':... "
" injected_event_shift simulation subset run substep timestep \n",
"0 0 0 0 1 6 1 \n",
"1 0 0 0 1 6 2 \n",
"2 0 0 0 1 6 3 \n",
"3 0 0 0 1 6 4 \n",
"4 0 0 0 1 6 5 "
]
},
"execution_count": 3,
Expand All @@ -227,11 +207,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"id": "260a79c6-d6b3-400a-93b2-8fe9ee10bb7a",
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"data": {
"text/plain": [
"self.id=1, self.shares=Decimal('0E-25'), self.holdings=Decimal('0'), self.undelegated_tokens=0"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.indexers.loc[1528]['0x7ab4cf25330ed7277ac7ab59380b68eea68abb0e'].delegators[1]"
]
}
],
"metadata": {
Expand All @@ -250,7 +243,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.10"
}
},
"nbformat": 4,
Expand Down
6 changes: 6 additions & 0 deletions model/parts/delegate_front_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,11 @@ def generate_output(self):
if self.plan:
# output must be a list of events.
self.output.append(self.plan)

def __str__(self):
"""
Print all attributes of a class
"""
return str(self.__class__) + ": " + str(self.__dict__)


8 changes: 7 additions & 1 deletion model/parts/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,10 @@ def __init__(self, indexer_id, pool_delegated_stake=Decimal(0), shares=Decimal(0

self.subgraphs = {} # key is subgraphDeploymentID, value is Subgraph

self.buffered_rewards_assigned = 0 # this is indexing rewards--we cannot attribute to subgraph until allocationCloseds event
self.buffered_rewards_assigned = 0 # this is indexing rewards--we cannot attribute to subgraph until allocationCloseds event

def __str__(self):
"""
Print all attributes of a class
"""
return str(self.__class__) + ": " + str(self.__dict__)
8 changes: 7 additions & 1 deletion model/parts/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ def __init__(self, id, holdings = Decimal(1000000000), eth_holdings = Decimal(10
self.delegate_block_number = delegate_block_number
self.withdraw_block_number = withdraw_block_number
self.indexer_ROI = indexer_ROI
self.indexer_ROI_time = indexer_ROI_time
self.indexer_ROI_time = indexer_ROI_time

def __str__(self):
"""
Print all attributes of a class
"""
return str(self.__class__) + ": " + str(self.__dict__)
2 changes: 1 addition & 1 deletion model/sys_params.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .parts import utils
from decimal import *
from decimal import Decimal
from sys import platform

R_i_rate = [0.03]
Expand Down