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
13 changes: 8 additions & 5 deletions light-token/defi/routers.mdx
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
---
title: "Router Integration"
description: "Add support for rent-free AMMs on Solana."

Check warning on line 3 in light-token/defi/routers.mdx

View check run for this annotation

Mintlify / Mintlify Validation (luminouslabs-cc5545c6) - vale-spellcheck

light-token/defi/routers.mdx#L3

Did you really mean 'AMMs'?

Check warning on line 3 in light-token/defi/routers.mdx

View check run for this annotation

Mintlify / Mintlify Validation (luminouslabs-cc5545c6) - vale-spellcheck

light-token/defi/routers.mdx#L3

Did you really mean 'Solana'?
---

1. Use `get_account_interface` instead of `get_account`
2. Store `AccountInterface` in your cache
3. Prepend `create_load_instructions` when accounts are cold
1. Use `get_account_interface` instead of `get_account` to store `AccountInterface`.
2. Use the AMM's LightProgramInterface trait to dynamically prepend load

Check warning on line 7 in light-token/defi/routers.mdx

View check run for this annotation

Mintlify / Mintlify Validation (luminouslabs-cc5545c6) - vale-spellcheck

light-token/defi/routers.mdx#L7

Did you really mean 'AMM's'?
instructions if the market is cold.


## Step 1: Use `get_account_interface`

`get_account_interface` is a new RPC endpoint that returns a superset of `get_account`. `AccountInterface` stores additional info `Option<ColdContext>` that you will need later.
`get_account_interface` is a new RPC endpoint that returns a superset of

Check warning on line 13 in light-token/defi/routers.mdx

View check run for this annotation

Mintlify / Mintlify Validation (luminouslabs-cc5545c6) - vale-spellcheck

light-token/defi/routers.mdx#L13

Did you really mean 'superset'?
`get_account`. `AccountInterface` stores additional info `Option<ColdContext>`
that you will need later.

<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '1rem' }}>
<div>
Expand Down Expand Up @@ -37,13 +40,13 @@
</div>


## Step 2: Store Account Interfaces in your cache.
## Step 2: Implement LightProgramInterface
All rent-free programs implement the `LightProgramInterface` trait.

This trait helps you:

1. Maintain a cache of `&[AccountInterface]`
2. Load cold accounts into the onchain account space when building Swap transactions.

Check warning on line 49 in light-token/defi/routers.mdx

View check run for this annotation

Mintlify / Mintlify Validation (luminouslabs-cc5545c6) - vale-spellcheck

light-token/defi/routers.mdx#L49

Did you really mean 'onchain'?

```rust
// Program implements this.
Expand Down Expand Up @@ -140,7 +143,7 @@
|------|--------|---------|
| `Rpc` trait | `light-client` | RPC client with `get_account_interface` methods |
| `AccountInterface` | `light-client` | Unified hot/cold account type |
| `LightProgramInterface` | `light-client` | Trait that program SDKs implement |

Check warning on line 146 in light-token/defi/routers.mdx

View check run for this annotation

Mintlify / Mintlify Validation (luminouslabs-cc5545c6) - vale-spellcheck

light-token/defi/routers.mdx#L146

Did you really mean 'SDKs'?
| `AccountSpec` | `light-client` | Specifies account load requirements |

### Reference Implementation
Expand All @@ -161,14 +164,14 @@
| Quote | Works | Works |
| Swap | Direct | Load first / Bundle |
| Latency | Normal | +0-200ms* |
| Tx size | Normal | +100-2400 bytes*|

Check warning on line 167 in light-token/defi/routers.mdx

View check run for this annotation

Mintlify / Mintlify Validation (luminouslabs-cc5545c6) - vale-spellcheck

light-token/defi/routers.mdx#L167

Did you really mean 'Tx'?
| CU | Normal | +15k-400k CU*|

Latency, tx size, and CU depend on the number and type of cold accounts.

Check warning on line 170 in light-token/defi/routers.mdx

View check run for this annotation

Mintlify / Mintlify Validation (luminouslabs-cc5545c6) - vale-spellcheck

light-token/defi/routers.mdx#L170

Did you really mean 'tx'?

### When does a market go cold?
A market is "cold" after it has been compressed by a miner. Accounts become
eligible for compression when inactive (e.g., after 24h without lamport bumps

Check warning on line 174 in light-token/defi/routers.mdx

View check run for this annotation

Mintlify / Mintlify Validation (luminouslabs-cc5545c6) - vale-spellcheck

light-token/defi/routers.mdx#L174

Did you really mean 'lamport'?
from fee payers), causing the virtual rent balance to fall below threshold.

**To ensure swaps execute regardless of whether the market is hot or cold,
Expand Down
222 changes: 222 additions & 0 deletions openapi/getColdMint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
openapi: 3.0.3
info:
title: photon-indexer
description: Solana indexer for general compression
license:
name: Apache-2.0
version: 0.50.0
servers:
- url: https://mainnet.helius-rpc.com
paths:
/getColdMint:
summary: getColdMint
post:
requestBody:
content:
application/json:
schema:
type: object
required:
- jsonrpc
- id
- method
- params
properties:
id:
type: string
description: An ID to identify the request.
enum:
- test-account
jsonrpc:
type: string
description: The version of the JSON-RPC protocol.
enum:
- '2.0'
method:
type: string
description: The name of the method to invoke.
enum:
- getColdMint
params:
type: object
description: Request for cold mint data. Provide either address or mintPda.
properties:
address:
allOf:
- $ref: '#/components/schemas/SerializablePubkey'
nullable: true
description: The cold account address.
mintPda:
allOf:
- $ref: '#/components/schemas/SerializablePubkey'
nullable: true
description: The mint PDA (decompressed account address).
additionalProperties: false
required: true
responses:
'200':
description: ''
content:
application/json:
schema:
type: object
required:
- context
properties:
context:
$ref: '#/components/schemas/Context'
value:
$ref: '#/components/schemas/ColdMint'
additionalProperties: false
'429':
description: Exceeded rate limit.
content:
application/json:
schema:
type: object
properties:
error:
type: string
'500':
description: The server encountered an unexpected condition that prevented it from fulfilling the request.
content:
application/json:
schema:
type: object
properties:
error:
type: string
components:
schemas:
ColdMint:
type: object
required:
- mint
- account
properties:
mint:
$ref: '#/components/schemas/MintData'
account:
$ref: '#/components/schemas/Account'
additionalProperties: false
MintData:
type: object
required:
- mintPda
- mintSigner
- supply
- decimals
- version
- mintDecompressed
properties:
mintPda:
$ref: '#/components/schemas/SerializablePubkey'
description: The PDA (decompressed account address) for this mint.
mintSigner:
$ref: '#/components/schemas/Hash'
description: The signer/seed used for PDA derivation.
mintAuthority:
allOf:
- $ref: '#/components/schemas/SerializablePubkey'
nullable: true
description: Authority that can mint new tokens.
freezeAuthority:
allOf:
- $ref: '#/components/schemas/SerializablePubkey'
nullable: true
description: Authority that can freeze accounts.
supply:
type: integer
format: int64
minimum: 0
description: Total supply of tokens.
decimals:
type: integer
minimum: 0
maximum: 255
description: Number of decimals.
version:
type: integer
minimum: 0
maximum: 255
description: Version of the mint.
mintDecompressed:
type: boolean
description: Whether the mint has been decompressed.
extensions:
allOf:
- $ref: '#/components/schemas/Base64String'
nullable: true
description: Serialized extensions.
additionalProperties: false
Account:
type: object
required:
- hash
- owner
- lamports
- tree
- leafIndex
- seq
- slotCreated
properties:
address:
$ref: '#/components/schemas/SerializablePubkey'
data:
$ref: '#/components/schemas/AccountData'
hash:
$ref: '#/components/schemas/Hash'
lamports:
$ref: '#/components/schemas/UnsignedInteger'
leafIndex:
$ref: '#/components/schemas/UnsignedInteger'
owner:
$ref: '#/components/schemas/SerializablePubkey'
seq:
$ref: '#/components/schemas/UnsignedInteger'
slotCreated:
$ref: '#/components/schemas/UnsignedInteger'
tree:
$ref: '#/components/schemas/SerializablePubkey'
additionalProperties: false
AccountData:
type: object
required:
- discriminator
- data
- dataHash
properties:
data:
$ref: '#/components/schemas/Base64String'
dataHash:
$ref: '#/components/schemas/Hash'
discriminator:
$ref: '#/components/schemas/UnsignedInteger'
additionalProperties: false
Base64String:
type: string
description: A base 64 encoded string.
default: SGVsbG8sIFdvcmxkIQ==
example: SGVsbG8sIFdvcmxkIQ==
Context:
type: object
required:
- slot
properties:
slot:
type: integer
default: 100
example: 100
Hash:
type: string
description: A 32-byte hash represented as a base58 string.
example: 11111112cMQwSC9qirWGjZM6gLGwW69X22mqwLLGP
SerializablePubkey:
type: string
description: A Solana public key represented as a base58 string.
default: 11111112D1oxKts8YPdTJRG5FzxTNpMtWmq8hkVx3
example: 11111112D1oxKts8YPdTJRG5FzxTNpMtWmq8hkVx3
UnsignedInteger:
type: integer
default: 100
example: 100
Loading
Loading