-
Notifications
You must be signed in to change notification settings - Fork 13
docs: getQuote API #48
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
base: main
Are you sure you want to change the base?
Conversation
docs/intents/getQuote.md
Outdated
| // priority: which token the user prefeer to spend (e.g., 0 = Max Priority) | ||
| userBalances: Map<chainId, {balance, tokenAddress, priority}> | ||
|
|
||
| // Desired amount to receive on target chain (as integer string in wei) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should consider the target outputs to be a mapping as well, accepting multiple desired outputs
docs/intents/getQuote.md
Outdated
| targetTokenAddress: string | ||
|
|
||
| // Optional: specify which routing algorithm to use | ||
| algorithm?: 'greedy' | 'dynamic-programming' | 'dijkstra' | 'multi-objective' | 'genetic' | 'simulated-annealing' | 'ant-colony' | 'a-star' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the server does not support this configuration, should it return an error or simply ignore it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could return a NotValidAttribute error, and if the algorithm attribute is valid but the algorithm is not there, we could return a NotFoundAlgorithm error, mentioning the implemented algorithms
docs/intents/getQuote.md
Outdated
| }> | ||
|
|
||
| // Sum of all fees across all steps (in wei of respective native tokens) | ||
| totalFee: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would this work if there are multiple native tokens involved? We should consider this to be an array of objects (network, fee)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right let's change this for usdTotalFee and then they have each fee inside each step
docs/intents/getQuote.md
Outdated
|
|
||
| ### **Disadvantages:** | ||
|
|
||
| - **Limited Transparency**: Users cannot see alternative options or understand trade-offs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can potentially change the response format to be an array of options, each option being the currently proposed schema, but allowing solvers to return different options that the client then can decide to show to the users
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a good idea.
docs/intents/getQuote.md
Outdated
|
|
||
| - **Limited Transparency**: Users cannot see alternative options or understand trade-offs | ||
| - **Reduced Control**: Wallets cannot implement custom routing preferences | ||
| - **Trust Dependency**: Users must trust the server's optimization choices |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not the definition of an intent? Users do not need to worry about middle steps, and rather select the better output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. But anyway, I think it's worth mentioning it as a disadvantage to see the trade-offs between approaches.
Like, Approach 2: Client-Side Route Calculation plus a Route endpoint would still have Users do not need to worry about middle steps but also give flexibility for those who want to see what's happening.
|
I think the API should be a bit simpler than proposed here. This is closer to what I was imagining: interface AssetAmount {
asset: string; // interoperable address
amount: bigint;
}
interface GetQuoteRequest {
availableInputs: {
input: AssetAmount;
priority?: number;
}[];
requestedMinOutputs: AssetAmount[];
preference?: 'price' | 'speed' | 'input-priority';
}
interface GetQuoteResponse {
quotes: {
orders: {
settler: string; // interoperable address
data: object; // to be signed and submitted back
};
requiredAllowances: AssetAmount[];
validUntil: number;
eta: number;
totalFeeUsd: number;
}[];
}Notes on the proposal in this PR:
|
|
I can't seem to notice that there is no obvious return for the tokens? I generally support @frangio's feedback with the following comments: ServerSideQuoteRequest
I am not sure what consideration has been given to async quoting endpoints, however, the current spec does not seem to include features to accommodate that. In an ideal world this would be part of the spec as you can imagine that a common use case would be for aggregators to aggregate quote calls. Those calls may have to be asynchronously called. Is there also an argument to be made for aggregators of aggregators? In that case, should there be an option in the quote to not do tree style quoting but return immediate quotes instead? ServerSideQuoteResponse
I have attached 2 modified drafts. interface ServerSideQuoteRequest {
userBalances: {chainId, balance, tokenAddress, priority}[]
targetBalances: {chainId, balance, tokenAddress}[]
algorithm?: 'greedy' | 'dynamic-programming' | 'dijkstra' | 'multi-objective' | 'genetic' | 'simulated-annealing' | 'ant-colony' | 'a-star'
userPreferences?: {
exactOut: boolean // Whether the output is allowed to deviate slightly to optimise the route.
maxSlippage: number
costWeight: number
}
}Notable differences:
interface ServerSideQuoteResponse Map<name: string, {
usedUserBalances: {chainId, balance, tokenAddress, priority}[]
estimatedProvided: {chainId, balance, tokenAddress}[]
minimumProvided: {chainId, balance, tokenAddress}[]
route: {
steps: {
chain: chainId
assets: {amount, tokenAddress}
fee: string
bridgeAddress: hex
bridgeCall: hex
gas: string // Amount of gas used
gasCost: string // estimated cost of gas used (in wei)
usdGasEstimate: string
timeEstimate: number
bridgeProvider: string
}[]
totalFee: string
totalGasEstimate: string
usdTotalGasEstimate: string
estimatedCompletionTime: number
maxCompletionTime?: number // Not provided if there is a user activity.
}
algorithmUsed: string
quoteId: string
validUntil: timestamp
}Notable differences:
On stepsI generally agree with @frangio however I can see that if we wanted this to be compatible with non-intent systems and ordinary bridges, it may be needed. As a result, I don't have anything against it. Instead, I would argue that it should contain execution instructions so that the API becomes more self-serve and these steps don't become arbitrary. |
|
How would this interface be used if you had a fixed number of desired inputs and wanted the maximum outputs? |
|
The latest spec is found in openintentsframework/oif-specs. |
Universal Intent Interface
Purpose: A standardized API specification that enables cross-chain intent systems to interoperate, creating a unified ecosystem for multi-chain value transfer and execution.
Enabled Flows:
Standards Compliance: ERC-7683 Cross Chain Intents and ERC-7930 Interoperable Addresses.