Skip to content

Added ember package #20

Open
dvidsilva wants to merge 7 commits intocollabland:mainfrom
dvidsilva:feat/ember
Open

Added ember package #20
dvidsilva wants to merge 7 commits intocollabland:mainfrom
dvidsilva:feat/ember

Conversation

@dvidsilva
Copy link
Copy Markdown

@dvidsilva dvidsilva commented Jan 29, 2025

Description

Added ember dependencies to server/package.json

Created route for /ember

Created ember service, and initializing in route

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🎨 Style update
  • ♻️ Code refactor
  • 🔧 Configuration changes

How Has This Been Tested?

  • Unit Tests
  • Integration Tests
  • Manual Testing

Screenshots (if applicable)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Related Issues

@dvidsilva dvidsilva marked this pull request as draft January 29, 2025 21:49
@dvidsilva
Copy link
Copy Markdown
Author

@gitaalekhyapaul created a sample route

image

@dvidsilva
Copy link
Copy Markdown
Author

@dvidsilva
Copy link
Copy Markdown
Author

Chains example response

Screenshot 2025-01-30 at 11 13 29 AM

@dvidsilva
Copy link
Copy Markdown
Author

dvidsilva commented Jan 31, 2025

Creating a /swap endpoint, POST, that expects the following body

POST /ember/swap
const { baseToken, quoteToken, amount, recipient } = req.body;

To use Ember to perform a swap action

export interface AgentSwapAction {
  type: 'SWAP' | 'YIELD' | 'BALANCE_CHECK';
  params: {
    baseToken: string;
    quoteToken: string;
    amount: string;
    recipient: string;
  };
  status: 'PENDING' | 'EXECUTED' | 'FAILED';
}

fetch('http://localhost:8081/ember/agent/swap', {
  method: 'POST',
  headers: {
    'content-type': 'application/json'
  }, body: JSON.stringify({
    baseToken: 'USDC',
    quoteToken: 'WETH',
    amount: '1',
    recipient: '0x',
  })
});

Comment thread server/bin/validate-env
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • EmberClient needs to always be instantiated with a URL and optional API key.
  • There is no getClient method. It's instantiated directly.
const client = new EmberClient({
  endpoint: process.env.EMBER_ENDPOINT_URL, // grpc.api.emberai.xyz:50051
  apiKey: process.env.EMBER_API_KEY,
})
  • The /agent/swap endpoint is incorrectly instantiating the EmberClient. See above example.
  • There are only two options active for swap type right now.
    1. MARKET_BUY - buys the base token with the quote token
    2. MARKET_SELL - sells the base token for the quote token

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0xTomDaniel changed the order Type, this method is a wrapper included in the ember.service, to follow convention - beihnd the scenes is the same

https://github.com/collabland/AI-Agent-Starter-Kit/pull/20/files/ed98278a160e7556ed79e3c3cca1260ae4eca847

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Sorry I completely overlooked that!

@0xTomDaniel
Copy link
Copy Markdown

I've published v0.2.0 of the SDK. Please update.

  • Added: New providerTracking object in the swapTokens response. This can be used with the transaction hash to track the swap status on a dashboard. See example
  • Breaking change: Renamed type to orderType in swap request and response objects
  • Breaking change: Renamed tokenId to address in token identifier object
  • Updated Readme and examples

@dvidsilva dvidsilva marked this pull request as ready for review January 31, 2025 17:44
Copy link
Copy Markdown

@0xTomDaniel 0xTomDaniel Feb 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I correct in understanding that this is just a proof-of-concept that will be refactored?

  • Sorry if I'm pointing out the obvious, but I just want to note that the execute swap route definitely shouldn't be hard coded to always swap the same thing
  • Also, the ideal use of Ember is that methods should be packaged as Tools (Actions) for the agent to call
  • The agent signs the transaction returned by Ember with its own agent wallet

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0xTomDaniel yes, this would't be useful released as this

waiting for some agent documentation, or someone to refactor into the workflow. but they wanted to check how things are working

I was traveling but we'll be around for a few days if we have instructions to execute

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0xTomDaniel if you understand the flow better, and have that info, we can develop that together. we could find more in the chat and improve the documentation in this repo with some examples and diagrams

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants