Skip to content
Merged
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
49 changes: 25 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ sdk.configure({
});

// Discover yield opportunities
const yields = await sdk.api.yieldsGetYields({
const yields = await sdk.api.getYields({
network: 'ethereum',
limit: 10
});

// Get balances for a specific yield and address
const balances = await sdk.api.yieldsGetYieldBalances('yield-id', {
const balances = await sdk.api.getYieldBalances('yield-id', {
address: '0x1234567890123456789012345678901234567890',
arguments: {}
});

// Enter a yield position
const action = await sdk.api.actionsEnterYield({
const action = await sdk.api.enterYield({
yieldId: 'yield-id',
address: '0x1234567890123456789012345678901234567890',
arguments: {
Expand All @@ -72,7 +72,7 @@ const action = await sdk.api.actionsEnterYield({

#### Get All Yields
```typescript
const yields = await sdk.api.yieldsGetYields({
const yields = await sdk.api.getYields({
network?: string;
limit?: number;
offset?: number;
Expand All @@ -81,21 +81,21 @@ const yields = await sdk.api.yieldsGetYields({

#### Get Specific Yield
```typescript
const yieldDetails = await sdk.api.yieldsGetYield('yield-id');
const yieldDetails = await sdk.api.getYield('yield-id');
```

#### Get Yield Balances
```typescript
const balances = await sdk.api.yieldsGetYieldBalances('yield-id', {
const balances = await sdk.api.getYieldBalances('yield-id', {
address: '0x...',
arguments?: object
});
```

#### Get Aggregate Balances
```typescript
const aggregateBalances = await sdk.api.yieldsGetAggregateBalances({
requests: [
const aggregateBalances = await sdk.api.getAggregateBalances({
queries: [
{
yieldId: 'yield-id-1',
address: '0x...',
Expand All @@ -114,7 +114,7 @@ const aggregateBalances = await sdk.api.yieldsGetAggregateBalances({

#### Enter Yield Position
```typescript
const enterAction = await sdk.api.actionsEnterYield({
const enterAction = await sdk.api.enterYield({
yieldId: 'yield-id',
address: '0x...',
arguments: {
Expand All @@ -125,7 +125,7 @@ const enterAction = await sdk.api.actionsEnterYield({

#### Exit Yield Position
```typescript
const exitAction = await sdk.api.actionsExitYield({
const exitAction = await sdk.api.exitYield({
yieldId: 'yield-id',
address: '0x...',
arguments: {
Expand All @@ -136,17 +136,18 @@ const exitAction = await sdk.api.actionsExitYield({

#### Manage Yield Position
```typescript
const manageAction = await sdk.api.actionsManageYield({
const manageAction = await sdk.api.manageYield({
yieldId: 'yield-id',
address: '0x...',
action: 'claim', // or other management actions
action: 'CLAIM_REWARDS', // or other management actions
passthrough: 'server-generated-passthrough',
arguments: {}
});
```

#### Get Actions
```typescript
const actions = await sdk.api.actionsGetActions({
const actions = await sdk.api.getActions({
address: '0x...',
status?: 'pending' | 'completed' | 'failed',
yieldId?: 'yield-id',
Expand All @@ -157,14 +158,14 @@ const actions = await sdk.api.actionsGetActions({

#### Get Action Details
```typescript
const action = await sdk.api.actionsGetAction('action-id');
const action = await sdk.api.getAction('action-id');
```

### Transactions

#### Submit Transaction Hash
```typescript
const transaction = await sdk.api.transactionsSubmitTransactionHash(
const transaction = await sdk.api.submitTransactionHash(
'transaction-id',
{
hash: '0x...'
Expand All @@ -174,34 +175,34 @@ const transaction = await sdk.api.transactionsSubmitTransactionHash(

#### Get Transaction Details
```typescript
const transaction = await sdk.api.transactionsGetTransaction('transaction-id');
const transaction = await sdk.api.getTransaction('transaction-id');
```

### Networks & Providers

#### Get Networks
```typescript
const networks = await sdk.api.networksGetNetworks();
const networks = await sdk.api.getNetworks();
```

#### Get Providers
```typescript
const providers = await sdk.api.providersGetProviders({
const providers = await sdk.api.getProviders({
limit?: 10,
offset?: 0
});
```

#### Get Provider Details
```typescript
const provider = await sdk.api.providersGetProvider('provider-id');
const provider = await sdk.api.getProvider('provider-id');
```

### Validators

#### Get Yield Validators
```typescript
const validators = await sdk.api.yieldsGetYieldValidators('yield-id', {
const validators = await sdk.api.getYieldValidators('yield-id', {
limit?: 10,
offset?: 0
});
Expand All @@ -211,7 +212,7 @@ const validators = await sdk.api.yieldsGetYieldValidators('yield-id', {

#### Get Health Status
```typescript
const healthStatus = await sdk.api.healthHealth();
const healthStatus = await sdk.api.health();
```

## Advanced Configuration
Expand All @@ -236,7 +237,7 @@ const customFetch: FetchInstance = async <T>(url: string, init: RequestInit): Pr

sdk.configure({
apiKey: 'your-api-key',
baseURL: 'https://api.stakek.it/',
baseURL: 'https://api.yield.xyz/',
fetchInstance: customFetch
});
```
Expand Down Expand Up @@ -284,7 +285,7 @@ import { sdk } from '@yieldxyz/sdk';

try {
// This will throw an error if not configured
const yields = await sdk.api.yieldsGetYields();
const yields = await sdk.api.getYields();
} catch (error) {
console.error('SDK not configured:', error.message);
}
Expand All @@ -293,7 +294,7 @@ try {
sdk.configure({ apiKey: 'your-api-key' });

// Now API calls will work
const yields = await sdk.api.yieldsGetYields();
const yields = await sdk.api.getYields();
```

## Development
Expand Down
2 changes: 1 addition & 1 deletion example/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { sdk } from "../src";
sdk.configure({ apiKey: "your-api-key" });

const main = async () => {
const res = await sdk.api.yieldsGetYield("yieldId");
const res = await sdk.api.getYield("yieldId");

console.log(res);
};
Expand Down
32 changes: 28 additions & 4 deletions orval.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,34 @@ export default defineConfig({
path: apiClientPath,
name: "customFetch",
},
transformer: (val) => ({
...val,
operationName: val.operationName?.replace(/controller/i, ""),
}),
transformer: (val) => {
let operationName = val.operationName?.replace(/controller/i, "");

// Remove redundant prefixes to clean up function names
if (operationName) {
operationName = operationName
.replace(/^yields/i, "")
.replace(/^actions/i, "")
.replace(/^transactions/i, "")
.replace(/^networks/i, "")
.replace(/^providers/i, "")
.replace(/^health/i, "");

// Ensure the first letter is lowercase
operationName =
operationName.charAt(0).toLowerCase() + operationName.slice(1);

// Handle special cases where removing prefix leaves empty or awkward names
if (operationName === "health" || operationName === "") {
operationName = "health";
}
}

return {
...val,
operationName,
};
},
},
},
input: {
Expand Down
2 changes: 1 addition & 1 deletion src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const customFetch = async <T>({
}): Promise<T> => {
const {
apiKey,
baseURL = "https://api.stakek.it/",
baseURL = "https://api.yield.xyz/",
fetchInstance,
} = sdkConfig;

Expand Down
Loading