AllocationOpt.allocatablesubgraphs
— Method allocatablesubgraphs(s::FlexTable, config::AbstractDict)
For the subgraphs s
return a view of the subgraphs on which we can allocate.
julia> using AllocationOpt
+ 2.5
diff --git a/latest/api/index.html b/latest/api/index.html
index 23b255f..605fbd2 100644
--- a/latest/api/index.html
+++ b/latest/api/index.html
@@ -19,7 +19,7 @@
julia> SemioticOpt.x(alg)
2-element Vector{Float64}:
2.5
- 2.5source For the subgraphs For the subgraphs Create and push allocate actions to the action queue. Create and push allocate actions to the action queue. Do nothing. Do nothing. Print the rules that allocates to new subgraphs. ```julia julia> using AllocationOpt julia> using TheGraphData julia> a = flextable([ Dict("subgraphDeployment.ipfsHash" => "Qma", "id" => "0xa") ]) julia> t = flextable([ Dict("amount" => "1", "profit" => "0", "ipfshash" => "Qma"), Dict("amount" => "2", "profit" => "0", "ipfshash" => "Qmb"), ]) julia> AllocationOpt.allocate_action(Val(:rules), a, t, Dict()) graph indexer rules set Qmb decisionBasis always allocationAmount 2 1-element Vector{String}: "[0mgraph indexer rules set Qmb decisionBasis always allocationAmount 2" Return the components of a GraphQL query for active allocations of indexer For use with the TheGraphData.jl package. Print the rules that allocates to new subgraphs. ```julia julia> using AllocationOpt julia> using TheGraphData julia> a = flextable([ Dict("subgraphDeployment.ipfsHash" => "Qma", "id" => "0xa") ]) julia> t = flextable([ Dict("amount" => "1", "profit" => "0", "ipfshash" => "Qma"), Dict("amount" => "2", "profit" => "0", "ipfshash" => "Qmb"), ]) julia> AllocationOpt.allocate_action(Val(:rules), a, t, Dict()) graph indexer rules set Qmb decisionBasis always allocationAmount 2 1-element Vector{String}: "[0mgraph indexer rules set Qmb decisionBasis always allocationAmount 2" Return the components of a GraphQL query for active allocations of indexer For use with the TheGraphData.jl package. Extended Help You can find TheGraphData.jl at https://github.com/semiotic-ai/TheGraphData.jl The tokens available for the indexer to allocate in table Extended Help You can find TheGraphData.jl at https://github.com/semiotic-ai/TheGraphData.jl The tokens available for the indexer to allocate in table Compute the best profit amongst the given Compute the best profit amongst the given The tokens issued per block. ```julia julia> using AllocationOpt julia> using TheGraphData julia> n = flextable([ Dict( "id" => 1, "networkGRTIssuancePerBlock" => 1, "epochLength" => 28, "totalTokensSignalled" => 2, "currentEpoch" => 1, ) ]) julia> AllocationOpt.blockissuance(Val(:network), n) 1 The number of blocks in each epoch. ```julia julia> using AllocationOpt julia> using TheGraphData julia> n = flextable([ Dict( "id" => 1, "networkGRTIssuancePerBlock" => 1, "epochLength" => 28, "totalTokensSignalled" => 2, "currentEpoch" => 1, ) ]) julia> AllocationOpt.blocksperepoch(Val(:network), n) 28 Get the list of the ipfs hashes of allocations to close. The tokens issued per block. ```julia julia> using AllocationOpt julia> using TheGraphData julia> n = flextable([ Dict( "id" => 1, "networkGRTIssuancePerBlock" => 1, "epochLength" => 28, "totalTokensSignalled" => 2, "currentEpoch" => 1, ) ]) julia> AllocationOpt.blockissuance(Val(:network), n) 1 The number of blocks in each epoch. ```julia julia> using AllocationOpt julia> using TheGraphData julia> n = flextable([ Dict( "id" => 1, "networkGRTIssuancePerBlock" => 1, "epochLength" => 28, "totalTokensSignalled" => 2, "currentEpoch" => 1, ) ]) julia> AllocationOpt.blocksperepoch(Val(:network), n) 28 Get the list of the ipfs hashes of allocations to close. Set default values for the config dictionary if the value was not specified in the config file. Config Specification Set default values for the config dictionary if the value was not specified in the config file. Config Specification Convert all tables to be in GRT. Convert all tables to be in GRT. Convert the string currency fields in the allocation table to be in GRT. Convert the string currency fields in the allocation table to be in GRT. Convert the string currency fields in the indexer table to be in GRT. Convert the string currency fields in the indexer table to be in GRT. Convert the string currency fields in the network table to be in GRT. Convert the string currency fields in the network table to be in GRT. Convert the string currency fields in the subgraph table to be in GRT. Convert the string currency fields in the subgraph table to be in GRT. The current epoch. ```julia julia> using AllocationOpt julia> using TheGraphData julia> n = flextable([ Dict( "id" => 1, "networkGRTIssuancePerBlock" => 1, "epochLength" => 28, "totalTokensSignalled" => 2, "currentEpoch" => 1, ) ]) julia> AllocationOpt.currentepoch(Val(:network), n) 1 The tokens delegated to the indexer in table The current epoch. ```julia julia> using AllocationOpt julia> using TheGraphData julia> n = flextable([ Dict( "id" => 1, "networkGRTIssuancePerBlock" => 1, "epochLength" => 28, "totalTokensSignalled" => 2, "currentEpoch" => 1, ) ]) julia> AllocationOpt.currentepoch(Val(:network), n) 1 The tokens delegated to the indexer in table If this value is non-zero, the subgraph doesn't receive indexing rewards. If this value is non-zero, the subgraph doesn't receive indexing rewards. Find the indices of subgraphs that have "deniedAt" equal to zero. Find the indices of subgraphs that have "deniedAt" equal to zero. Analytic solution of the dual form of the optimisation problem given signals You should probably not use this function directly. Use Analytic solution of the dual form of the optimisation problem given signals You should probably not use this function directly. Use Given a Given a The frozen stake of the indexer with allocations The frozen stake of the indexer with allocations Find the indices of each unique value in Find the indices of each unique value in Get the allocation id for each allocation in Get the allocation id for each allocation in The indexing rewards for the allocation scalar The indexing rewards for the allocation scalar The indexing rewards for the allocation vector The indexing rewards for the allocation vector Get the ipfs hash of Get the ipfs hash of Get the ipfs hash of Get the ipfs hash of Return the components of a GraphQL query for the stake of indexer For use with the TheGraphData.jl package. Return the components of a GraphQL query for the stake of indexer For use with the TheGraphData.jl package. Extended Help You can find TheGraphData.jl at https://github.com/semiotic-ai/TheGraphData.jl The Lipschitz constant of the indexing reward function given signals Extended Help You can find TheGraphData.jl at https://github.com/semiotic-ai/TheGraphData.jl The Lipschitz constant of the indexing reward function given signals The locked tokens of the indexer in table The locked tokens of the indexer in table How many new tokens are issued over the allocation lifetime given network parameters How many new tokens are issued over the allocation lifetime given network parameters Get the non-zero elements of vector Get the non-zero elements of vector Return the components of a GraphQL query for network parameters. For use with the TheGraphData.jl package. Return the components of a GraphQL query for network parameters. For use with the TheGraphData.jl package. Extended Help You can find TheGraphData.jl at https://github.com/semiotic-ai/TheGraphData.jl Find the optimal solution vector given allocations of other indexers Dispatches to If Extended Help You can find TheGraphData.jl at https://github.com/semiotic-ai/TheGraphData.jl Find the optimal solution vector given allocations of other indexers Dispatches to If Find the optimal vectors for k ∈ [1, Find the optimal vectors for k ∈ [1, Find the optimal solution vector given allocations of other indexers Example Find the optimal solution vector given allocations of other indexers Example Optimise analytically over existing allocation vector Optimise analytically over existing allocation vector Find the optimal Find the optimal Find the optimal Example Find the optimal Example The pinned vector of the indexer. The pinned vector of the indexer. Analytic solution of the primal form of the optimisation problem given signals You should probably not use this function directly. Use Compute the profit for one allocation with reward Analytic solution of the primal form of the optimisation problem given signals You should probably not use this function directly. Use Compute the profit for one allocation with reward Given a If you have specified a "readdir" in the config, this will read from CSV files in that directory. Otherwise, this will query the specified Given a If you have specified a "readdir" in the config, this will read from CSV files in that directory. Otherwise, this will query the specified Read the CSV files from Query the required data from the provided endpoint in the Read the CSV files from Query the required data from the provided endpoint in the Read the config file from path See Read the config file from path See Create and push reallocate actions to the action queue. Create and push reallocate actions to the action queue. Do nothing. ```julia julia> using AllocationOpt julia> using TheGraphData julia> a = flextable([ Dict("subgraphDeployment.ipfsHash" => "Qma", "id" => "0xa") ]) julia> t = flextable([ Dict("amount" => "1", "profit" => "0", "ipfshash" => "Qma"), Dict("amount" => "2", "profit" => "0", "ipfshash" => "Qmb"), ]) julia> AllocationOpt.reallocate_action(Val(:none), a, t, Dict()) Print a rule that reallocates the old allocation with a new allocation amount Do nothing. ```julia julia> using AllocationOpt julia> using TheGraphData julia> a = flextable([ Dict("subgraphDeployment.ipfsHash" => "Qma", "id" => "0xa") ]) julia> t = flextable([ Dict("amount" => "1", "profit" => "0", "ipfshash" => "Qma"), Dict("amount" => "2", "profit" => "0", "ipfshash" => "Qmb"), ]) julia> AllocationOpt.reallocate_action(Val(:none), a, t, Dict()) Print a rule that reallocates the old allocation with a new allocation amount Construct a table for the strategy mapping the ipfshash, allocation amount, and profit Return a generator of the generic names of the CSV files containing the data with the path specified by Return a generator of the generic names of the CSV files containing the data with the path specified by The total signal in the network ```julia julia> using AllocationOpt julia> using TheGraphData julia> n = flextable([ Dict( "id" => 1, "networkGRTIssuancePerBlock" => 1, "epochLength" => 28, "totalTokensSignalled" => 2, "currentEpoch" => 1, ) ]) julia> AllocationOpt.signal(Val(:network), n) 2 The tokens signalled on the subgraphs in table The total signal in the network ```julia julia> using AllocationOpt julia> using TheGraphData julia> n = flextable([ Dict( "id" => 1, "networkGRTIssuancePerBlock" => 1, "epochLength" => 28, "totalTokensSignalled" => 2, "currentEpoch" => 1, ) ]) julia> AllocationOpt.signal(Val(:network), n) 2 The tokens signalled on the subgraphs in table Sort the nonzero best profits from highest to lowest Sort the nonzero best profits from highest to lowest Return the components of a GraphQL query for subgraphs. For use with the TheGraphData.jl package. Return the components of a GraphQL query for subgraphs. For use with the TheGraphData.jl package. Extended Help You can find TheGraphData.jl at https://github.com/semiotic-ai/TheGraphData.jl Get the allocated tokens for each allocation in Extended Help You can find TheGraphData.jl at https://github.com/semiotic-ai/TheGraphData.jl Get the allocated tokens for each allocation in The tokens staked by the indexer in table The tokens staked by the indexer in table The tokens staked on the subgraphs in table The tokens staked on the subgraphs in table Subtract the indexer's allocated tokens from the total allocated tokens on each subgraph. Subtract the indexer's allocated tokens from the total allocated tokens on each subgraph. Convert This function is meant to be used with freshly queried data, so it operates on strings. Convert This function is meant to be used with freshly queried data, so it operates on strings. Create and push the unallocate actions to the action queue. ```julia julia> using AllocationOpt julia> using TheGraphData julia> a = flextable([ Dict("subgraphDeployment.ipfsHash" => "Qma", "id" => "0xa") ]) julia> t = flextable([ Dict("amount" => "2", "profit" => "0", "ipfshash" => "Qmb"), ]) julia> config = Dict( "frozenlist" => [], "indexerurl" => "http://localhost:18000" ) julia> TheGraphData.client!(config["indexerurl"]) julia> AllocationOpt.unallocate_action(Val(:actionqueue), a, t, config) 1-element Vector{Dict{String, Any}}: Dict("priority" => 0, "status" => AllocationOpt.queued, "allocationID" => "0xa", "source" => "AllocationOpt", "reason" => "AllocationOpt", "type" => AllocationOpt.unallocate, "deploymentID" => "Qma") Do nothing. Create and push the unallocate actions to the action queue. ```julia julia> using AllocationOpt julia> using TheGraphData julia> a = flextable([ Dict("subgraphDeployment.ipfsHash" => "Qma", "id" => "0xa") ]) julia> t = flextable([ Dict("amount" => "2", "profit" => "0", "ipfshash" => "Qmb"), ]) julia> config = Dict( "frozenlist" => [], "indexerurl" => "http://localhost:18000" ) julia> TheGraphData.client!(config["indexerurl"]) julia> AllocationOpt.unallocate_action(Val(:actionqueue), a, t, config) 1-element Vector{Dict{String, Any}}: Dict("priority" => 0, "status" => AllocationOpt.queued, "allocationID" => "0xa", "source" => "AllocationOpt", "reason" => "AllocationOpt", "type" => AllocationOpt.unallocate, "deploymentID" => "Qma") Do nothing. Print a rule that stops old allocations that the optimiser has not chosen and that aren't frozen. Print a rule that stops old allocations that the optimiser has not chosen and that aren't frozen. Write the tables to the Write the tables to the Write the optimized results to the Write the optimized results to the Perform the analytic optimisation. Return the current best guess for the solution.AllocationOpt.allocatablesubgraphs
— Method allocatablesubgraphs(s::FlexTable, config::AbstractDict)
s
return a view of the subgraphs on which we can allocate.julia> using AllocationOpt
+ 2.5
AllocationOpt.allocatablesubgraphs
— Method allocatablesubgraphs(s::FlexTable, config::AbstractDict)
s
return a view of the subgraphs on which we can allocate.julia> using AllocationOpt
julia> using TheGraphData
julia> s = flextable([
Dict("ipfsHash" => "Qma", "signalledTokens" => 10,),
@@ -38,7 +38,7 @@
signalledTokens ipfsHash
┌──────────────────────────
1 │ 20 Qmb
- 2 │ 5 Qmc
AllocationOpt.allocate_action
— Methodallocate_action(::Val{:actionqueue}, a::FlexTable, t::FlexTable, config::AbstractDict)
julia> using AllocationOpt
+ 2 │ 5 Qmc
AllocationOpt.allocate_action
— Methodallocate_action(::Val{:actionqueue}, a::FlexTable, t::FlexTable, config::AbstractDict)
julia> using AllocationOpt
julia> using TheGraphData
julia> a = flextable([
Dict("subgraphDeployment.ipfsHash" => "Qma", "id" => "0xa")
@@ -53,7 +53,7 @@
julia> TheGraphData.client!(config["indexer_url"])
julia> AllocationOpt.allocate_action(Val(:actionqueue), a, t, Dict())
1-element Vector{Dict{String, Any}}:
- Dict("amount" => "2", "priority" => 0, "status" => AllocationOpt.queued, "source" => "AllocationOpt", "reason" => "Expected profit: 0", "type" => AllocationOpt.allocate, "deploymentID" => "Qmb")
AllocationOpt.allocate_action
— Methodallocate_action(::Val{:none}, a, t, config)
julia> using AllocationOpt
+ Dict("amount" => "2", "priority" => 0, "status" => AllocationOpt.queued, "source" => "AllocationOpt", "reason" => "Expected profit: 0", "type" => AllocationOpt.allocate, "deploymentID" => "Qmb")
AllocationOpt.allocate_action
— Methodallocate_action(::Val{:none}, a, t, config)
julia> using AllocationOpt
julia> using TheGraphData
julia> a = flextable([
Dict("subgraphDeployment.ipfsHash" => "Qma", "id" => "0xa")
@@ -62,10 +62,10 @@
Dict("amount" => "1", "profit" => "0", "ipfshash" => "Qma"),
Dict("amount" => "2", "profit" => "0", "ipfshash" => "Qmb"),
])
-julia> AllocationOpt.allocate_action(Val(:none), a, t, Dict())
AllocationOpt.allocate_action
— Methodallocate_action(::Val{:rules}, a::FlexTable, t::FlexTable, config::AbstractDict)
AllocationOpt.aquery
— Methodaquery(id::AbstractString)
id
.julia> using AllocationOpt
+julia> AllocationOpt.allocate_action(Val(:none), a, t, Dict())
AllocationOpt.allocate_action
— Methodallocate_action(::Val{:rules}, a::FlexTable, t::FlexTable, config::AbstractDict)
AllocationOpt.aquery
— Methodaquery(id::AbstractString)
id
.julia> using AllocationOpt
julia> id = "0xa"
julia> value, args, fields = AllocationOpt.aquery(id)
-("allocations", Dict{String, Union{Dict{String, String}, String}}("where" => Dict("status" => "Active", "indexer" => "0xa")), ["allocatedTokens", "id", "subgraphDeployment{ipfsHash}"])
AllocationOpt.availablestake
— Methodavailable(::Val{:indexer}, x)
x
.julia> using AllocationOpt
+("allocations", Dict{String, Union{Dict{String, String}, String}}("where" => Dict("status" => "Active", "indexer" => "0xa")), ["allocatedTokens", "id", "subgraphDeployment{ipfsHash}"])
AllocationOpt.availablestake
— Methodavailable(::Val{:indexer}, x)
x
.julia> using AllocationOpt
julia> using TheGraphData
julia> x = flextable([
Dict(
@@ -75,16 +75,16 @@
),
])
julia> AllocationOpt.availablestake(Val(:indexer), x)
-25.0
AllocationOpt.bestprofitpernz
— Methodbestprofitpernz(ixs::AbstractVector{Integer}, profitmatrix::AbstractMatrix{Real})
ixs
given profit matrix p
julia> using AllocationOpt
+25.0
AllocationOpt.bestprofitpernz
— Methodbestprofitpernz(ixs::AbstractVector{Integer}, profitmatrix::AbstractMatrix{Real})
ixs
given profit matrix p
julia> using AllocationOpt
julia> ixs = Dict([1] => [1], [2] => [2])
julia> profitmatrix = [[2.5 5.0]; [2.5 1.0]]
julia> AllocationOpt.bestprofitpernz.(values(ixs), Ref(profitmatrix))
2-element Vector{NamedTuple{(:profit, :index), Tuple{Float64, Int64}}}:
(profit = 5.0, index = 1)
- (profit = 6.0, index = 2)
AllocationOpt.blockissuance
— Methodblockissuance(::Val{:network}, x)
AllocationOpt.blocksperepoch
— Methodblocksperepoch(::Val{:network}, x)
AllocationOpt.closeipfs
— Methodcloseipfs(existingipfs, proposedipfs, frozenlist)
julia> using AllocationOpt
+ (profit = 6.0, index = 2)
AllocationOpt.blockissuance
— Methodblockissuance(::Val{:network}, x)
AllocationOpt.blocksperepoch
— Methodblocksperepoch(::Val{:network}, x)
AllocationOpt.closeipfs
— Methodcloseipfs(existingipfs, proposedipfs, frozenlist)
julia> using AllocationOpt
julia> AllocationOpt.closeipfs(["Qma"], ["Qmb"], String[])
1-element Vector{String}:
- "Qma"
AllocationOpt.configuredefaults!
— Methodconfiguredefaults!(config::AbstractDict)
id::String
: The ID of the indexer for whom we're optimising. No default value.network_subgraph_endpoint::String
: The network subgraph endpoint to query. By default, "https://api.thegraph.com/subgraphs/name/graphprotocol/graph-network-mainnet"
writedir::String
: The directory to which to write the results of optimisation. If don't specify readdir
, writedir
also specifies the path to which to save the input data tables. By default, "."
readdir::Union{String, Nothing}
: The directory from which to read saved data tables. This speeds up the process as we won't have to query the network subgraph for the relevant data. If you don't specify readdir
, we will query your specified network_subgraph_endpoint
for the data and write it to CSV files in writedir
. This way, you can use your previous writedir
as your readdir
in future runs. By default, nothing
whitelist::Vector{String}
: A list of subgraph IPFS hashes that you want to consider as candidates to which to allocate. If you leave this empty, we'll assume all subgraphs are in the whitelist. By default, String[]
blacklist::Vector{String}
: A list of subgraph IPFS hashes that you do not want to consider allocating to. For example, this list could include broken subgraphs or subgraphs that you don't want to index. By default, String[]
frozenlist::Vector{String}
: If you have open allocations that you don't want to change, add the corresponding subgraph IPFS hashes to this list. By default, String[]
pinnedlist::Vector{String}
: If you have subgraphs that you absolutely want to be allocated to, even if only with a negligible amount of GRT, add it to this list. By default, String[]
allocation_lifetime::Integer
: The number of epochs for which you expect the allocations the optimiser finds to be open. By default, 28
gas::Real
: The estimated gas cost in GRT to open/close allocations. By default, 100
min_signal::Real
: The minimum amount of signal in GRT that must be on a subgraph in order for you to consider allocating to it. By default, 1000
max_allocations::Integer
: The maximum number of new allocations you'd like the optimiser to consider opening. By default, 10
num_reported_options::Integer
: The number of proposed allocation strategies to report. For example, if you select 10
we'd report best 10 allocation strategies ranked by profit. By default, 1
verbose::Bool
: If true, the optimiser will print details about what it is doing to stdout. By default, false
execution_mode::String
: How the optimiser should execute the allocation strategies it finds. Options are "none"
, which won't do anything, "actionqueue"
, which will push actions to the action queue, and "rules"
, which will generate indexing rules. By default, "none"
indexer_url::Union{String, Nothing}
: The URL of the indexer management server you want to execute the allocation strategies on. If you specify "actionqueue"
, you must also specify indexer_url
. By default, nothing
opt_mode::String
: We support two optimisation modes. One is "fast"
. This mode is fast, but may not find the optimal strategy. This mode is also used to the top num_reported_options
allocation strategies. The other mode is "optimal"
. This mode is slower, but it satisfy stronger optimality conditions. It will find strategies at least as good as "fast"
, but not guaranteed to be better. In general, we recommend exploring config options using "fast"
mode first, and then using "optimal"
mode to find the optimal allocation. By default, "optimal"
julia> using AllocationOpt
+ "Qma"
AllocationOpt.configuredefaults!
— Methodconfiguredefaults!(config::AbstractDict)
id::String
: The ID of the indexer for whom we're optimising. No default value.network_subgraph_endpoint::String
: The network subgraph endpoint to query. By default, "https://api.thegraph.com/subgraphs/name/graphprotocol/graph-network-mainnet"
writedir::String
: The directory to which to write the results of optimisation. If don't specify readdir
, writedir
also specifies the path to which to save the input data tables. By default, "."
readdir::Union{String, Nothing}
: The directory from which to read saved data tables. This speeds up the process as we won't have to query the network subgraph for the relevant data. If you don't specify readdir
, we will query your specified network_subgraph_endpoint
for the data and write it to CSV files in writedir
. This way, you can use your previous writedir
as your readdir
in future runs. By default, nothing
whitelist::Vector{String}
: A list of subgraph IPFS hashes that you want to consider as candidates to which to allocate. If you leave this empty, we'll assume all subgraphs are in the whitelist. By default, String[]
blacklist::Vector{String}
: A list of subgraph IPFS hashes that you do not want to consider allocating to. For example, this list could include broken subgraphs or subgraphs that you don't want to index. By default, String[]
frozenlist::Vector{String}
: If you have open allocations that you don't want to change, add the corresponding subgraph IPFS hashes to this list. By default, String[]
pinnedlist::Vector{String}
: If you have subgraphs that you absolutely want to be allocated to, even if only with a negligible amount of GRT, add it to this list. By default, String[]
allocation_lifetime::Integer
: The number of epochs for which you expect the allocations the optimiser finds to be open. By default, 28
gas::Real
: The estimated gas cost in GRT to open/close allocations. By default, 100
min_signal::Real
: The minimum amount of signal in GRT that must be on a subgraph in order for you to consider allocating to it. By default, 1000
max_allocations::Integer
: The maximum number of new allocations you'd like the optimiser to consider opening. By default, 10
num_reported_options::Integer
: The number of proposed allocation strategies to report. For example, if you select 10
we'd report best 10 allocation strategies ranked by profit. By default, 1
verbose::Bool
: If true, the optimiser will print details about what it is doing to stdout. By default, false
execution_mode::String
: How the optimiser should execute the allocation strategies it finds. Options are "none"
, which won't do anything, "actionqueue"
, which will push actions to the action queue, and "rules"
, which will generate indexing rules. By default, "none"
indexer_url::Union{String, Nothing}
: The URL of the indexer management server you want to execute the allocation strategies on. If you specify "actionqueue"
, you must also specify indexer_url
. By default, nothing
opt_mode::String
: We support two optimisation modes. One is "fast"
. This mode is fast, but may not find the optimal strategy. This mode is also used to the top num_reported_options
allocation strategies. The other mode is "optimal"
. This mode is slower, but it satisfy stronger optimality conditions. It will find strategies at least as good as "fast"
, but not guaranteed to be better. In general, we recommend exploring config options using "fast"
mode first, and then using "optimal"
mode to find the optimal allocation. By default, "optimal"
julia> using AllocationOpt
julia> config = Dict{String, Any}("id" => "0xa")
julia> config = AllocationOpt.configuredefaults!(config)
Dict{String, Any} with 16 entries:
@@ -102,7 +102,7 @@
"min_signal" => 1000
"network_subgraph_endpoint" => "https://api.thegraph.com/subgraphs/name/graphprotocol/graph-network-mainnet"
"whitelist" => String[]
- ⋮ => ⋮
AllocationOpt.correcttypes!
— Methodcorrecttypes!(i::FlexTable, a::FlexTable, s::FlexTable, n::FlexTable)
julia> using AllocationOpt
+ ⋮ => ⋮
AllocationOpt.correcttypes!
— Methodcorrecttypes!(i::FlexTable, a::FlexTable, s::FlexTable, n::FlexTable)
julia> using AllocationOpt
julia> using TheGraphData
julia> i = flextable([
Dict(
@@ -134,7 +134,7 @@
"currentEpoch" => 1,
)
])
-julia> i, a, s, n = AllocationOpt.correcttypes!(i, a, s, n)
AllocationOpt.correcttypes!
— Methodcorrecttypes!(::Val{:allocation}, a::FlexTable)
julia> using AllocationOpt
+julia> i, a, s, n = AllocationOpt.correcttypes!(i, a, s, n)
AllocationOpt.correcttypes!
— Methodcorrecttypes!(::Val{:allocation}, a::FlexTable)
julia> using AllocationOpt
julia> using TheGraphData
julia> a = flextable([
Dict(
@@ -146,7 +146,7 @@
FlexTable with 2 columns and 1 row:
subgraphDeployment.ipfsHash allocatedTokens
┌─────────────────────────────────────────────
- 1 │ Qma 1.0e-18
AllocationOpt.correcttypes!
— Methodcorrecttypes!(::Val{:indexer}, i::FlexTable)
julia> using AllocationOpt
+ 1 │ Qma 1.0e-18
AllocationOpt.correcttypes!
— Methodcorrecttypes!(::Val{:indexer}, i::FlexTable)
julia> using AllocationOpt
julia> using TheGraphData
julia> i = flextable([
Dict(
@@ -160,7 +160,7 @@
FlexTable with 4 columns and 1 row:
stakedTokens delegatedTokens id lockedTokens
┌─────────────────────────────────────────────────
- 1 │ 1.0e-18 0.0 0xa 0.0
AllocationOpt.correcttypes!
— Methodcorrecttypes!(::Val{:network}, n::FlexTable)
julia> using AllocationOpt
+ 1 │ 1.0e-18 0.0 0xa 0.0
AllocationOpt.correcttypes!
— Methodcorrecttypes!(::Val{:network}, n::FlexTable)
julia> using AllocationOpt
julia> using TheGraphData
julia> n = flextable([
Dict(
@@ -175,7 +175,7 @@
FlexTable with 6 columns and 1 row:
totalTokensSignalled currentEpoch id networkGRTIssuancePerBlock epochLength
┌────────────────────────────────────────────────────────────────────────────────
-1 │ 2.0e-18 1 1 1.0e-18 28
AllocationOpt.correcttypes!
— Methodcorrecttypes!(::Val{:subgraph}, s::FlexTable)
julia> using AllocationOpt
+1 │ 2.0e-18 1 1 1.0e-18 28
AllocationOpt.correcttypes!
— Methodcorrecttypes!(::Val{:subgraph}, s::FlexTable)
julia> using AllocationOpt
julia> using TheGraphData
julia> s = flextable([
Dict(
@@ -189,7 +189,7 @@
FlexTable with 4 columns and 1 row:
deniedAt stakedTokens signalledTokens ipfsHash
┌──────────────────────────────────────────────────
- 1 │ 0 1.0e-18 0.0 Qma
AllocationOpt.currentepoch
— Methodcurrentepoch(::Val{:network}, x)
AllocationOpt.delegation
— Methoddelegation(::Val{:indexer}, x)
x
.julia> using AllocationOpt
+ 1 │ 0 1.0e-18 0.0 Qma
AllocationOpt.currentepoch
— Methodcurrentepoch(::Val{:network}, x)
AllocationOpt.delegation
— Methoddelegation(::Val{:indexer}, x)
x
.julia> using AllocationOpt
julia> using TheGraphData
julia> x = flextable([
Dict(
@@ -197,7 +197,7 @@
),
])
julia> AllocationOpt.delegation(Val(:indexer), x)
-10
AllocationOpt.deniedat
— Methoddeniedat(::Val{:subgraph}, x)
julia> using AllocationOpt
+10
AllocationOpt.deniedat
— Methoddeniedat(::Val{:subgraph}, x)
julia> using AllocationOpt
julia> using TheGraphData
julia> x = flextable([
Dict("deniedAt" => 10,),
@@ -206,7 +206,7 @@
julia> AllocationOpt.deniedat(Val(:subgraph), x)
2-element view(transpose(lazystack(::Vector{Vector{Int64}})), :, 1) with eltype Int64:
10
- 0
AllocationOpt.deniedzeroixs
— Methoddeniedzeroixs(s::FlexTable)
julia> using AllocationOpt
+ 0
AllocationOpt.deniedzeroixs
— Methoddeniedzeroixs(s::FlexTable)
julia> using AllocationOpt
julia> using TheGraphData
julia> s = flextable([
Dict("ipfsHash" => "Qma", "signalledTokens" => 5.0, "deniedAt" => 0),
@@ -216,7 +216,7 @@
julia> AllocationOpt.deniedzeroixs(s)
2-element Vector{Int64}:
1
- 3
AllocationOpt.dual
— Methoddual(Ω, ψ, σ)
ψ
, allocation vector Ω
, and stake σ
.optimizeanalytic
instead.AllocationOpt.execute
— Methodexecute(
+ 3
AllocationOpt.dual
— Methoddual(Ω, ψ, σ)
ψ
, allocation vector Ω
, and stake σ
.optimizeanalytic
instead.AllocationOpt.execute
— Methodexecute(
a::FlexTable,
ix::Integer,
s::FlexTable,
@@ -236,11 +236,11 @@
])
julia> config = Dict("execution_mode" => "none")
julia> ix = 1
-julia> AllocationOpt.execute(a, ix, s, xs, ps, config)
AllocationOpt.formatconfig!
— Methodformatconfig!(config::AbstractDict)
config
, reformat values that need to be standardised.julia> using AllocationOpt
+julia> AllocationOpt.execute(a, ix, s, xs, ps, config)
AllocationOpt.formatconfig!
— Methodformatconfig!(config::AbstractDict)
config
, reformat values that need to be standardised.julia> using AllocationOpt
julia> config = Dict("id" => "0xA")
julia> AllocationOpt.formatconfig!(config)
Dict{String, String} with 1 entry:
- "id" => "0xa"
AllocationOpt.frozen
— Methodfrozen(a::FlexTable, config::AbstractDict)
a
.julia> using AllocationOpt
+ "id" => "0xa"
AllocationOpt.frozen
— Methodfrozen(a::FlexTable, config::AbstractDict)
a
.julia> using AllocationOpt
julia> using TheGraphData
julia> a = flextable([
Dict("subgraphDeployment.ipfsHash" => "Qma", "allocatedTokens" => 5),
@@ -248,13 +248,13 @@
])
julia> config = Dict("frozenlist" => ["Qma", "Qmb"])
julia> AllocationOpt.frozen(a, config)
-15.0
AllocationOpt.groupunique
— Methodgroupunique(x::AbstractVector)
x
julia> using AllocationOpt
+15.0
AllocationOpt.groupunique
— Methodgroupunique(x::AbstractVector)
x
julia> using AllocationOpt
julia> x = [1, 2, 1, 3, 2, 3]
julia> AllocationOpt.groupunique(x)
Dict{Vector{Int64}, Vector{Int64}} with 3 entries:
[3] => [4, 6]
[1] => [1, 3]
- [2] => [2, 5]
AllocationOpt.id
— Methodid(::Val{:allocation}, x)
x
.julia> using AllocationOpt
+ [2] => [2, 5]
AllocationOpt.id
— Methodid(::Val{:allocation}, x)
x
.julia> using AllocationOpt
julia> using TheGraphData
julia> x = flextable([
Dict(
@@ -263,21 +263,21 @@
])
julia> AllocationOpt.id(Val(:allocation), x)
1-element view(lazystack(::Vector{Vector{String}}), 1, :) with eltype String:
- "0x1"
AllocationOpt.indexingreward
— Methodindexingreward(x::Real, Ω::Real, ψ::Real, Φ::Real, Ψ::Real)
x
given signals ψ
, the existing allocation on subgraphs Ω
, token issuance Φ
, and total signal Ψ
.julia> using AllocationOpt
+ "0x1"
AllocationOpt.indexingreward
— Methodindexingreward(x::Real, Ω::Real, ψ::Real, Φ::Real, Ψ::Real)
x
given signals ψ
, the existing allocation on subgraphs Ω
, token issuance Φ
, and total signal Ψ
.julia> using AllocationOpt
julia> ψ = 0.0
julia> Ω = 1.0
julia> Φ = 1.0
julia> Ψ = 2.0
julia> x = 1.0
julia> AllocationOpt.indexingreward(x, Ω, ψ, Φ, Ψ)
-0.0
AllocationOpt.indexingreward
— Methodindexingreward(
+0.0
AllocationOpt.indexingreward
— Methodindexingreward(
ixs::AbstractArray{Integer},
x::AbstractVector{Real},
Ω::AbstractVector{Real},
ψ::AbstractVector{Real},
Φ::Real,
Ψ::Real
-)
x
given signals ψ
, the existing allocations on subgraphs Ω
, token issuance Φ
, and total signal Ψ
. Here ixs
is a vector of indices Ω
, and ψ
. x
will be filtered by SemioticOpt
, so we don't do this here.julia julia> using AllocationOpt julia> ixs = Int32[2] julia> ψ = [0.0, 1.0] julia> Ω = [1.0, 1.0] julia> Φ = 1.0 julia> Ψ = 2.0 julia> x = [0.0, 1.0] julia> AllocationOpt.indexingreward(ixs, x, Ω, ψ, Φ, Ψ) 0.25
`AllocationOpt.indexingreward
— Methodindexingreward(
+)
x
given signals ψ
, the existing allocations on subgraphs Ω
, token issuance Φ
, and total signal Ψ
. Here ixs
is a vector of indices Ω
, and ψ
. x
will be filtered by SemioticOpt
, so we don't do this here.julia julia> using AllocationOpt julia> ixs = Int32[2] julia> ψ = [0.0, 1.0] julia> Ω = [1.0, 1.0] julia> Φ = 1.0 julia> Ψ = 2.0 julia> x = [0.0, 1.0] julia> AllocationOpt.indexingreward(ixs, x, Ω, ψ, Φ, Ψ) 0.25
`AllocationOpt.indexingreward
— Methodindexingreward(
x::AbstractVector{Real},
Ω::AbstractVector{Real},
ψ::AbstractVector{Real},
@@ -290,7 +290,7 @@
julia> Ψ = 2.0
julia> x = [0.0, 1.0]
julia> AllocationOpt.indexingreward(x, Ω, ψ, Φ, Ψ)
-0.25
AllocationOpt.ipfshash
— Methodipfshash(::Val{:allocation}, x)
x
when x
is part of the allocation table.julia> using AllocationOpt
+0.25
AllocationOpt.ipfshash
— Methodipfshash(::Val{:allocation}, x)
x
when x
is part of the allocation table.julia> using AllocationOpt
julia> using TheGraphData
julia> x = flextable([
Dict(
@@ -299,7 +299,7 @@
])
julia> AllocationOpt.ipfshash(Val(:allocation), x)
1-element view(lazystack(::Vector{Vector{String}}), 1, :) with eltype String:
- "Qma"
AllocationOpt.ipfshash
— Methodipfshash(::Val{:subgraph}, x)
x
when x
is part of the allocation table.julia> using AllocationOpt
+ "Qma"
AllocationOpt.ipfshash
— Methodipfshash(::Val{:subgraph}, x)
x
when x
is part of the allocation table.julia> using AllocationOpt
julia> using TheGraphData
julia> x = flextable([
Dict(
@@ -308,14 +308,14 @@
])
julia> AllocationOpt.ipfshash(Val(:subgraph), x)
1-element view(lazystack(::Vector{Vector{String}}), 1, :) with eltype String:
- "Qma"
AllocationOpt.iquery
— Methodiquery(id::AbstractString)
id
.julia> using AllocationOpt
+ "Qma"
AllocationOpt.iquery
— Methodiquery(id::AbstractString)
id
.julia> using AllocationOpt
julia> id = "0xa"
julia> value, args, fields = AllocationOpt.iquery(id)
-("indexer", Dict{String, Union{Int64, Dict{String, String}, String}}("id" => "0xa"), ["delegatedTokens", "stakedTokens", "lockedTokens"])
AllocationOpt.lipschitzconstant
— Methodlipschitzconstant(ψ, Ω)
ψ
and allocations Ω
.julia> using AllocationOpt
+("indexer", Dict{String, Union{Int64, Dict{String, String}, String}}("id" => "0xa"), ["delegatedTokens", "stakedTokens", "lockedTokens"])
AllocationOpt.lipschitzconstant
— Methodlipschitzconstant(ψ, Ω)
ψ
and allocations Ω
.julia> using AllocationOpt
julia> ψ = [0.0, 1.0]
julia> Ω = [1.0, 1.0]
julia> AllocationOpt.lipschitzconstant(ψ, Ω)
-2.0
AllocationOpt.locked
— Methodlocked(::Val{:indexer}, x)
x
.julia> using AllocationOpt
+2.0
AllocationOpt.locked
— Methodlocked(::Val{:indexer}, x)
x
.julia> using AllocationOpt
julia> using TheGraphData
julia> x = flextable([
Dict(
@@ -323,7 +323,7 @@
),
])
julia> AllocationOpt.locked(Val(:indexer), x)
-10
AllocationOpt.newtokenissuance
— Methodnewtokenissuance(n::FlexTable, config::Dict)
n
. Calcualted by networkGRTIssuancePerBlock * epochLength * allocation_lifetimejulia> using AllocationOpt
+10
AllocationOpt.newtokenissuance
— Methodnewtokenissuance(n::FlexTable, config::Dict)
n
. Calcualted by networkGRTIssuancePerBlock * epochLength * allocation_lifetimejulia> using AllocationOpt
julia> using TheGraphData
julia> n = flextable([
Dict(
@@ -336,13 +336,13 @@
])
julia> config = Dict("allocation_lifetime" => 1)
julia> AllocationOpt.newtokenissuance(n, config)
-1.0
AllocationOpt.nonzero
— Methodnonzero(v::AbstractVector)
v
.julia> using AllocationOpt
+1.0
AllocationOpt.nonzero
— Methodnonzero(v::AbstractVector)
v
.julia> using AllocationOpt
julia> v = [0.0, 1.0]
julia> AllocationOpt.nonzero(v)
1-element view(::Vector{Float64}, [2]) with eltype Float64:
- 1.0
AllocationOpt.nquery
— Methodnquery()
julia> using AllocationOpt
+ 1.0
AllocationOpt.nquery
— Methodnquery()
julia> using AllocationOpt
julia> value, args, fields = AllocationOpt.nquery()
-("graphNetwork", Dict("id" => 1), ["id", "networkGRTIssuance", "epochLength", "totalTokensSignalled", "currentEpoch"])
AllocationOpt.optimize
— Methodoptimize(Ω, ψ, σ, K, Φ, Ψ, g, rixs, config::AbstractDict)
Ω
, signals ψ
, available stake σ
, new tokens issued Φ
, total signal Ψ
, and gas in grt g
. rixs
are the indices of subgraphs that are eligible to receive indexing rewards.optimize
with the opt_mode
key.opt_mode
is fast
, then run projected gradient descent with GSSP and Halpern. If opt_mode
is optimal
, then run Pairwise Greedy Optimisation.julia> using AllocationOpt
+("graphNetwork", Dict("id" => 1), ["id", "networkGRTIssuance", "epochLength", "totalTokensSignalled", "currentEpoch"])
AllocationOpt.optimize
— Methodoptimize(Ω, ψ, σ, K, Φ, Ψ, g, rixs, config::AbstractDict)
Ω
, signals ψ
, available stake σ
, new tokens issued Φ
, total signal Ψ
, and gas in grt g
. rixs
are the indices of subgraphs that are eligible to receive indexing rewards.optimize
with the opt_mode
key.opt_mode
is fast
, then run projected gradient descent with GSSP and Halpern. If opt_mode
is optimal
, then run Pairwise Greedy Optimisation.julia> using AllocationOpt
julia> config = Dict("opt_mode" => "fast")
julia> rixs = [1, 2]
julia> Ω = [1.0, 1.0]
@@ -353,7 +353,7 @@
julia> Ψ = 20.0
julia> g = 0.01
julia> xs, nonzeros, profits = AllocationOpt.optimize(Ω, ψ, σ, K, Φ, Ψ, g, rixs, config)
-([5.0 2.5; 0.0 2.5], Int32[1, 2], [0.4066666666666667 0.34714285714285714; 0.0 0.34714285714285714])
AllocationOpt.optimize
— Methodoptimize(::Val{:fast}, Ω, ψ, σ, K, Φ, Ψ, g, rixs)
K
] given allocations of other indexers Ω
, signals ψ
, available stake σ
, new tokens issued Φ
, total signal Ψ
, and gas in grt g
. rixs
are the indices of subgraphs that are eligible to receive indexing rewards.julia> using AllocationOpt
+([5.0 2.5; 0.0 2.5], Int32[1, 2], [0.4066666666666667 0.34714285714285714; 0.0 0.34714285714285714])
AllocationOpt.optimize
— Methodoptimize(::Val{:fast}, Ω, ψ, σ, K, Φ, Ψ, g, rixs)
K
] given allocations of other indexers Ω
, signals ψ
, available stake σ
, new tokens issued Φ
, total signal Ψ
, and gas in grt g
. rixs
are the indices of subgraphs that are eligible to receive indexing rewards.julia> using AllocationOpt
julia> rixs = [1, 2]
julia> Ω = [1.0, 1.0]
julia> ψ = [10.0, 10.0]
@@ -363,7 +363,7 @@
julia> Ψ = 20.0
julia> g = 0.01
julia> xs, nonzeros, profits = AllocationOpt.optimize(Val(:fast), Ω, ψ, σ, K, Φ, Ψ, g, rixs)
-([5.0 2.5; 0.0 2.5], Int32[1, 2], [0.4066666666666667 0.34714285714285714; 0.0 0.34714285714285714])
AllocationOpt.optimize
— Methodoptimize(::Val{:optimal}, Ω, ψ, σ, K, Φ, Ψ, g, rixs)
Ω
, signals ψ
, available stake σ
, new tokens issued Φ
, total signal Ψ
, and gas in grt g
. rixs
are the indices of subgraphs that are eligible to receive indexing rewards.julia> using AllocationOpt
+([5.0 2.5; 0.0 2.5], Int32[1, 2], [0.4066666666666667 0.34714285714285714; 0.0 0.34714285714285714])
AllocationOpt.optimize
— Methodoptimize(::Val{:optimal}, Ω, ψ, σ, K, Φ, Ψ, g, rixs)
Ω
, signals ψ
, available stake σ
, new tokens issued Φ
, total signal Ψ
, and gas in grt g
. rixs
are the indices of subgraphs that are eligible to receive indexing rewards.julia> using AllocationOpt
julia> rixs = [1, 2]
julia> Ω = [1.0, 1.0]
julia> ψ = [10.0, 10.0]
@@ -375,14 +375,14 @@
julia> xs, nonzeros, profits = AllocationOpt.optimize(
Val(:optimal), Ω, ψ, σ, K, Φ, Ψ, g, rixs
)
-([5.0 2.5; 0.0 2.5], Int32[1, 2], [0.4066666666666667 0.34714285714285714; 0.0 0.34714285714285714])
AllocationOpt.optimizeanalytic
— Methodoptimizeanalytic(Ω, ψ, σ)
Ω
, signals ψ
, and stake σ
.julia> using AllocationOpt
+([5.0 2.5; 0.0 2.5], Int32[1, 2], [0.4066666666666667 0.34714285714285714; 0.0 0.34714285714285714])
AllocationOpt.optimizeanalytic
— Methodoptimizeanalytic(Ω, ψ, σ)
Ω
, signals ψ
, and stake σ
.julia> using AllocationOpt
julia> Ω = [1.0, 7.0]
julia> ψ = [10.0, 5.0]
julia> σ = 5.0
julia> AllocationOpt.optimizeanalytic(Ω, ψ, σ)
2-element Vector{Float64}:
3.5283092056122474
- 1.4716907943877526
AllocationOpt.optimizek
— Methodoptimizek(::Val{:fast}, x₀, Ω, ψ, σ, k, Φ, Ψ)
k
sparse vector given initial value x₀
, allocations of other indexers Ω
, signals ψ
, available stake σ
, new tokens issued Φ
, and total signal Ψ
.julia> using AllocationOpt
+ 1.4716907943877526
AllocationOpt.optimizek
— Methodoptimizek(::Val{:fast}, x₀, Ω, ψ, σ, k, Φ, Ψ)
k
sparse vector given initial value x₀
, allocations of other indexers Ω
, signals ψ
, available stake σ
, new tokens issued Φ
, and total signal Ψ
.julia> using AllocationOpt
julia> x₀ = [2.5, 2.5]
julia> Ω = [1.0, 1.0]
julia> ψ = [10.0, 10.0]
@@ -393,7 +393,7 @@
julia> AllocationOpt.optimizek(Val(:fast), x₀, Ω, ψ, σ, k, Φ, Ψ)
2-element Vector{Float64}:
5.0
- 0.0
AllocationOpt.optimizek
— Methodoptimizek(::Val{:optimal}, x₀, Ω, ψ, σ, k, Φ, Ψ, g)
k
sparse vector given allocations of other indexers Ω
, signals ψ
, available stake σ
, new tokens issued Φ
, total signal Ψ
, and gas g
.julia> using AllocationOpt
+ 0.0
AllocationOpt.optimizek
— Methodoptimizek(::Val{:optimal}, x₀, Ω, ψ, σ, k, Φ, Ψ, g)
k
sparse vector given allocations of other indexers Ω
, signals ψ
, available stake σ
, new tokens issued Φ
, total signal Ψ
, and gas g
.julia> using AllocationOpt
julia> Ω = [1.0, 1.0]
julia> ψ = [10.0, 10.0]
julia> σ = 5.0
@@ -405,7 +405,7 @@
julia> x = AllocationOpt.optimizek(Val(:optimal), x₀, Ω, ψ, σ, k, Φ, Ψ, g)
2-element Vector{Float64}:
5.0
- 0.0
AllocationOpt.pinned
— Methodpinned(config::AbstractDict)
julia> using AllocationOpt
+ 0.0
AllocationOpt.pinned
— Methodpinned(config::AbstractDict)
julia> using AllocationOpt
julia> s = flextable([
Dict("ipfsHash" => "Qma", "signalledTokens" => 5.0),
Dict("ipfsHash" => "Qmb", "signalledTokens" => 10.0),
@@ -416,11 +416,11 @@
3-element Vector{Float64}:
0.1
0.1
- 0.0
AllocationOpt.primal
— Methodprimal(Ω, ψ, ν)
ψ
, allocations Ω
, and a dual solution vector ν
.optimizeanalytic
instead.AllocationOpt.profit
— Methodprofit(r::Real, g::Real)
r
and gas cost g
.julia> using AllocationOpt
+ 0.0
AllocationOpt.primal
— Methodprimal(Ω, ψ, ν)
ψ
, allocations Ω
, and a dual solution vector ν
.optimizeanalytic
instead.AllocationOpt.profit
— Methodprofit(r::Real, g::Real)
r
and gas cost g
.julia> using AllocationOpt
julia> r = 10
julia> g = 1
julia> AllocationOpt.profit(r, g)
-9
AllocationOpt.read
— Methodread(config::AbstractDict)
config
, read the data in as flextables."network_subgraph_endpoint"
julia> using AllocationOpt
+9
AllocationOpt.read
— Methodread(config::AbstractDict)
config
, read the data in as flextables."network_subgraph_endpoint"
julia> using AllocationOpt
julia> config = Dict("verbose" => false, "readdir" => "mydatadir")
julia> i, a, s, n = AllocationOpt.read(config) # Read data from CSVs
julia> using AllocationOpt
julia> config = Dict(
@@ -428,13 +428,13 @@
"network_subgraph_endpoint" => "https://api.thegraph.com/subgraphs/name/graphprotocol/graph-network-mainnet",
"readdir" => nothing,
)
-julia> i, a, s, n = AllocationOpt.read(config) # Query GQL endpoint
AllocationOpt.read
— Methodread(f::AbstractString, config::AbstractDict)
f
and return the tables from those files.julia> using AllocationOpt
-julia> i, a, s, n = AllocationOpt.read("myreaddir", Dict("verbose" => true))
AllocationOpt.read
— Methodread(::Nothing, config::AbstractDict)
config
.julia> using AllocationOpt
+julia> i, a, s, n = AllocationOpt.read(config) # Query GQL endpoint
AllocationOpt.read
— Methodread(f::AbstractString, config::AbstractDict)
f
and return the tables from those files.julia> using AllocationOpt
+julia> i, a, s, n = AllocationOpt.read("myreaddir", Dict("verbose" => true))
AllocationOpt.read
— Methodread(::Nothing, config::AbstractDict)
config
.julia> using AllocationOpt
julia> config = Dict(
"verbose" => true,
"network_subgraph_endpoint" => "https://api.thegraph.com/subgraphs/name/graphprotocol/graph-network-mainnet",
)
-julia> i, a, s, n = AllocationOpt.read(nothing, config)
AllocationOpt.readconfig
— Methodreadconfig(p::AbstractString)
p
. The config file must be specifed as a TOML.configuredefaults!
to see which fields you should specify in the config.julia> using AllocationOpt
+julia> i, a, s, n = AllocationOpt.read(nothing, config)
AllocationOpt.readconfig
— Methodreadconfig(p::AbstractString)
p
. The config file must be specifed as a TOML.configuredefaults!
to see which fields you should specify in the config.julia> using AllocationOpt
julia> path = "myconfig.toml"
julia> config = AllocationOpt.readconfig(path)
Dict{String, Any} with 13 entries:
@@ -450,7 +450,7 @@
"min_signal" => 1000
"whitelist" => Union{}[]
"max_allocations" => 5
- "frozenlist" => Union{}[]
AllocationOpt.reallocate_action
— Methodreallocate_action(::Val{:actionqueue}, a::FlexTable, t::FlexTable, config::AbstractDict)
julia> using AllocationOpt
+ "frozenlist" => Union{}[]
AllocationOpt.reallocate_action
— Methodreallocate_action(::Val{:actionqueue}, a::FlexTable, t::FlexTable, config::AbstractDict)
julia> using AllocationOpt
julia> using TheGraphData
julia> a = flextable([
Dict("subgraphDeployment.ipfsHash" => "Qma", "id" => "0xa")
@@ -463,7 +463,7 @@
julia> TheGraphData.client!(config["indexer_url"])
julia> AllocationOpt.reallocate_action(Val(:actionqueue), a, t, config)
1-element Vector{Dict{String, Any}}:
- Dict("amount" => "1", "priority" => 0, "status" => AllocationOpt.queued, "allocationID" => "0xa", "source" => "AllocationOpt", "reason" => "Expected profit: 0", "type" => AllocationOpt.reallocate, "deploymentID" => "Qma")
AllocationOpt.reallocate_action
— Methodreallocate_action(::Val{:none}, a, t, config)
AllocationOpt.reallocate_action
— Methodreallocate_action(::Val{:rules}, a::FlexTable, t::FlexTable, config::AbstractDict)
julia> using AllocationOpt
+ Dict("amount" => "1", "priority" => 0, "status" => AllocationOpt.queued, "allocationID" => "0xa", "source" => "AllocationOpt", "reason" => "Expected profit: 0", "type" => AllocationOpt.reallocate, "deploymentID" => "Qma")
AllocationOpt.reallocate_action
— Methodreallocate_action(::Val{:none}, a, t, config)
AllocationOpt.reallocate_action
— Methodreallocate_action(::Val{:rules}, a::FlexTable, t::FlexTable, config::AbstractDict)
julia> using AllocationOpt
julia> using TheGraphData
julia> a = flextable([
Dict("subgraphDeployment.ipfsHash" => "Qma", "id" => "0xa")
@@ -476,7 +476,7 @@
graph indexer rules stop Qma
Check allocation status being closed before submitting: graph indexer rules set Qma decisionBasis always allocationAmount 1
1-element Vector{String}:
- "[0mgraph indexer rules stop Qm" ⋯ 122 bytes ⋯ "asis always allocationAmount 1"
AllocationOpt.reportingtable
— Methodreportingtable(
+ "[0mgraph indexer rules stop Qm" ⋯ 122 bytes ⋯ "asis always allocationAmount 1"
AllocationOpt.reportingtable
— Methodreportingtable(
s::FlexTable, xs::AbstractMatrix{Real}, ps::AbstractMatrix{Real}, i::Integer
)
julia> using AllocationOpt
julia> s = flextable([
@@ -491,10 +491,10 @@
ipfshash amount profit
┌─────────────────────────
1 │ Qma 2.5 3.0
- 2 │ Qmb 2.5 3.0
AllocationOpt.savenames
— Methodsavenames(p::AbstractString)
p
.julia> using AllocationOpt
+ 2 │ Qmb 2.5 3.0
AllocationOpt.savenames
— Methodsavenames(p::AbstractString)
p
.julia> using AllocationOpt
julia> path = "mypath"
julia> paths = AllocationOpt.savenames(path)
-Base.Generator{NTuple{4, String}, AllocationOpt.var"#1#2"{String}}(AllocationOpt.var"#1#2"{String}("mypath"), ("indexer.csv", "allocation.csv", "subgraph.csv", "network.csv"))
AllocationOpt.signal
— Methodsignal(::Val{:network}, x)
AllocationOpt.signal
— Methodsignal(::Val{:subgraph}, x)
x
.julia> using AllocationOpt
+Base.Generator{NTuple{4, String}, AllocationOpt.var"#1#2"{String}}(AllocationOpt.var"#1#2"{String}("mypath"), ("indexer.csv", "allocation.csv", "subgraph.csv", "network.csv"))
AllocationOpt.signal
— Methodsignal(::Val{:network}, x)
AllocationOpt.signal
— Methodsignal(::Val{:subgraph}, x)
x
.julia> using AllocationOpt
julia> using TheGraphData
julia> x = flextable([
Dict("signalledTokens" => 10,),
@@ -503,7 +503,7 @@
julia> AllocationOpt.signal(Val(:subgraph), x)
2-element view(transpose(lazystack(::Vector{Vector{Int64}})), :, 1) with eltype Int64:
10
- 5
AllocationOpt.sortprofits!
— Methodsortprofits!(NamedTuple{Tuple{Float64, Int64}})
julia> using AllocationOpt
+ 5
AllocationOpt.sortprofits!
— Methodsortprofits!(NamedTuple{Tuple{Float64, Int64}})
julia> using AllocationOpt
julia> popts = [
(; :profit => 5.0, :index => 2),
(; :profit => 6.0, :index => 1)
@@ -511,9 +511,9 @@
julia> popts = AllocationOpt.sortprofits!(popts)
2-element Vector{NamedTuple{(:profit, :index), Tuple{Float64, Int64}}}:
(profit = 6.0, index = 1)
- (profit = 5.0, index = 2)
AllocationOpt.squery
— Methodsquery()
julia> using AllocationOpt
+ (profit = 5.0, index = 2)
AllocationOpt.squery
— Methodsquery()
julia> using AllocationOpt
julia> value, args, fields = AllocationOpt.squery()
-("subgraphDeployments", Dict{String, Union{Dict{String, String}, String}}(), ["ipfsHash", "signalledTokens", "stakedTokens"])
AllocationOpt.stake
— Methodstake(::Val{:allocation}, x)
x
.julia> using AllocationOpt
+("subgraphDeployments", Dict{String, Union{Dict{String, String}, String}}(), ["ipfsHash", "signalledTokens", "stakedTokens"])
AllocationOpt.stake
— Methodstake(::Val{:allocation}, x)
x
.julia> using AllocationOpt
julia> using TheGraphData
julia> x = flextable([
Dict(
@@ -522,7 +522,7 @@
])
julia> AllocationOpt.stake(Val(:allocation), x)
1-element view(transpose(lazystack(::Vector{Vector{Int64}})), :, 1) with eltype Int64:
- 1
AllocationOpt.stake
— Methodstake(::Val{:indexer}, x)
x
.julia> using AllocationOpt
+ 1
AllocationOpt.stake
— Methodstake(::Val{:indexer}, x)
x
.julia> using AllocationOpt
julia> using TheGraphData
julia> x = flextable([
Dict(
@@ -530,7 +530,7 @@
),
])
julia> AllocationOpt.stake(Val(:indexer), x)
-10
AllocationOpt.stake
— Methodstake(::Val{:subgraph}, x)
x
.julia> using AllocationOpt
+10
AllocationOpt.stake
— Methodstake(::Val{:subgraph}, x)
x
.julia> using AllocationOpt
julia> using TheGraphData
julia> x = flextable([
Dict("stakedTokens" => 10,),
@@ -539,7 +539,7 @@
julia> AllocationOpt.stake(Val(:subgraph), x)
2-element view(transpose(lazystack(::Vector{Vector{Int64}})), :, 1) with eltype Int64:
10
- 5
AllocationOpt.strategydict
— Methodstrategydict(
+ 5
AllocationOpt.strategydict
— Methodstrategydict(
p::NamedTuple,
xs::AbstractMatrix{Real},
nonzeros::AbstractVector{Integer},
@@ -561,7 +561,7 @@
julia> AllocationOpt.strategydict.(popts, Ref(xs), Ref(nonzeros), Ref(fs), Ref(profits))
2-element Vector{Dict{String, Any}}:
Dict("num_allocations" => 2, "profit" => 6.0, "allocations" => Dict{String, Any}[Dict("allocationAmount" => "2.5", "profit" => 3.0, "deploymentID" => "Qma"), Dict("allocationAmount" => "2.5", "profit" => 3.0, "deploymentID" => "Qmb")])
- Dict("num_allocations" => 1, "profit" => 5.0, "allocations" => Dict{String, Any}[Dict("allocationAmount" => "5", "profit" => 5.0, "deploymentID" => "Qma")])
AllocationOpt.subtractindexer!
— Methodsubtractindexer!(a::FlexTable, s::FlexTable)
julia> using AllocationOpt
+ Dict("num_allocations" => 1, "profit" => 5.0, "allocations" => Dict{String, Any}[Dict("allocationAmount" => "5", "profit" => 5.0, "deploymentID" => "Qma")])
AllocationOpt.subtractindexer!
— Methodsubtractindexer!(a::FlexTable, s::FlexTable)
julia> using AllocationOpt
julia> using TheGraphData
julia> s = flextable([
Dict("ipfsHash" => "Qmb", "stakedTokens" => 20),
@@ -573,9 +573,9 @@
Dict("subgraphDeployment.ipfsHash" => "Qmb", "allocatedTokens" => 10, "id" => "0xb"),
])
julia> a, s = AllocationOpt.subtractindexer!(a, s)
-(NamedTuple[(var"subgraphDeployment.ipfsHash" = "Qma", allocatedTokens = 5, id = "0xa"), (var"subgraphDeployment.ipfsHash" = "Qmb", allocatedTokens = 10, id = "0xb")], NamedTuple[(stakedTokens = 5.0, ipfsHash = "Qma"), (stakedTokens = 10, ipfsHash = "Qmb"), (stakedTokens = 5, ipfsHash = "Qmc")])
AllocationOpt.togrt
— Methodtogrt(x::AbstractString)
x
to GRT.julia> using AllocationOpt
+(NamedTuple[(var"subgraphDeployment.ipfsHash" = "Qma", allocatedTokens = 5, id = "0xa"), (var"subgraphDeployment.ipfsHash" = "Qmb", allocatedTokens = 10, id = "0xb")], NamedTuple[(stakedTokens = 5.0, ipfsHash = "Qma"), (stakedTokens = 10, ipfsHash = "Qmb"), (stakedTokens = 5, ipfsHash = "Qmc")])
AllocationOpt.togrt
— Methodtogrt(x::AbstractString)
x
to GRT.julia> using AllocationOpt
julia> AllocationOpt.togrt("1")
-1.0e-18
AllocationOpt.unallocate_action
— Methodunallocate_action(::Val{:actionqueue}, a::FlexTable, t::FlexTable, config::AbstractDict)
AllocationOpt.unallocate_action
— Methodunallocate_action(::Val{:none}, a, t, config)
julia> using AllocationOpt
+1.0e-18
AllocationOpt.unallocate_action
— Methodunallocate_action(::Val{:actionqueue}, a::FlexTable, t::FlexTable, config::AbstractDict)
AllocationOpt.unallocate_action
— Methodunallocate_action(::Val{:none}, a, t, config)
julia> using AllocationOpt
julia> a = flextable([
Dict("subgraphDeployment.ipfsHash" => "Qma", "id" => "0xa")
])
@@ -583,7 +583,7 @@
Dict("amount" => "1", "profit" => "0", "ipfshash" => "Qma"),
Dict("amount" => "2", "profit" => "0", "ipfshash" => "Qmb"),
])
-julia> AllocationOpt.unallocate_action(Val(:none), a, t, Dict())
AllocationOpt.unallocate_action
— Methodunallocate_action(::Val{:rules}, a::FlexTable, t::FlexTable, config::AbstractDict)
julia> using AllocationOpt
+julia> AllocationOpt.unallocate_action(Val(:none), a, t, Dict())
AllocationOpt.unallocate_action
— Methodunallocate_action(::Val{:rules}, a::FlexTable, t::FlexTable, config::AbstractDict)
julia> using AllocationOpt
julia> a = flextable([
Dict("subgraphDeployment.ipfsHash" => "Qma", "id" => "0xa")
])
@@ -593,7 +593,7 @@
julia> AllocationOpt.unallocate_action(Val(:rules), a, t, Dict("frozenlist" => []))
graph indexer rules stop Qma
1-element Vector{String}:
- "[0mgraph indexer rules stop Qma"
AllocationOpt.write
— Methodwrite(i::FlexTable, a::FlexTable, s::FlexTable, n::FlexTable, config::AbstractDict)
writedir
specified in the config
.julia> using AllocationOpt
+ "[0mgraph indexer rules stop Qma"
AllocationOpt.write
— Methodwrite(i::FlexTable, a::FlexTable, s::FlexTable, n::FlexTable, config::AbstractDict)
writedir
specified in the config
.julia> using AllocationOpt
julia> using TheGraphData
julia> config = Dict("verbose" => true, "writedir" => "datadir")
julia> t = flextable([
@@ -601,7 +601,7 @@
Dict("ipfsHash" => "Qmb", "signalledTokens" => "2"),
])
julia> i, a, s, n = repeat([t,], 4)
-juila> AllocationOpt.write(i, a, s, n, config)
AllocationOpt.writejson
— Methodfunction writejson(results::AbstractString, config::AbstractDict)
writedir
specified in the config
.julia> Using AllocationOpt
+juila> AllocationOpt.write(i, a, s, n, config)
AllocationOpt.writejson
— Methodfunction writejson(results::AbstractString, config::AbstractDict)
writedir
specified in the config
.julia> Using AllocationOpt
julia> results = "{"strategies":[{"num_allocations":2,"profit":6.0,"allocations":[{"allocationAmount":2.5,"profit":3.0,"deploymentID":"Qma"},{"allocationAmount":2.5,"profit":3.0,"deploymentID":"Qmb"}]},{"num_allocations":1,"profit":5.0,"allocations":[{"allocationAmount":5.0,"profit":5.0,"deploymentID":"Qma"}]}]}"
julia> config = Dict{"writedir" => "."}
-julia> AllocationOpt.writejson(results, config)
SemioticOpt.iteration
— Methoditeration(f::Function, a::AnalyticOpt)
SemioticOpt.x!
— MethodSemioticOpt.x
— Methodx(a::AnalyticOpt)
Settings
This document was generated with Documenter.jl version 0.27.24 on Thursday 24 August 2023. Using Julia version 1.8.5.